7729-devToTest_2430 #554

Merged
alexm merged 401 commits from 7729-devToTest_2430 into test 2024-07-16 07:17:04 +00:00
2 changed files with 31 additions and 15 deletions
Showing only changes of commit 9956561e4c - Show all commits

View File

@ -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,
};
}

View File

@ -3,13 +3,7 @@ import { defineStore } from 'pinia';
export const useArrayDataStore = defineStore('arrayDataStore', () => {
const state = ref({});
function get(key) {
return state.value[key];
}
function set(key) {
state.value[key] = {
const defaultOpts = {
filter: {},
userFilter: {},
userParams: {},
@ -24,15 +18,32 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
searchUrl: 'params',
navigate: null,
};
function get(key) {
return state.value[key];
}
function set(key) {
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,
};
});