diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index cd5a3caf1..94b64c0db 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -78,11 +78,23 @@ watch( ); const isLoading = ref(false); +function eliminarPropiedadesNull(objeto) { + for (let clave in objeto) { + if (objeto[clave] === null) { + delete objeto[clave]; + } + } + return objeto; +} + async function search() { isLoading.value = true; + const objetoSinNull = eliminarPropiedadesNull(userParams.value); + userParams.value = objetoSinNull; const params = { ...userParams.value }; if (Object.entries(params).length > 0) store.exprBuilder = props.exprBuilder; - + else delete store.filter.where; + store.userParams = userParams.value; store.userParamsChanged = true; store.filter.skip = 0; store.skip = 0; @@ -146,25 +158,26 @@ 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(''); -}); +// 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; - delete userParams.value[key]; - if (Object.entries(userParams.value).length === 0) { - store.exprBuilder = null; - delete store.filter.where; - } else { - store.exprBuilder = props.exprBuilder; - } + if (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/Item/ItemTypeList.vue b/src/pages/Item/ItemTypeList.vue index 1e21c1719..6e31cdd25 100644 --- a/src/pages/Item/ItemTypeList.vue +++ b/src/pages/Item/ItemTypeList.vue @@ -24,17 +24,10 @@ const redirectToItemTypeSummary = (id) => { const redirectToCreateView = () => { router.push({ name: 'ItemTypeCreate' }); }; -const exprBuilder = (param, value) => { - switch (param) { - case 'name': - case 'code': - case 'search': - return { - name: { like: `%${value}%` }, - code: { like: `%${value}%` }, - }; - } -}; +const exprBuilder = (param, value) => ({ + name: { like: `%${value}%` }, + code: { like: `%${value}%` }, +});