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