From f52f5df78bfceef92f8a7cdc46bfb58ae6c9e8b7 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Sun, 26 May 2024 19:35:12 -0300 Subject: [PATCH] Make searchbar work --- src/components/common/VnCard.vue | 2 ++ src/components/ui/VnSearchbar.vue | 18 ++++++++++++------ src/pages/Zone/Card/ZoneCard.vue | 2 ++ src/pages/Zone/Card/ZoneEventsPanel.vue | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index e836badec..929c24c58 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -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" /> diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index e5b2f02d2..34fc880d2 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -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; diff --git a/src/pages/Zone/Card/ZoneCard.vue b/src/pages/Zone/Card/ZoneCard.vue index fc427c8cd..1cbc01dd7 100644 --- a/src/pages/Zone/Card/ZoneCard.vue +++ b/src/pages/Zone/Card/ZoneCard.vue @@ -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')" /> diff --git a/src/pages/Zone/Card/ZoneEventsPanel.vue b/src/pages/Zone/Card/ZoneEventsPanel.vue index 5f282c968..1ec82c54c 100644 --- a/src/pages/Zone/Card/ZoneEventsPanel.vue +++ b/src/pages/Zone/Card/ZoneEventsPanel.vue @@ -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, });