0
0
Fork 0

feat: solve ItemFixedFilterPanel

This commit is contained in:
Javier Segarra 2024-07-04 22:57:24 +02:00
parent ff80a768d7
commit 3a7050d6c4
2 changed files with 9 additions and 5 deletions

View File

@ -110,6 +110,7 @@ async function search(evt) {
store.filter.where = {}; store.filter.where = {};
isLoading.value = true; isLoading.value = true;
if (evt?.param) Object.assign(userParams.value, evt.param);
const filter = { ...userParams.value }; const filter = { ...userParams.value };
store.userParamsChanged = true; store.userParamsChanged = true;
arrayData.reset(['skip', 'filter.skip', 'page']); arrayData.reset(['skip', 'filter.skip', 'page']);

View File

@ -24,12 +24,16 @@ const route = useRoute();
const itemTypeWorkersOptions = ref([]); const itemTypeWorkersOptions = ref([]);
const sanitizeParam = (param) => { const sanitizeParam = (param) => {
return JSON.parse(route.query.params)[param] ? 'true' : 'false'; const params = JSON.parse(route.query.params);
return params[param] ?? 'false';
}; };
const $params = ref({}); const $params = ref({});
onMounted(() => { onMounted(() => {
['mine', 'hasMinPrice'].forEach((tag) => ($params.value[tag] = sanitizeParam(tag))); ['mine', 'hasMinPrice'].forEach((tag) => ($params.value[tag] = sanitizeParam(tag)));
}); });
const pushParam = (param) => ({
param: { [param]: $params.value[param] },
});
</script> </script>
<template> <template>
@ -42,6 +46,7 @@ onMounted(() => {
/> />
<ItemsFilterPanel :data-key="dataKey" :custom-tags="['tags']"> <ItemsFilterPanel :data-key="dataKey" :custom-tags="['tags']">
<template #body="{ params, searchFn }"> <template #body="{ params, searchFn }">
{{ $params }}
{{ JSON.parse(route.query.params).mine }} {{ JSON.parse(route.query.params).mine }}
<QItem class="q-my-md"> <QItem class="q-my-md">
<QItemSection> <QItemSection>
@ -102,8 +107,7 @@ onMounted(() => {
v-model="$params.mine" v-model="$params.mine"
:true-value="'true'" :true-value="'true'"
:false-value="'false'" :false-value="'false'"
toggle-indeterminate="true" @update:model-value="searchFn(pushParam('mine'))"
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
<QItemSection> <QItemSection>
@ -112,8 +116,7 @@ onMounted(() => {
v-model="$params.hasMinPrice" v-model="$params.hasMinPrice"
:true-value="'true'" :true-value="'true'"
:false-value="'false'" :false-value="'false'"
toggle-indeterminate @update:model-value="searchFn(pushParam('hasMinPrice'))"
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>