fix: mobile view for lead & deal is broken
This commit is contained in:
parent
b7d2a896f7
commit
9edeadc855
@ -488,7 +488,7 @@ const fieldsLayout = createResource({
|
|||||||
transform: (data) => getParsedFields(data),
|
transform: (data) => getParsedFields(data),
|
||||||
})
|
})
|
||||||
|
|
||||||
function getParsedFields(sections, contacts) {
|
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.fields.forEach((field) => {
|
||||||
|
|||||||
@ -58,15 +58,15 @@
|
|||||||
@updateField="updateField"
|
@updateField="updateField"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="detailSections.length"
|
v-if="fieldsLayout.data"
|
||||||
class="flex flex-1 flex-col justify-between overflow-hidden"
|
class="flex flex-1 flex-col justify-between overflow-hidden"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col overflow-y-auto">
|
<div class="flex flex-col overflow-y-auto">
|
||||||
<div
|
<div
|
||||||
v-for="(section, i) in detailSections"
|
v-for="(section, i) in fieldsLayout.data"
|
||||||
:key="section.label"
|
:key="section.label"
|
||||||
class="flex flex-col px-2 py-3 sm:p-3"
|
class="flex flex-col px-2 py-3 sm:p-3"
|
||||||
:class="{ 'border-b': i !== detailSections.length - 1 }"
|
:class="{ 'border-b': i !== fieldsLayout.data.length - 1 }"
|
||||||
>
|
>
|
||||||
<Section :is-opened="section.opened" :label="section.label">
|
<Section :is-opened="section.opened" :label="section.label">
|
||||||
<template #actions>
|
<template #actions>
|
||||||
@ -441,44 +441,31 @@ const tabs = computed(() => {
|
|||||||
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))
|
return tabOptions.filter((tab) => (tab.condition ? tab.condition() : true))
|
||||||
})
|
})
|
||||||
|
|
||||||
const detailSections = computed(() => {
|
const fieldsLayout = createResource({
|
||||||
let data = deal.data
|
url: 'crm.api.doc.get_sidebar_fields',
|
||||||
if (!data) return []
|
cache: ['fieldsLayout', props.dealId],
|
||||||
return getParsedFields(data.doctype_fields, deal_contacts.data)
|
params: { doctype: 'CRM Deal', name: props.dealId },
|
||||||
|
auto: true,
|
||||||
|
transform: (data) => getParsedFields(data),
|
||||||
})
|
})
|
||||||
|
|
||||||
function getParsedFields(sections, contacts) {
|
function getParsedFields(sections) {
|
||||||
sections.forEach((section) => {
|
sections.forEach((section) => {
|
||||||
if (section.name == 'contacts_tab') {
|
if (section.name == 'contacts_section') return
|
||||||
delete section.fields
|
section.fields.forEach((field) => {
|
||||||
section.contacts =
|
if (field.name == 'organization') {
|
||||||
contacts?.map((contact) => {
|
field.create = (value, close) => {
|
||||||
return {
|
_organization.value.organization_name = value
|
||||||
name: contact.name,
|
showOrganizationModal.value = true
|
||||||
full_name: contact.full_name,
|
close()
|
||||||
email: contact.email,
|
|
||||||
mobile_no: contact.mobile_no,
|
|
||||||
image: contact.image,
|
|
||||||
is_primary: contact.is_primary,
|
|
||||||
opened: false,
|
|
||||||
}
|
|
||||||
}) || []
|
|
||||||
} else {
|
|
||||||
section.fields.forEach((field) => {
|
|
||||||
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 },
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
field.link = (org) =>
|
||||||
}
|
router.push({
|
||||||
|
name: 'Organization',
|
||||||
|
params: { organizationId: org },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
return sections
|
return sections
|
||||||
}
|
}
|
||||||
@ -556,6 +543,23 @@ const deal_contacts = createResource({
|
|||||||
params: { name: props.dealId },
|
params: { name: props.dealId },
|
||||||
cache: ['deal_contacts', props.dealId],
|
cache: ['deal_contacts', props.dealId],
|
||||||
auto: true,
|
auto: true,
|
||||||
|
onSuccess: (data) => {
|
||||||
|
let contactSection = fieldsLayout.data?.find(
|
||||||
|
(section) => section.name == 'contacts_section',
|
||||||
|
)
|
||||||
|
if (!contactSection) return
|
||||||
|
contactSection.contacts = data.map((contact) => {
|
||||||
|
return {
|
||||||
|
name: contact.name,
|
||||||
|
full_name: contact.full_name,
|
||||||
|
email: contact.email,
|
||||||
|
mobile_no: contact.mobile_no,
|
||||||
|
image: contact.image,
|
||||||
|
is_primary: contact.is_primary,
|
||||||
|
opened: false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
function updateField(name, value, callback) {
|
function updateField(name, value, callback) {
|
||||||
|
|||||||
@ -63,15 +63,15 @@
|
|||||||
@updateField="updateField"
|
@updateField="updateField"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="detailSections.length"
|
v-if="fieldsLayout.data"
|
||||||
class="flex flex-1 flex-col justify-between overflow-hidden"
|
class="flex flex-1 flex-col justify-between overflow-hidden"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col overflow-y-auto">
|
<div class="flex flex-col overflow-y-auto">
|
||||||
<div
|
<div
|
||||||
v-for="(section, i) in detailSections"
|
v-for="(section, i) in fieldsLayout.data"
|
||||||
:key="section.label"
|
:key="section.label"
|
||||||
class="flex flex-col px-2 py-3 sm:p-3"
|
class="flex flex-col px-2 py-3 sm:p-3"
|
||||||
:class="{ 'border-b': i !== detailSections.length - 1 }"
|
:class="{ 'border-b': i !== fieldsLayout.data.length - 1 }"
|
||||||
>
|
>
|
||||||
<Section :is-opened="section.opened" :label="section.label">
|
<Section :is-opened="section.opened" :label="section.label">
|
||||||
<SectionFields
|
<SectionFields
|
||||||
@ -367,10 +367,11 @@ watch(tabs, (value) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const detailSections = computed(() => {
|
const fieldsLayout = createResource({
|
||||||
let data = lead.data
|
url: 'crm.api.doc.get_sidebar_fields',
|
||||||
if (!data) return []
|
cache: ['fieldsLayout', props.leadId],
|
||||||
return data.doctype_fields
|
params: { doctype: 'CRM Lead', name: props.leadId },
|
||||||
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
function updateField(name, value, callback) {
|
function updateField(name, value, callback) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user