Hotfix: fixed filter when searching by id #1063

Merged
jon merged 6 commits from Hotfix-TicketFilter into master 2024-12-11 13:35:56 +00:00
3 changed files with 15 additions and 31 deletions
Showing only changes of commit c61ad16681 - Show all commits

View File

@ -63,10 +63,6 @@ const props = defineProps({
type: Function,
default: undefined,
},
beforeSearch: {
type: Function,
default: undefined,
},
});
const searchText = ref();
@ -102,22 +98,26 @@ onMounted(() => {
async function search() {
const staticParams = Object.entries(store.userParams);
arrayData.reset(['skip', 'page']);
let filter = {
params: {
...Object.fromEntries(staticParams),
search: searchText.value,
},
...{ filter: props.filter },
};
if (props.whereFilter) {
filter.filter = {
where: props.whereFilter(searchText.value),
if (!(searchText.value && searchText.value !== '')) {
Outdated
Review

if (!searchText.value)

if (!searchText.value)
filter = {
params: {
...Object.fromEntries(staticParams),
},
...{ filter: props.filter },
};
delete filter.params.search;
if (props.whereFilter) {
filter.filter = {
where: props.whereFilter(searchText.value),
};
delete filter.params.search;
}
}
if (props.beforeSearch) filter = props.beforeSearch(filter);
await arrayData.applyFilter(filter);
}
</script>

View File

@ -18,13 +18,6 @@ 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;
},
}"
/>
</template>

View File

@ -1,6 +1,6 @@
<script setup>
import axios from 'axios';
import { computed, ref, onMounted } from 'vue';
import { computed, ref, onBeforeMount } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
@ -46,7 +46,7 @@ const userParams = {
from: null,
to: null,
};
onMounted(() => {
onBeforeMount(() => {
initializeFromQuery();
stateStore.rightDrawer = true;
if (!route.query.createForm) return;
@ -457,15 +457,6 @@ function setReference(data) {
:label="t('Search ticket')"
:info="t('You can search by ticket id or alias')"
data-cy="ticketListSearchBar"
:before-search="
(filter) => {
if (filter.params.search) {
delete filter.params.from;
delete filter.params.to;
}
return filter;
}
"
/>
<RightMenu>
<template #right-panel>