feat: added logic to avoid other filter params when searching on vnsearchbar
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
2cdc8916cc
commit
c61ad16681
|
@ -63,10 +63,6 @@ const props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
},
|
},
|
||||||
beforeSearch: {
|
|
||||||
type: Function,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const searchText = ref();
|
const searchText = ref();
|
||||||
|
@ -102,12 +98,16 @@ onMounted(() => {
|
||||||
async function search() {
|
async function search() {
|
||||||
const staticParams = Object.entries(store.userParams);
|
const staticParams = Object.entries(store.userParams);
|
||||||
arrayData.reset(['skip', 'page']);
|
arrayData.reset(['skip', 'page']);
|
||||||
|
|
||||||
let filter = {
|
let filter = {
|
||||||
params: {
|
params: {
|
||||||
...Object.fromEntries(staticParams),
|
|
||||||
search: searchText.value,
|
search: searchText.value,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
if (!(searchText.value && searchText.value !== '')) {
|
||||||
|
filter = {
|
||||||
|
params: {
|
||||||
|
...Object.fromEntries(staticParams),
|
||||||
|
},
|
||||||
...{ filter: props.filter },
|
...{ filter: props.filter },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +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>
|
||||||
|
|
|
@ -18,13 +18,6 @@ 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>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { computed, ref, onMounted } from 'vue';
|
import { computed, ref, onBeforeMount } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
@ -46,7 +46,7 @@ const userParams = {
|
||||||
from: null,
|
from: null,
|
||||||
to: null,
|
to: null,
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onBeforeMount(() => {
|
||||||
initializeFromQuery();
|
initializeFromQuery();
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
if (!route.query.createForm) return;
|
if (!route.query.createForm) return;
|
||||||
|
@ -457,15 +457,6 @@ function setReference(data) {
|
||||||
: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')"
|
||||||
data-cy="ticketListSearchBar"
|
data-cy="ticketListSearchBar"
|
||||||
: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>
|
||||||
|
|
Loading…
Reference in New Issue