From 9956561e4c907a39d7199646c05dc4e34555bf58 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 24 Jun 2024 16:17:21 +0200 Subject: [PATCH 1/5] chore: refs #7300 wip: create reset function --- src/composables/useArrayData.js | 5 ++++ src/stores/useArrayDataStore.js | 41 +++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index f97ade7bf..385cb6045 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -130,6 +130,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { delete store[option]; } + function reset(opts = []) { + if (arrayDataStore.get(key)) arrayDataStore.reset(key, opts); + } + function cancelRequest() { if (canceller) { canceller.abort(); @@ -245,5 +249,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { updateStateParams, isLoading, deleteOption, + reset, }; } diff --git a/src/stores/useArrayDataStore.js b/src/stores/useArrayDataStore.js index ebe32f8d0..0fe16d075 100644 --- a/src/stores/useArrayDataStore.js +++ b/src/stores/useArrayDataStore.js @@ -3,36 +3,47 @@ import { defineStore } from 'pinia'; export const useArrayDataStore = defineStore('arrayDataStore', () => { const state = ref({}); + const defaultOpts = { + filter: {}, + userFilter: {}, + userParams: {}, + url: '', + limit: 10, + skip: 0, + order: '', + data: ref(), + isLoading: false, + userParamsChanged: false, + exprBuilder: null, + searchUrl: 'params', + navigate: null, + }; function get(key) { return state.value[key]; } function set(key) { - state.value[key] = { - filter: {}, - userFilter: {}, - userParams: {}, - url: '', - limit: 10, - skip: 0, - order: '', - data: ref(), - isLoading: false, - userParamsChanged: false, - exprBuilder: null, - searchUrl: 'params', - navigate: null, - }; + state.value[key] = defaultOpts; } function clear(key) { delete state.value[key]; } + function reset(key, opts = []) { + let obj = state.value[key]; + if (!opts.length) obj = defaultOpts; + else + for (const opt in opts) { + if (Object.hasOwn(obj, opt)) obj[opt] = defaultOpts[opt]; + } + } + return { get, set, clear, + reset, }; }); From d0038d7e61a0b001664b7ae2cb5506f629dbb55a Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 27 Jun 2024 10:45:37 +0200 Subject: [PATCH 2/5] fix: refs #6943 removes duplicate toggle menu & fix loading animation --- src/pages/Customer/Card/CustomerGreuges.vue | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/pages/Customer/Card/CustomerGreuges.vue b/src/pages/Customer/Card/CustomerGreuges.vue index 0dcb3a3a9..eb35a8bdf 100644 --- a/src/pages/Customer/Card/CustomerGreuges.vue +++ b/src/pages/Customer/Card/CustomerGreuges.vue @@ -108,26 +108,9 @@ const setRows = (data) => {