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 });