fix(VnFilterPanel): emit userParams better
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-08-09 11:40:05 +02:00
parent 2dd8376bcd
commit 43ca7e1667
3 changed files with 13 additions and 7 deletions

View File

@ -41,6 +41,7 @@ async function orderBy(name, direction) {
break;
}
if (!direction) return await arrayData.deleteOrder(name);
console.log('name, direction: ', name, direction);
await arrayData.addOrder(name, direction);
}

View File

@ -154,7 +154,7 @@ watch(
const isTableMode = computed(() => mode.value == TABLE_MODE);
function setUserParams(watchedParams) {
function setUserParams(watchedParams, watchedOrder) {
if (!watchedParams) return;
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
@ -163,7 +163,7 @@ function setUserParams(watchedParams) {
? JSON.parse(watchedParams?.filter)
: watchedParams?.filter;
const where = filter?.where;
const order = filter?.order;
const order = watchedOrder ?? filter?.order;
watchedParams = { ...watchedParams, ...where };
delete watchedParams.filter;

View File

@ -82,23 +82,28 @@ onMounted(() => {
});
function setUserParams(watchedParams) {
if (!watchedParams) return;
if (!watchedParams || Object.keys(watchedParams).length == 0) return;
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
if (typeof watchedParams?.filter == 'string')
watchedParams.filter = JSON.parse(watchedParams.filter);
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
const order = watchedParams.filter?.order;
delete watchedParams.filter;
userParams.value = { ...userParams.value, ...watchedParams };
emit('setUserParams', userParams.value);
userParams.value = { ...userParams.value, ...sanitizer(watchedParams) };
emit('setUserParams', userParams.value, order);
}
watch(
() => route.query[$props.searchUrl],
(val) => setUserParams(val)
(val, oldValue) => (val || oldValue) && setUserParams(val)
);
watch(
() => arrayData.store.userParams,
(val) => setUserParams(val)
(val, oldValue) => (val || oldValue) && setUserParams(val)
);
watch(