fix: better caching in lead/deal page
This commit is contained in:
parent
1fc0e74098
commit
cd697de6e1
@ -772,7 +772,7 @@ import {
|
|||||||
call,
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { useElementVisibility } from '@vueuse/core'
|
import { useElementVisibility } from '@vueuse/core'
|
||||||
import { ref, computed, h, defineModel, markRaw, watch, nextTick } from 'vue'
|
import { ref, computed, h, defineModel, markRaw, watch, nextTick, onMounted } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
const { makeCall } = globalStore()
|
const { makeCall } = globalStore()
|
||||||
@ -799,7 +799,21 @@ const versions = createResource({
|
|||||||
url: 'crm.api.activities.get_activities',
|
url: 'crm.api.activities.get_activities',
|
||||||
params: { name: doc.value.data.name },
|
params: { name: doc.value.data.name },
|
||||||
cache: ['activity', doc.value.data.name],
|
cache: ['activity', doc.value.data.name],
|
||||||
auto: true,
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (versions.data == null) {
|
||||||
|
versions.fetch()
|
||||||
|
}
|
||||||
|
if (calls.data == null) {
|
||||||
|
calls.fetch()
|
||||||
|
}
|
||||||
|
if (notes.data == null) {
|
||||||
|
notes.fetch()
|
||||||
|
}
|
||||||
|
if (tasks.data == null) {
|
||||||
|
tasks.fetch()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const calls = createListResource({
|
const calls = createListResource({
|
||||||
@ -824,7 +838,6 @@ const calls = createListResource({
|
|||||||
filters: { reference_docname: doc.value.data.name },
|
filters: { reference_docname: doc.value.data.name },
|
||||||
orderBy: 'creation desc',
|
orderBy: 'creation desc',
|
||||||
pageLength: 999,
|
pageLength: 999,
|
||||||
auto: true,
|
|
||||||
transform: (docs) => {
|
transform: (docs) => {
|
||||||
docs.forEach((doc) => {
|
docs.forEach((doc) => {
|
||||||
doc.show_recording = false
|
doc.show_recording = false
|
||||||
@ -869,7 +882,6 @@ const notes = createListResource({
|
|||||||
filters: { reference_docname: doc.value.data.name },
|
filters: { reference_docname: doc.value.data.name },
|
||||||
orderBy: 'modified desc',
|
orderBy: 'modified desc',
|
||||||
pageLength: 999,
|
pageLength: 999,
|
||||||
auto: true,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tasks = createListResource({
|
const tasks = createListResource({
|
||||||
@ -890,7 +902,6 @@ const tasks = createListResource({
|
|||||||
filters: { reference_docname: doc.value.data.name },
|
filters: { reference_docname: doc.value.data.name },
|
||||||
orderBy: 'modified desc',
|
orderBy: 'modified desc',
|
||||||
pageLength: 999,
|
pageLength: 999,
|
||||||
auto: true,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function all_activities() {
|
function all_activities() {
|
||||||
@ -911,15 +922,15 @@ const activities = computed(() => {
|
|||||||
.filter((activity) => activity.activity_type === 'communication')
|
.filter((activity) => activity.activity_type === 'communication')
|
||||||
.sort((a, b) => new Date(a.creation) - new Date(b.creation))
|
.sort((a, b) => new Date(a.creation) - new Date(b.creation))
|
||||||
} else if (props.title == 'Calls') {
|
} else if (props.title == 'Calls') {
|
||||||
return calls.data.sort(
|
return calls.data?.sort(
|
||||||
(a, b) => new Date(a.creation) - new Date(b.creation)
|
(a, b) => new Date(a.creation) - new Date(b.creation)
|
||||||
)
|
)
|
||||||
} else if (props.title == 'Tasks') {
|
} else if (props.title == 'Tasks') {
|
||||||
return tasks.data.sort(
|
return tasks.data?.sort(
|
||||||
(a, b) => new Date(a.creation) - new Date(b.creation)
|
(a, b) => new Date(a.creation) - new Date(b.creation)
|
||||||
)
|
)
|
||||||
} else if (props.title == 'Notes') {
|
} else if (props.title == 'Notes') {
|
||||||
return notes.data.sort(
|
return notes.data?.sort(
|
||||||
(a, b) => new Date(a.creation) - new Date(b.creation)
|
(a, b) => new Date(a.creation) - new Date(b.creation)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,6 +129,13 @@ const options = createResource({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function reload(val) {
|
function reload(val) {
|
||||||
|
if (
|
||||||
|
options.data?.length &&
|
||||||
|
val === options.params?.txt &&
|
||||||
|
props.doctype === options.params?.doctype
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
options.update({
|
options.update({
|
||||||
params: {
|
params: {
|
||||||
txt: val,
|
txt: val,
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import EmailTemplateModal from '@/components/Modals/EmailTemplateModal.vue'
|
import EmailTemplateModal from '@/components/Modals/EmailTemplateModal.vue'
|
||||||
import { TextEditor, createListResource } from 'frappe-ui'
|
import { TextEditor, createListResource } from 'frappe-ui'
|
||||||
import { defineModel, ref, computed, nextTick, watch } from 'vue'
|
import { defineModel, ref, computed, nextTick, watch, onMounted } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
doctype: {
|
doctype: {
|
||||||
@ -85,7 +85,7 @@ const search = ref('')
|
|||||||
const templates = createListResource({
|
const templates = createListResource({
|
||||||
type: 'list',
|
type: 'list',
|
||||||
doctype: 'Email Template',
|
doctype: 'Email Template',
|
||||||
cache: ['Email Templates', props.doctype],
|
cache: ['emailTemplates', props.doctype],
|
||||||
fields: [
|
fields: [
|
||||||
'name',
|
'name',
|
||||||
'enabled',
|
'enabled',
|
||||||
@ -98,7 +98,12 @@ const templates = createListResource({
|
|||||||
filters: { enabled: 1, reference_doctype: props.doctype },
|
filters: { enabled: 1, reference_doctype: props.doctype },
|
||||||
orderBy: 'modified desc',
|
orderBy: 'modified desc',
|
||||||
pageLength: 99999,
|
pageLength: 99999,
|
||||||
auto: true,
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (templates.data == null) {
|
||||||
|
templates.fetch()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const filteredTemplates = computed(() => {
|
const filteredTemplates = computed(() => {
|
||||||
|
|||||||
@ -325,7 +325,7 @@ import {
|
|||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
call,
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref, computed, h } from 'vue'
|
import { ref, computed, h, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const { $dialog, makeCall } = globalStore()
|
const { $dialog, makeCall } = globalStore()
|
||||||
@ -345,7 +345,6 @@ const deal = createResource({
|
|||||||
url: 'crm.fcrm.doctype.crm_deal.api.get_deal',
|
url: 'crm.fcrm.doctype.crm_deal.api.get_deal',
|
||||||
params: { name: props.dealId },
|
params: { name: props.dealId },
|
||||||
cache: ['deal', props.dealId],
|
cache: ['deal', props.dealId],
|
||||||
auto: true,
|
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
setupAssignees(data)
|
setupAssignees(data)
|
||||||
setupCustomActions(data, {
|
setupCustomActions(data, {
|
||||||
@ -360,6 +359,11 @@ const deal = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (deal.data) return
|
||||||
|
deal.fetch()
|
||||||
|
})
|
||||||
|
|
||||||
const reload = ref(false)
|
const reload = ref(false)
|
||||||
const showOrganizationModal = ref(false)
|
const showOrganizationModal = ref(false)
|
||||||
const showAssignmentModal = ref(false)
|
const showAssignmentModal = ref(false)
|
||||||
|
|||||||
@ -290,7 +290,7 @@ import {
|
|||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
call,
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const { $dialog, makeCall } = globalStore()
|
const { $dialog, makeCall } = globalStore()
|
||||||
@ -310,7 +310,6 @@ const lead = createResource({
|
|||||||
url: 'crm.fcrm.doctype.crm_lead.api.get_lead',
|
url: 'crm.fcrm.doctype.crm_lead.api.get_lead',
|
||||||
params: { name: props.leadId },
|
params: { name: props.leadId },
|
||||||
cache: ['lead', props.leadId],
|
cache: ['lead', props.leadId],
|
||||||
auto: true,
|
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
setupAssignees(data)
|
setupAssignees(data)
|
||||||
setupCustomActions(data, {
|
setupCustomActions(data, {
|
||||||
@ -325,6 +324,11 @@ const lead = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (lead.data) return
|
||||||
|
lead.fetch()
|
||||||
|
})
|
||||||
|
|
||||||
const reload = ref(false)
|
const reload = ref(false)
|
||||||
const showAssignmentModal = ref(false)
|
const showAssignmentModal = ref(false)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user