diff --git a/src/components/CreateThermographForm.vue b/src/components/CreateThermographForm.vue index 0b7e4c5c6..54844ee8f 100644 --- a/src/components/CreateThermographForm.vue +++ b/src/components/CreateThermographForm.vue @@ -38,7 +38,7 @@ const onDataSaved = (dataSaved) => { @on-fetch="(data) => (warehousesOptions = data)" auto-load url="Warehouses" - :filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }" + :filter="{ fields: ['id', 'name'], order: 'name ASC' }" /> { }); watch(modelValue, async (newValue) => { - if (!myOptions.value.some((option) => option[optionValue.value] == newValue)) + if (!myOptions?.value?.some((option) => option[optionValue.value] == newValue)) await fetchFilter(newValue); if ($props.noOne) myOptions.value.unshift(noOneOpt.value); @@ -138,6 +140,7 @@ function findKeyInOptions() { } function setOptions(data) { + data = dataByOrder(data, $props.sortBy); myOptions.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); emit('update:options', data); diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 43d634ad9..a8aca49dd 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,29 @@ 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) + ); + return formatTags(filteredTags); }); + const customTags = computed(() => tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label)) ); @@ -193,13 +212,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 });