Item types #319

Merged
jsegarra merged 28 commits from :feature/ItemFamily into dev 2024-05-02 07:39:59 +00:00
3 changed files with 36 additions and 40 deletions
Showing only changes of commit a03049a721 - Show all commits

View File

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

View File

@ -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) => ({
Outdated
Review

En Salix no esta así.
Pero en todo caso seria con un OR.

En Salix no esta así. Pero en todo caso seria con un OR.

exprBuilder corregido.

Commit: 6276c433d1

exprBuilder corregido. Commit: https://gitea.verdnatura.es/verdnatura/salix-front/commit/6276c433d13b9afea9e3e2726bd0dda469bdc14e
name: { like: `%${value}%` },
code: { like: `%${value}%` },
});
</script>
<template>

View File

@ -29,22 +29,12 @@ const emit = defineEmits(['search']);
<template #body="{ params }">
<QItem>
<QItemSection>
<VnInput
@update:model-value="emit('search')"
:label="t('Name')"
v-model="params.name"
is-outlined
/>
<VnInput :label="t('Name')" v-model="params.name" is-outlined />
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInput
@update:model-value="emit('search')"
v-model="params.code"
:label="t('Code')"
is-outlined
/>
<VnInput v-model="params.code" :label="t('Code')" is-outlined />
</QItemSection>
</QItem>
</template>