fix: fixed filter when searching by id
gitea/salix-front/pipeline/pr-master There was a failure building this commit Details

This commit is contained in:
Jon Elias 2024-12-10 14:06:34 +01:00
parent 0198a25972
commit a6f970cec8
3 changed files with 22 additions and 5 deletions

View File

@ -51,10 +51,6 @@ const props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
staticParams: {
type: Array,
default: () => [],
},
exprBuilder: { exprBuilder: {
type: Function, type: Function,
default: null, default: null,
@ -67,6 +63,10 @@ const props = defineProps({
type: Function, type: Function,
default: undefined, default: undefined,
}, },
beforeSearch: {
type: Function,
default: undefined,
},
}); });
const searchText = ref(); const searchText = ref();
@ -103,7 +103,7 @@ async function search() {
const staticParams = Object.entries(store.userParams); const staticParams = Object.entries(store.userParams);
arrayData.reset(['skip', 'page']); arrayData.reset(['skip', 'page']);
const filter = { let filter = {
params: { params: {
...Object.fromEntries(staticParams), ...Object.fromEntries(staticParams),
search: searchText.value, search: searchText.value,
@ -117,6 +117,7 @@ async function search() {
}; };
delete filter.params.search; delete filter.params.search;
} }
if (props.beforeSearch) filter = props.beforeSearch(filter);
await arrayData.applyFilter(filter); await arrayData.applyFilter(filter);
} }
</script> </script>

View File

@ -18,6 +18,13 @@ const { t } = useI18n();
url: 'Tickets/filter', url: 'Tickets/filter',
label: t('card.search'), label: t('card.search'),
info: t('card.searchInfo'), info: t('card.searchInfo'),
beforeSearch: (filter) => {
if (filter.params.search) {
delete filter.params.from;
delete filter.params.to;
}
return filter;
},
}" }"
/> />
</template> </template>

View File

@ -455,6 +455,15 @@ function setReference(data) {
data-key="TicketList" data-key="TicketList"
:label="t('Search ticket')" :label="t('Search ticket')"
:info="t('You can search by ticket id or alias')" :info="t('You can search by ticket id or alias')"
:before-search="
(filter) => {
if (filter.params.search) {
delete filter.params.from;
delete filter.params.to;
}
return filter;
}
"
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>