fix: render fields in side panel, quick entry & data tab in new format
This commit is contained in:
parent
0b4ee64a36
commit
37f357ac08
@ -593,17 +593,18 @@ def get_sidebar_fields(doctype, name):
|
|||||||
|
|
||||||
for section in layout:
|
for section in layout:
|
||||||
section["name"] = section.get("name") or section.get("label")
|
section["name"] = section.get("name") or section.get("label")
|
||||||
for field in section.get("fields") if section.get("fields") else []:
|
for column in section.get("columns") if section.get("columns") else []:
|
||||||
field_obj = next((f for f in fields if f.fieldname == field), None)
|
for field in column.get("fields") if column.get("fields") else []:
|
||||||
if field_obj:
|
field_obj = next((f for f in fields if f.fieldname == field), None)
|
||||||
if field_obj.permlevel > 0:
|
if field_obj:
|
||||||
field_has_write_access = field_obj.permlevel in has_write_access_to_permlevels
|
if field_obj.permlevel > 0:
|
||||||
field_has_read_access = field_obj.permlevel in has_read_access_to_permlevels
|
field_has_write_access = field_obj.permlevel in has_write_access_to_permlevels
|
||||||
if not field_has_write_access and field_has_read_access:
|
field_has_read_access = field_obj.permlevel in has_read_access_to_permlevels
|
||||||
field_obj.read_only = 1
|
if not field_has_write_access and field_has_read_access:
|
||||||
if not field_has_read_access and not field_has_write_access:
|
field_obj.read_only = 1
|
||||||
field_obj.hidden = 1
|
if not field_has_read_access and not field_has_write_access:
|
||||||
section["fields"][section.get("fields").index(field)] = get_field_obj(field_obj)
|
field_obj.hidden = 1
|
||||||
|
column["fields"][column.get("fields").index(field)] = get_field_obj(field_obj)
|
||||||
|
|
||||||
fields_meta = {}
|
fields_meta = {}
|
||||||
for field in fields:
|
for field in fields:
|
||||||
|
|||||||
@ -101,10 +101,12 @@ function saveChanges() {
|
|||||||
_tabs.forEach((tab) => {
|
_tabs.forEach((tab) => {
|
||||||
if (!tab.sections) return
|
if (!tab.sections) return
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
if (!section.fields) return
|
section.columns.forEach((column) => {
|
||||||
section.fields = section.fields.map(
|
if (!column.fields) return
|
||||||
(field) => field.fieldname || field.name,
|
column.fields = column.fields.map(
|
||||||
)
|
(field) => field.fieldname || field.name,
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|||||||
@ -125,10 +125,12 @@ const tabs = createResource({
|
|||||||
transform: (_tabs) => {
|
transform: (_tabs) => {
|
||||||
return _tabs.forEach((tab) => {
|
return _tabs.forEach((tab) => {
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
section.fields.forEach((field) => {
|
section.columns.forEach((column) => {
|
||||||
if (field.type === 'Table') {
|
column.fields.forEach((field) => {
|
||||||
_contact.value[field.name] = []
|
if (field.type === 'Table') {
|
||||||
}
|
_contact.value[field.name] = []
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -101,10 +101,12 @@ function saveChanges() {
|
|||||||
_tabs.forEach((tab) => {
|
_tabs.forEach((tab) => {
|
||||||
if (!tab.sections) return
|
if (!tab.sections) return
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
if (!section.fields) return
|
section.columns.forEach((column) => {
|
||||||
section.fields = section.fields.map(
|
if (!column.fields) return
|
||||||
(field) => field.fieldname || field.name,
|
column.fields = column.fields.map(
|
||||||
)
|
(field) => field.fieldname || field.name,
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|||||||
@ -109,18 +109,20 @@ const tabs = createResource({
|
|||||||
transform: (_tabs) => {
|
transform: (_tabs) => {
|
||||||
return _tabs.forEach((tab) => {
|
return _tabs.forEach((tab) => {
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
section.fields.forEach((field) => {
|
section.columns.forEach((column) => {
|
||||||
if (field.name == 'status') {
|
column.fields.forEach((field) => {
|
||||||
field.type = 'Select'
|
if (field.name == 'status') {
|
||||||
field.options = dealStatuses.value
|
field.type = 'Select'
|
||||||
field.prefix = getDealStatus(deal.status).iconColorClass
|
field.options = dealStatuses.value
|
||||||
} else if (field.name == 'deal_owner') {
|
field.prefix = getDealStatus(deal.status).iconColorClass
|
||||||
field.type = 'User'
|
} else if (field.name == 'deal_owner') {
|
||||||
}
|
field.type = 'User'
|
||||||
|
}
|
||||||
|
|
||||||
if (field.type === 'Table') {
|
if (field.type === 'Table') {
|
||||||
deal[field.name] = []
|
deal[field.name] = []
|
||||||
}
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -71,18 +71,20 @@ const tabs = createResource({
|
|||||||
transform: (_tabs) => {
|
transform: (_tabs) => {
|
||||||
return _tabs.forEach((tab) => {
|
return _tabs.forEach((tab) => {
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
section.fields.forEach((field) => {
|
section.columns.forEach((column) => {
|
||||||
if (field.name == 'status') {
|
column.fields.forEach((field) => {
|
||||||
field.type = 'Select'
|
if (field.name == 'status') {
|
||||||
field.options = leadStatuses.value
|
field.type = 'Select'
|
||||||
field.prefix = getLeadStatus(lead.status).iconColorClass
|
field.options = leadStatuses.value
|
||||||
} else if (field.name == 'lead_owner') {
|
field.prefix = getLeadStatus(lead.status).iconColorClass
|
||||||
field.type = 'User'
|
} else if (field.name == 'lead_owner') {
|
||||||
}
|
field.type = 'User'
|
||||||
|
}
|
||||||
|
|
||||||
if (field.type === 'Table') {
|
if (field.type === 'Table') {
|
||||||
lead[field.name] = []
|
lead[field.name] = []
|
||||||
}
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -124,10 +124,12 @@ const tabs = createResource({
|
|||||||
transform: (_tabs) => {
|
transform: (_tabs) => {
|
||||||
return _tabs.forEach((tab) => {
|
return _tabs.forEach((tab) => {
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
section.fields.forEach((field) => {
|
section.columns.forEach((column) => {
|
||||||
if (field.type === 'Table') {
|
column.fields.forEach((field) => {
|
||||||
_organization.value[field.name] = []
|
if (field.type === 'Table') {
|
||||||
}
|
_organization.value[field.name] = []
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -99,10 +99,12 @@ function saveChanges() {
|
|||||||
_tabs.forEach((tab) => {
|
_tabs.forEach((tab) => {
|
||||||
if (!tab.sections) return
|
if (!tab.sections) return
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
if (!section.fields) return
|
section.columns.forEach((column) => {
|
||||||
section.fields = section.fields.map(
|
if (!column.fields) return
|
||||||
(field) => field.fieldname || field.name,
|
column.fields = column.fields.map(
|
||||||
)
|
(field) => field.fieldname || field.name,
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
:opened="section.opened"
|
:opened="section.opened"
|
||||||
>
|
>
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == section.data?.length - 1"
|
:isLastSection="i == section.data?.length - 1"
|
||||||
v-model="data"
|
v-model="data"
|
||||||
/>
|
/>
|
||||||
@ -129,10 +129,12 @@ function saveChanges() {
|
|||||||
let _tabs = JSON.parse(JSON.stringify(tabs.data))
|
let _tabs = JSON.parse(JSON.stringify(tabs.data))
|
||||||
_tabs.forEach((tab) => {
|
_tabs.forEach((tab) => {
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
if (!section.fields) return
|
section.columns.forEach((column) => {
|
||||||
section.fields = section.fields
|
if (!column.fields) return
|
||||||
.map((field) => field.fieldname || field.name)
|
column.fields = column.fields
|
||||||
.filter(Boolean)
|
.map((field) => field.fieldname || field.name)
|
||||||
|
.filter(Boolean)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|||||||
@ -139,8 +139,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
v-if="section.fields"
|
v-if="section.columns?.[0].fields"
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
doctype="Contact"
|
doctype="Contact"
|
||||||
v-model="contact.data"
|
v-model="contact.data"
|
||||||
@ -377,148 +377,147 @@ const fieldsLayout = createResource({
|
|||||||
|
|
||||||
function getParsedFields(data) {
|
function getParsedFields(data) {
|
||||||
return data.map((section) => {
|
return data.map((section) => {
|
||||||
return {
|
section.columns = section.columns.map((column) => {
|
||||||
...section,
|
column.fields = column.fields.map((field) => {
|
||||||
fields: computed(() =>
|
if (field.name === 'email_id') {
|
||||||
section.fields.map((field) => {
|
return {
|
||||||
if (field.name === 'email_id') {
|
...field,
|
||||||
return {
|
read_only: false,
|
||||||
...field,
|
type: 'dropdown',
|
||||||
type: 'dropdown',
|
options:
|
||||||
options:
|
contact.data?.email_ids?.map((email) => {
|
||||||
contact.data?.email_ids?.map((email) => {
|
return {
|
||||||
return {
|
name: email.name,
|
||||||
name: email.name,
|
value: email.email_id,
|
||||||
value: email.email_id,
|
selected: email.email_id === contact.data.email_id,
|
||||||
selected: email.email_id === contact.data.email_id,
|
placeholder: 'john@doe.com',
|
||||||
placeholder: 'john@doe.com',
|
onClick: () => {
|
||||||
onClick: () => {
|
_contact.value.email_id = email.email_id
|
||||||
_contact.value.email_id = email.email_id
|
setAsPrimary('email', email.email_id)
|
||||||
setAsPrimary('email', email.email_id)
|
},
|
||||||
},
|
onSave: (option, isNew) => {
|
||||||
onSave: (option, isNew) => {
|
if (isNew) {
|
||||||
if (isNew) {
|
createNew('email', option.value)
|
||||||
createNew('email', option.value)
|
if (contact.data.email_ids.length === 1) {
|
||||||
if (contact.data.email_ids.length === 1) {
|
_contact.value.email_id = option.value
|
||||||
_contact.value.email_id = option.value
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
editOption(
|
|
||||||
'Contact Email',
|
|
||||||
option.name,
|
|
||||||
'email_id',
|
|
||||||
option.value,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
onDelete: async (option, isNew) => {
|
editOption(
|
||||||
contact.data.email_ids = contact.data.email_ids.filter(
|
'Contact Email',
|
||||||
(email) => email.name !== option.name,
|
option.name,
|
||||||
|
'email_id',
|
||||||
|
option.value,
|
||||||
)
|
)
|
||||||
!isNew &&
|
}
|
||||||
(await deleteOption('Contact Email', option.name))
|
},
|
||||||
if (_contact.value.email_id === option.value) {
|
onDelete: async (option, isNew) => {
|
||||||
if (contact.data.email_ids.length === 0) {
|
contact.data.email_ids = contact.data.email_ids.filter(
|
||||||
_contact.value.email_id = ''
|
(email) => email.name !== option.name,
|
||||||
} else {
|
)
|
||||||
_contact.value.email_id = contact.data.email_ids.find(
|
!isNew && (await deleteOption('Contact Email', option.name))
|
||||||
(email) => email.is_primary,
|
if (_contact.value.email_id === option.value) {
|
||||||
)?.email_id
|
if (contact.data.email_ids.length === 0) {
|
||||||
}
|
_contact.value.email_id = ''
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}) || [],
|
|
||||||
create: () => {
|
|
||||||
contact.data?.email_ids?.push({
|
|
||||||
name: 'new-1',
|
|
||||||
value: '',
|
|
||||||
selected: false,
|
|
||||||
isNew: true,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if (field.name === 'mobile_no') {
|
|
||||||
return {
|
|
||||||
...field,
|
|
||||||
type: 'dropdown',
|
|
||||||
options:
|
|
||||||
contact.data?.phone_nos?.map((phone) => {
|
|
||||||
return {
|
|
||||||
name: phone.name,
|
|
||||||
value: phone.phone,
|
|
||||||
selected: phone.phone === contact.data.actual_mobile_no,
|
|
||||||
onClick: () => {
|
|
||||||
_contact.value.actual_mobile_no = phone.phone
|
|
||||||
_contact.value.mobile_no = phone.phone
|
|
||||||
setAsPrimary('mobile_no', phone.phone)
|
|
||||||
},
|
|
||||||
onSave: (option, isNew) => {
|
|
||||||
if (isNew) {
|
|
||||||
createNew('phone', option.value)
|
|
||||||
if (contact.data.phone_nos.length === 1) {
|
|
||||||
_contact.value.actual_mobile_no = option.value
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
editOption(
|
_contact.value.email_id = contact.data.email_ids.find(
|
||||||
'Contact Phone',
|
(email) => email.is_primary,
|
||||||
option.name,
|
)?.email_id
|
||||||
'phone',
|
|
||||||
option.value,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
onDelete: async (option, isNew) => {
|
},
|
||||||
contact.data.phone_nos = contact.data.phone_nos.filter(
|
}
|
||||||
(phone) => phone.name !== option.name,
|
}) || [],
|
||||||
)
|
create: () => {
|
||||||
!isNew &&
|
contact.data?.email_ids?.push({
|
||||||
(await deleteOption('Contact Phone', option.name))
|
name: 'new-1',
|
||||||
if (_contact.value.actual_mobile_no === option.value) {
|
value: '',
|
||||||
if (contact.data.phone_nos.length === 0) {
|
selected: false,
|
||||||
_contact.value.actual_mobile_no = ''
|
isNew: true,
|
||||||
} else {
|
})
|
||||||
_contact.value.actual_mobile_no =
|
},
|
||||||
contact.data.phone_nos.find(
|
|
||||||
(phone) => phone.is_primary_mobile_no,
|
|
||||||
)?.phone
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}) || [],
|
|
||||||
create: () => {
|
|
||||||
contact.data?.phone_nos?.push({
|
|
||||||
name: 'new-1',
|
|
||||||
value: '',
|
|
||||||
selected: false,
|
|
||||||
isNew: true,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if (field.name === 'address') {
|
|
||||||
return {
|
|
||||||
...field,
|
|
||||||
create: (value, close) => {
|
|
||||||
_contact.value.address = value
|
|
||||||
_address.value = {}
|
|
||||||
showAddressModal.value = true
|
|
||||||
close()
|
|
||||||
},
|
|
||||||
edit: async (addr) => {
|
|
||||||
_address.value = await call('frappe.client.get', {
|
|
||||||
doctype: 'Address',
|
|
||||||
name: addr,
|
|
||||||
})
|
|
||||||
showAddressModal.value = true
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return field
|
|
||||||
}
|
}
|
||||||
}),
|
} else if (field.name === 'mobile_no') {
|
||||||
),
|
return {
|
||||||
}
|
...field,
|
||||||
|
read_only: false,
|
||||||
|
type: 'dropdown',
|
||||||
|
options:
|
||||||
|
contact.data?.phone_nos?.map((phone) => {
|
||||||
|
return {
|
||||||
|
name: phone.name,
|
||||||
|
value: phone.phone,
|
||||||
|
selected: phone.phone === contact.data.actual_mobile_no,
|
||||||
|
onClick: () => {
|
||||||
|
_contact.value.actual_mobile_no = phone.phone
|
||||||
|
_contact.value.mobile_no = phone.phone
|
||||||
|
setAsPrimary('mobile_no', phone.phone)
|
||||||
|
},
|
||||||
|
onSave: (option, isNew) => {
|
||||||
|
if (isNew) {
|
||||||
|
createNew('phone', option.value)
|
||||||
|
if (contact.data.phone_nos.length === 1) {
|
||||||
|
_contact.value.actual_mobile_no = option.value
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
editOption(
|
||||||
|
'Contact Phone',
|
||||||
|
option.name,
|
||||||
|
'phone',
|
||||||
|
option.value,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDelete: async (option, isNew) => {
|
||||||
|
contact.data.phone_nos = contact.data.phone_nos.filter(
|
||||||
|
(phone) => phone.name !== option.name,
|
||||||
|
)
|
||||||
|
!isNew && (await deleteOption('Contact Phone', option.name))
|
||||||
|
if (_contact.value.actual_mobile_no === option.value) {
|
||||||
|
if (contact.data.phone_nos.length === 0) {
|
||||||
|
_contact.value.actual_mobile_no = ''
|
||||||
|
} else {
|
||||||
|
_contact.value.actual_mobile_no =
|
||||||
|
contact.data.phone_nos.find(
|
||||||
|
(phone) => phone.is_primary_mobile_no,
|
||||||
|
)?.phone
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}) || [],
|
||||||
|
create: () => {
|
||||||
|
contact.data?.phone_nos?.push({
|
||||||
|
name: 'new-1',
|
||||||
|
value: '',
|
||||||
|
selected: false,
|
||||||
|
isNew: true,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else if (field.name === 'address') {
|
||||||
|
return {
|
||||||
|
...field,
|
||||||
|
create: (value, close) => {
|
||||||
|
_contact.value.address = value
|
||||||
|
_address.value = {}
|
||||||
|
showAddressModal.value = true
|
||||||
|
close()
|
||||||
|
},
|
||||||
|
edit: async (addr) => {
|
||||||
|
_address.value = await call('frappe.client.get', {
|
||||||
|
doctype: 'Address',
|
||||||
|
name: addr,
|
||||||
|
})
|
||||||
|
showAddressModal.value = true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return column
|
||||||
|
})
|
||||||
|
return section
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -168,8 +168,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
v-if="section.fields"
|
v-if="section.columns?.[0].fields"
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
doctype="CRM Deal"
|
doctype="CRM Deal"
|
||||||
v-model="deal.data"
|
v-model="deal.data"
|
||||||
@ -611,7 +611,7 @@ const fieldsLayout = createResource({
|
|||||||
function getParsedFields(sections) {
|
function getParsedFields(sections) {
|
||||||
sections.forEach((section) => {
|
sections.forEach((section) => {
|
||||||
if (section.name == 'contacts_section') return
|
if (section.name == 'contacts_section') return
|
||||||
section.fields.forEach((field) => {
|
section.columns[0].fields.forEach((field) => {
|
||||||
if (field.name == 'organization') {
|
if (field.name == 'organization') {
|
||||||
field.create = (value, close) => {
|
field.create = (value, close) => {
|
||||||
_organization.value.organization_name = value
|
_organization.value.organization_name = value
|
||||||
|
|||||||
@ -183,7 +183,7 @@
|
|||||||
:opened="section.opened"
|
:opened="section.opened"
|
||||||
>
|
>
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
v-model="lead.data"
|
v-model="lead.data"
|
||||||
@update="updateField"
|
@update="updateField"
|
||||||
|
|||||||
@ -143,7 +143,7 @@
|
|||||||
>
|
>
|
||||||
<Section :label="section.label" :opened="section.opened">
|
<Section :label="section.label" :opened="section.opened">
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
doctype="Contact"
|
doctype="Contact"
|
||||||
v-model="contact.data"
|
v-model="contact.data"
|
||||||
@ -357,148 +357,145 @@ const fieldsLayout = createResource({
|
|||||||
|
|
||||||
function getParsedFields(data) {
|
function getParsedFields(data) {
|
||||||
return data.map((section) => {
|
return data.map((section) => {
|
||||||
return {
|
section.columns = section.columns.map((column) => {
|
||||||
...section,
|
column.fields = column.fields.map((field) => {
|
||||||
fields: computed(() =>
|
if (field.name === 'email_id') {
|
||||||
section.fields.map((field) => {
|
return {
|
||||||
if (field.name === 'email_id') {
|
...field,
|
||||||
return {
|
type: 'dropdown',
|
||||||
...field,
|
options:
|
||||||
type: 'dropdown',
|
contact.data?.email_ids?.map((email) => {
|
||||||
options:
|
return {
|
||||||
contact.data?.email_ids?.map((email) => {
|
name: email.name,
|
||||||
return {
|
value: email.email_id,
|
||||||
name: email.name,
|
selected: email.email_id === contact.data.email_id,
|
||||||
value: email.email_id,
|
placeholder: 'john@doe.com',
|
||||||
selected: email.email_id === contact.data.email_id,
|
onClick: () => {
|
||||||
placeholder: 'john@doe.com',
|
_contact.value.email_id = email.email_id
|
||||||
onClick: () => {
|
setAsPrimary('email', email.email_id)
|
||||||
_contact.value.email_id = email.email_id
|
},
|
||||||
setAsPrimary('email', email.email_id)
|
onSave: (option, isNew) => {
|
||||||
},
|
if (isNew) {
|
||||||
onSave: (option, isNew) => {
|
createNew('email', option.value)
|
||||||
if (isNew) {
|
if (contact.data.email_ids.length === 1) {
|
||||||
createNew('email', option.value)
|
_contact.value.email_id = option.value
|
||||||
if (contact.data.email_ids.length === 1) {
|
|
||||||
_contact.value.email_id = option.value
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
editOption(
|
|
||||||
'Contact Email',
|
|
||||||
option.name,
|
|
||||||
'email_id',
|
|
||||||
option.value,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
onDelete: async (option, isNew) => {
|
editOption(
|
||||||
contact.data.email_ids = contact.data.email_ids.filter(
|
'Contact Email',
|
||||||
(email) => email.name !== option.name,
|
option.name,
|
||||||
|
'email_id',
|
||||||
|
option.value,
|
||||||
)
|
)
|
||||||
!isNew &&
|
}
|
||||||
(await deleteOption('Contact Email', option.name))
|
},
|
||||||
if (_contact.value.email_id === option.value) {
|
onDelete: async (option, isNew) => {
|
||||||
if (contact.data.email_ids.length === 0) {
|
contact.data.email_ids = contact.data.email_ids.filter(
|
||||||
_contact.value.email_id = ''
|
(email) => email.name !== option.name,
|
||||||
} else {
|
)
|
||||||
_contact.value.email_id = contact.data.email_ids.find(
|
!isNew && (await deleteOption('Contact Email', option.name))
|
||||||
(email) => email.is_primary,
|
if (_contact.value.email_id === option.value) {
|
||||||
)?.email_id
|
if (contact.data.email_ids.length === 0) {
|
||||||
}
|
_contact.value.email_id = ''
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}) || [],
|
|
||||||
create: () => {
|
|
||||||
contact.data?.email_ids?.push({
|
|
||||||
name: 'new-1',
|
|
||||||
value: '',
|
|
||||||
selected: false,
|
|
||||||
isNew: true,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if (field.name === 'mobile_no') {
|
|
||||||
return {
|
|
||||||
...field,
|
|
||||||
type: 'dropdown',
|
|
||||||
options:
|
|
||||||
contact.data?.phone_nos?.map((phone) => {
|
|
||||||
return {
|
|
||||||
name: phone.name,
|
|
||||||
value: phone.phone,
|
|
||||||
selected: phone.phone === contact.data.actual_mobile_no,
|
|
||||||
onClick: () => {
|
|
||||||
_contact.value.actual_mobile_no = phone.phone
|
|
||||||
_contact.value.mobile_no = phone.phone
|
|
||||||
setAsPrimary('mobile_no', phone.phone)
|
|
||||||
},
|
|
||||||
onSave: (option, isNew) => {
|
|
||||||
if (isNew) {
|
|
||||||
createNew('phone', option.value)
|
|
||||||
if (contact.data.phone_nos.length === 1) {
|
|
||||||
_contact.value.actual_mobile_no = option.value
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
editOption(
|
_contact.value.email_id = contact.data.email_ids.find(
|
||||||
'Contact Phone',
|
(email) => email.is_primary,
|
||||||
option.name,
|
)?.email_id
|
||||||
'phone',
|
|
||||||
option.value,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
onDelete: async (option, isNew) => {
|
},
|
||||||
contact.data.phone_nos = contact.data.phone_nos.filter(
|
}
|
||||||
(phone) => phone.name !== option.name,
|
}) || [],
|
||||||
)
|
create: () => {
|
||||||
!isNew &&
|
contact.data?.email_ids?.push({
|
||||||
(await deleteOption('Contact Phone', option.name))
|
name: 'new-1',
|
||||||
if (_contact.value.actual_mobile_no === option.value) {
|
value: '',
|
||||||
if (contact.data.phone_nos.length === 0) {
|
selected: false,
|
||||||
_contact.value.actual_mobile_no = ''
|
isNew: true,
|
||||||
} else {
|
})
|
||||||
_contact.value.actual_mobile_no =
|
},
|
||||||
contact.data.phone_nos.find(
|
|
||||||
(phone) => phone.is_primary_mobile_no,
|
|
||||||
)?.phone
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}) || [],
|
|
||||||
create: () => {
|
|
||||||
contact.data?.phone_nos?.push({
|
|
||||||
name: 'new-1',
|
|
||||||
value: '',
|
|
||||||
selected: false,
|
|
||||||
isNew: true,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if (field.name === 'address') {
|
|
||||||
return {
|
|
||||||
...field,
|
|
||||||
create: (value, close) => {
|
|
||||||
_contact.value.address = value
|
|
||||||
_address.value = {}
|
|
||||||
showAddressModal.value = true
|
|
||||||
close()
|
|
||||||
},
|
|
||||||
edit: async (addr) => {
|
|
||||||
_address.value = await call('frappe.client.get', {
|
|
||||||
doctype: 'Address',
|
|
||||||
name: addr,
|
|
||||||
})
|
|
||||||
showAddressModal.value = true
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return field
|
|
||||||
}
|
}
|
||||||
}),
|
} else if (field.name === 'mobile_no') {
|
||||||
),
|
return {
|
||||||
}
|
...field,
|
||||||
|
type: 'dropdown',
|
||||||
|
options:
|
||||||
|
contact.data?.phone_nos?.map((phone) => {
|
||||||
|
return {
|
||||||
|
name: phone.name,
|
||||||
|
value: phone.phone,
|
||||||
|
selected: phone.phone === contact.data.actual_mobile_no,
|
||||||
|
onClick: () => {
|
||||||
|
_contact.value.actual_mobile_no = phone.phone
|
||||||
|
_contact.value.mobile_no = phone.phone
|
||||||
|
setAsPrimary('mobile_no', phone.phone)
|
||||||
|
},
|
||||||
|
onSave: (option, isNew) => {
|
||||||
|
if (isNew) {
|
||||||
|
createNew('phone', option.value)
|
||||||
|
if (contact.data.phone_nos.length === 1) {
|
||||||
|
_contact.value.actual_mobile_no = option.value
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
editOption(
|
||||||
|
'Contact Phone',
|
||||||
|
option.name,
|
||||||
|
'phone',
|
||||||
|
option.value,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDelete: async (option, isNew) => {
|
||||||
|
contact.data.phone_nos = contact.data.phone_nos.filter(
|
||||||
|
(phone) => phone.name !== option.name,
|
||||||
|
)
|
||||||
|
!isNew && (await deleteOption('Contact Phone', option.name))
|
||||||
|
if (_contact.value.actual_mobile_no === option.value) {
|
||||||
|
if (contact.data.phone_nos.length === 0) {
|
||||||
|
_contact.value.actual_mobile_no = ''
|
||||||
|
} else {
|
||||||
|
_contact.value.actual_mobile_no =
|
||||||
|
contact.data.phone_nos.find(
|
||||||
|
(phone) => phone.is_primary_mobile_no,
|
||||||
|
)?.phone
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}) || [],
|
||||||
|
create: () => {
|
||||||
|
contact.data?.phone_nos?.push({
|
||||||
|
name: 'new-1',
|
||||||
|
value: '',
|
||||||
|
selected: false,
|
||||||
|
isNew: true,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else if (field.name === 'address') {
|
||||||
|
return {
|
||||||
|
...field,
|
||||||
|
create: (value, close) => {
|
||||||
|
_contact.value.address = value
|
||||||
|
_address.value = {}
|
||||||
|
showAddressModal.value = true
|
||||||
|
close()
|
||||||
|
},
|
||||||
|
edit: async (addr) => {
|
||||||
|
_address.value = await call('frappe.client.get', {
|
||||||
|
doctype: 'Address',
|
||||||
|
name: addr,
|
||||||
|
})
|
||||||
|
showAddressModal.value = true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return column
|
||||||
|
})
|
||||||
|
return section
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,8 +99,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
v-if="section.fields"
|
v-if="section.columns?.[0].fields"
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
doctype="CRM Deal"
|
doctype="CRM Deal"
|
||||||
v-model="deal.data"
|
v-model="deal.data"
|
||||||
@ -289,7 +289,7 @@ import {
|
|||||||
Tabs,
|
Tabs,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
call,
|
call,
|
||||||
usePageMeta
|
usePageMeta,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref, computed, h, onMounted } from 'vue'
|
import { ref, computed, h, onMounted } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
@ -511,7 +511,7 @@ const fieldsLayout = createResource({
|
|||||||
function getParsedFields(sections) {
|
function getParsedFields(sections) {
|
||||||
sections.forEach((section) => {
|
sections.forEach((section) => {
|
||||||
if (section.name == 'contacts_section') return
|
if (section.name == 'contacts_section') return
|
||||||
section.fields.forEach((field) => {
|
section.columns[0].fields.forEach((field) => {
|
||||||
if (field.name == 'organization') {
|
if (field.name == 'organization') {
|
||||||
field.create = (value, close) => {
|
field.create = (value, close) => {
|
||||||
_organization.value.organization_name = value
|
_organization.value.organization_name = value
|
||||||
|
|||||||
@ -76,7 +76,7 @@
|
|||||||
>
|
>
|
||||||
<Section :label="section.label" :opened="section.opened">
|
<Section :label="section.label" :opened="section.opened">
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
v-model="lead.data"
|
v-model="lead.data"
|
||||||
@update="updateField"
|
@update="updateField"
|
||||||
|
|||||||
@ -125,8 +125,9 @@
|
|||||||
>
|
>
|
||||||
<Section :label="section.label" :opened="section.opened">
|
<Section :label="section.label" :opened="section.opened">
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
|
v-if="section.columns?.[0].fields"
|
||||||
v-model="organization.doc"
|
v-model="organization.doc"
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
doctype="CRM Organization"
|
doctype="CRM Organization"
|
||||||
@update="updateField"
|
@update="updateField"
|
||||||
@ -335,33 +336,32 @@ const fieldsLayout = createResource({
|
|||||||
|
|
||||||
function getParsedFields(data) {
|
function getParsedFields(data) {
|
||||||
return data.map((section) => {
|
return data.map((section) => {
|
||||||
return {
|
section.columns = section.columns.map((column) => {
|
||||||
...section,
|
column.fields = column.fields.map((field) => {
|
||||||
fields: computed(() =>
|
if (field.name === 'address') {
|
||||||
section.fields.map((field) => {
|
return {
|
||||||
if (field.name === 'address') {
|
...field,
|
||||||
return {
|
create: (value, close) => {
|
||||||
...field,
|
_organization.value.address = value
|
||||||
create: (value, close) => {
|
_address.value = {}
|
||||||
_organization.value.address = value
|
showAddressModal.value = true
|
||||||
_address.value = {}
|
close()
|
||||||
showAddressModal.value = true
|
},
|
||||||
close()
|
edit: async (addr) => {
|
||||||
},
|
_address.value = await call('frappe.client.get', {
|
||||||
edit: async (addr) => {
|
doctype: 'Address',
|
||||||
_address.value = await call('frappe.client.get', {
|
name: addr,
|
||||||
doctype: 'Address',
|
})
|
||||||
name: addr,
|
showAddressModal.value = true
|
||||||
})
|
},
|
||||||
showAddressModal.value = true
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return field
|
|
||||||
}
|
}
|
||||||
}),
|
} else {
|
||||||
),
|
return field
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
return column
|
||||||
|
})
|
||||||
|
return section
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -124,9 +124,9 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
<SidePanelLayout
|
<SidePanelLayout
|
||||||
v-if="section.fields"
|
v-if="section.columns?.[0].fields"
|
||||||
v-model="organization.doc"
|
v-model="organization.doc"
|
||||||
:fields="section.fields"
|
:fields="section.columns[0].fields"
|
||||||
:isLastSection="i == fieldsLayout.data.length - 1"
|
:isLastSection="i == fieldsLayout.data.length - 1"
|
||||||
doctype="CRM Organization"
|
doctype="CRM Organization"
|
||||||
@update="updateField"
|
@update="updateField"
|
||||||
@ -377,33 +377,32 @@ const fieldsLayout = createResource({
|
|||||||
|
|
||||||
function getParsedFields(data) {
|
function getParsedFields(data) {
|
||||||
return data.map((section) => {
|
return data.map((section) => {
|
||||||
return {
|
section.columns = section.columns.map((column) => {
|
||||||
...section,
|
column.fields = column.fields.map((field) => {
|
||||||
fields: computed(() =>
|
if (field.name === 'address') {
|
||||||
section.fields.map((field) => {
|
return {
|
||||||
if (field.name === 'address') {
|
...field,
|
||||||
return {
|
create: (value, close) => {
|
||||||
...field,
|
_organization.value.address = value
|
||||||
create: (value, close) => {
|
_address.value = {}
|
||||||
_organization.value.address = value
|
showAddressModal.value = true
|
||||||
_address.value = {}
|
close()
|
||||||
showAddressModal.value = true
|
},
|
||||||
close()
|
edit: async (addr) => {
|
||||||
},
|
_address.value = await call('frappe.client.get', {
|
||||||
edit: async (addr) => {
|
doctype: 'Address',
|
||||||
_address.value = await call('frappe.client.get', {
|
name: addr,
|
||||||
doctype: 'Address',
|
})
|
||||||
name: addr,
|
showAddressModal.value = true
|
||||||
})
|
},
|
||||||
showAddressModal.value = true
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return field
|
|
||||||
}
|
}
|
||||||
}),
|
} else {
|
||||||
),
|
return field
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
return column
|
||||||
|
})
|
||||||
|
return section
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user