fix: also handle it for mobile view
This commit is contained in:
parent
e84351cb57
commit
faa2bdd5ef
@ -178,7 +178,6 @@ import { createToast, setupAssignees, setupCustomizations } from '@/utils'
|
|||||||
import { getView } from '@/utils/view'
|
import { getView } from '@/utils/view'
|
||||||
import { getSettings } from '@/stores/settings'
|
import { getSettings } from '@/stores/settings'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { contactsStore } from '@/stores/contacts'
|
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
import { getMeta } from '@/stores/meta'
|
import { getMeta } from '@/stores/meta'
|
||||||
import {
|
import {
|
||||||
@ -186,6 +185,7 @@ import {
|
|||||||
callEnabled,
|
callEnabled,
|
||||||
isMobileView,
|
isMobileView,
|
||||||
} from '@/composables/settings'
|
} from '@/composables/settings'
|
||||||
|
import { capture } from '@/telemetry'
|
||||||
import { useActiveTabManager } from '@/composables/useActiveTabManager'
|
import { useActiveTabManager } from '@/composables/useActiveTabManager'
|
||||||
import {
|
import {
|
||||||
createResource,
|
createResource,
|
||||||
@ -203,7 +203,6 @@ import { useRouter, useRoute } from 'vue-router'
|
|||||||
|
|
||||||
const { brand } = getSettings()
|
const { brand } = getSettings()
|
||||||
const { $dialog, $socket } = globalStore()
|
const { $dialog, $socket } = globalStore()
|
||||||
const { getContactByName, contacts } = contactsStore()
|
|
||||||
const { statusOptions, getLeadStatus } = statusesStore()
|
const { statusOptions, getLeadStatus } = statusesStore()
|
||||||
const { doctypeMeta } = getMeta('CRM Lead')
|
const { doctypeMeta } = getMeta('CRM Lead')
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -433,9 +432,7 @@ const existingOrganizationChecked = ref(false)
|
|||||||
const existingContact = ref('')
|
const existingContact = ref('')
|
||||||
const existingOrganization = ref('')
|
const existingOrganization = ref('')
|
||||||
|
|
||||||
async function convertToDeal(updated) {
|
async function convertToDeal() {
|
||||||
let valueUpdated = false
|
|
||||||
|
|
||||||
if (existingContactChecked.value && !existingContact.value) {
|
if (existingContactChecked.value && !existingContact.value) {
|
||||||
createToast({
|
createToast({
|
||||||
title: __('Error'),
|
title: __('Error'),
|
||||||
@ -456,49 +453,28 @@ async function convertToDeal(updated) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingContactChecked.value && existingContact.value) {
|
if (!existingContactChecked.value && existingContact.value) {
|
||||||
lead.data.salutation = getContactByName(existingContact.value).salutation
|
existingContact.value = ''
|
||||||
lead.data.first_name = getContactByName(existingContact.value).first_name
|
|
||||||
lead.data.last_name = getContactByName(existingContact.value).last_name
|
|
||||||
lead.data.email_id = getContactByName(existingContact.value).email_id
|
|
||||||
lead.data.mobile_no = getContactByName(existingContact.value).mobile_no
|
|
||||||
existingContactChecked.value = false
|
|
||||||
valueUpdated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingOrganizationChecked.value && existingOrganization.value) {
|
if (!existingOrganizationChecked.value && existingOrganization.value) {
|
||||||
lead.data.organization = existingOrganization.value
|
existingOrganization.value = ''
|
||||||
existingOrganizationChecked.value = false
|
|
||||||
valueUpdated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueUpdated) {
|
let deal = await call('crm.fcrm.doctype.crm_lead.crm_lead.convert_to_deal', {
|
||||||
updateLead(
|
lead: lead.data.name,
|
||||||
{
|
deal: {},
|
||||||
salutation: lead.data.salutation,
|
existing_contact: existingContact.value,
|
||||||
first_name: lead.data.first_name,
|
existing_organization: existingOrganization.value,
|
||||||
last_name: lead.data.last_name,
|
})
|
||||||
email_id: lead.data.email_id,
|
if (deal) {
|
||||||
mobile_no: lead.data.mobile_no,
|
|
||||||
organization: lead.data.organization,
|
|
||||||
},
|
|
||||||
'',
|
|
||||||
() => convertToDeal(true),
|
|
||||||
)
|
|
||||||
showConvertToDealModal.value = false
|
showConvertToDealModal.value = false
|
||||||
} else {
|
existingContactChecked.value = false
|
||||||
let deal = await call(
|
existingOrganizationChecked.value = false
|
||||||
'crm.fcrm.doctype.crm_lead.crm_lead.convert_to_deal',
|
existingContact.value = ''
|
||||||
{
|
existingOrganization.value = ''
|
||||||
lead: lead.data.name,
|
capture('convert_lead_to_deal')
|
||||||
},
|
router.push({ name: 'Deal', params: { dealId: deal } })
|
||||||
)
|
|
||||||
if (deal) {
|
|
||||||
if (updated) {
|
|
||||||
await contacts.reload()
|
|
||||||
}
|
|
||||||
router.push({ name: 'Deal', params: { dealId: deal } })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user