fix: useDocument in organization page

(cherry picked from commit 6760798f180e1630612080905eebbded0ec81551)
This commit is contained in:
Shariq Ansari 2025-07-05 14:17:26 +05:30 committed by Mergify
parent 69277c5fb0
commit a78a110914
2 changed files with 11 additions and 38 deletions

View File

@ -158,6 +158,7 @@ import CameraIcon from '@/components/Icons/CameraIcon.vue'
import DealsIcon from '@/components/Icons/DealsIcon.vue'
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import { showAddressModal, addressProps } from '@/composables/modals'
import { useDocument } from '@/data/document'
import { getSettings } from '@/stores/settings'
import { getMeta } from '@/stores/meta'
import { globalStore } from '@/stores/global'
@ -175,7 +176,6 @@ import {
TabPanel,
call,
createListResource,
createDocumentResource,
usePageMeta,
createResource,
toast,
@ -199,13 +199,10 @@ const { doctypeMeta } = getMeta('CRM Organization')
const route = useRoute()
const router = useRouter()
const organization = createDocumentResource({
doctype: 'CRM Organization',
name: props.organizationId,
cache: ['organization', props.organizationId],
fields: ['*'],
auto: true,
})
const { document: organization } = useDocument(
'CRM Organization',
props.organizationId,
)
const breadcrumbs = computed(() => {
let items = [{ label: __('Organizations'), route: { name: 'Organizations' } }]
@ -288,8 +285,6 @@ function openWebsite() {
else window.open(organization.doc.website, '_blank')
}
const _organization = ref({})
const sections = createResource({
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
cache: ['sidePanelSections', 'CRM Organization'],
@ -306,7 +301,6 @@ function getParsedSections(_sections) {
return {
...field,
create: (value, close) => {
_organization.value.address = value
openAddressModal()
close()
},

View File

@ -186,9 +186,9 @@ import CameraIcon from '@/components/Icons/CameraIcon.vue'
import DealsIcon from '@/components/Icons/DealsIcon.vue'
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import { showAddressModal, addressProps } from '@/composables/modals'
import { useDocument } from '@/data/document'
import { getSettings } from '@/stores/settings'
import { getMeta } from '@/stores/meta'
import { globalStore } from '@/stores/global'
import { usersStore } from '@/stores/users'
import { statusesStore } from '@/stores/statuses'
import { getView } from '@/utils/view'
@ -202,13 +202,12 @@ import {
Tabs,
call,
createListResource,
createDocumentResource,
usePageMeta,
createResource,
toast,
} from 'frappe-ui'
import { h, computed, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useRoute } from 'vue-router'
import DeleteLinkedDocModal from '@/components/DeleteLinkedDocModal.vue'
const props = defineProps({
@ -220,37 +219,20 @@ const props = defineProps({
const { brand } = getSettings()
const { getUser } = usersStore()
const { $dialog } = globalStore()
const { getDealStatus } = statusesStore()
const { doctypeMeta } = getMeta('CRM Organization')
const route = useRoute()
const router = useRouter()
const errorTitle = ref('')
const errorMessage = ref('')
const showDeleteLinkedDocModal = ref(false)
const organization = createDocumentResource({
doctype: 'CRM Organization',
name: props.organizationId,
cache: ['organization', props.organizationId],
fields: ['*'],
auto: true,
onSuccess: () => {
errorTitle.value = ''
errorMessage.value = ''
},
onError: (err) => {
if (err.messages?.[0]) {
errorTitle.value = __('Not permitted')
errorMessage.value = __(err.messages?.[0])
} else {
router.push({ name: 'Organizations' })
}
},
})
const { document: organization } = useDocument(
'CRM Organization',
props.organizationId,
)
const breadcrumbs = computed(() => {
let items = [{ label: __('Organizations'), route: { name: 'Organizations' } }]
@ -319,8 +301,6 @@ function openWebsite() {
else window.open(organization.doc.website, '_blank')
}
const _organization = ref({})
const sections = createResource({
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
cache: ['sidePanelSections', 'CRM Organization'],
@ -337,7 +317,6 @@ function getParsedSections(_sections) {
return {
...field,
create: (value, close) => {
_organization.value.address = value
openAddressModal()
close()
},