Skip to content

Commit 06670e6

Browse files
authored
Merge pull request #893 from frappe/mergify/bp/main/pr-891
fixes (backport #891)
2 parents e4173cb + 95184b5 commit 06670e6

File tree

11 files changed

+55
-62
lines changed

11 files changed

+55
-62
lines changed

frontend/src/components/Activities/Activities.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
{{ startCase(__(activity.type)) }}
321321
</span>
322322
<span
323-
v-if="activity.data.old_value"
323+
v-if="activity.data?.old_value"
324324
class="max-w-xs font-medium text-ink-gray-8"
325325
>
326326
<div
@@ -336,7 +336,7 @@
336336
</span>
337337
<span v-if="activity.to">{{ __('to') }}</span>
338338
<span
339-
v-if="activity.data.value"
339+
v-if="activity.data?.value"
340340
class="max-w-xs font-medium text-ink-gray-8"
341341
>
342342
<div

frontend/src/components/Activities/AllModals.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
@after="redirect('notes')"
1717
/>
1818
<CallLogModal
19+
v-if="showCallLogModal"
1920
v-model="showCallLogModal"
20-
v-model:callLog="callLog"
21+
:data="callLog"
2122
:options="{ afterInsert: () => activities.reload() }"
2223
/>
2324
</template>

frontend/src/components/Activities/CallArea.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@
9797
v-model:callLogModal="showCallLogModal"
9898
v-model:callLog="callLog"
9999
/>
100-
<CallLogModal v-model="showCallLogModal" v-model:callLog="callLog.data" />
100+
<CallLogModal
101+
v-if="showCallLogModal"
102+
v-model="showCallLogModal"
103+
:data="callLog.data"
104+
/>
101105
</div>
102106
</template>
103107
<script setup>

frontend/src/components/Modals/CallLogModal.vue

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ import { getRandom } from '@/utils'
4444
import { capture } from '@/telemetry'
4545
import { useDocument } from '@/data/document'
4646
import { FeatherIcon, createResource, ErrorMessage, Badge } from 'frappe-ui'
47-
import { ref, nextTick, watch, computed } from 'vue'
47+
import { ref, nextTick, computed, onMounted } from 'vue'
4848
4949
const props = defineProps({
50+
data: {
51+
type: Object,
52+
default: () => ({}),
53+
},
5054
options: {
5155
type: Object,
5256
default: {
@@ -58,14 +62,15 @@ const props = defineProps({
5862
const { isManager } = usersStore()
5963
6064
const show = defineModel()
61-
const _callLog = defineModel('callLog')
6265
6366
const loading = ref(false)
6467
const error = ref(null)
65-
const title = ref(null)
6668
const editMode = ref(false)
6769
68-
const callLog = ref(null)
70+
const { document: callLog } = useDocument(
71+
'CRM Call Log',
72+
props.data?.name || '',
73+
)
6974
7075
const dialogOptions = computed(() => {
7176
let title = !editMode.value ? __('New Call Log') : __('Edit Call Log')
@@ -109,7 +114,7 @@ const callBacks = {
109114
110115
async function updateCallLog() {
111116
loading.value = true
112-
await callLog.value.save.submit(null, callBacks)
117+
await callLog.save.submit(null, callBacks)
113118
}
114119
115120
const createCallLog = createResource({
@@ -120,7 +125,7 @@ const createCallLog = createResource({
120125
doctype: 'CRM Call Log',
121126
id: getRandom(6),
122127
telephony_medium: 'Manual',
123-
...callLog.value.doc,
128+
...callLog.doc,
124129
},
125130
}
126131
},
@@ -141,23 +146,13 @@ function handleCallLogUpdate(doc) {
141146
props.options.afterInsert && props.options.afterInsert(doc)
142147
}
143148
144-
watch(
145-
() => show.value,
146-
(value) => {
147-
if (!value) return
148-
editMode.value = false
149-
150-
let docname = _callLog.value?.name
151-
const { document } = useDocument('CRM Call Log', docname)
152-
callLog.value = document
149+
onMounted(() => {
150+
editMode.value = props.data?.name ? true : false
153151
154-
if (docname) {
155-
editMode.value = true
156-
} else {
157-
callLog.value.doc = { ..._callLog.value }
158-
}
159-
},
160-
)
152+
if (!props.data?.name) {
153+
callLog.doc = { ...props.data }
154+
}
155+
})
161156
162157
function openQuickEntryModal() {
163158
showQuickEntryModal.value = true

frontend/src/components/Modals/ContactModal.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ const loading = ref(false)
8484
8585
const { document: _contact } = useDocument('Contact')
8686
87-
if (Object.keys(_contact.doc).length != 0) {
88-
_contact.doc = {}
89-
}
90-
9187
async function createContact() {
9288
if (_contact.doc.email_id) {
9389
_contact.doc.email_ids = [{ email_id: _contact.doc.email_id }]
@@ -155,7 +151,8 @@ const tabs = createResource({
155151
})
156152
157153
onMounted(() => {
158-
Object.assign(_contact.doc, props.contact.data || props.contact || {})
154+
_contact.doc = {}
155+
Object.assign(_contact.doc, props.contact.data || props.contact)
159156
})
160157
161158
function openQuickEntryModal() {

frontend/src/components/Modals/DealModal.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ const error = ref(null)
9696
9797
const { document: deal } = useDocument('CRM Deal')
9898
99-
if (Object.keys(deal.doc).length != 0) {
100-
deal.doc = {}
101-
}
102-
10399
const hasOrganizationSections = ref(true)
104100
const hasContactSections = ref(true)
105101
@@ -241,7 +237,9 @@ function openQuickEntryModal() {
241237
}
242238
243239
onMounted(() => {
240+
deal.doc = { no_of_employees: '1-10' }
244241
Object.assign(deal.doc, props.defaults)
242+
245243
if (!deal.doc.deal_owner) {
246244
deal.doc.deal_owner = getUser().name
247245
}

frontend/src/components/Modals/LeadModal.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ const isLeadCreating = ref(false)
7272
7373
const { document: lead } = useDocument('CRM Lead')
7474
75-
if (Object.keys(lead.doc).length != 0) {
76-
lead.doc = {}
77-
}
78-
7975
const leadStatuses = computed(() => {
8076
let statuses = statusOptions('lead')
8177
if (!lead.doc.status) {
@@ -186,7 +182,9 @@ function openQuickEntryModal() {
186182
}
187183
188184
onMounted(() => {
185+
lead.doc = { no_of_employees: '1-10' }
189186
Object.assign(lead.doc, props.defaults)
187+
190188
if (!lead.doc?.lead_owner) {
191189
lead.doc.lead_owner = getUser().name
192190
}

frontend/src/components/Modals/OrganizationModal.vue

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
</Button>
1818
</div>
1919
</div>
20-
<FieldLayout v-if="tabs.data?.length" :tabs="tabs.data" :data="_organization" doctype="CRM Organization" />
20+
<FieldLayout
21+
v-if="tabs.data?.length"
22+
:tabs="tabs.data"
23+
:data="organization.doc"
24+
doctype="CRM Organization"
25+
/>
2126
<ErrorMessage class="mt-8" v-if="error" :message="__(error)" />
2227
</div>
2328
<div class="px-4 pt-4 pb-7 sm:px-6">
@@ -47,6 +52,10 @@ import { ref, nextTick, onMounted } from 'vue'
4752
import { useRouter } from 'vue-router'
4853
4954
const props = defineProps({
55+
data: {
56+
type: Object,
57+
default: () => ({}),
58+
},
5059
options: {
5160
type: Object,
5261
default: {
@@ -60,27 +69,19 @@ const { isManager } = usersStore()
6069
6170
const router = useRouter()
6271
const show = defineModel()
63-
const organization = defineModel('organization')
6472
6573
const loading = ref(false)
66-
const title = ref(null)
67-
68-
const { document: _organization } = useDocument('CRM Organization')
69-
70-
if (Object.keys(_organization.doc).length != 0) {
71-
_organization.doc = { no_of_employees: '1-10' }
72-
}
73-
74-
let doc = ref({})
7574
const error = ref(null)
7675
76+
const { document: organization } = useDocument('CRM Organization')
77+
7778
async function createOrganization() {
7879
const doc = await call(
7980
'frappe.client.insert',
8081
{
8182
doc: {
8283
doctype: 'CRM Organization',
83-
..._organization.doc,
84+
...organization.doc,
8485
},
8586
},
8687
{
@@ -104,8 +105,6 @@ function handleOrganizationUpdate(doc) {
104105
name: 'Organization',
105106
params: { organizationId: doc.name },
106107
})
107-
} else {
108-
organization.value?.reload?.()
109108
}
110109
show.value = false
111110
props.options.afterInsert && props.options.afterInsert(doc)
@@ -123,13 +122,13 @@ const tabs = createResource({
123122
column.fields.forEach((field) => {
124123
if (field.fieldname == 'address') {
125124
field.create = (value, close) => {
126-
_organization.doc.address = value
125+
organization.doc.address = value
127126
openAddressModal()
128127
close()
129128
}
130129
field.edit = (address) => openAddressModal(address)
131130
} else if (field.fieldtype === 'Table') {
132-
_organization.doc[field.fieldname] = []
131+
organization.doc[field.fieldname] = []
133132
}
134133
})
135134
})
@@ -139,10 +138,8 @@ const tabs = createResource({
139138
})
140139
141140
onMounted(() => {
142-
Object.assign(
143-
_organization.doc,
144-
organization.value?.doc || organization.value || {},
145-
)
141+
organization.doc = { no_of_employees: '1-10' }
142+
Object.assign(organization.doc, props.data)
146143
})
147144
148145
function openQuickEntryModal() {

frontend/src/pages/CallLogs.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
v-model:callLog="callLog"
6363
/>
6464
<CallLogModal
65+
v-if="showCallLogModal"
6566
v-model="showCallLogModal"
66-
v-model:callLog="callLog.data"
67+
:data="callLog.data"
6768
:options="{ afterInsert: () => callLogs.reload() }"
6869
/>
6970
</template>

frontend/src/pages/Deal.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@
272272
:errorMessage="errorMessage"
273273
/>
274274
<OrganizationModal
275+
v-if="showOrganizationModal"
275276
v-model="showOrganizationModal"
276-
v-model:organization="_organization"
277+
:data="_organization"
277278
:options="{
278279
redirect: false,
279280
afterInsert: (doc) => updateField('organization', doc.name),

frontend/src/pages/MobileDeal.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@
214214
</Tabs>
215215
</div>
216216
<OrganizationModal
217+
v-if="showOrganizationModal"
217218
v-model="showOrganizationModal"
218-
v-model:organization="_organization"
219+
:data="_organization"
219220
:options="{
220221
redirect: false,
221222
afterInsert: (doc) => updateField('organization', doc.name),

0 commit comments

Comments
 (0)