fix: add exprBuilder
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-04-26 14:49:54 +02:00
parent 127567898d
commit c1ed4ab032
4 changed files with 26 additions and 4 deletions

View File

@ -145,7 +145,8 @@ const customTags = computed(() =>
); );
async function remove(key) { async function remove(key) {
userParams.value[key] = null; // userParams.value[key] = null;
if (userParams.value[key]) delete userParams.value[key];
await search(); await search();
emit('remove', key); emit('remove', key);
} }

View File

@ -81,8 +81,10 @@ async function search() {
const staticParams = Object.entries(store.userParams).filter( const staticParams = Object.entries(store.userParams).filter(
([key, value]) => value && (props.staticParams || []).includes(key) ([key, value]) => value && (props.staticParams || []).includes(key)
); );
// const filter =props?.where? { where: JSON.parse(props.where) }: {}
await arrayData.applyFilter({ await arrayData.applyFilter({
params: { params: {
// filter ,
...Object.fromEntries(staticParams), ...Object.fromEntries(staticParams),
search: searchText.value, search: searchText.value,
}, },

View File

@ -24,6 +24,17 @@ const redirectToItemTypeSummary = (id) => {
const redirectToCreateView = () => { const redirectToCreateView = () => {
router.push({ name: 'ItemTypeCreate' }); router.push({ name: 'ItemTypeCreate' });
}; };
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
case 'code':
case 'search':
return {
name: { like: `%${value}%` },
code: { like: `%${value}%` },
};
}
};
</script> </script>
<template> <template>
@ -32,8 +43,10 @@ const redirectToCreateView = () => {
<VnSearchbar <VnSearchbar
data-key="ItemTypeList" data-key="ItemTypeList"
url="ItemTypes" url="ItemTypes"
:label="t('Search item type')" :label="t('Search item type')"
:redirect="false"
:info="t('Search itemType by id, name or code')" :info="t('Search itemType by id, name or code')"
:expr-builder="exprBuilder"
/> />
</Teleport> </Teleport>
<Teleport to="#actions-append"> <Teleport to="#actions-append">
@ -54,7 +67,7 @@ const redirectToCreateView = () => {
</template> </template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8"> <QScrollArea class="fit text-grey-8">
<ItemTypeFilter data-key="ItemTypes" /> <ItemTypeFilter data-key="ItemTypeList" :expr-builder="exprBuilder" />
</QScrollArea> </QScrollArea>
</QDrawer> </QDrawer>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">

View File

@ -10,10 +10,16 @@ const props = defineProps({
required: true, required: true,
}, },
}); });
const emit = defineEmits(['search']);
</script> </script>
<template> <template>
<VnFilterPanel :data-key="props.dataKey" :search-button="true"> <VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
@search="emit('search')"
>
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>