From af6970569f1f86769ef16235842927811efe8f09 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 5 Sep 2025 15:42:51 +0530 Subject: [PATCH] Revert "fix: add PrimaryDropdown and PrimaryDropdownItem components for enhanced dropdown functionality in forms" This reverts commit 816bc700ede63c2e9d12f70cea1e90c26f11acc1. --- frontend/components.d.ts | 3 +- ...imaryDropdownItem.vue => DropdownItem.vue} | 2 +- frontend/src/components/PrimaryDropdown.vue | 69 ------- frontend/src/components/SidePanelLayout.vue | 82 ++++++++- frontend/src/pages/Contact.vue | 174 +++++++++--------- 5 files changed, 166 insertions(+), 164 deletions(-) rename frontend/src/components/{PrimaryDropdownItem.vue => DropdownItem.vue} (98%) delete mode 100644 frontend/src/components/PrimaryDropdown.vue diff --git a/frontend/components.d.ts b/frontend/components.d.ts index 43fe5a81..98e64668 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -99,6 +99,7 @@ declare module 'vue' { DoubleCheckIcon: typeof import('./src/components/Icons/DoubleCheckIcon.vue')['default'] DragIcon: typeof import('./src/components/Icons/DragIcon.vue')['default'] DragVerticalIcon: typeof import('./src/components/Icons/DragVerticalIcon.vue')['default'] + DropdownItem: typeof import('./src/components/DropdownItem.vue')['default'] DuplicateIcon: typeof import('./src/components/Icons/DuplicateIcon.vue')['default'] DurationIcon: typeof import('./src/components/Icons/DurationIcon.vue')['default'] EditEmailTemplate: typeof import('./src/components/Settings/EmailTemplate/EditEmailTemplate.vue')['default'] @@ -223,8 +224,6 @@ declare module 'vue' { PlaybackSpeedIcon: typeof import('./src/components/Icons/PlaybackSpeedIcon.vue')['default'] PlaybackSpeedOption: typeof import('./src/components/Activities/PlaybackSpeedOption.vue')['default'] PlayIcon: typeof import('./src/components/Icons/PlayIcon.vue')['default'] - PrimaryDropdown: typeof import('./src/components/PrimaryDropdown.vue')['default'] - PrimaryDropdownItem: typeof import('./src/components/PrimaryDropdownItem.vue')['default'] ProfileSettings: typeof import('./src/components/Settings/ProfileSettings.vue')['default'] QuickEntryModal: typeof import('./src/components/Modals/QuickEntryModal.vue')['default'] QuickFilterField: typeof import('./src/components/QuickFilterField.vue')['default'] diff --git a/frontend/src/components/PrimaryDropdownItem.vue b/frontend/src/components/DropdownItem.vue similarity index 98% rename from frontend/src/components/PrimaryDropdownItem.vue rename to frontend/src/components/DropdownItem.vue index 53db17d0..52536afd 100644 --- a/frontend/src/components/PrimaryDropdownItem.vue +++ b/frontend/src/components/DropdownItem.vue @@ -56,7 +56,7 @@ - - diff --git a/frontend/src/components/SidePanelLayout.vue b/frontend/src/components/SidePanelLayout.vue index 7ee8e321..5f7d96f7 100644 --- a/frontend/src/components/SidePanelLayout.vue +++ b/frontend/src/components/SidePanelLayout.vue @@ -79,14 +79,70 @@
{{ doc[field.fieldname] }}
- +
+ + + + +
computed(() => getParsedSections(data)), }) -const parsedSections = computed(() => { - if (!sections.data) return [] - return sections.data.map((section) => ({ - ...section, - columns: section.columns.map((column) => ({ - ...column, - fields: column.fields.map((field) => { +function getParsedSections(_sections) { + return _sections.map((section) => { + section.columns = section.columns.map((column) => { + column.fields = column.fields.map((field) => { if (field.fieldname === 'email_id') { return { ...field, read_only: false, fieldtype: 'Dropdown', - options: (contact.doc?.email_ids || []).map((email) => ({ - name: email.name, - value: email.email_id, - selected: email.email_id === contact.doc.email_id, - placeholder: 'john@doe.com', - onClick: () => setAsPrimary('email', email.email_id), - onSave: (option, isNew) => - isNew - ? createNew('email', option.value) - : editOption( - 'Contact Email', - option.name, - 'email_id', - option.value, - ), - onDelete: async (option, isNew) => { - contact.doc.email_ids = contact.doc.email_ids.filter( - (e) => e.name !== option.name, - ) - if (!isNew) await deleteOption('Contact Email', option.name) - }, - })), + options: + contact.doc?.email_ids?.map((email) => { + return { + name: email.name, + value: email.email_id, + selected: email.email_id === contact.doc.email_id, + placeholder: 'john@doe.com', + onClick: () => { + setAsPrimary('email', email.email_id) + }, + onSave: (option, isNew) => { + if (isNew) { + createNew('email', option.value) + } else { + editOption( + 'Contact Email', + option.name, + 'email_id', + option.value, + ) + } + }, + onDelete: async (option, isNew) => { + contact.doc.email_ids = contact.doc.email_ids.filter( + (email) => email.name !== option.name, + ) + !isNew && (await deleteOption('Contact Email', option.name)) + }, + } + }) || [], create: () => { - // Add a temporary new option locally (mirrors original behavior) - contact.doc.email_ids = [ - ...(contact.doc.email_ids || []), - { - name: 'new-1', - value: '', - selected: false, - isNew: true, - }, - ] + contact.doc?.email_ids?.push({ + name: 'new-1', + value: '', + selected: false, + isNew: true, + }) }, } - } - if (field.fieldname === 'mobile_no') { + } else if (field.fieldname === 'mobile_no') { return { ...field, read_only: false, fieldtype: 'Dropdown', - options: (contact.doc?.phone_nos || []).map((phone) => ({ - name: phone.name, - value: phone.phone, - selected: phone.phone === contact.doc.mobile_no, - onClick: () => setAsPrimary('mobile_no', phone.phone), - onSave: (option, isNew) => - isNew - ? createNew('phone', option.value) - : editOption( - 'Contact Phone', - option.name, - 'phone', - option.value, - ), - onDelete: async (option, isNew) => { - contact.doc.phone_nos = contact.doc.phone_nos.filter( - (p) => p.name !== option.name, - ) - if (!isNew) await deleteOption('Contact Phone', option.name) - }, - })), + options: + contact.doc?.phone_nos?.map((phone) => { + return { + name: phone.name, + value: phone.phone, + selected: phone.phone === contact.doc.mobile_no, + onClick: () => { + setAsPrimary('mobile_no', phone.phone) + }, + onSave: (option, isNew) => { + if (isNew) { + createNew('phone', option.value) + } else { + editOption( + 'Contact Phone', + option.name, + 'phone', + option.value, + ) + } + }, + onDelete: async (option, isNew) => { + contact.doc.phone_nos = contact.doc.phone_nos.filter( + (phone) => phone.name !== option.name, + ) + !isNew && (await deleteOption('Contact Phone', option.name)) + }, + } + }) || [], create: () => { - contact.doc.phone_nos = [ - ...(contact.doc.phone_nos || []), - { - name: 'new-1', - value: '', - selected: false, - isNew: true, - }, - ] + contact.doc?.phone_nos?.push({ + name: 'new-1', + value: '', + selected: false, + isNew: true, + }) }, } - } - if (field.fieldname === 'address') { + } else if (field.fieldname === 'address') { return { ...field, - create: (_value, close) => { + create: (value, close) => { openAddressModal() - close && close() + close() }, edit: (address) => openAddressModal(address), } + } else { + return field } - return field - }), - })), - })) -}) + }) + return column + }) + return section + }) +} async function setAsPrimary(field, value) { let d = await call('crm.api.contact.set_as_primary', {