Merge branch 'develop' into fix/image-upload
This commit is contained in:
commit
db2a6c65b7
@ -8,7 +8,7 @@
|
||||
|
||||
**Simplify Sales, Amplify Relationships**
|
||||
|
||||

|
||||
[](https://github.com/frappe/crm/releases)
|
||||
|
||||
<div>
|
||||
<picture>
|
||||
@ -181,6 +181,7 @@ You need Docker, docker-compose and git setup on your machine. Refer [Docker doc
|
||||
- [Discuss Forum](https://discuss.frappe.io/c/frappe-crm)
|
||||
- [Documentation](https://docs.frappe.io/crm)
|
||||
- [YouTube](https://www.youtube.com/channel/UCn3bV5kx77HsVwtnlCeEi_A)
|
||||
- [X/Twitter](https://x.com/frappetech)
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
@ -3,6 +3,7 @@ import json
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
from frappe.desk.form.assign_to import set_status
|
||||
from frappe.model import no_value_fields
|
||||
from frappe.model.document import get_controller
|
||||
from frappe.utils import make_filter_tuple
|
||||
@ -659,6 +660,24 @@ def get_fields_meta(doctype, restricted_fieldtypes=None, as_array=False, only_re
|
||||
return fields_meta
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def remove_assignments(doctype, name, assignees, ignore_permissions=False):
|
||||
assignees = json.loads(assignees)
|
||||
|
||||
if not assignees:
|
||||
return
|
||||
|
||||
for assign_to in assignees:
|
||||
set_status(
|
||||
doctype,
|
||||
name,
|
||||
todo=None,
|
||||
assign_to=assign_to,
|
||||
status="Cancelled",
|
||||
ignore_permissions=ignore_permissions,
|
||||
)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_assigned_users(doctype, name, default_assigned_to=None):
|
||||
assigned_users = frappe.get_all(
|
||||
"ToDo",
|
||||
|
||||
@ -13,7 +13,6 @@ def get_deal(name):
|
||||
|
||||
deal["fields_meta"] = get_fields_meta("CRM Deal")
|
||||
deal["_form_script"] = get_form_script("CRM Deal")
|
||||
deal["_assign"] = get_assigned_users("CRM Deal", deal.name)
|
||||
return deal
|
||||
|
||||
|
||||
|
||||
@ -13,5 +13,4 @@ def get_lead(name):
|
||||
|
||||
lead["fields_meta"] = get_fields_meta("CRM Lead")
|
||||
lead["_form_script"] = get_form_script("CRM Lead")
|
||||
lead["_assign"] = get_assigned_users("CRM Lead", lead.name)
|
||||
return lead
|
||||
|
||||
@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Frappe CRM VERSION\n"
|
||||
"Report-Msgid-Bugs-To: shariq@frappe.io\n"
|
||||
"POT-Creation-Date: 2025-05-25 09:35+0000\n"
|
||||
"PO-Revision-Date: 2025-05-25 09:35+0000\n"
|
||||
"POT-Creation-Date: 2025-06-01 09:36+0000\n"
|
||||
"PO-Revision-Date: 2025-06-01 09:36+0000\n"
|
||||
"Last-Translator: shariq@frappe.io\n"
|
||||
"Language-Team: shariq@frappe.io\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -25,6 +25,26 @@ msgstr ""
|
||||
msgid "01/04/2024 11:30 PM"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:122
|
||||
msgid "1 hour ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:118
|
||||
msgid "1 minute ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:136
|
||||
msgid "1 month ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:132
|
||||
msgid "1 week ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:140
|
||||
msgid "1 year ago"
|
||||
msgstr ""
|
||||
|
||||
#. Option for the 'No. of Employees' (Select) field in DocType 'CRM Deal'
|
||||
#. Option for the 'No. of Employees' (Select) field in DocType 'CRM Lead'
|
||||
#. Option for the 'No. of Employees' (Select) field in DocType 'CRM
|
||||
@ -176,7 +196,7 @@ msgstr ""
|
||||
msgid "Actions"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:527 frontend/src/pages/Lead.vue:519
|
||||
#: frontend/src/pages/Deal.vue:527 frontend/src/pages/Lead.vue:520
|
||||
#: frontend/src/pages/MobileDeal.vue:428 frontend/src/pages/MobileLead.vue:331
|
||||
msgid "Activity"
|
||||
msgstr ""
|
||||
@ -421,7 +441,7 @@ msgstr ""
|
||||
msgid "Attach a file"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:562 frontend/src/pages/Lead.vue:554
|
||||
#: frontend/src/pages/Deal.vue:562 frontend/src/pages/Lead.vue:555
|
||||
#: frontend/src/pages/MobileDeal.vue:464 frontend/src/pages/MobileLead.vue:367
|
||||
msgid "Attachments"
|
||||
msgstr ""
|
||||
@ -685,7 +705,7 @@ msgstr ""
|
||||
msgid "Calling..."
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:547 frontend/src/pages/Lead.vue:539
|
||||
#: frontend/src/pages/Deal.vue:547 frontend/src/pages/Lead.vue:540
|
||||
#: frontend/src/pages/MobileDeal.vue:448 frontend/src/pages/MobileLead.vue:351
|
||||
msgid "Calls"
|
||||
msgstr ""
|
||||
@ -829,7 +849,7 @@ msgstr ""
|
||||
msgid "Comment"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:537 frontend/src/pages/Lead.vue:529
|
||||
#: frontend/src/pages/Deal.vue:537 frontend/src/pages/Lead.vue:530
|
||||
#: frontend/src/pages/MobileDeal.vue:438 frontend/src/pages/MobileLead.vue:341
|
||||
msgid "Comments"
|
||||
msgstr ""
|
||||
@ -975,7 +995,7 @@ msgstr ""
|
||||
msgid "Converted successfully"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:218
|
||||
#: frontend/src/utils/index.js:295
|
||||
msgid "Copied to clipboard"
|
||||
msgstr ""
|
||||
|
||||
@ -1104,7 +1124,7 @@ msgstr ""
|
||||
|
||||
#: frontend/src/components/Activities/DataFields.vue:6
|
||||
#: frontend/src/components/Layouts/AppSidebar.vue:569
|
||||
#: frontend/src/pages/Deal.vue:542 frontend/src/pages/Lead.vue:534
|
||||
#: frontend/src/pages/Deal.vue:542 frontend/src/pages/Lead.vue:535
|
||||
#: frontend/src/pages/MobileDeal.vue:443 frontend/src/pages/MobileLead.vue:346
|
||||
msgid "Data"
|
||||
msgstr ""
|
||||
@ -1567,7 +1587,7 @@ msgstr ""
|
||||
msgid "Email template"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:532 frontend/src/pages/Lead.vue:524
|
||||
#: frontend/src/pages/Deal.vue:532 frontend/src/pages/Lead.vue:525
|
||||
#: frontend/src/pages/MobileDeal.vue:433 frontend/src/pages/MobileLead.vue:336
|
||||
msgid "Emails"
|
||||
msgstr ""
|
||||
@ -1636,7 +1656,7 @@ msgstr ""
|
||||
msgid "Equals"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Lead.vue:642
|
||||
#: frontend/src/pages/Lead.vue:651
|
||||
msgid "Error converting to deal: {0}"
|
||||
msgstr ""
|
||||
|
||||
@ -1652,7 +1672,7 @@ msgstr ""
|
||||
msgid "Error updating document"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Lead.vue:464
|
||||
#: frontend/src/pages/Lead.vue:465
|
||||
msgid "Error updating lead"
|
||||
msgstr ""
|
||||
|
||||
@ -1759,7 +1779,7 @@ msgstr ""
|
||||
msgid "Failed to create email account, Invalid credentials"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:97
|
||||
#: frontend/src/data/script.js:105
|
||||
msgid "Failed to load form controller: {0}"
|
||||
msgstr ""
|
||||
|
||||
@ -2357,13 +2377,13 @@ msgstr ""
|
||||
msgid "Lead Statuses"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Lead.vue:460 frontend/src/pages/MobileLead.vue:266
|
||||
#: frontend/src/pages/Lead.vue:461 frontend/src/pages/MobileLead.vue:266
|
||||
msgid "Lead updated successfully"
|
||||
msgstr ""
|
||||
|
||||
#. Label of a shortcut in the Frappe CRM Workspace
|
||||
#: crm/fcrm/workspace/frappe_crm/frappe_crm.json
|
||||
#: frontend/src/pages/Lead.vue:479 frontend/src/pages/MobileLead.vue:285
|
||||
#: frontend/src/pages/Lead.vue:480 frontend/src/pages/MobileLead.vue:285
|
||||
msgid "Leads"
|
||||
msgstr ""
|
||||
|
||||
@ -2876,7 +2896,7 @@ msgid "Not allowed to set primary contact for Deal"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Contact.vue:256 frontend/src/pages/Deal.vue:417
|
||||
#: frontend/src/pages/Lead.vue:427 frontend/src/pages/Organization.vue:245
|
||||
#: frontend/src/pages/Lead.vue:428 frontend/src/pages/Organization.vue:245
|
||||
msgid "Not permitted"
|
||||
msgstr ""
|
||||
|
||||
@ -2886,7 +2906,7 @@ msgstr ""
|
||||
msgid "Note"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:557 frontend/src/pages/Lead.vue:549
|
||||
#: frontend/src/pages/Deal.vue:557 frontend/src/pages/Lead.vue:550
|
||||
#: frontend/src/pages/MobileDeal.vue:459 frontend/src/pages/MobileLead.vue:362
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
@ -2934,7 +2954,7 @@ msgstr ""
|
||||
msgid "Old Parent"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Contact.vue:304 frontend/src/pages/Lead.vue:583
|
||||
#: frontend/src/pages/Contact.vue:304 frontend/src/pages/Lead.vue:584
|
||||
#: frontend/src/pages/MobileContact.vue:275
|
||||
#: frontend/src/pages/MobileOrganization.vue:258
|
||||
#: frontend/src/pages/Organization.vue:300
|
||||
@ -3148,11 +3168,11 @@ msgstr ""
|
||||
msgid "Please enter a valid URL"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Lead.vue:619 frontend/src/pages/MobileLead.vue:424
|
||||
#: frontend/src/pages/Lead.vue:622 frontend/src/pages/MobileLead.vue:424
|
||||
msgid "Please select an existing contact"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Lead.vue:624 frontend/src/pages/MobileLead.vue:429
|
||||
#: frontend/src/pages/Lead.vue:627 frontend/src/pages/MobileLead.vue:429
|
||||
msgid "Please select an existing organization"
|
||||
msgstr ""
|
||||
|
||||
@ -3929,7 +3949,7 @@ msgstr ""
|
||||
msgid "Task"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:552 frontend/src/pages/Lead.vue:544
|
||||
#: frontend/src/pages/Deal.vue:552 frontend/src/pages/Lead.vue:545
|
||||
#: frontend/src/pages/MobileDeal.vue:454 frontend/src/pages/MobileLead.vue:357
|
||||
msgid "Tasks"
|
||||
msgstr ""
|
||||
@ -4320,7 +4340,7 @@ msgstr ""
|
||||
#: crm/fcrm/doctype/crm_notification/crm_notification.json
|
||||
#: frontend/src/components/Layouts/AppSidebar.vue:592
|
||||
#: frontend/src/components/Settings/Settings.vue:124
|
||||
#: frontend/src/pages/Deal.vue:567 frontend/src/pages/Lead.vue:559
|
||||
#: frontend/src/pages/Deal.vue:567 frontend/src/pages/Lead.vue:560
|
||||
#: frontend/src/pages/MobileDeal.vue:469 frontend/src/pages/MobileLead.vue:372
|
||||
msgid "WhatsApp"
|
||||
msgstr ""
|
||||
@ -4479,6 +4499,10 @@ msgstr ""
|
||||
msgid "john@doe.com"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:116
|
||||
msgid "just now"
|
||||
msgstr ""
|
||||
|
||||
#. Option for the 'Type' (Select) field in DocType 'CRM View Settings'
|
||||
#: crm/fcrm/doctype/crm_view_settings/crm_view_settings.json
|
||||
msgid "kanban"
|
||||
@ -4502,6 +4526,10 @@ msgstr ""
|
||||
msgid "next"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:95
|
||||
msgid "now"
|
||||
msgstr ""
|
||||
|
||||
#. Option for the 'Color' (Select) field in DocType 'CRM Deal Status'
|
||||
#. Option for the 'Color' (Select) field in DocType 'CRM Lead Status'
|
||||
#: crm/fcrm/doctype/crm_deal_status/crm_deal_status.json
|
||||
@ -4572,11 +4600,35 @@ msgstr ""
|
||||
msgid "yellow"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:128
|
||||
msgid "yesterday"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:107
|
||||
msgid "{0} M"
|
||||
msgstr ""
|
||||
|
||||
#: crm/api/todo.py:50
|
||||
msgid "{0} assigned a {1} {2} to you"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:480 frontend/src/pages/Lead.vue:472
|
||||
#: frontend/src/utils/index.js:103
|
||||
msgid "{0} d"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:130
|
||||
msgid "{0} days ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:99
|
||||
msgid "{0} h"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:124
|
||||
msgid "{0} hours ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/pages/Deal.vue:480 frontend/src/pages/Lead.vue:473
|
||||
#: frontend/src/pages/MobileDeal.vue:375 frontend/src/pages/MobileLead.vue:278
|
||||
msgid "{0} is a required field"
|
||||
msgstr ""
|
||||
@ -4588,23 +4640,51 @@ msgstr ""
|
||||
msgid "{0} is an invalid email address"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:232
|
||||
#: frontend/src/utils/index.js:97
|
||||
msgid "{0} m"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:120
|
||||
msgid "{0} minutes ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:138
|
||||
msgid "{0} months ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:105
|
||||
msgid "{0} w"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:134
|
||||
msgid "{0} weeks ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:109
|
||||
msgid "{0} y"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/utils/index.js:142
|
||||
msgid "{0} years ago"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:250
|
||||
msgid "⚠️ Avoid using \"trigger\" as a field name — it conflicts with the built-in trigger() method."
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:244
|
||||
#: frontend/src/data/script.js:262
|
||||
msgid "⚠️ Method \"{0}\" not found in class."
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:74
|
||||
#: frontend/src/data/script.js:82
|
||||
msgid "⚠️ No class found for doctype: {0}, it is mandatory to have a class for the parent doctype. it can be empty, but it should be present."
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:167
|
||||
#: frontend/src/data/script.js:174
|
||||
msgid "⚠️ No data found for parent field: {0}"
|
||||
msgstr ""
|
||||
|
||||
#: frontend/src/data/script.js:175
|
||||
#: frontend/src/data/script.js:182
|
||||
msgid "⚠️ No row found for idx: {0} in parent field: {1}"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@ -250,14 +250,14 @@
|
||||
</span>
|
||||
<span v-if="activity.type">{{ __(activity.type) }}</span>
|
||||
<span
|
||||
v-if="activity.data.field_label"
|
||||
v-if="activity.data?.field_label"
|
||||
class="max-w-xs truncate font-medium text-ink-gray-8"
|
||||
>
|
||||
{{ __(activity.data.field_label) }}
|
||||
</span>
|
||||
<span v-if="activity.value">{{ __(activity.value) }}</span>
|
||||
<span
|
||||
v-if="activity.data.old_value"
|
||||
v-if="activity.data?.old_value"
|
||||
class="max-w-xs font-medium text-ink-gray-8"
|
||||
>
|
||||
<div
|
||||
@ -273,7 +273,7 @@
|
||||
</span>
|
||||
<span v-if="activity.to">{{ __('to') }}</span>
|
||||
<span
|
||||
v-if="activity.data.value"
|
||||
v-if="activity.data?.value"
|
||||
class="max-w-xs font-medium text-ink-gray-8"
|
||||
>
|
||||
<div
|
||||
@ -307,7 +307,7 @@
|
||||
>
|
||||
<div class="inline-flex flex-wrap gap-1 text-ink-gray-5">
|
||||
<span
|
||||
v-if="activity.data.field_label"
|
||||
v-if="activity.data?.field_label"
|
||||
class="max-w-xs truncate text-ink-gray-5"
|
||||
>
|
||||
{{ __(activity.data.field_label) }}
|
||||
@ -320,7 +320,7 @@
|
||||
{{ startCase(__(activity.type)) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="activity.data.old_value"
|
||||
v-if="activity.data?.old_value"
|
||||
class="max-w-xs font-medium text-ink-gray-8"
|
||||
>
|
||||
<div
|
||||
@ -336,7 +336,7 @@
|
||||
</span>
|
||||
<span v-if="activity.to">{{ __('to') }}</span>
|
||||
<span
|
||||
v-if="activity.data.value"
|
||||
v-if="activity.data?.value"
|
||||
class="max-w-xs font-medium text-ink-gray-8"
|
||||
>
|
||||
<div
|
||||
@ -365,7 +365,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="title == 'Data'" class="h-full flex flex-col px-3 sm:px-10">
|
||||
<DataFields :doctype="doctype" :docname="doc.data.name" />
|
||||
<DataFields
|
||||
:doctype="doctype"
|
||||
:docname="doc.data.name"
|
||||
@afterSave="(data) => emit('afterSave', data)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
@ -514,6 +518,8 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['afterSave'])
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const doc = defineModel()
|
||||
|
||||
@ -16,8 +16,9 @@
|
||||
@after="redirect('notes')"
|
||||
/>
|
||||
<CallLogModal
|
||||
v-if="showCallLogModal"
|
||||
v-model="showCallLogModal"
|
||||
v-model:callLog="callLog"
|
||||
:data="callLog"
|
||||
:options="{ afterInsert: () => activities.reload() }"
|
||||
/>
|
||||
</template>
|
||||
@ -91,10 +92,8 @@ function createCallLog() {
|
||||
let doctype = props.doctype
|
||||
let docname = props.doc.data?.name
|
||||
callLog.value = {
|
||||
data: {
|
||||
reference_doctype: doctype,
|
||||
reference_docname: docname,
|
||||
},
|
||||
reference_doctype: doctype,
|
||||
reference_docname: docname,
|
||||
}
|
||||
showCallLogModal.value = true
|
||||
}
|
||||
|
||||
@ -97,7 +97,11 @@
|
||||
v-model:callLogModal="showCallLogModal"
|
||||
v-model:callLog="callLog"
|
||||
/>
|
||||
<CallLogModal v-model="showCallLogModal" v-model:callLog="callLog" />
|
||||
<CallLogModal
|
||||
v-if="showCallLogModal"
|
||||
v-model="showCallLogModal"
|
||||
:data="callLog.data"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
@ -76,6 +76,9 @@ const props = defineProps({
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['afterSave'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const showDataFieldsModal = ref(false)
|
||||
@ -90,7 +93,21 @@ const tabs = createResource({
|
||||
})
|
||||
|
||||
function saveChanges() {
|
||||
document.save.submit()
|
||||
if (!document.isDirty) return
|
||||
|
||||
const updatedDoc = { ...document.doc }
|
||||
const oldDoc = { ...document.originalDoc }
|
||||
|
||||
const changes = Object.keys(updatedDoc).reduce((acc, key) => {
|
||||
if (JSON.stringify(updatedDoc[key]) !== JSON.stringify(oldDoc[key])) {
|
||||
acc[key] = updatedDoc[key]
|
||||
}
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
document.save.submit(null, {
|
||||
onSuccess: () => emit('afterSave', changes),
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
|
||||
@ -5,9 +5,11 @@
|
||||
<MobileAppHeader />
|
||||
<slot />
|
||||
</div>
|
||||
<GlobalModals />
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import MobileSidebar from '@/components/Mobile/MobileSidebar.vue'
|
||||
import MobileAppHeader from '@/components/Mobile/MobileAppHeader.vue'
|
||||
import GlobalModals from '@/components/Modals/GlobalModals.vue'
|
||||
</script>
|
||||
|
||||
@ -22,8 +22,12 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tabs.data">
|
||||
<FieldLayout :tabs="tabs.data" :data="_address" doctype="Address" />
|
||||
<div v-if="tabs.data && _address.doc">
|
||||
<FieldLayout
|
||||
:tabs="tabs.data"
|
||||
:data="_address.doc"
|
||||
doctype="Address"
|
||||
/>
|
||||
<ErrorMessage class="mt-2" :message="error" />
|
||||
</div>
|
||||
</div>
|
||||
@ -41,24 +45,24 @@
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="Address"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { FeatherIcon, createResource, ErrorMessage } from 'frappe-ui'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
import { ref, nextTick, computed, onMounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
address: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: {
|
||||
@ -70,30 +74,18 @@ const props = defineProps({
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const show = defineModel()
|
||||
const address = defineModel('address')
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
const title = ref(null)
|
||||
const editMode = ref(false)
|
||||
|
||||
let _address = ref({
|
||||
name: '',
|
||||
address_title: '',
|
||||
address_type: 'Billing',
|
||||
address_line1: '',
|
||||
address_line2: '',
|
||||
city: '',
|
||||
county: '',
|
||||
state: '',
|
||||
country: '',
|
||||
pincode: '',
|
||||
})
|
||||
const { document: _address } = useDocument('Address', props.address || '')
|
||||
|
||||
const dialogOptions = computed(() => {
|
||||
let title = !editMode.value
|
||||
? __('New Address')
|
||||
: __(_address.value.address_title)
|
||||
: __(_address.doc?.address_title)
|
||||
let size = 'xl'
|
||||
let actions = [
|
||||
{
|
||||
@ -114,42 +106,28 @@ const tabs = createResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
let doc = ref({})
|
||||
|
||||
function updateAddress() {
|
||||
error.value = null
|
||||
const old = { ...doc.value }
|
||||
const newAddress = { ..._address.value }
|
||||
|
||||
const dirty = JSON.stringify(old) !== JSON.stringify(newAddress)
|
||||
const values = newAddress
|
||||
|
||||
if (!dirty) {
|
||||
show.value = false
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
updateAddressValues.submit({
|
||||
doctype: 'Address',
|
||||
name: _address.value.name,
|
||||
fieldname: values,
|
||||
})
|
||||
}
|
||||
|
||||
const updateAddressValues = createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
onSuccess(doc) {
|
||||
const callBacks = {
|
||||
onSuccess: (doc) => {
|
||||
loading.value = false
|
||||
if (doc.name) {
|
||||
handleAddressUpdate(doc)
|
||||
}
|
||||
handleAddressUpdate(doc)
|
||||
},
|
||||
onError(err) {
|
||||
onError: (err) => {
|
||||
loading.value = false
|
||||
if (err.exc_type == 'MandatoryError') {
|
||||
const errorMessage = err.messages
|
||||
.map((msg) => msg.split(': ')[2].trim())
|
||||
.join(', ')
|
||||
error.value = __('These fields are required: {0}', [errorMessage])
|
||||
return
|
||||
}
|
||||
error.value = err
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function updateAddress() {
|
||||
loading.value = true
|
||||
await _address.save.submit(null, callBacks)
|
||||
}
|
||||
|
||||
const createAddress = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
@ -157,7 +135,7 @@ const createAddress = createResource({
|
||||
return {
|
||||
doc: {
|
||||
doctype: 'Address',
|
||||
..._address.value,
|
||||
..._address.doc,
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -179,27 +157,17 @@ function handleAddressUpdate(doc) {
|
||||
props.options.afterInsert && props.options.afterInsert(doc)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
editMode.value = false
|
||||
nextTick(() => {
|
||||
// TODO: Issue with FormControl
|
||||
// title.value.el.focus()
|
||||
doc.value = address.value?.doc || address.value || {}
|
||||
_address.value = { ...doc.value }
|
||||
if (_address.value.name) {
|
||||
editMode.value = true
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
onMounted(() => {
|
||||
editMode.value = props.address ? true : false
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
if (!props.address) {
|
||||
_address.doc = { address_type: 'Billing' }
|
||||
}
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: 'Address' }
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
|
||||
@ -145,13 +145,11 @@ function updateAssignees() {
|
||||
.map((assignee) => assignee.name)
|
||||
|
||||
if (removedAssignees.length) {
|
||||
for (let a of removedAssignees) {
|
||||
call('frappe.desk.form.assign_to.remove', {
|
||||
doctype: props.doctype,
|
||||
name: props.doc.name,
|
||||
assign_to: a,
|
||||
})
|
||||
}
|
||||
call('crm.api.doc.remove_assignments', {
|
||||
doctype: props.doctype,
|
||||
name: props.doc.name,
|
||||
assignees: JSON.stringify(removedAssignees),
|
||||
})
|
||||
}
|
||||
|
||||
if (addedAssignees.length) {
|
||||
|
||||
@ -3,13 +3,19 @@
|
||||
<template #body>
|
||||
<div class="px-4 pt-5 pb-6 bg-surface-modal sm:px-6">
|
||||
<div class="flex items-center justify-between mb-5">
|
||||
<div>
|
||||
<div class="flex items-center gap-2">
|
||||
<h3 class="text-2xl font-semibold leading-6 text-ink-gray-9">
|
||||
{{ __(dialogOptions.title) || __('Untitled') }}
|
||||
</h3>
|
||||
<Badge v-if="callLog.isDirty" :label="'Not Saved'" theme="orange" />
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<Button v-if="isManager() && !isMobileView" variant="ghost" class="w-7" @click="openQuickEntryModal">
|
||||
<Button
|
||||
v-if="isManager() && !isMobileView"
|
||||
variant="ghost"
|
||||
class="w-7"
|
||||
@click="openQuickEntryModal"
|
||||
>
|
||||
<EditIcon class="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" class="w-7" @click="show = false">
|
||||
@ -18,37 +24,51 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tabs.data">
|
||||
<FieldLayout :tabs="tabs.data" :data="_callLog" doctype="CRM Call Log" />
|
||||
<FieldLayout
|
||||
:tabs="tabs.data"
|
||||
:data="callLog.doc"
|
||||
doctype="CRM Call Log"
|
||||
/>
|
||||
<ErrorMessage class="mt-8" :message="error" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 pt-4 pb-7 sm:px-6">
|
||||
<div class="space-y-2">
|
||||
<Button class="w-full" v-for="action in dialogOptions.actions" :key="action.label" v-bind="action"
|
||||
:label="__(action.label)" :loading="loading" />
|
||||
<Button
|
||||
class="w-full"
|
||||
v-for="action in dialogOptions.actions"
|
||||
:key="action.label"
|
||||
v-bind="action"
|
||||
:label="__(action.label)"
|
||||
:loading="loading"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
<QuickEntryModal v-if="showQuickEntryModal" v-model="showQuickEntryModal" doctype="CRM Call Log" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { getRandom } from '@/utils'
|
||||
import { capture } from '@/telemetry'
|
||||
import { FeatherIcon, createResource, ErrorMessage } from 'frappe-ui'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { FeatherIcon, createResource, ErrorMessage, Badge } from 'frappe-ui'
|
||||
import { ref, nextTick, computed, onMounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: {
|
||||
afterInsert: () => { },
|
||||
afterInsert: () => {},
|
||||
},
|
||||
},
|
||||
})
|
||||
@ -56,26 +76,15 @@ const props = defineProps({
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const show = defineModel()
|
||||
const callLog = defineModel('callLog')
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
const title = ref(null)
|
||||
const editMode = ref(false)
|
||||
|
||||
let _callLog = ref({
|
||||
name: '',
|
||||
type: '',
|
||||
from: '',
|
||||
to: '',
|
||||
medium: '',
|
||||
duration: '',
|
||||
caller: '',
|
||||
receiver: '',
|
||||
status: '',
|
||||
recording_url: '',
|
||||
telephony_medium: 'Manual',
|
||||
})
|
||||
const { document: callLog } = useDocument(
|
||||
'CRM Call Log',
|
||||
props.data?.name || '',
|
||||
)
|
||||
|
||||
const dialogOptions = computed(() => {
|
||||
let title = !editMode.value ? __('New Call Log') : __('Edit Call Log')
|
||||
@ -99,41 +108,28 @@ const tabs = createResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
let doc = ref({})
|
||||
|
||||
function updateCallLog() {
|
||||
error.value = null
|
||||
const old = { ...doc.value }
|
||||
const newCallLog = { ..._callLog.value }
|
||||
|
||||
const dirty = JSON.stringify(old) !== JSON.stringify(newCallLog)
|
||||
|
||||
if (!dirty) {
|
||||
show.value = false
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
updateCallLogValues.submit({
|
||||
doctype: 'CRM Call Log',
|
||||
name: _callLog.value.name,
|
||||
fieldname: newCallLog,
|
||||
})
|
||||
}
|
||||
|
||||
const updateCallLogValues = createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
onSuccess(doc) {
|
||||
const callBacks = {
|
||||
onSuccess: (doc) => {
|
||||
loading.value = false
|
||||
if (doc.name) {
|
||||
handleCallLogUpdate(doc)
|
||||
}
|
||||
handleCallLogUpdate(doc)
|
||||
},
|
||||
onError(err) {
|
||||
onError: (err) => {
|
||||
loading.value = false
|
||||
if (err.exc_type == 'MandatoryError') {
|
||||
const errorMessage = err.messages
|
||||
.map((msg) => msg.split(': ')[2].trim())
|
||||
.join(', ')
|
||||
error.value = __('These fields are required: {0}', [errorMessage])
|
||||
return
|
||||
}
|
||||
error.value = err
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function updateCallLog() {
|
||||
loading.value = true
|
||||
await callLog.save.submit(null, callBacks)
|
||||
}
|
||||
|
||||
const createCallLog = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
@ -143,7 +139,7 @@ const createCallLog = createResource({
|
||||
doctype: 'CRM Call Log',
|
||||
id: getRandom(6),
|
||||
telephony_medium: 'Manual',
|
||||
..._callLog.value,
|
||||
...callLog.doc,
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -155,15 +151,7 @@ const createCallLog = createResource({
|
||||
}
|
||||
},
|
||||
onError(err) {
|
||||
loading.value = false
|
||||
if (err.exc_type == 'MandatoryError') {
|
||||
const errorMessage = err.messages
|
||||
.map(msg => msg.split('Log:')[1].trim())
|
||||
.join(', ')
|
||||
error.value = `These fields are required: ${errorMessage}`
|
||||
return
|
||||
}
|
||||
error.value = err
|
||||
callBacks.onError(err)
|
||||
},
|
||||
})
|
||||
|
||||
@ -172,29 +160,17 @@ function handleCallLogUpdate(doc) {
|
||||
props.options.afterInsert && props.options.afterInsert(doc)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
editMode.value = false
|
||||
nextTick(() => {
|
||||
// TODO: Issue with FormControl
|
||||
// title.value.el.focus()
|
||||
doc.value = callLog.value?.data || {}
|
||||
_callLog.value = { ...doc.value }
|
||||
if (_callLog.value.name) {
|
||||
editMode.value = true
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
onMounted(() => {
|
||||
editMode.value = props.data?.name ? true : false
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
if (!props.data?.name) {
|
||||
callLog.doc = { ...props.data }
|
||||
}
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
quickEntryProps.value = { doctype: 'CRM Call Log' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
<FieldLayout
|
||||
v-if="tabs.data?.length"
|
||||
:tabs="tabs.data"
|
||||
:data="_contact"
|
||||
:data="_contact.doc"
|
||||
doctype="Contact"
|
||||
/>
|
||||
</div>
|
||||
@ -49,9 +49,16 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import {
|
||||
showQuickEntryModal,
|
||||
quickEntryProps,
|
||||
showAddressModal,
|
||||
addressProps,
|
||||
} from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { call, createResource } from 'frappe-ui'
|
||||
import { ref, nextTick, watch } from 'vue'
|
||||
import { ref, nextTick, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -68,8 +75,6 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['openAddressModal'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const router = useRouter()
|
||||
@ -77,23 +82,23 @@ const show = defineModel()
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
let _contact = ref({})
|
||||
const { document: _contact } = useDocument('Contact')
|
||||
|
||||
async function createContact() {
|
||||
if (_contact.value.email_id) {
|
||||
_contact.value.email_ids = [{ email_id: _contact.value.email_id }]
|
||||
delete _contact.value.email_id
|
||||
if (_contact.doc.email_id) {
|
||||
_contact.doc.email_ids = [{ email_id: _contact.doc.email_id }]
|
||||
delete _contact.doc.email_id
|
||||
}
|
||||
|
||||
if (_contact.value.mobile_no) {
|
||||
_contact.value.phone_nos = [{ phone: _contact.value.mobile_no }]
|
||||
delete _contact.value.mobile_no
|
||||
if (_contact.doc.mobile_no) {
|
||||
_contact.doc.phone_nos = [{ phone: _contact.doc.mobile_no }]
|
||||
delete _contact.doc.mobile_no
|
||||
}
|
||||
|
||||
const doc = await call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: 'Contact',
|
||||
..._contact.value,
|
||||
..._contact.doc,
|
||||
},
|
||||
})
|
||||
if (doc.name) {
|
||||
@ -130,17 +135,13 @@ const tabs = createResource({
|
||||
field.read_only = false
|
||||
} else if (field.fieldname == 'address') {
|
||||
field.create = (value, close) => {
|
||||
_contact.value.address = value
|
||||
emit('openAddressModal')
|
||||
show.value = false
|
||||
_contact.doc.address = value
|
||||
openAddressModal()
|
||||
close()
|
||||
}
|
||||
field.edit = (address) => {
|
||||
emit('openAddressModal', address)
|
||||
show.value = false
|
||||
}
|
||||
field.edit = (address) => openAddressModal(address)
|
||||
} else if (field.fieldtype === 'Table') {
|
||||
_contact.value[field.fieldname] = []
|
||||
_contact.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -149,20 +150,23 @@ const tabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
nextTick(() => {
|
||||
_contact.value = { ...props.contact.data }
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
const showQuickEntryModal = defineModel('showQuickEntryModal')
|
||||
onMounted(() => {
|
||||
_contact.doc = {}
|
||||
Object.assign(_contact.doc, props.contact.data || props.contact)
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: 'Contact' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -48,6 +48,7 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { FeatherIcon, createResource, ErrorMessage, call } from 'frappe-ui'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
|
||||
@ -62,7 +63,7 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['showQuickEntryModal', 'callback'])
|
||||
const emit = defineEmits(['callback'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
@ -139,9 +140,8 @@ watch(
|
||||
)
|
||||
|
||||
function openQuickEntryModal() {
|
||||
emit('showQuickEntryModal', props.doctype)
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: props.doctype }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
ref="fieldLayoutRef"
|
||||
v-if="tabs.data?.length"
|
||||
:tabs="tabs.data"
|
||||
:data="deal"
|
||||
:data="deal.doc"
|
||||
doctype="CRM Deal"
|
||||
/>
|
||||
<ErrorMessage class="mt-4" v-if="error" :message="__(error)" />
|
||||
@ -76,9 +76,11 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { Switch, createResource } from 'frappe-ui'
|
||||
import { computed, ref, reactive, onMounted, nextTick, watch } from 'vue'
|
||||
import { computed, ref, onMounted, nextTick, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -92,24 +94,7 @@ const show = defineModel()
|
||||
const router = useRouter()
|
||||
const error = ref(null)
|
||||
|
||||
const deal = reactive({
|
||||
organization: '',
|
||||
organization_name: '',
|
||||
website: '',
|
||||
no_of_employees: '',
|
||||
territory: '',
|
||||
annual_revenue: '',
|
||||
industry: '',
|
||||
contact: '',
|
||||
salutation: '',
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
email: '',
|
||||
mobile_no: '',
|
||||
gender: '',
|
||||
status: '',
|
||||
deal_owner: '',
|
||||
})
|
||||
const { document: deal } = useDocument('CRM Deal')
|
||||
|
||||
const hasOrganizationSections = ref(true)
|
||||
const hasContactSections = ref(true)
|
||||
@ -165,11 +150,11 @@ const tabs = createResource({
|
||||
if (field.fieldname == 'status') {
|
||||
field.fieldtype = 'Select'
|
||||
field.options = dealStatuses.value
|
||||
field.prefix = getDealStatus(deal.status).color
|
||||
field.prefix = getDealStatus(deal.doc.status).color
|
||||
}
|
||||
|
||||
if (field.fieldtype === 'Table') {
|
||||
deal[field.fieldname] = []
|
||||
deal.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -180,46 +165,49 @@ const tabs = createResource({
|
||||
|
||||
const dealStatuses = computed(() => {
|
||||
let statuses = statusOptions('deal')
|
||||
if (!deal.status) {
|
||||
deal.status = statuses[0].value
|
||||
if (!deal.doc.status) {
|
||||
deal.doc.status = statuses[0].value
|
||||
}
|
||||
return statuses
|
||||
})
|
||||
|
||||
function createDeal() {
|
||||
if (deal.website && !deal.website.startsWith('http')) {
|
||||
deal.website = 'https://' + deal.website
|
||||
if (deal.doc.website && !deal.doc.website.startsWith('http')) {
|
||||
deal.doc.website = 'https://' + deal.doc.website
|
||||
}
|
||||
if (chooseExistingContact.value) {
|
||||
deal['first_name'] = null
|
||||
deal['last_name'] = null
|
||||
deal['email'] = null
|
||||
deal['mobile_no'] = null
|
||||
} else deal['contact'] = null
|
||||
deal.doc['first_name'] = null
|
||||
deal.doc['last_name'] = null
|
||||
deal.doc['email'] = null
|
||||
deal.doc['mobile_no'] = null
|
||||
} else deal.doc['contact'] = null
|
||||
|
||||
createResource({
|
||||
url: 'crm.fcrm.doctype.crm_deal.crm_deal.create_deal',
|
||||
params: { args: deal },
|
||||
params: { args: deal.doc },
|
||||
auto: true,
|
||||
validate() {
|
||||
error.value = null
|
||||
if (deal.annual_revenue) {
|
||||
if (typeof deal.annual_revenue === 'string') {
|
||||
deal.annual_revenue = deal.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(deal.annual_revenue)) {
|
||||
if (deal.doc.annual_revenue) {
|
||||
if (typeof deal.doc.annual_revenue === 'string') {
|
||||
deal.doc.annual_revenue = deal.doc.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(deal.doc.annual_revenue)) {
|
||||
error.value = __('Annual Revenue should be a number')
|
||||
return error.value
|
||||
}
|
||||
}
|
||||
if (deal.mobile_no && isNaN(deal.mobile_no.replace(/[-+() ]/g, ''))) {
|
||||
if (
|
||||
deal.doc.mobile_no &&
|
||||
isNaN(deal.doc.mobile_no.replace(/[-+() ]/g, ''))
|
||||
) {
|
||||
error.value = __('Mobile No should be a number')
|
||||
return error.value
|
||||
}
|
||||
if (deal.email && !deal.email.includes('@')) {
|
||||
if (deal.doc.email && !deal.doc.email.includes('@')) {
|
||||
error.value = __('Invalid Email')
|
||||
return error.value
|
||||
}
|
||||
if (!deal.status) {
|
||||
if (!deal.doc.status) {
|
||||
error.value = __('Status is required')
|
||||
return error.value
|
||||
}
|
||||
@ -242,22 +230,21 @@ function createDeal() {
|
||||
})
|
||||
}
|
||||
|
||||
const showQuickEntryModal = defineModel('quickEntry')
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
quickEntryProps.value = { doctype: 'CRM Deal' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
Object.assign(deal, props.defaults)
|
||||
if (!deal.deal_owner) {
|
||||
deal.deal_owner = getUser().name
|
||||
deal.doc = { no_of_employees: '1-10' }
|
||||
Object.assign(deal.doc, props.defaults)
|
||||
|
||||
if (!deal.doc.deal_owner) {
|
||||
deal.doc.deal_owner = getUser().name
|
||||
}
|
||||
if (!deal.status && dealStatuses.value[0].value) {
|
||||
deal.status = dealStatuses.value[0].value
|
||||
if (!deal.doc.status && dealStatuses.value[0].value) {
|
||||
deal.doc.status = dealStatuses.value[0].value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -4,19 +4,24 @@
|
||||
v-model="showCreateDocumentModal"
|
||||
:doctype="createDocumentDoctype"
|
||||
:data="createDocumentData"
|
||||
@showQuickEntryModal="(dt) => openQuickEntryModal(dt)"
|
||||
@callback="(data) => createDocumentCallback(data)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
:doctype="quickEntryDoctype"
|
||||
v-bind="quickEntryProps"
|
||||
/>
|
||||
<AddressModal
|
||||
v-if="showAddressModal"
|
||||
v-model="showAddressModal"
|
||||
v-bind="addressProps"
|
||||
/>
|
||||
<AboutModal v-model="showAboutModal" />
|
||||
</template>
|
||||
<script setup>
|
||||
import CreateDocumentModal from '@/components/Modals/CreateDocumentModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import AboutModal from '@/components/Modals/AboutModal.vue'
|
||||
import {
|
||||
showCreateDocumentModal,
|
||||
@ -24,14 +29,11 @@ import {
|
||||
createDocumentData,
|
||||
createDocumentCallback,
|
||||
} from '@/composables/document'
|
||||
import { showAboutModal } from '@/composables/settings'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
const quickEntryDoctype = ref('')
|
||||
|
||||
function openQuickEntryModal(dt) {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryDoctype.value = dt
|
||||
}
|
||||
import {
|
||||
showQuickEntryModal,
|
||||
quickEntryProps,
|
||||
showAddressModal,
|
||||
addressProps,
|
||||
showAboutModal
|
||||
} from '@/composables/modals'
|
||||
</script>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<FieldLayout v-if="tabs.data" :tabs="tabs.data" :data="lead" />
|
||||
<FieldLayout v-if="tabs.data" :tabs="tabs.data" :data="lead.doc" />
|
||||
<ErrorMessage class="mt-4" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
</div>
|
||||
@ -48,10 +48,12 @@ import { usersStore } from '@/stores/users'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { capture } from '@/telemetry'
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { useOnboarding } from 'frappe-ui/frappe'
|
||||
import { computed, onMounted, ref, reactive, nextTick } from 'vue'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { computed, onMounted, ref, nextTick } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -68,6 +70,16 @@ const router = useRouter()
|
||||
const error = ref(null)
|
||||
const isLeadCreating = ref(false)
|
||||
|
||||
const { document: lead } = useDocument('CRM Lead')
|
||||
|
||||
const leadStatuses = computed(() => {
|
||||
let statuses = statusOptions('lead')
|
||||
if (!lead.doc.status) {
|
||||
lead.doc.status = statuses?.[0]?.value
|
||||
}
|
||||
return statuses
|
||||
})
|
||||
|
||||
const tabs = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout',
|
||||
cache: ['QuickEntry', 'CRM Lead'],
|
||||
@ -81,11 +93,11 @@ const tabs = createResource({
|
||||
if (field.fieldname == 'status') {
|
||||
field.fieldtype = 'Select'
|
||||
field.options = leadStatuses.value
|
||||
field.prefix = getLeadStatus(lead.status).color
|
||||
field.prefix = getLeadStatus(lead.doc.status).color
|
||||
}
|
||||
|
||||
if (field.fieldtype === 'Table') {
|
||||
lead[field.fieldname] = []
|
||||
lead.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -94,23 +106,6 @@ const tabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const lead = reactive({
|
||||
salutation: '',
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
email: '',
|
||||
mobile_no: '',
|
||||
gender: '',
|
||||
organization: '',
|
||||
website: '',
|
||||
no_of_employees: '',
|
||||
territory: '',
|
||||
annual_revenue: '',
|
||||
industry: '',
|
||||
status: '',
|
||||
lead_owner: '',
|
||||
})
|
||||
|
||||
const createLead = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
makeParams(values) {
|
||||
@ -123,43 +118,38 @@ const createLead = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const leadStatuses = computed(() => {
|
||||
let statuses = statusOptions('lead')
|
||||
if (!lead.status) {
|
||||
lead.status = statuses?.[0]?.value
|
||||
}
|
||||
return statuses
|
||||
})
|
||||
|
||||
function createNewLead() {
|
||||
if (lead.website && !lead.website.startsWith('http')) {
|
||||
lead.website = 'https://' + lead.website
|
||||
if (lead.doc.website && !lead.doc.website.startsWith('http')) {
|
||||
lead.doc.website = 'https://' + lead.doc.website
|
||||
}
|
||||
|
||||
createLead.submit(lead, {
|
||||
createLead.submit(lead.doc, {
|
||||
validate() {
|
||||
error.value = null
|
||||
if (!lead.first_name) {
|
||||
if (!lead.doc.first_name) {
|
||||
error.value = __('First Name is mandatory')
|
||||
return error.value
|
||||
}
|
||||
if (lead.annual_revenue) {
|
||||
if (typeof lead.annual_revenue === 'string') {
|
||||
lead.annual_revenue = lead.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(lead.annual_revenue)) {
|
||||
if (lead.doc.annual_revenue) {
|
||||
if (typeof lead.doc.annual_revenue === 'string') {
|
||||
lead.doc.annual_revenue = lead.doc.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(lead.doc.annual_revenue)) {
|
||||
error.value = __('Annual Revenue should be a number')
|
||||
return error.value
|
||||
}
|
||||
}
|
||||
if (lead.mobile_no && isNaN(lead.mobile_no.replace(/[-+() ]/g, ''))) {
|
||||
if (
|
||||
lead.doc.mobile_no &&
|
||||
isNaN(lead.doc.mobile_no.replace(/[-+() ]/g, ''))
|
||||
) {
|
||||
error.value = __('Mobile No should be a number')
|
||||
return error.value
|
||||
}
|
||||
if (lead.email && !lead.email.includes('@')) {
|
||||
if (lead.doc.email && !lead.doc.email.includes('@')) {
|
||||
error.value = __('Invalid Email')
|
||||
return error.value
|
||||
}
|
||||
if (!lead.status) {
|
||||
if (!lead.doc.status) {
|
||||
error.value = __('Status is required')
|
||||
return error.value
|
||||
}
|
||||
@ -185,22 +175,21 @@ function createNewLead() {
|
||||
})
|
||||
}
|
||||
|
||||
const showQuickEntryModal = defineModel('quickEntry')
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
quickEntryProps.value = { doctype: 'CRM Lead' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
Object.assign(lead, props.defaults)
|
||||
if (!lead.lead_owner) {
|
||||
lead.lead_owner = getUser().name
|
||||
lead.doc = { no_of_employees: '1-10' }
|
||||
Object.assign(lead.doc, props.defaults)
|
||||
|
||||
if (!lead.doc?.lead_owner) {
|
||||
lead.doc.lead_owner = getUser().name
|
||||
}
|
||||
if (!lead.status && leadStatuses.value[0]?.value) {
|
||||
lead.status = leadStatuses.value[0].value
|
||||
if (!lead.doc?.status && leadStatuses.value[0]?.value) {
|
||||
lead.doc.status = leadStatuses.value[0].value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -9,7 +9,12 @@
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<Button v-if="isManager() && !isMobileView" variant="ghost" class="w-7" @click="openQuickEntryModal">
|
||||
<Button
|
||||
v-if="isManager() && !isMobileView"
|
||||
variant="ghost"
|
||||
class="w-7"
|
||||
@click="openQuickEntryModal"
|
||||
>
|
||||
<EditIcon class="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" class="w-7" @click="show = false">
|
||||
@ -17,12 +22,23 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<FieldLayout v-if="tabs.data?.length" :tabs="tabs.data" :data="_organization" doctype="CRM Organization" />
|
||||
<FieldLayout
|
||||
v-if="tabs.data?.length"
|
||||
:tabs="tabs.data"
|
||||
:data="organization.doc"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
<ErrorMessage class="mt-8" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
<div class="px-4 pt-4 pb-7 sm:px-6">
|
||||
<div class="space-y-2">
|
||||
<Button class="w-full" variant="solid" :label="__('Create')" :loading="loading" @click="createOrganization" />
|
||||
<Button
|
||||
class="w-full"
|
||||
variant="solid"
|
||||
:label="__('Create')"
|
||||
:loading="loading"
|
||||
@click="createOrganization"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -34,56 +50,59 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import {
|
||||
showQuickEntryModal,
|
||||
quickEntryProps,
|
||||
showAddressModal,
|
||||
addressProps,
|
||||
} from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { call, FeatherIcon, createResource } from 'frappe-ui'
|
||||
import { ref, nextTick, watch } from 'vue'
|
||||
import { ref, nextTick, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: {
|
||||
redirect: true,
|
||||
afterInsert: () => { },
|
||||
afterInsert: () => {},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['openAddressModal'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const router = useRouter()
|
||||
const show = defineModel()
|
||||
const organization = defineModel('organization')
|
||||
|
||||
const loading = ref(false)
|
||||
const title = ref(null)
|
||||
|
||||
let _organization = ref({
|
||||
organization_name: '',
|
||||
website: '',
|
||||
annual_revenue: '',
|
||||
no_of_employees: '1-10',
|
||||
industry: '',
|
||||
})
|
||||
|
||||
let doc = ref({})
|
||||
const error = ref(null)
|
||||
|
||||
const { document: organization } = useDocument('CRM Organization')
|
||||
|
||||
async function createOrganization() {
|
||||
const doc = await call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: 'CRM Organization',
|
||||
..._organization.value,
|
||||
const doc = await call(
|
||||
'frappe.client.insert',
|
||||
{
|
||||
doc: {
|
||||
doctype: 'CRM Organization',
|
||||
...organization.doc,
|
||||
},
|
||||
},
|
||||
}, {
|
||||
onError: (err) => {
|
||||
if (err.error.exc_type == 'ValidationError') {
|
||||
error.value = err.error?.messages?.[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
onError: (err) => {
|
||||
if (err.error.exc_type == 'ValidationError') {
|
||||
error.value = err.error?.messages?.[0]
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
loading.value = false
|
||||
if (doc.name) {
|
||||
capture('organization_created')
|
||||
@ -97,8 +116,6 @@ function handleOrganizationUpdate(doc) {
|
||||
name: 'Organization',
|
||||
params: { organizationId: doc.name },
|
||||
})
|
||||
} else {
|
||||
organization.value?.reload?.()
|
||||
}
|
||||
show.value = false
|
||||
props.options.afterInsert && props.options.afterInsert(doc)
|
||||
@ -116,17 +133,13 @@ const tabs = createResource({
|
||||
column.fields.forEach((field) => {
|
||||
if (field.fieldname == 'address') {
|
||||
field.create = (value, close) => {
|
||||
_organization.value.address = value
|
||||
emit('openAddressModal')
|
||||
show.value = false
|
||||
organization.doc.address = value
|
||||
openAddressModal()
|
||||
close()
|
||||
}
|
||||
field.edit = (address) => {
|
||||
emit('openAddressModal', address)
|
||||
show.value = false
|
||||
}
|
||||
field.edit = (address) => openAddressModal(address)
|
||||
} else if (field.fieldtype === 'Table') {
|
||||
_organization.value[field.fieldname] = []
|
||||
organization.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -135,23 +148,23 @@ const tabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
nextTick(() => {
|
||||
// TODO: Issue with FormControl
|
||||
// title.value.el.focus()
|
||||
doc.value = organization.value?.doc || organization.value || {}
|
||||
_organization.value = { ...doc.value }
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
const showQuickEntryModal = defineModel('showQuickEntryModal')
|
||||
onMounted(() => {
|
||||
organization.doc = { no_of_employees: '1-10' }
|
||||
Object.assign(organization.doc, props.data)
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: 'CRM Organization' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -417,13 +417,13 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['afterFieldChange', 'reload'])
|
||||
|
||||
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
getMeta(props.doctype)
|
||||
|
||||
const { isManager, getUser } = usersStore()
|
||||
|
||||
const emit = defineEmits(['reload'])
|
||||
|
||||
const showSidePanelModal = ref(false)
|
||||
|
||||
let document = { doc: {} }
|
||||
@ -493,7 +493,13 @@ async function fieldChange(value, df) {
|
||||
|
||||
await triggerOnChange(df.fieldname)
|
||||
|
||||
document.save.submit()
|
||||
document.save.submit(null, {
|
||||
onSuccess: () => {
|
||||
emit('afterFieldChange', {
|
||||
[df.fieldname]: value,
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function parsedSection(section, editButtonAdded) {
|
||||
|
||||
@ -55,11 +55,8 @@ import Apps from '@/components/Apps.vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import {
|
||||
showSettings,
|
||||
isMobileView,
|
||||
showAboutModal,
|
||||
} from '@/composables/settings'
|
||||
import { showSettings, isMobileView } from '@/composables/settings'
|
||||
import { showAboutModal } from '@/composables/modals'
|
||||
import { confirmLoginToFrappeCloud } from '@/composables/frappecloud'
|
||||
import { Dropdown } from 'frappe-ui'
|
||||
import { theme, toggleTheme } from '@/stores/theme'
|
||||
|
||||
9
frontend/src/composables/modals.js
Normal file
9
frontend/src/composables/modals.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const showQuickEntryModal = ref(false);
|
||||
export const quickEntryProps = ref({});
|
||||
|
||||
export const showAddressModal = ref(false);
|
||||
export const addressProps = ref({});
|
||||
|
||||
export const showAboutModal = ref(false);
|
||||
@ -42,5 +42,3 @@ export const isMobileView = computed(() => window.innerWidth < 768)
|
||||
|
||||
export const showSettings = ref(false)
|
||||
export const activeSettingsPage = ref('')
|
||||
|
||||
export const showAboutModal = ref(false)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { getScript } from '@/data/script'
|
||||
import { runSequentially } from '@/utils'
|
||||
import { createDocumentResource, toast } from 'frappe-ui'
|
||||
import { runSequentially, parseAssignees } from '@/utils'
|
||||
import { createDocumentResource, createResource, toast } from 'frappe-ui'
|
||||
import { reactive } from 'vue'
|
||||
|
||||
const documentsCache = {}
|
||||
const controllersCache = {}
|
||||
@ -10,27 +11,46 @@ export function useDocument(doctype, docname) {
|
||||
|
||||
documentsCache[doctype] = documentsCache[doctype] || {}
|
||||
|
||||
if (!documentsCache[doctype][docname]) {
|
||||
documentsCache[doctype][docname] = createDocumentResource({
|
||||
if (!documentsCache[doctype][docname || '']) {
|
||||
if (docname) {
|
||||
documentsCache[doctype][docname] = createDocumentResource({
|
||||
doctype: doctype,
|
||||
name: docname,
|
||||
onSuccess: async () => await setupFormScript(),
|
||||
setValue: {
|
||||
onSuccess: () => {
|
||||
triggerOnSave()
|
||||
toast.success(__('Document updated successfully'))
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(__('Error updating document'))
|
||||
console.error(err)
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
documentsCache[doctype][''] = reactive({
|
||||
doc: {},
|
||||
})
|
||||
setupFormScript()
|
||||
}
|
||||
}
|
||||
|
||||
const assignees = createResource({
|
||||
url: 'crm.api.doc.get_assigned_users',
|
||||
cache: `assignees:${doctype}:${docname}`,
|
||||
auto: docname ? true : false,
|
||||
params: {
|
||||
doctype: doctype,
|
||||
name: docname,
|
||||
onSuccess: async () => await setupFormScript(),
|
||||
setValue: {
|
||||
onSuccess: () => {
|
||||
toast.success(__('Document updated successfully'))
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(__('Error updating document'))
|
||||
console.error(err)
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
transform: (data) => parseAssignees(data),
|
||||
})
|
||||
|
||||
async function setupFormScript() {
|
||||
if (
|
||||
controllersCache[doctype] &&
|
||||
typeof controllersCache[doctype][docname] === 'object'
|
||||
typeof controllersCache[doctype][docname || ''] === 'object'
|
||||
) {
|
||||
return
|
||||
}
|
||||
@ -39,9 +59,11 @@ export function useDocument(doctype, docname) {
|
||||
controllersCache[doctype] = {}
|
||||
}
|
||||
|
||||
controllersCache[doctype][docname] = {}
|
||||
controllersCache[doctype][docname || ''] = {}
|
||||
|
||||
const controllersArray = await setupScript(documentsCache[doctype][docname])
|
||||
const controllersArray = await setupScript(
|
||||
documentsCache[doctype][docname || ''],
|
||||
)
|
||||
|
||||
if (!controllersArray || controllersArray.length === 0) return
|
||||
|
||||
@ -53,14 +75,16 @@ export function useDocument(doctype, docname) {
|
||||
}
|
||||
organizedControllers[controllerKey].push(controller)
|
||||
}
|
||||
controllersCache[doctype][docname] = organizedControllers
|
||||
controllersCache[doctype][docname || ''] = organizedControllers
|
||||
|
||||
triggerOnLoad()
|
||||
}
|
||||
|
||||
function getControllers(row = null) {
|
||||
const _doctype = row?.doctype || doctype
|
||||
const controllerKey = _doctype.replace(/\s+/g, '')
|
||||
|
||||
const docControllers = controllersCache[doctype]?.[docname]
|
||||
const docControllers = controllersCache[doctype]?.[docname || '']
|
||||
|
||||
if (
|
||||
typeof docControllers === 'object' &&
|
||||
@ -72,9 +96,23 @@ export function useDocument(doctype, docname) {
|
||||
return []
|
||||
}
|
||||
|
||||
async function triggerOnLoad() {
|
||||
const handler = async function () {
|
||||
await (this.onLoad?.() || this.on_load?.() || this.onload?.())
|
||||
}
|
||||
await trigger(handler)
|
||||
}
|
||||
|
||||
async function triggerOnSave() {
|
||||
const handler = async function () {
|
||||
await (this.onSave?.() || this.on_save?.())
|
||||
}
|
||||
await trigger(handler)
|
||||
}
|
||||
|
||||
async function triggerOnRefresh() {
|
||||
const handler = async function () {
|
||||
await this.refresh()
|
||||
await this.refresh?.()
|
||||
}
|
||||
await trigger(handler)
|
||||
}
|
||||
@ -86,7 +124,7 @@ export function useDocument(doctype, docname) {
|
||||
this.value = row[fieldname]
|
||||
this.oldValue = getOldValue(fieldname, row)
|
||||
} else {
|
||||
this.value = documentsCache[doctype][docname].doc[fieldname]
|
||||
this.value = documentsCache[doctype][docname || ''].doc[fieldname]
|
||||
this.oldValue = getOldValue(fieldname)
|
||||
}
|
||||
await this[fieldname]?.()
|
||||
@ -126,7 +164,7 @@ export function useDocument(doctype, docname) {
|
||||
async function triggerOnCreateLead() {
|
||||
const args = Array.from(arguments)
|
||||
const handler = async function () {
|
||||
await this.on_create_lead?.(...args)
|
||||
await (this.onCreateLead?.(...args) || this.on_create_lead?.(...args))
|
||||
}
|
||||
await trigger(handler)
|
||||
}
|
||||
@ -134,7 +172,8 @@ export function useDocument(doctype, docname) {
|
||||
async function triggerConvertToDeal() {
|
||||
const args = Array.from(arguments)
|
||||
const handler = async function () {
|
||||
await this.convert_to_deal?.(...args)
|
||||
await (this.convertToDeal?.(...args) ||
|
||||
this.on_convert_to_deal?.(...args))
|
||||
}
|
||||
await trigger(handler)
|
||||
}
|
||||
@ -151,9 +190,9 @@ export function useDocument(doctype, docname) {
|
||||
}
|
||||
|
||||
function getOldValue(fieldname, row) {
|
||||
if (!documentsCache[doctype][docname]) return ''
|
||||
if (!documentsCache[doctype][docname || '']) return ''
|
||||
|
||||
const document = documentsCache[doctype][docname]
|
||||
const document = documentsCache[doctype][docname || '']
|
||||
const oldDoc = document.originalDoc
|
||||
|
||||
if (row?.name) {
|
||||
@ -166,11 +205,15 @@ export function useDocument(doctype, docname) {
|
||||
}
|
||||
|
||||
return {
|
||||
document: documentsCache[doctype][docname],
|
||||
document: documentsCache[doctype][docname || ''],
|
||||
assignees,
|
||||
getControllers,
|
||||
triggerOnLoad,
|
||||
triggerOnSave,
|
||||
triggerOnRefresh,
|
||||
triggerOnChange,
|
||||
triggerOnRowAdd,
|
||||
triggerOnRowRemove,
|
||||
triggerOnRefresh,
|
||||
setupFormScript,
|
||||
triggerOnCreateLead,
|
||||
triggerConvertToDeal,
|
||||
|
||||
@ -33,7 +33,7 @@ export function getScript(doctype, view = 'Form') {
|
||||
}
|
||||
|
||||
async function setupScript(document, helpers = {}) {
|
||||
await scripts.promise
|
||||
await scripts.list.promise
|
||||
|
||||
let scriptDefs = doctypeScripts[doctype]
|
||||
if (!scriptDefs || Object.keys(scriptDefs).length === 0) return null
|
||||
@ -116,8 +116,13 @@ export function getScript(doctype, view = 'Form') {
|
||||
parentInstance = null,
|
||||
isChildDoctype = false,
|
||||
) {
|
||||
document.actions = document.actions || []
|
||||
document.statuses = document.statuses || []
|
||||
|
||||
let instance = new FormClass()
|
||||
|
||||
// Store the original document context to be used by properties like 'actions'
|
||||
instance._originalDocumentContext = document
|
||||
instance._isChildDoctype = isChildDoctype
|
||||
|
||||
for (const key in document) {
|
||||
@ -199,6 +204,76 @@ export function getScript(doctype, view = 'Form') {
|
||||
return createDocProxy(row, this)
|
||||
}
|
||||
}
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(FormClass.prototype, 'actions')) {
|
||||
Object.defineProperty(FormClass.prototype, 'actions', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
if (!this._originalDocumentContext) {
|
||||
console.warn(
|
||||
'CRM Script: _originalDocumentContext not found on instance for actions getter.',
|
||||
)
|
||||
return []
|
||||
}
|
||||
|
||||
return this._originalDocumentContext.actions
|
||||
},
|
||||
set(newValue) {
|
||||
if (!this._originalDocumentContext) {
|
||||
console.warn(
|
||||
'CRM Script: _originalDocumentContext not found on instance for actions setter.',
|
||||
)
|
||||
return
|
||||
}
|
||||
if (!Array.isArray(newValue)) {
|
||||
console.warn(
|
||||
'CRM Script: "actions" property must be an array. Value was not set.',
|
||||
newValue,
|
||||
)
|
||||
this._originalDocumentContext.actions = []
|
||||
return
|
||||
}
|
||||
this._originalDocumentContext.actions = newValue
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(FormClass.prototype, 'statuses')
|
||||
) {
|
||||
Object.defineProperty(FormClass.prototype, 'statuses', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
if (!this._originalDocumentContext) {
|
||||
console.warn(
|
||||
'CRM Script: _originalDocumentContext not found on instance for statuses getter.',
|
||||
)
|
||||
return []
|
||||
}
|
||||
|
||||
return this._originalDocumentContext.statuses
|
||||
},
|
||||
set(newValue) {
|
||||
if (!this._originalDocumentContext) {
|
||||
console.warn(
|
||||
'CRM Script: _originalDocumentContext not found on instance for statuses setter.',
|
||||
)
|
||||
return
|
||||
}
|
||||
if (!Array.isArray(newValue)) {
|
||||
console.warn(
|
||||
'CRM Script: "statuses" property must be an array. Value was not set.',
|
||||
newValue,
|
||||
)
|
||||
this._originalDocumentContext.statuses = []
|
||||
return
|
||||
}
|
||||
this._originalDocumentContext.statuses = newValue
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// utility function to setup a form controller
|
||||
|
||||
@ -62,8 +62,9 @@
|
||||
v-model:callLog="callLog"
|
||||
/>
|
||||
<CallLogModal
|
||||
v-if="showCallLogModal"
|
||||
v-model="showCallLogModal"
|
||||
v-model:callLog="callLog"
|
||||
:data="callLog.data"
|
||||
:options="{ afterInsert: () => callLogs.reload() }"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@ -172,7 +172,6 @@
|
||||
:errorTitle="errorTitle"
|
||||
:errorMessage="errorMessage"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -187,6 +186,7 @@ import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import { formatDate, timeAgo, validateIsImageFile } from '@/utils'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
@ -208,7 +208,6 @@ import {
|
||||
} from 'frappe-ui'
|
||||
import { ref, computed, h } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { errorMessage as _errorMessage } from '../utils'
|
||||
|
||||
const { brand } = getSettings()
|
||||
const { $dialog, makeCall } = globalStore()
|
||||
@ -228,9 +227,7 @@ const props = defineProps({
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _contact = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const errorTitle = ref('')
|
||||
const errorMessage = ref('')
|
||||
@ -486,17 +483,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_contact.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -555,18 +545,6 @@ async function deleteOption(doctype, name) {
|
||||
toast.success(__('Contact updated'))
|
||||
}
|
||||
|
||||
async function updateField(fieldname, value) {
|
||||
await call('frappe.client.set_value', {
|
||||
doctype: 'Contact',
|
||||
name: props.contactId,
|
||||
fieldname,
|
||||
value,
|
||||
})
|
||||
toast.success(__('Contact updated'))
|
||||
|
||||
contact.reload()
|
||||
}
|
||||
|
||||
const { getFormattedCurrency } = getMeta('CRM Deal')
|
||||
|
||||
const columns = computed(() => dealColumns)
|
||||
@ -634,4 +612,12 @@ const dealColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -63,17 +63,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<ContactModal
|
||||
v-if="showContactModal"
|
||||
v-model="showContactModal"
|
||||
v-model:showQuickEntryModal="showQuickEntryModal"
|
||||
:contact="{}"
|
||||
@openAddressModal="(_address) => openAddressModal(_address)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="Contact"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -82,14 +75,11 @@ import CustomActions from '@/components/CustomActions.vue'
|
||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import ContactModal from '@/components/Modals/ContactModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { organizationsStore } from '@/stores/organizations.js'
|
||||
import { formatDate, timeAgo } from '@/utils'
|
||||
import { call } from 'frappe-ui'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
@ -97,14 +87,11 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
const { getOrganization } = organizationsStore()
|
||||
|
||||
const showContactModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
const showAddressModal = ref(false)
|
||||
|
||||
const contactsListView = ref(null)
|
||||
|
||||
// contacts data is loaded in the ViewControls component
|
||||
const contacts = ref({})
|
||||
const address = ref({})
|
||||
const loadMore = ref(1)
|
||||
const triggerResize = ref(1)
|
||||
const updatedPageCount = ref(20)
|
||||
@ -166,15 +153,4 @@ const rows = computed(() => {
|
||||
return _rows
|
||||
})
|
||||
})
|
||||
|
||||
async function openAddressModal(_address) {
|
||||
if (_address) {
|
||||
_address = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: _address,
|
||||
})
|
||||
}
|
||||
showAddressModal.value = true
|
||||
address.value = _address || {}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,18 +12,25 @@
|
||||
v-if="deal.data._customActions?.length"
|
||||
:actions="deal.data._customActions"
|
||||
/>
|
||||
<CustomActions
|
||||
v-if="document.actions?.length"
|
||||
:actions="document.actions"
|
||||
/>
|
||||
<AssignTo
|
||||
v-model="deal.data._assignedTo"
|
||||
:data="deal.data"
|
||||
v-model="assignees.data"
|
||||
:data="document.doc"
|
||||
doctype="CRM Deal"
|
||||
/>
|
||||
<Dropdown
|
||||
:options="statusOptions('deal', updateField, deal.data._customStatuses)"
|
||||
v-if="document.doc"
|
||||
:options="statusOptions('deal', document, deal.data._customStatuses)"
|
||||
>
|
||||
<template #default="{ open }">
|
||||
<Button :label="deal.data.status">
|
||||
<Button :label="document.doc.status">
|
||||
<template #prefix>
|
||||
<IndicatorIcon :class="getDealStatus(deal.data.status).color" />
|
||||
<IndicatorIcon
|
||||
:class="getDealStatus(document.doc.status).color"
|
||||
/>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<FeatherIcon
|
||||
@ -46,6 +53,7 @@
|
||||
v-model:reload="reload"
|
||||
v-model:tabIndex="tabIndex"
|
||||
v-model="deal"
|
||||
@afterSave="reloadAssignees"
|
||||
/>
|
||||
</template>
|
||||
</Tabs>
|
||||
@ -134,6 +142,7 @@
|
||||
doctype="CRM Deal"
|
||||
:docname="deal.data.name"
|
||||
@reload="sections.reload"
|
||||
@afterFieldChange="reloadAssignees"
|
||||
>
|
||||
<template #actions="{ section }">
|
||||
<div v-if="section.name == 'contacts_section'" class="pr-2">
|
||||
@ -272,14 +281,16 @@
|
||||
:errorMessage="errorMessage"
|
||||
/>
|
||||
<OrganizationModal
|
||||
v-if="showOrganizationModal"
|
||||
v-model="showOrganizationModal"
|
||||
v-model:organization="_organization"
|
||||
:data="_organization"
|
||||
:options="{
|
||||
redirect: false,
|
||||
afterInsert: (doc) => updateField('organization', doc.name),
|
||||
}"
|
||||
/>
|
||||
<ContactModal
|
||||
v-if="showContactModal"
|
||||
v-model="showContactModal"
|
||||
:contact="_contact"
|
||||
:options="{
|
||||
@ -330,17 +341,13 @@ import Section from '@/components/Section.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import SLASection from '@/components/SLASection.vue'
|
||||
import CustomActions from '@/components/CustomActions.vue'
|
||||
import {
|
||||
openWebsite,
|
||||
setupAssignees,
|
||||
setupCustomizations,
|
||||
copyToClipboard,
|
||||
} from '@/utils'
|
||||
import { openWebsite, setupCustomizations, copyToClipboard } from '@/utils'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { globalStore } from '@/stores/global'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { whatsappEnabled, callEnabled } from '@/composables/settings'
|
||||
import {
|
||||
createResource,
|
||||
@ -394,7 +401,6 @@ const deal = createResource({
|
||||
organization.fetch()
|
||||
}
|
||||
|
||||
setupAssignees(deal)
|
||||
setupCustomizations(deal, {
|
||||
doc: data,
|
||||
$dialog,
|
||||
@ -719,4 +725,12 @@ const activities = ref(null)
|
||||
function openEmailBox() {
|
||||
activities.value.emailBox.show = true
|
||||
}
|
||||
|
||||
const { assignees, document } = useDocument('CRM Deal', props.dealId)
|
||||
|
||||
function reloadAssignees(data) {
|
||||
if (data?.hasOwnProperty('deal_owner')) {
|
||||
assignees.reload()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -241,7 +241,6 @@
|
||||
<DealModal
|
||||
v-if="showDealModal"
|
||||
v-model="showDealModal"
|
||||
v-model:quickEntry="showQuickEntryModal"
|
||||
:defaults="defaults"
|
||||
/>
|
||||
<NoteModal
|
||||
@ -258,11 +257,6 @@
|
||||
doctype="CRM Deal"
|
||||
:doc="docname"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Deal"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -282,7 +276,6 @@ import KanbanView from '@/components/Kanban/KanbanView.vue'
|
||||
import DealModal from '@/components/Modals/DealModal.vue'
|
||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -306,7 +299,6 @@ const route = useRoute()
|
||||
|
||||
const dealsListView = ref(null)
|
||||
const showDealModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
const defaults = reactive({})
|
||||
|
||||
|
||||
@ -12,18 +12,25 @@
|
||||
v-if="lead.data._customActions?.length"
|
||||
:actions="lead.data._customActions"
|
||||
/>
|
||||
<CustomActions
|
||||
v-if="document.actions?.length"
|
||||
:actions="document.actions"
|
||||
/>
|
||||
<AssignTo
|
||||
v-model="lead.data._assignedTo"
|
||||
:data="lead.data"
|
||||
v-model="assignees.data"
|
||||
:data="document.doc"
|
||||
doctype="CRM Lead"
|
||||
/>
|
||||
<Dropdown
|
||||
:options="statusOptions('lead', updateField, lead.data._customStatuses)"
|
||||
v-if="document.doc"
|
||||
:options="statusOptions('lead', document, lead.data._customStatuses)"
|
||||
>
|
||||
<template #default="{ open }">
|
||||
<Button :label="lead.data.status">
|
||||
<Button :label="document.doc.status">
|
||||
<template #prefix>
|
||||
<IndicatorIcon :class="getLeadStatus(lead.data.status).color" />
|
||||
<IndicatorIcon
|
||||
:class="getLeadStatus(document.doc.status).color"
|
||||
/>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<FeatherIcon
|
||||
@ -51,6 +58,7 @@
|
||||
v-model:reload="reload"
|
||||
v-model:tabIndex="tabIndex"
|
||||
v-model="lead"
|
||||
@afterSave="reloadAssignees"
|
||||
/>
|
||||
</template>
|
||||
</Tabs>
|
||||
@ -186,6 +194,7 @@
|
||||
doctype="CRM Lead"
|
||||
:docname="lead.data.name"
|
||||
@reload="sections.reload"
|
||||
@afterFieldChange="reloadAssignees"
|
||||
/>
|
||||
</div>
|
||||
</Resizer>
|
||||
@ -293,12 +302,6 @@
|
||||
/>
|
||||
</template>
|
||||
</Dialog>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Deal"
|
||||
:onlyRequired="true"
|
||||
/>
|
||||
<FilesUploader
|
||||
v-if="lead.data?.name"
|
||||
v-model="showFilesUploader"
|
||||
@ -339,16 +342,10 @@ import FilesUploader from '@/components/FilesUploader/FilesUploader.vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import SLASection from '@/components/SLASection.vue'
|
||||
import CustomActions from '@/components/CustomActions.vue'
|
||||
import {
|
||||
openWebsite,
|
||||
setupAssignees,
|
||||
setupCustomizations,
|
||||
copyToClipboard,
|
||||
validateIsImageFile
|
||||
} from '@/utils'
|
||||
import { openWebsite, setupCustomizations, copyToClipboard, validateIsImageFile } from '@/utils'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
@ -410,7 +407,6 @@ const lead = createResource({
|
||||
onSuccess: (data) => {
|
||||
errorTitle.value = ''
|
||||
errorMessage.value = ''
|
||||
setupAssignees(lead)
|
||||
setupCustomizations(lead, {
|
||||
doc: data,
|
||||
$dialog,
|
||||
@ -609,7 +605,10 @@ const existingOrganizationChecked = ref(false)
|
||||
const existingContact = ref('')
|
||||
const existingOrganization = ref('')
|
||||
|
||||
const { triggerConvertToDeal } = useDocument('CRM Lead', props.leadId)
|
||||
const { triggerConvertToDeal, assignees, document } = useDocument(
|
||||
'CRM Lead',
|
||||
props.leadId,
|
||||
)
|
||||
|
||||
async function convertToDeal() {
|
||||
if (existingContactChecked.value && !existingContact.value) {
|
||||
@ -703,10 +702,18 @@ const dealTabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = {
|
||||
doctype: 'CRM Deal',
|
||||
onlyRequired: true,
|
||||
}
|
||||
showConvertToDealModal.value = false
|
||||
}
|
||||
|
||||
function reloadAssignees(data) {
|
||||
if (data?.hasOwnProperty('lead_owner')) {
|
||||
assignees.reload()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -267,7 +267,6 @@
|
||||
<LeadModal
|
||||
v-if="showLeadModal"
|
||||
v-model="showLeadModal"
|
||||
v-model:quickEntry="showQuickEntryModal"
|
||||
:defaults="defaults"
|
||||
/>
|
||||
<NoteModal
|
||||
@ -284,7 +283,6 @@
|
||||
doctype="CRM Lead"
|
||||
:doc="docname"
|
||||
/>
|
||||
<QuickEntryModal v-if="showQuickEntryModal" v-model="showQuickEntryModal" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -304,7 +302,6 @@ import KanbanView from '@/components/Kanban/KanbanView.vue'
|
||||
import LeadModal from '@/components/Modals/LeadModal.vue'
|
||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -326,7 +323,6 @@ const route = useRoute()
|
||||
|
||||
const leadsListView = ref(null)
|
||||
const showLeadModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
const defaults = reactive({})
|
||||
|
||||
|
||||
@ -156,7 +156,6 @@
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
</div>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -171,6 +170,7 @@ import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import { formatDate, timeAgo, validateIsImageFile } from '@/utils'
|
||||
import { getView } from '@/utils/view'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global.js'
|
||||
@ -212,9 +212,7 @@ const props = defineProps({
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _contact = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const contact = createResource({
|
||||
url: 'crm.api.contact.get_contact',
|
||||
@ -460,17 +458,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_contact.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -529,18 +520,6 @@ async function deleteOption(doctype, name) {
|
||||
toast.success(__('Contact updated'))
|
||||
}
|
||||
|
||||
async function updateField(fieldname, value) {
|
||||
await call('frappe.client.set_value', {
|
||||
doctype: 'Contact',
|
||||
name: props.contactId,
|
||||
fieldname,
|
||||
value,
|
||||
})
|
||||
toast.success(__('Contact updated'))
|
||||
|
||||
contact.reload()
|
||||
}
|
||||
|
||||
const { getFormattedCurrency } = getMeta('CRM Deal')
|
||||
|
||||
const columns = computed(() => dealColumns)
|
||||
@ -608,4 +587,12 @@ const dealColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -10,14 +10,15 @@
|
||||
</Breadcrumbs>
|
||||
<div class="absolute right-0">
|
||||
<Dropdown
|
||||
:options="
|
||||
statusOptions('deal', updateField, deal.data._customStatuses)
|
||||
"
|
||||
v-if="document.doc"
|
||||
:options="statusOptions('deal', document, deal.data._customStatuses)"
|
||||
>
|
||||
<template #default="{ open }">
|
||||
<Button :label="deal.data.status">
|
||||
<Button :label="document.doc.status">
|
||||
<template #prefix>
|
||||
<IndicatorIcon :class="getDealStatus(deal.data.status).color" />
|
||||
<IndicatorIcon
|
||||
:class="getDealStatus(document.doc.status).color"
|
||||
/>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<FeatherIcon
|
||||
@ -36,8 +37,8 @@
|
||||
class="flex h-12 items-center justify-between gap-2 border-b px-3 py-2.5"
|
||||
>
|
||||
<AssignTo
|
||||
v-model="deal.data._assignedTo"
|
||||
:data="deal.data"
|
||||
v-model="assignees.data"
|
||||
:data="document.doc"
|
||||
doctype="CRM Deal"
|
||||
/>
|
||||
<div class="flex items-center gap-2">
|
||||
@ -45,6 +46,10 @@
|
||||
v-if="deal.data._customActions?.length"
|
||||
:actions="deal.data._customActions"
|
||||
/>
|
||||
<CustomActions
|
||||
v-if="document.actions?.length"
|
||||
:actions="document.actions"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="deal.data" class="flex h-full overflow-hidden">
|
||||
@ -66,6 +71,7 @@
|
||||
doctype="CRM Deal"
|
||||
:docname="deal.data.name"
|
||||
@reload="sections.reload"
|
||||
@afterFieldChange="reloadAssignees"
|
||||
>
|
||||
<template #actions="{ section }">
|
||||
<div v-if="section.name == 'contacts_section'" class="pr-2">
|
||||
@ -214,14 +220,16 @@
|
||||
</Tabs>
|
||||
</div>
|
||||
<OrganizationModal
|
||||
v-if="showOrganizationModal"
|
||||
v-model="showOrganizationModal"
|
||||
v-model:organization="_organization"
|
||||
:data="_organization"
|
||||
:options="{
|
||||
redirect: false,
|
||||
afterInsert: (doc) => updateField('organization', doc.name),
|
||||
}"
|
||||
/>
|
||||
<ContactModal
|
||||
v-if="showContactModal"
|
||||
v-model="showContactModal"
|
||||
:contact="_contact"
|
||||
:options="{
|
||||
@ -256,12 +264,13 @@ import Link from '@/components/Controls/Link.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import SLASection from '@/components/SLASection.vue'
|
||||
import CustomActions from '@/components/CustomActions.vue'
|
||||
import { setupAssignees, setupCustomizations } from '@/utils'
|
||||
import { setupCustomizations } from '@/utils'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { globalStore } from '@/stores/global'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { useDocument } from '@/data/document'
|
||||
import {
|
||||
whatsappEnabled,
|
||||
callEnabled,
|
||||
@ -309,7 +318,6 @@ const deal = createResource({
|
||||
organization.fetch()
|
||||
}
|
||||
|
||||
setupAssignees(deal)
|
||||
setupCustomizations(deal, {
|
||||
doc: data,
|
||||
$dialog,
|
||||
@ -603,4 +611,12 @@ async function deleteDeal(name) {
|
||||
})
|
||||
router.push({ name: 'Deals' })
|
||||
}
|
||||
|
||||
const { assignees, document } = useDocument('CRM Deal', props.dealId)
|
||||
|
||||
function reloadAssignees(data) {
|
||||
if (data?.hasOwnProperty('deal_owner')) {
|
||||
assignees.reload()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -10,14 +10,15 @@
|
||||
</Breadcrumbs>
|
||||
<div class="absolute right-0">
|
||||
<Dropdown
|
||||
:options="
|
||||
statusOptions('lead', updateField, lead.data._customStatuses)
|
||||
"
|
||||
v-if="document.doc"
|
||||
:options="statusOptions('lead', document, lead.data._customStatuses)"
|
||||
>
|
||||
<template #default="{ open }">
|
||||
<Button :label="lead.data.status">
|
||||
<Button :label="document.doc.status">
|
||||
<template #prefix>
|
||||
<IndicatorIcon :class="getLeadStatus(lead.data.status).color" />
|
||||
<IndicatorIcon
|
||||
:class="getLeadStatus(document.doc.status).color"
|
||||
/>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<FeatherIcon
|
||||
@ -36,8 +37,8 @@
|
||||
class="flex h-12 items-center justify-between gap-2 border-b px-3 py-2.5"
|
||||
>
|
||||
<AssignTo
|
||||
v-model="lead.data._assignedTo"
|
||||
:data="lead.data"
|
||||
v-model="assignees.data"
|
||||
:data="document.doc"
|
||||
doctype="CRM Lead"
|
||||
/>
|
||||
<div class="flex items-center gap-2">
|
||||
@ -45,6 +46,10 @@
|
||||
v-if="lead.data._customActions?.length"
|
||||
:actions="lead.data._customActions"
|
||||
/>
|
||||
<CustomActions
|
||||
v-if="document.actions?.length"
|
||||
:actions="document.actions"
|
||||
/>
|
||||
<Button
|
||||
:label="__('Convert')"
|
||||
variant="solid"
|
||||
@ -71,6 +76,7 @@
|
||||
doctype="CRM Lead"
|
||||
:docname="lead.data.name"
|
||||
@reload="sections.reload"
|
||||
@afterFieldChange="reloadAssignees"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -173,12 +179,13 @@ import Link from '@/components/Controls/Link.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import SLASection from '@/components/SLASection.vue'
|
||||
import CustomActions from '@/components/CustomActions.vue'
|
||||
import { setupAssignees, setupCustomizations } from '@/utils'
|
||||
import { setupCustomizations } from '@/utils'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { globalStore } from '@/stores/global'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { useDocument } from '@/data/document'
|
||||
import {
|
||||
whatsappEnabled,
|
||||
callEnabled,
|
||||
@ -220,7 +227,6 @@ const lead = createResource({
|
||||
params: { name: props.leadId },
|
||||
cache: ['lead', props.leadId],
|
||||
onSuccess: (data) => {
|
||||
setupAssignees(lead)
|
||||
setupCustomizations(lead, {
|
||||
doc: data,
|
||||
$dialog,
|
||||
@ -454,4 +460,12 @@ async function convertToDeal() {
|
||||
router.push({ name: 'Deal', params: { dealId: deal } })
|
||||
}
|
||||
}
|
||||
|
||||
const { assignees, document } = useDocument('CRM Lead', props.leadId)
|
||||
|
||||
function reloadAssignees(data) {
|
||||
if (data?.hasOwnProperty('lead_owner')) {
|
||||
assignees.reload()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -145,20 +145,19 @@
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
</div>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import Icon from '@/components/Icon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||
import DetailsIcon from '@/components/Icons/DetailsIcon.vue'
|
||||
import CameraIcon from '@/components/Icons/CameraIcon.vue'
|
||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -289,9 +288,7 @@ function openWebsite() {
|
||||
else window.open(organization.doc.website, '_blank')
|
||||
}
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _organization = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const sections = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
|
||||
@ -310,17 +307,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_organization.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -526,4 +516,12 @@ const contactColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -164,12 +164,6 @@
|
||||
:errorTitle="errorTitle"
|
||||
:errorMessage="errorMessage"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -178,14 +172,13 @@ import Resizer from '@/components/Resizer.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import Icon from '@/components/Icon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||
import WebsiteIcon from '@/components/Icons/WebsiteIcon.vue'
|
||||
import CameraIcon from '@/components/Icons/CameraIcon.vue'
|
||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -222,7 +215,6 @@ const { getUser } = usersStore()
|
||||
const { $dialog } = globalStore()
|
||||
const { getDealStatus } = statusesStore()
|
||||
const { doctypeMeta } = getMeta('CRM Organization')
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@ -335,9 +327,7 @@ function openWebsite() {
|
||||
else window.open(organization.doc.website, '_blank')
|
||||
}
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _organization = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const sections = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
|
||||
@ -356,17 +346,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_organization.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -565,4 +548,12 @@ const contactColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -63,16 +63,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<OrganizationModal
|
||||
v-if="showOrganizationModal"
|
||||
v-model="showOrganizationModal"
|
||||
v-model:showQuickEntryModal="showQuickEntryModal"
|
||||
@openAddressModal="(_address) => openAddressModal(_address)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="address" />
|
||||
</template>
|
||||
<script setup>
|
||||
import ViewBreadcrumbs from '@/components/ViewBreadcrumbs.vue'
|
||||
@ -80,8 +73,6 @@ import CustomActions from '@/components/CustomActions.vue'
|
||||
import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import OrganizationModal from '@/components/Modals/OrganizationModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import OrganizationsListView from '@/components/ListViews/OrganizationsListView.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
@ -94,12 +85,9 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
|
||||
const organizationsListView = ref(null)
|
||||
const showOrganizationModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
const showAddressModal = ref(false)
|
||||
|
||||
// organizations data is loaded in the ViewControls component
|
||||
const organizations = ref({})
|
||||
const address = ref({})
|
||||
const loadMore = ref(1)
|
||||
const triggerResize = ref(1)
|
||||
const updatedPageCount = ref(20)
|
||||
@ -162,15 +150,4 @@ const rows = computed(() => {
|
||||
return _rows
|
||||
})
|
||||
})
|
||||
|
||||
async function openAddressModal(_address) {
|
||||
if (_address) {
|
||||
_address = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: _address,
|
||||
})
|
||||
}
|
||||
showAddressModal.value = true
|
||||
address.value = _address || {}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -41,21 +41,14 @@
|
||||
@click="showLeadModal = true"
|
||||
/>
|
||||
</div>
|
||||
<LeadModal
|
||||
v-if="showLeadModal"
|
||||
v-model="showLeadModal"
|
||||
v-model:quickEntry="showQuickEntryModal"
|
||||
/>
|
||||
<QuickEntryModal v-if="showQuickEntryModal" v-model="showQuickEntryModal" />
|
||||
<LeadModal v-if="showLeadModal" v-model="showLeadModal" />
|
||||
</template>
|
||||
<script setup>
|
||||
import AvatarIcon from '@/components/Icons/AvatarIcon.vue'
|
||||
import GoogleIcon from '@/components/Icons/GoogleIcon.vue'
|
||||
import LeadModal from '@/components/Modals/LeadModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const name = ref('John Doe')
|
||||
const showLeadModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
</script>
|
||||
|
||||
@ -77,10 +77,14 @@ export const statusesStore = defineStore('crm-statuses', () => {
|
||||
return communicationStatuses[name]
|
||||
}
|
||||
|
||||
function statusOptions(doctype, action, statuses = []) {
|
||||
function statusOptions(doctype, document, statuses = []) {
|
||||
let statusesByName =
|
||||
doctype == 'deal' ? dealStatusesByName : leadStatusesByName
|
||||
|
||||
if (document?.statuses?.length) {
|
||||
statuses = document.statuses
|
||||
}
|
||||
|
||||
if (statuses.length) {
|
||||
statusesByName = statuses.reduce((acc, status) => {
|
||||
acc[status] = statusesByName[status]
|
||||
@ -96,7 +100,10 @@ export const statusesStore = defineStore('crm-statuses', () => {
|
||||
icon: () => h(IndicatorIcon, { class: statusesByName[status]?.color }),
|
||||
onClick: () => {
|
||||
capture('status_changed', { doctype, status })
|
||||
action && action('status', statusesByName[status]?.name)
|
||||
if (document) {
|
||||
document.doc.status = statusesByName[status]?.name
|
||||
document.save.submit()
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -49,7 +49,8 @@ function initPosthog(ps: PosthogSettings) {
|
||||
capture_pageview: true,
|
||||
capture_pageleave: true,
|
||||
enable_heatmaps: false,
|
||||
disable_session_recording: false,
|
||||
disable_session_recording: true,
|
||||
advanced_disable_decide: true,
|
||||
loaded: (ph: typeof posthog) => {
|
||||
window.posthog = ph
|
||||
ph.identify(window.location.hostname)
|
||||
@ -67,17 +68,9 @@ function capture(
|
||||
}
|
||||
|
||||
function startRecording() {
|
||||
if (!isTelemetryEnabled()) return
|
||||
if (window.posthog?.__loaded) {
|
||||
window.posthog.startSessionRecording()
|
||||
}
|
||||
}
|
||||
|
||||
function stopRecording() {
|
||||
if (!isTelemetryEnabled()) return
|
||||
if (window.posthog?.__loaded && window.posthog.sessionRecordingStarted()) {
|
||||
window.posthog.stopSessionRecording()
|
||||
}
|
||||
}
|
||||
|
||||
// Posthog Plugin
|
||||
|
||||
@ -211,10 +211,9 @@ export function validateEmail(email) {
|
||||
return regExp.test(email)
|
||||
}
|
||||
|
||||
export function setupAssignees(doc) {
|
||||
export function parseAssignees(assignees) {
|
||||
let { getUser } = usersStore()
|
||||
let assignees = doc.data?._assign || []
|
||||
doc.data._assignedTo = assignees.map((user) => ({
|
||||
return assignees.map((user) => ({
|
||||
name: user,
|
||||
image: getUser(user).user_image,
|
||||
label: getUser(user).full_name,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user