0
0
Fork 0

ref #5417 fix autoload and filters

This commit is contained in:
Jorge Penadés 2023-10-11 10:40:13 +02:00
parent 8d28a5f82c
commit 0aefe13935
5 changed files with 9 additions and 18 deletions

View File

@ -51,7 +51,9 @@ async function search() {
}
isLoading.value = true;
await arrayData.addFilter({ params });
if (!props.showAll && !Object.values(params).length) store.data = [];
if (!props.showAll && !Object.values(userParams.value).find((param) => param)) {
store.data = [];
}
isLoading.value = false;
}
@ -59,7 +61,8 @@ async function reload() {
isLoading.value = true;
await arrayData.fetch({ append: false });
if (!props.showAll && !Object.values(userParams.value).length) store.data = [];
if (!props.showAll && !Object.values(userParams.value).find((param) => param))
store.data = [];
isLoading.value = false;
emit('refresh');
}

View File

@ -50,10 +50,6 @@ const props = defineProps({
type: Boolean,
default: true,
},
showAll: {
type: Boolean,
default: true,
},
});
const emit = defineEmits(['onFetch', 'onPaginate']);
@ -76,12 +72,7 @@ const arrayData = useArrayData(props.dataKey, {
const store = arrayData.store;
onMounted(() => {
if (props.autoLoad) {
if (props.showAll) fetch();
else if (!props.showAll && Object.values(store.userParams).length) fetch();
else if (!props.showAll && !Object.values(store.userParams).length)
store.data = [];
}
if (props.autoLoad) fetch();
});
watch(

View File

@ -135,9 +135,8 @@ export function useArrayData(key, userOptions) {
await fetch({ append: true });
}
async function refresh(showAll = true) {
if (showAll || Object.values(store.userParams).length)
await fetch({ append: false });
async function refresh() {
if (Object.values(store.userParams).length) await fetch({ append: false });
}
function updateStateParams() {

View File

@ -144,8 +144,7 @@ function stateColor(row) {
order="created DESC"
:limit="20"
:offset="50"
auto-load
:show-all="false"
:auto-load="!!$route?.query.params"
>
<template #body="{ rows }">
<QTable

View File

@ -140,7 +140,6 @@ function isValidNumber(value) {
:label="t('globals.confirm')"
color="primary"
flat
@click="save"
v-close-popup
/>
</div>