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; isLoading.value = true;
await arrayData.addFilter({ params }); 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; isLoading.value = false;
} }
@ -59,7 +61,8 @@ async function reload() {
isLoading.value = true; isLoading.value = true;
await arrayData.fetch({ append: false }); 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; isLoading.value = false;
emit('refresh'); emit('refresh');
} }

View File

@ -50,10 +50,6 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
showAll: {
type: Boolean,
default: true,
},
}); });
const emit = defineEmits(['onFetch', 'onPaginate']); const emit = defineEmits(['onFetch', 'onPaginate']);
@ -76,12 +72,7 @@ const arrayData = useArrayData(props.dataKey, {
const store = arrayData.store; const store = arrayData.store;
onMounted(() => { onMounted(() => {
if (props.autoLoad) { if (props.autoLoad) fetch();
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 = [];
}
}); });
watch( watch(

View File

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

View File

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

View File

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