fix: make caching of filter & sort by better
This commit is contained in:
parent
7212421bd5
commit
1d4040a774
@ -101,7 +101,7 @@ import FilterIcon from '@/components/Icons/FilterIcon.vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import Autocomplete from '@/components/frappe-ui/Autocomplete.vue'
|
||||
import { FormControl, createResource } from 'frappe-ui'
|
||||
import { h, defineModel, computed } from 'vue'
|
||||
import { h, defineModel, computed, onMounted } from 'vue'
|
||||
|
||||
const typeCheck = ['Check']
|
||||
const typeLink = ['Link', 'Dynamic Link']
|
||||
@ -127,7 +127,6 @@ const list = defineModel()
|
||||
|
||||
const filterableFields = createResource({
|
||||
url: 'crm.api.doc.get_filterable_fields',
|
||||
auto: true,
|
||||
cache: ['filterableFields', props.doctype],
|
||||
params: {
|
||||
doctype: props.doctype,
|
||||
@ -144,6 +143,11 @@ const filterableFields = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (filterableFields.data?.length) return
|
||||
filterableFields.fetch()
|
||||
})
|
||||
|
||||
const filters = computed(() => {
|
||||
if (!list.value?.data) return new Set()
|
||||
let allFilters = list.value?.params?.filters
|
||||
|
||||
@ -101,7 +101,7 @@ import DragIcon from '@/components/Icons/DragIcon.vue'
|
||||
import { useSortable } from '@vueuse/integrations/useSortable'
|
||||
import Autocomplete from '@/components/frappe-ui/Autocomplete.vue'
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { computed, ref, nextTick } from 'vue'
|
||||
import { computed, ref, nextTick, onMounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
doctype: {
|
||||
@ -117,12 +117,17 @@ const sortButtonRef = ref(null)
|
||||
|
||||
const sortOptions = createResource({
|
||||
url: 'crm.api.doc.sort_options',
|
||||
auto: true,
|
||||
cache: ['sortOptions', props.doctype],
|
||||
params: {
|
||||
doctype: props.doctype,
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (sortOptions.data?.length) return
|
||||
sortOptions.fetch()
|
||||
})
|
||||
|
||||
const sortValues = computed({
|
||||
get: () => {
|
||||
if (!list.value?.data) return new Set()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user