From a6f970cec8e0f7fffe15ee31b2ce09a4a4bc9ff4 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 10 Dec 2024 14:06:34 +0100 Subject: [PATCH 1/5] fix: fixed filter when searching by id --- src/components/ui/VnSearchbar.vue | 11 ++++++----- src/pages/Ticket/Card/TicketCard.vue | 7 +++++++ src/pages/Ticket/TicketList.vue | 9 +++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index da2d370fe..cabc6ff18 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -51,10 +51,6 @@ const props = defineProps({ type: Object, default: null, }, - staticParams: { - type: Array, - default: () => [], - }, exprBuilder: { type: Function, default: null, @@ -67,6 +63,10 @@ const props = defineProps({ type: Function, default: undefined, }, + beforeSearch: { + type: Function, + default: undefined, + }, }); const searchText = ref(); @@ -103,7 +103,7 @@ async function search() { const staticParams = Object.entries(store.userParams); arrayData.reset(['skip', 'page']); - const filter = { + let filter = { params: { ...Object.fromEntries(staticParams), search: searchText.value, @@ -117,6 +117,7 @@ async function search() { }; delete filter.params.search; } + if (props.beforeSearch) filter = props.beforeSearch(filter); await arrayData.applyFilter(filter); } diff --git a/src/pages/Ticket/Card/TicketCard.vue b/src/pages/Ticket/Card/TicketCard.vue index 73b6f5543..8832cb8b0 100644 --- a/src/pages/Ticket/Card/TicketCard.vue +++ b/src/pages/Ticket/Card/TicketCard.vue @@ -18,6 +18,13 @@ const { t } = useI18n(); url: 'Tickets/filter', label: t('card.search'), info: t('card.searchInfo'), + beforeSearch: (filter) => { + if (filter.params.search) { + delete filter.params.from; + delete filter.params.to; + } + return filter; + }, }" /> diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue index 6f6c556ca..c06dcfa39 100644 --- a/src/pages/Ticket/TicketList.vue +++ b/src/pages/Ticket/TicketList.vue @@ -455,6 +455,15 @@ function setReference(data) { data-key="TicketList" :label="t('Search ticket')" :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; + } + " /> diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue index 9fbdea3aa..eb03a4927 100644 --- a/src/pages/Ticket/TicketList.vue +++ b/src/pages/Ticket/TicketList.vue @@ -1,6 +1,6 @@