From 8381a250171c00c8bf832b9efde290bce4fd1ab9 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 18 Oct 2024 13:46:34 +0200 Subject: [PATCH 1/3] fix: refs #8036 apply exprBuilder after save filters --- src/components/ui/VnFilterPanel.vue | 3 +-- src/composables/useArrayData.js | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 43d634ad9..4dececa91 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -37,7 +37,7 @@ const $props = defineProps({ }, hiddenTags: { type: Array, - default: () => ['filter', 'search', 'or', 'and'], + default: () => ['filter', 'or', 'and'], }, customTags: { type: Array, @@ -62,7 +62,6 @@ const emit = defineEmits([ 'update:modelValue', 'refresh', 'clear', - 'search', 'init', 'remove', 'setUserParams', diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 30bcac66b..c55e08d74 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -74,18 +74,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { limit: store.limit, }; - let exprFilter; let userParams = { ...store.userParams }; - if (store?.exprBuilder) { - const where = buildFilter(userParams, (param, value) => { - const res = store.exprBuilder(param, value); - if (res) delete userParams[param]; - return res; - }); - exprFilter = where ? { where } : null; - } - Object.assign(filter, store.userFilter, exprFilter); + Object.assign(filter, store.userFilter); + let where; if (filter?.where || store.filter?.where) where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {}); @@ -98,8 +90,22 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (store.order && store.order.length) params.filter.order = store.order; else delete params.filter.order; + store.currentFilter = JSON.parse(JSON.stringify(params)); + store.currentFilter.filter = JSON.stringify(store.currentFilter.filter); + + let exprFilter; + if (store?.exprBuilder) { + exprFilter = buildFilter(params, (param, value) => { + if (param == 'filter') return; + const res = store.exprBuilder(param, value); + if (res) delete params[param]; + return res; + }); + } + + params.filter.where = { ...params.filter.where, ...exprFilter }; params.filter = JSON.stringify(params.filter); - store.currentFilter = params; + store.isLoading = true; const response = await axios.get(store.url, { signal: canceller.signal, -- 2.40.1 From bfc906a3469077b448df99163690b4d20b0afd3b Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 18 Oct 2024 13:48:10 +0200 Subject: [PATCH 2/3] fix: refs #8036 only add where when required --- src/composables/useArrayData.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index c55e08d74..6b1d183f2 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -103,7 +103,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { }); } - params.filter.where = { ...params.filter.where, ...exprFilter }; + if (params.filter.where || exprFilter) + params.filter.where = { ...params.filter.where, ...exprFilter }; params.filter = JSON.stringify(params.filter); store.isLoading = true; -- 2.40.1 From 1e04ead78027fb3e5b7c6804d50021a62d32bf3b Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 24 Oct 2024 15:11:58 +0200 Subject: [PATCH 3/3] perf: refs #8036 currentFilter --- src/composables/useArrayData.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 6b1d183f2..4e0cad9c9 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -87,10 +87,12 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { Object.assign(params, userParams); params.filter.skip = store.skip; - if (store.order && store.order.length) params.filter.order = store.order; + if (store?.order && typeof store?.order == 'string') store.order = [store.order]; + if (store.order && store.order.length) params.filter.order = [...store.order]; else delete params.filter.order; store.currentFilter = JSON.parse(JSON.stringify(params)); + delete store.currentFilter.filter.include; store.currentFilter.filter = JSON.stringify(store.currentFilter.filter); let exprFilter; -- 2.40.1