Compare commits

...

9 Commits

Author SHA1 Message Date
Jorge Penadés 79d6f133a1 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6919-syncData
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2024-11-19 11:23:33 +01:00
Alex Moreno 19cb781800 Merge pull request '#8036 - arrayData_exprBuilder_after' (!845) from 8036-arrayData_exprBuilder_after into dev
gitea/salix-front/pipeline/head This commit looks good Details
Reviewed-on: #845
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
2024-11-19 09:03:49 +00:00
Alex Moreno 88d2384c35 Merge branch 'dev' of https: refs #8036//gitea.verdnatura.es/verdnatura/salix-front into 8036-arrayData_exprBuilder_after
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2024-11-19 10:00:20 +01:00
Alex Moreno 6f1e6a3bfa Merge branch 'dev' into 8036-arrayData_exprBuilder_after
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2024-11-13 06:22:52 +00:00
Alex Moreno 1e04ead780 perf: refs #8036 currentFilter
gitea/salix-front/pipeline/pr-test Build started... Details
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2024-10-24 15:11:58 +02:00
Alex Moreno e739f42ddf Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8036-arrayData_exprBuilder_after 2024-10-24 14:46:00 +02:00
Alex Moreno 99549c6787 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8036-arrayData_exprBuilder_after
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2024-10-24 07:58:00 +02:00
Alex Moreno bfc906a346 fix: refs #8036 only add where when required
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2024-10-18 13:48:10 +02:00
Alex Moreno 8381a25017 fix: refs #8036 apply exprBuilder after save filters 2024-10-18 13:46:34 +02:00
2 changed files with 22 additions and 14 deletions

View File

@ -37,7 +37,7 @@ const $props = defineProps({
},
hiddenTags: {
type: Array,
default: () => ['filter', 'search', 'or', 'and'],
default: () => ['filter', 'or', 'and'],
},
customTags: {
type: Array,
@ -61,7 +61,6 @@ const emit = defineEmits([
'update:modelValue',
'refresh',
'clear',
'search',
'init',
'remove',
'setUserParams',

View File

@ -75,18 +75,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 ?? {});
@ -96,11 +88,28 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
Object.assign(params, userParams);
params.filter.skip = store.skip;
if (store.order?.length) params.filter.order = store.order;
if (store?.order && typeof store?.order == 'string') store.order = [store.order];
if (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;
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;
});
}
if (params.filter.where || exprFilter)
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,