0
0
Fork 0

Make searchbar work

This commit is contained in:
William Buezas 2024-05-26 19:35:12 -03:00
parent dbcd701725
commit f52f5df78b
4 changed files with 17 additions and 6 deletions

View File

@ -22,6 +22,7 @@ const props = defineProps({
searchbarInfo: { type: String, default: '' },
searchCustomRouteRedirect: { type: String, default: undefined },
searchRedirect: { type: Boolean, default: false },
searchMakeFetch: { type: Boolean, default: true },
});
const stateStore = useStateStore();
@ -66,6 +67,7 @@ watchEffect(() => {
:info="props.searchbarInfo"
:custom-route-redirect-name="searchCustomRouteRedirect"
:redirect="searchRedirect"
:make-fetch="props.searchMakeFetch"
/>
</slot>
</Teleport>

View File

@ -65,6 +65,10 @@ const props = defineProps({
type: String,
default: '',
},
makeFetch: {
type: Boolean,
default: true,
},
});
let arrayData = useArrayData(props.dataKey, { ...props });
@ -92,12 +96,14 @@ async function search() {
([key, value]) => value && (props.staticParams || []).includes(key)
);
store.skip = 0;
await arrayData.applyFilter({
params: {
...Object.fromEntries(staticParams),
search: searchText.value,
},
});
if (props.makeFetch)
await arrayData.applyFilter({
params: {
...Object.fromEntries(staticParams),
search: searchText.value,
},
});
if (!props.redirect) return;

View File

@ -14,6 +14,7 @@ const customRouteRedirectName = computed(() => {
if (routeName.value === 'ZoneLocations') return null;
return routeName.value;
});
const searchbarMakeFetch = computed(() => routeName.value !== 'ZoneEvents');
const searchBarDataKeys = {
ZoneWarehouses: 'ZoneWarehouses',
ZoneSummary: 'ZoneSummary',
@ -28,6 +29,7 @@ const searchBarDataKeys = {
:search-data-key="searchBarDataKeys[routeName]"
:search-custom-route-redirect="customRouteRedirectName"
:search-redirect="!!customRouteRedirectName"
:search-make-fetch="searchbarMakeFetch"
:searchbar-label="t('list.searchZone')"
:searchbar-info="t('list.searchInfo')"
/>

View File

@ -68,6 +68,7 @@ const startParamsWatcher = () => {
const fetchData = async () => {
try {
if (!params.value.zoneFk || !params.value.started || !params.value.ended) return;
await arrayData.applyFilter({
params: params.value,
});