From 38cea32ba740a7273a9a333b4f1d6537799c1397 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 25 Jan 2024 21:09:24 +0530 Subject: [PATCH] fix: allow moving contacts section in deal page --- crm/api/doc.py | 1 + crm/fcrm/doctype/crm_deal/crm_deal.json | 5 +- frontend/src/pages/Deal.vue | 66 ++++++++++++------------- frontend/src/stores/views.js | 1 - 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index 346b563e..abb12ca1 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -246,6 +246,7 @@ def get_doctype_fields(doctype): last_section = field.fieldname sections[field.fieldname] = { "label": field.label, + "name": field.fieldname, "opened": True, "fields": [], } diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index c8b497a7..8b91b3db 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -112,8 +112,7 @@ { "fieldname": "contacts_tab", "fieldtype": "Tab Break", - "label": "Contacts", - "read_only": 1 + "label": "Contacts" }, { "fieldname": "email", @@ -275,7 +274,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-19 21:43:58.940722", + "modified": "2024-01-25 21:00:08.216020", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue index aba5d0b7..ef1224ca 100644 --- a/frontend/src/pages/Deal.vue +++ b/frontend/src/pages/Deal.vue @@ -467,42 +467,40 @@ const detailSections = computed(() => { function getParsedFields(sections, contacts) { sections.forEach((section) => { - section.fields.forEach((field) => { - if ( - !deal.data.organization && - ['website', 'territory', 'annual_revenue'].includes(field.name) - ) { - field.hidden = true - } - if (field.name == 'organization') { - field.create = (value, close) => { - _organization.value.organization_name = value - showOrganizationModal.value = true - close() + if (section.name == 'contacts_tab') { + delete section.fields + section.contacts = + contacts?.map((contact) => { + return { + name: contact.contact, + is_primary: contact.is_primary, + opened: false, + } + }) || [] + } else { + section.fields.forEach((field) => { + if ( + !deal.data.organization && + ['website', 'territory', 'annual_revenue'].includes(field.name) + ) { + field.hidden = true } - field.link = (org) => - router.push({ - name: 'Organization', - params: { organizationId: org }, - }) - } - }) + if (field.name == 'organization') { + field.create = (value, close) => { + _organization.value.organization_name = value + showOrganizationModal.value = true + close() + } + field.link = (org) => + router.push({ + name: 'Organization', + params: { organizationId: org }, + }) + } + }) + } }) - - let contactSection = { - label: 'Contacts', - opened: true, - contacts: - contacts?.map((contact) => { - return { - name: contact.contact, - is_primary: contact.is_primary, - opened: false, - } - }) || [], - } - - return [...sections, contactSection] + return sections } const showContactModal = ref(false) diff --git a/frontend/src/stores/views.js b/frontend/src/stores/views.js index 516b4e10..7347ac52 100644 --- a/frontend/src/stores/views.js +++ b/frontend/src/stores/views.js @@ -19,7 +19,6 @@ export const viewsStore = defineStore('crm-views', (doctype) => { initialData: [], auto: true, transform(views) { - debugger pinnedViews.value = [] publicViews.value = [] for (let view of views) {