From 0d50944c2d9b79da840deac5621e70dc1b64d29a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 26 Apr 2024 15:24:44 +0200 Subject: [PATCH] fix: add exprBuilder --- src/components/ui/VnFilterPanel.vue | 20 +++++++++++++++++++- src/pages/ItemType/ItemTypeFilter.vue | 14 ++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index cde48e9b3..cd5a3caf1 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -81,6 +81,8 @@ const isLoading = ref(false); async function search() { isLoading.value = true; const params = { ...userParams.value }; + if (Object.entries(params).length > 0) store.exprBuilder = props.exprBuilder; + store.userParamsChanged = true; store.filter.skip = 0; store.skip = 0; @@ -144,9 +146,25 @@ const customTags = computed(() => tagsList.value.filter((tag) => (props.customTags || []).includes(tag.label)) ); +watch(tags, (now, before) => { + if (now.length < before.length) { + const beforeMap = before.map(({ label }) => label); + const nowMap = now.map(({ label }) => label); + const key = beforeMap.filter((elemento) => !nowMap.includes(elemento))[0]; + remove(key ?? beforeMap[0]); + } + console.error(''); +}); + async function remove(key) { // userParams.value[key] = null; - if (userParams.value[key]) delete userParams.value[key]; + delete userParams.value[key]; + if (Object.entries(userParams.value).length === 0) { + store.exprBuilder = null; + delete store.filter.where; + } else { + store.exprBuilder = props.exprBuilder; + } await search(); emit('remove', key); } diff --git a/src/pages/ItemType/ItemTypeFilter.vue b/src/pages/ItemType/ItemTypeFilter.vue index 2a86795c2..176fca22a 100644 --- a/src/pages/ItemType/ItemTypeFilter.vue +++ b/src/pages/ItemType/ItemTypeFilter.vue @@ -29,12 +29,22 @@ const emit = defineEmits(['search']);