From 211da859bd20cdab9a041bc821ea60b7fb073ae2 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Fri, 25 Oct 2024 08:57:16 -0300 Subject: [PATCH 1/9] fix: catalog view category and type filter --- src/components/ui/VnFilterPanel.vue | 33 +++++++++++++++++-- src/filters/getParamWhere.js | 12 +++++-- src/pages/Order/Card/OrderCatalog.vue | 35 +++++++++++++++++---- src/pages/Order/Card/OrderCatalogFilter.vue | 26 +++++++++++---- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 43d634ad9..5bdaf150c 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -57,7 +57,6 @@ const $props = defineProps({ }, }); -defineExpose({ search, sanitizer }); const emit = defineEmits([ 'update:modelValue', 'refresh', @@ -170,9 +169,30 @@ const tagsList = computed(() => { return tagList; }); +const formatTags = (tags) => { + const formattedTags = []; + tags.forEach((tag) => { + if (tag.label === 'and') { + tag.value.forEach((item) => { + for (const key in item) { + formattedTags.push({ label: key, value: item[key] }); + } + }); + } else { + formattedTags.push(tag); + } + }); + return formattedTags; +}; + const tags = computed(() => { - return tagsList.value.filter((tag) => !($props.customTags || []).includes(tag.label)); + const filteredTags = tagsList.value.filter( + (tag) => !($props.customTags || []).includes(tag.label) + ); + console.log('formatTags: ', formatTags(filteredTags)); + return formatTags(filteredTags); }); + const customTags = computed(() => tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label)) ); @@ -193,13 +213,20 @@ function formatValue(value) { function sanitizer(params) { for (const [key, value] of Object.entries(params)) { - if (value && typeof value === 'object') { + if (key === 'and' && Array.isArray(value)) { + value.forEach((item) => { + Object.assign(params, item); + }); + delete params[key]; + } else if (value && typeof value === 'object') { const param = Object.values(value)[0]; if (typeof param == 'string') params[key] = param.replaceAll('%', ''); } } return params; } + +defineExpose({ search, sanitizer, userParams }); - - - From 8bff7fc1d617bf1e5d2c06115248232fe673cd4c Mon Sep 17 00:00:00 2001 From: wbuezas Date: Thu, 7 Nov 2024 21:09:39 -0300 Subject: [PATCH 6/9] fix: reset category --- src/pages/Order/Card/OrderCatalogFilter.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue index 27023262e..532c79322 100644 --- a/src/pages/Order/Card/OrderCatalogFilter.vue +++ b/src/pages/Order/Card/OrderCatalogFilter.vue @@ -10,10 +10,8 @@ import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue'; import VnInput from 'src/components/common/VnInput.vue'; import getParamWhere from 'src/filters/getParamWhere'; import CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue'; +import { useArrayData } from 'composables/useArrayData'; -const { t } = useI18n(); - -const route = useRoute(); const props = defineProps({ dataKey: { type: String, @@ -29,6 +27,11 @@ const props = defineProps({ }, }); +const { t } = useI18n(); +const route = useRoute(); + +const arrayData = useArrayData(props.dataKey); + const categoryList = ref(null); const selectedCategoryFk = ref(null); const typeList = ref([]); @@ -54,7 +57,8 @@ const resetCategory = (params, search) => { typeList.value = null; params.categoryFk = null; params.typeFk = null; - search(); + arrayData.store.userFilter = null; + removeTagGroupParam(params, search); }; const selectCategory = (params, category, search) => { From 3825dc385134071cea196a2f640bbd43609b1eee Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 8 Nov 2024 11:54:04 +0100 Subject: [PATCH 7/9] feat: disabled buttons --- .../Order/Card/CatalogFilterValueDialog.vue | 43 ++++++++++++------- src/pages/Order/Card/OrderCatalogFilter.vue | 13 ++++-- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/pages/Order/Card/CatalogFilterValueDialog.vue b/src/pages/Order/Card/CatalogFilterValueDialog.vue index ada0c2889..28e235f6a 100644 --- a/src/pages/Order/Card/CatalogFilterValueDialog.vue +++ b/src/pages/Order/Card/CatalogFilterValueDialog.vue @@ -63,6 +63,15 @@ const getSelectedTagValues = async (tag) => { diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue index 532c79322..f684db03e 100644 --- a/src/pages/Order/Card/OrderCatalogFilter.vue +++ b/src/pages/Order/Card/OrderCatalogFilter.vue @@ -35,6 +35,7 @@ const arrayData = useArrayData(props.dataKey); const categoryList = ref(null); const selectedCategoryFk = ref(null); const typeList = ref([]); +const tagsValues = ref([]); const selectedTypeFk = ref(null); const generalSearchParam = ref(null); @@ -289,9 +290,12 @@ onMounted(() => { - -