forked from verdnatura/salix-front
Make searchbar work
This commit is contained in:
parent
dbcd701725
commit
f52f5df78b
|
@ -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>
|
||||
|
|
|
@ -65,6 +65,10 @@ const props = defineProps({
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
makeFetch: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
let arrayData = useArrayData(props.dataKey, { ...props });
|
||||
|
@ -92,6 +96,8 @@ async function search() {
|
|||
([key, value]) => value && (props.staticParams || []).includes(key)
|
||||
);
|
||||
store.skip = 0;
|
||||
|
||||
if (props.makeFetch)
|
||||
await arrayData.applyFilter({
|
||||
params: {
|
||||
...Object.fromEntries(staticParams),
|
||||
|
|
|
@ -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')"
|
||||
/>
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue