From aec43cb1c5ab555d623300bbb072d4917b733384 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 4 Jul 2024 12:51:46 +0200 Subject: [PATCH] refactor: arrayData & VnCard refactor --- src/components/common/VnCard.vue | 2 +- src/composables/useArrayData.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index c81bcd8e2..17fa74317 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -39,7 +39,7 @@ const arrayData = useArrayData(props.dataKey, { onBeforeMount(async () => { if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id }; - await arrayData.fetch({ append: false }); + await arrayData.fetch({ append: false, updateRouter: false }); }); if (props.baseUrl) { diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index db59b7d78..8fda4b15d 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -84,8 +84,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } Object.assign(filter, store.userFilter, exprFilter); - Object.assign(store.filter, filter); - const params = { filter: store.filter }; + const where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {}); + Object.assign(filter, store.filter); + filter.where = where; + const params = { filter }; Object.assign(params, userParams); params.filter.skip = store.skip; @@ -143,7 +145,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } async function addFilter({ filter, params }) { - if (filter) store.userFilter = Object.assign(store.userFilter, filter); + if (filter) store.filter = filter; let userParams = { ...store.userParams, ...params }; userParams = sanitizerParams(userParams, store?.exprBuilder); @@ -157,7 +159,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { } async function addFilterWhere(where) { - const storedFilter = { ...store.userFilter }; + const storedFilter = { ...store.filter }; if (!storedFilter?.where) storedFilter.where = {}; where = { ...storedFilter.where, ...where }; await addFilter({ filter: { where } }); @@ -187,7 +189,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { store.page += 1; await fetch({ append: true }); - updateStateParams(); } async function refresh() {