fix: removed organization store from lead/deal page
This commit is contained in:
parent
b1bfeca712
commit
cc15309f9c
@ -59,15 +59,15 @@
|
|||||||
<Avatar
|
<Avatar
|
||||||
size="3xl"
|
size="3xl"
|
||||||
class="size-12"
|
class="size-12"
|
||||||
:label="organization?.name || __('Untitled')"
|
:label="organization.data?.name || __('Untitled')"
|
||||||
:image="organization?.organization_logo"
|
:image="organization.data?.organization_logo"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div class="flex flex-col gap-2.5 truncate">
|
<div class="flex flex-col gap-2.5 truncate">
|
||||||
<Tooltip :text="organization?.name || __('Set an organization')">
|
<Tooltip :text="organization.data?.name || __('Set an organization')">
|
||||||
<div class="truncate text-2xl font-medium">
|
<div class="truncate text-2xl font-medium">
|
||||||
{{ organization?.name || __('Untitled') }}
|
{{ organization.data?.name || __('Untitled') }}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div class="flex gap-1.5">
|
<div class="flex gap-1.5">
|
||||||
@ -275,10 +275,7 @@
|
|||||||
v-model:organization="_organization"
|
v-model:organization="_organization"
|
||||||
:options="{
|
:options="{
|
||||||
redirect: false,
|
redirect: false,
|
||||||
afterInsert: (doc) =>
|
afterInsert: (doc) => updateField('organization', doc.name),
|
||||||
updateField('organization', doc.name, () => {
|
|
||||||
organizations.reload()
|
|
||||||
}),
|
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<ContactModal
|
<ContactModal
|
||||||
@ -342,7 +339,6 @@ import {
|
|||||||
} from '@/utils'
|
} from '@/utils'
|
||||||
import { getView } from '@/utils/view'
|
import { getView } from '@/utils/view'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { organizationsStore } from '@/stores/organizations'
|
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { whatsappEnabled, callEnabled } from '@/composables/settings'
|
import { whatsappEnabled, callEnabled } from '@/composables/settings'
|
||||||
@ -360,7 +356,6 @@ import { ref, computed, h, onMounted, onBeforeUnmount } from 'vue'
|
|||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
const { $dialog, $socket, makeCall } = globalStore()
|
const { $dialog, $socket, makeCall } = globalStore()
|
||||||
const { organizations, getOrganization } = organizationsStore()
|
|
||||||
const { statusOptions, getDealStatus } = statusesStore()
|
const { statusOptions, getDealStatus } = statusesStore()
|
||||||
const { isManager } = usersStore()
|
const { isManager } = usersStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -381,6 +376,10 @@ const deal = createResource({
|
|||||||
params: { name: props.dealId },
|
params: { name: props.dealId },
|
||||||
cache: ['deal', props.dealId],
|
cache: ['deal', props.dealId],
|
||||||
onSuccess: async (data) => {
|
onSuccess: async (data) => {
|
||||||
|
organization.update({
|
||||||
|
params: { doctype: 'CRM Organization', name: data.organization },
|
||||||
|
})
|
||||||
|
organization.fetch()
|
||||||
let obj = {
|
let obj = {
|
||||||
doc: data,
|
doc: data,
|
||||||
$dialog,
|
$dialog,
|
||||||
@ -403,6 +402,11 @@ const deal = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const organization = createResource({
|
||||||
|
url: 'frappe.client.get',
|
||||||
|
onSuccess: (data) => (deal.data._organizationObj = data),
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
$socket.on('crm_customer_created', () => {
|
$socket.on('crm_customer_created', () => {
|
||||||
createToast({
|
createToast({
|
||||||
@ -412,7 +416,10 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
if (deal.data) return
|
if (deal.data) {
|
||||||
|
organization.data = deal.data._organizationObj
|
||||||
|
return
|
||||||
|
}
|
||||||
deal.fetch()
|
deal.fetch()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -426,10 +433,6 @@ const showAssignmentModal = ref(false)
|
|||||||
const showSidePanelModal = ref(false)
|
const showSidePanelModal = ref(false)
|
||||||
const _organization = ref({})
|
const _organization = ref({})
|
||||||
|
|
||||||
const organization = computed(() => {
|
|
||||||
return deal.data?.organization && getOrganization(deal.data.organization)
|
|
||||||
})
|
|
||||||
|
|
||||||
function updateDeal(fieldname, value, callback) {
|
function updateDeal(fieldname, value, callback) {
|
||||||
value = Array.isArray(fieldname) ? '' : value
|
value = Array.isArray(fieldname) ? '' : value
|
||||||
|
|
||||||
@ -498,7 +501,7 @@ const breadcrumbs = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
label: organization.value?.name || __('Untitled'),
|
label: organization.data?.name || __('Untitled'),
|
||||||
route: { name: 'Deal', params: { dealId: deal.data.name } },
|
route: { name: 'Deal', params: { dealId: deal.data.name } },
|
||||||
})
|
})
|
||||||
return items
|
return items
|
||||||
@ -506,7 +509,7 @@ const breadcrumbs = computed(() => {
|
|||||||
|
|
||||||
usePageMeta(() => {
|
usePageMeta(() => {
|
||||||
return {
|
return {
|
||||||
title: organization.value?.name || deal.data?.name,
|
title: organization.data?.name || deal.data?.name,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -312,7 +312,6 @@ import {
|
|||||||
import { getView } from '@/utils/view'
|
import { getView } from '@/utils/view'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { contactsStore } from '@/stores/contacts'
|
import { contactsStore } from '@/stores/contacts'
|
||||||
import { organizationsStore } from '@/stores/organizations'
|
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { whatsappEnabled, callEnabled } from '@/composables/settings'
|
import { whatsappEnabled, callEnabled } from '@/composables/settings'
|
||||||
@ -334,7 +333,6 @@ import { useRouter, useRoute } from 'vue-router'
|
|||||||
|
|
||||||
const { $dialog, $socket, makeCall } = globalStore()
|
const { $dialog, $socket, makeCall } = globalStore()
|
||||||
const { getContactByName, contacts } = contactsStore()
|
const { getContactByName, contacts } = contactsStore()
|
||||||
const { organizations } = organizationsStore()
|
|
||||||
const { statusOptions, getLeadStatus } = statusesStore()
|
const { statusOptions, getLeadStatus } = statusesStore()
|
||||||
const { isManager } = usersStore()
|
const { isManager } = usersStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -621,7 +619,6 @@ async function convertToDeal(updated) {
|
|||||||
if (deal) {
|
if (deal) {
|
||||||
capture('convert_lead_to_deal')
|
capture('convert_lead_to_deal')
|
||||||
if (updated) {
|
if (updated) {
|
||||||
await organizations.reload()
|
|
||||||
await contacts.reload()
|
await contacts.reload()
|
||||||
}
|
}
|
||||||
router.push({ name: 'Deal', params: { dealId: deal } })
|
router.push({ name: 'Deal', params: { dealId: deal } })
|
||||||
|
|||||||
@ -305,7 +305,6 @@ import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
|||||||
import ViewControls from '@/components/ViewControls.vue'
|
import ViewControls from '@/components/ViewControls.vue'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { organizationsStore } from '@/stores/organizations'
|
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
import { callEnabled } from '@/composables/settings'
|
import { callEnabled } from '@/composables/settings'
|
||||||
import { dateFormat, dateTooltipFormat, timeAgo, formatTime } from '@/utils'
|
import { dateFormat, dateTooltipFormat, timeAgo, formatTime } from '@/utils'
|
||||||
@ -315,7 +314,6 @@ import { ref, computed, reactive, h } from 'vue'
|
|||||||
|
|
||||||
const { makeCall } = globalStore()
|
const { makeCall } = globalStore()
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
const { getOrganization } = organizationsStore()
|
|
||||||
const { getLeadStatus } = statusesStore()
|
const { getLeadStatus } = statusesStore()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -412,10 +410,7 @@ function parseRows(rows) {
|
|||||||
image_label: lead.first_name,
|
image_label: lead.first_name,
|
||||||
}
|
}
|
||||||
} else if (row == 'organization') {
|
} else if (row == 'organization') {
|
||||||
_rows[row] = {
|
_rows[row] = lead.organization
|
||||||
label: lead.organization,
|
|
||||||
logo: getOrganization(lead.organization)?.organization_logo,
|
|
||||||
}
|
|
||||||
} else if (row == 'status') {
|
} else if (row == 'status') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: lead.status,
|
label: lead.status,
|
||||||
|
|||||||
@ -224,10 +224,7 @@
|
|||||||
v-model:organization="_organization"
|
v-model:organization="_organization"
|
||||||
:options="{
|
:options="{
|
||||||
redirect: false,
|
redirect: false,
|
||||||
afterInsert: (doc) =>
|
afterInsert: (doc) => updateField('organization', doc.name),
|
||||||
updateField('organization', doc.name, () => {
|
|
||||||
organizations.reload()
|
|
||||||
}),
|
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<ContactModal
|
<ContactModal
|
||||||
@ -275,7 +272,6 @@ import CustomActions from '@/components/CustomActions.vue'
|
|||||||
import { createToast, setupAssignees, setupCustomizations } from '@/utils'
|
import { createToast, setupAssignees, setupCustomizations } from '@/utils'
|
||||||
import { getView } from '@/utils/view'
|
import { getView } from '@/utils/view'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { organizationsStore } from '@/stores/organizations'
|
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
import {
|
import {
|
||||||
whatsappEnabled,
|
whatsappEnabled,
|
||||||
@ -294,7 +290,6 @@ import { ref, computed, h, onMounted } from 'vue'
|
|||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
const { $dialog, $socket } = globalStore()
|
const { $dialog, $socket } = globalStore()
|
||||||
const { organizations, getOrganization } = organizationsStore()
|
|
||||||
const { statusOptions, getDealStatus } = statusesStore()
|
const { statusOptions, getDealStatus } = statusesStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -314,6 +309,10 @@ const deal = createResource({
|
|||||||
params: { name: props.dealId },
|
params: { name: props.dealId },
|
||||||
cache: ['deal', props.dealId],
|
cache: ['deal', props.dealId],
|
||||||
onSuccess: async (data) => {
|
onSuccess: async (data) => {
|
||||||
|
organization.update({
|
||||||
|
params: { doctype: 'CRM Organization', name: data.organization },
|
||||||
|
})
|
||||||
|
organization.fetch()
|
||||||
let obj = {
|
let obj = {
|
||||||
doc: data,
|
doc: data,
|
||||||
$dialog,
|
$dialog,
|
||||||
@ -336,6 +335,11 @@ const deal = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const organization = createResource({
|
||||||
|
url: 'frappe.client.get',
|
||||||
|
onSuccess: (data) => (deal.data._organizationObj = data),
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (deal.data) return
|
if (deal.data) return
|
||||||
deal.fetch()
|
deal.fetch()
|
||||||
@ -346,10 +350,6 @@ const showOrganizationModal = ref(false)
|
|||||||
const showAssignmentModal = ref(false)
|
const showAssignmentModal = ref(false)
|
||||||
const _organization = ref({})
|
const _organization = ref({})
|
||||||
|
|
||||||
const organization = computed(() => {
|
|
||||||
return deal.data?.organization && getOrganization(deal.data.organization)
|
|
||||||
})
|
|
||||||
|
|
||||||
function updateDeal(fieldname, value, callback) {
|
function updateDeal(fieldname, value, callback) {
|
||||||
value = Array.isArray(fieldname) ? '' : value
|
value = Array.isArray(fieldname) ? '' : value
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ const breadcrumbs = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
label: organization.value?.name || __('Untitled'),
|
label: organization.data?.name || __('Untitled'),
|
||||||
route: { name: 'Deal', params: { dealId: deal.data.name } },
|
route: { name: 'Deal', params: { dealId: deal.data.name } },
|
||||||
})
|
})
|
||||||
return items
|
return items
|
||||||
|
|||||||
@ -197,7 +197,6 @@ import { createToast, setupAssignees, setupCustomizations } from '@/utils'
|
|||||||
import { getView } from '@/utils/view'
|
import { getView } from '@/utils/view'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { contactsStore } from '@/stores/contacts'
|
import { contactsStore } from '@/stores/contacts'
|
||||||
import { organizationsStore } from '@/stores/organizations'
|
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
import {
|
import {
|
||||||
whatsappEnabled,
|
whatsappEnabled,
|
||||||
@ -217,7 +216,6 @@ import { useRouter, useRoute } from 'vue-router'
|
|||||||
|
|
||||||
const { $dialog, $socket } = globalStore()
|
const { $dialog, $socket } = globalStore()
|
||||||
const { getContactByName, contacts } = contactsStore()
|
const { getContactByName, contacts } = contactsStore()
|
||||||
const { organizations } = organizationsStore()
|
|
||||||
const { statusOptions, getLeadStatus } = statusesStore()
|
const { statusOptions, getLeadStatus } = statusesStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -494,7 +492,6 @@ async function convertToDeal(updated) {
|
|||||||
)
|
)
|
||||||
if (deal) {
|
if (deal) {
|
||||||
if (updated) {
|
if (updated) {
|
||||||
await organizations.reload()
|
|
||||||
await contacts.reload()
|
await contacts.reload()
|
||||||
}
|
}
|
||||||
router.push({ name: 'Deal', params: { dealId: deal } })
|
router.push({ name: 'Deal', params: { dealId: deal } })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user