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: '' },
|
searchbarInfo: { type: String, default: '' },
|
||||||
searchCustomRouteRedirect: { type: String, default: undefined },
|
searchCustomRouteRedirect: { type: String, default: undefined },
|
||||||
searchRedirect: { type: Boolean, default: false },
|
searchRedirect: { type: Boolean, default: false },
|
||||||
|
searchMakeFetch: { type: Boolean, default: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
@ -66,6 +67,7 @@ watchEffect(() => {
|
||||||
:info="props.searchbarInfo"
|
:info="props.searchbarInfo"
|
||||||
:custom-route-redirect-name="searchCustomRouteRedirect"
|
:custom-route-redirect-name="searchCustomRouteRedirect"
|
||||||
:redirect="searchRedirect"
|
:redirect="searchRedirect"
|
||||||
|
:make-fetch="props.searchMakeFetch"
|
||||||
/>
|
/>
|
||||||
</slot>
|
</slot>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
|
|
|
@ -65,6 +65,10 @@ const props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
makeFetch: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let arrayData = useArrayData(props.dataKey, { ...props });
|
let arrayData = useArrayData(props.dataKey, { ...props });
|
||||||
|
@ -92,12 +96,14 @@ async function search() {
|
||||||
([key, value]) => value && (props.staticParams || []).includes(key)
|
([key, value]) => value && (props.staticParams || []).includes(key)
|
||||||
);
|
);
|
||||||
store.skip = 0;
|
store.skip = 0;
|
||||||
await arrayData.applyFilter({
|
|
||||||
params: {
|
if (props.makeFetch)
|
||||||
...Object.fromEntries(staticParams),
|
await arrayData.applyFilter({
|
||||||
search: searchText.value,
|
params: {
|
||||||
},
|
...Object.fromEntries(staticParams),
|
||||||
});
|
search: searchText.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!props.redirect) return;
|
if (!props.redirect) return;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ const customRouteRedirectName = computed(() => {
|
||||||
if (routeName.value === 'ZoneLocations') return null;
|
if (routeName.value === 'ZoneLocations') return null;
|
||||||
return routeName.value;
|
return routeName.value;
|
||||||
});
|
});
|
||||||
|
const searchbarMakeFetch = computed(() => routeName.value !== 'ZoneEvents');
|
||||||
const searchBarDataKeys = {
|
const searchBarDataKeys = {
|
||||||
ZoneWarehouses: 'ZoneWarehouses',
|
ZoneWarehouses: 'ZoneWarehouses',
|
||||||
ZoneSummary: 'ZoneSummary',
|
ZoneSummary: 'ZoneSummary',
|
||||||
|
@ -28,6 +29,7 @@ const searchBarDataKeys = {
|
||||||
:search-data-key="searchBarDataKeys[routeName]"
|
:search-data-key="searchBarDataKeys[routeName]"
|
||||||
:search-custom-route-redirect="customRouteRedirectName"
|
:search-custom-route-redirect="customRouteRedirectName"
|
||||||
:search-redirect="!!customRouteRedirectName"
|
:search-redirect="!!customRouteRedirectName"
|
||||||
|
:search-make-fetch="searchbarMakeFetch"
|
||||||
:searchbar-label="t('list.searchZone')"
|
:searchbar-label="t('list.searchZone')"
|
||||||
:searchbar-info="t('list.searchInfo')"
|
:searchbar-info="t('list.searchInfo')"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -68,6 +68,7 @@ const startParamsWatcher = () => {
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
|
if (!params.value.zoneFk || !params.value.started || !params.value.ended) return;
|
||||||
await arrayData.applyFilter({
|
await arrayData.applyFilter({
|
||||||
params: params.value,
|
params: params.value,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue