Merge pull request '#6074 ArrayData.Skip filter bug' (!156) from 6704_fixArrayDataSkipFilter into dev
gitea/salix-front/pipeline/head There was a failure building this commit Details

Reviewed-on: #156
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Javier Segarra 2024-01-18 07:44:18 +00:00
commit cf6a26b742
7 changed files with 19 additions and 11 deletions

View File

@ -64,10 +64,12 @@ onMounted(() => {
}); });
const isLoading = ref(false); const isLoading = ref(false);
async function search() { async function search() {
isLoading.value = true; isLoading.value = true;
const params = { ...userParams.value }; const params = { ...userParams.value };
store.userParamsChanged = true;
store.filter.skip = 0;
store.skip = 0;
const { params: newParams } = await arrayData.addFilter({ params }); const { params: newParams } = await arrayData.addFilter({ params });
userParams.value = newParams; userParams.value = newParams;
@ -89,7 +91,9 @@ async function reload() {
async function clearFilters() { async function clearFilters() {
isLoading.value = true; isLoading.value = true;
store.userParamsChanged = true;
store.filter.skip = 0;
store.skip = 0;
// Filtrar los params no removibles // Filtrar los params no removibles
const removableFilters = Object.keys(userParams.value).filter((param) => const removableFilters = Object.keys(userParams.value).filter((param) =>
props.unremovableParams.includes(param) props.unremovableParams.includes(param)

View File

@ -104,6 +104,8 @@ async function paginate() {
await arrayData.loadMore(); await arrayData.loadMore();
if (!arrayData.hasMoreData.value) { if (!arrayData.hasMoreData.value) {
if (store.userParamsChanged) arrayData.hasMoreData.value = true;
store.userParamsChanged = false;
isLoading.value = false; isLoading.value = false;
return; return;
} }
@ -129,9 +131,9 @@ async function onLoad(...params) {
pagination.value.page = pagination.value.page + 1; pagination.value.page = pagination.value.page + 1;
await paginate(); await paginate();
let isDone = false;
const endOfPages = !arrayData.hasMoreData.value; if (store.userParamsChanged) isDone = !arrayData.hasMoreData.value;
done(endOfPages); done(isDone);
} }
</script> </script>
@ -172,7 +174,7 @@ async function onLoad(...params) {
v-if="store.data" v-if="store.data"
@load="onLoad" @load="onLoad"
:offset="offset" :offset="offset"
class="full-width full-height overflow-auto" class="full-width full-height"
> >
<slot name="body" :rows="store.data"></slot> <slot name="body" :rows="store.data"></slot>
<div v-if="isLoading" class="info-row q-pa-md text-center"> <div v-if="isLoading" class="info-row q-pa-md text-center">

View File

@ -142,7 +142,8 @@ export function useArrayData(key, userOptions) {
userParams = sanitizerParams(userParams, store?.exprBuilder); userParams = sanitizerParams(userParams, store?.exprBuilder);
store.userParams = userParams; store.userParams = userParams;
store.skip = 0;
store.filter.skip = 0;
await fetch({ append: false }); await fetch({ append: false });
return { filter, params }; return { filter, params };
} }

View File

@ -30,7 +30,7 @@ const body = {
</script> </script>
<template> <template>
<div class="column items-center"> <div class="column items-center">
<VnNotes <VnNotes style="overflow-y: scroll;"
:add-note="$props.addNote" :add-note="$props.addNote"
:id="id" :id="id"
url="claimObservations" url="claimObservations"

View File

@ -9,7 +9,7 @@ import VnInputDate from 'components/common/VnInputDate.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnSelectCreate from 'src/components/common/VnSelectCreate.vue'; import VnSelectCreate from 'src/components/common/VnSelectCreate.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue'; import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
import CustomerCreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue'; import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
@ -189,7 +189,7 @@ onMounted(async () => {
hide-selected hide-selected
> >
<template #form> <template #form>
<CustomerCreateNewPostcode <CreateNewPostcode
@on-data-saved="onPostcodeCreated($event)" @on-data-saved="onPostcodeCreated($event)"
/> />
</template> </template>

View File

@ -19,6 +19,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
order: '', order: '',
data: ref(), data: ref(),
isLoading: false, isLoading: false,
userParamsChanged: true,
exprBuilder: null, exprBuilder: null,
}; };
} }

View File

@ -119,7 +119,7 @@ describe('VnPaginate', () => {
await vm.onLoad(index, done); await vm.onLoad(index, done);
expect(vm.pagination.page).toEqual(2); expect(vm.pagination.page).toEqual(2);
expect(done).toHaveBeenCalledWith(true); expect(done).toHaveBeenCalledWith(false);
}); });
}); });
}); });