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
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:
commit
cf6a26b742
|
@ -64,10 +64,12 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
async function search() {
|
||||
isLoading.value = true;
|
||||
const params = { ...userParams.value };
|
||||
store.userParamsChanged = true;
|
||||
store.filter.skip = 0;
|
||||
store.skip = 0;
|
||||
const { params: newParams } = await arrayData.addFilter({ params });
|
||||
userParams.value = newParams;
|
||||
|
||||
|
@ -89,7 +91,9 @@ async function reload() {
|
|||
|
||||
async function clearFilters() {
|
||||
isLoading.value = true;
|
||||
|
||||
store.userParamsChanged = true;
|
||||
store.filter.skip = 0;
|
||||
store.skip = 0;
|
||||
// Filtrar los params no removibles
|
||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||
props.unremovableParams.includes(param)
|
||||
|
|
|
@ -104,6 +104,8 @@ async function paginate() {
|
|||
await arrayData.loadMore();
|
||||
|
||||
if (!arrayData.hasMoreData.value) {
|
||||
if (store.userParamsChanged) arrayData.hasMoreData.value = true;
|
||||
store.userParamsChanged = false;
|
||||
isLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
@ -129,9 +131,9 @@ async function onLoad(...params) {
|
|||
pagination.value.page = pagination.value.page + 1;
|
||||
|
||||
await paginate();
|
||||
|
||||
const endOfPages = !arrayData.hasMoreData.value;
|
||||
done(endOfPages);
|
||||
let isDone = false;
|
||||
if (store.userParamsChanged) isDone = !arrayData.hasMoreData.value;
|
||||
done(isDone);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -172,7 +174,7 @@ async function onLoad(...params) {
|
|||
v-if="store.data"
|
||||
@load="onLoad"
|
||||
:offset="offset"
|
||||
class="full-width full-height overflow-auto"
|
||||
class="full-width full-height"
|
||||
>
|
||||
<slot name="body" :rows="store.data"></slot>
|
||||
<div v-if="isLoading" class="info-row q-pa-md text-center">
|
||||
|
|
|
@ -142,7 +142,8 @@ export function useArrayData(key, userOptions) {
|
|||
userParams = sanitizerParams(userParams, store?.exprBuilder);
|
||||
|
||||
store.userParams = userParams;
|
||||
|
||||
store.skip = 0;
|
||||
store.filter.skip = 0;
|
||||
await fetch({ append: false });
|
||||
return { filter, params };
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ const body = {
|
|||
</script>
|
||||
<template>
|
||||
<div class="column items-center">
|
||||
<VnNotes
|
||||
<VnNotes style="overflow-y: scroll;"
|
||||
:add-note="$props.addNote"
|
||||
:id="id"
|
||||
url="claimObservations"
|
||||
|
|
|
@ -9,7 +9,7 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
|||
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||
import VnSelectCreate from 'src/components/common/VnSelectCreate.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 VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
|
||||
|
@ -189,7 +189,7 @@ onMounted(async () => {
|
|||
hide-selected
|
||||
>
|
||||
<template #form>
|
||||
<CustomerCreateNewPostcode
|
||||
<CreateNewPostcode
|
||||
@on-data-saved="onPostcodeCreated($event)"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -19,6 +19,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
|
|||
order: '',
|
||||
data: ref(),
|
||||
isLoading: false,
|
||||
userParamsChanged: true,
|
||||
exprBuilder: null,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ describe('VnPaginate', () => {
|
|||
await vm.onLoad(index, done);
|
||||
|
||||
expect(vm.pagination.page).toEqual(2);
|
||||
expect(done).toHaveBeenCalledWith(true);
|
||||
expect(done).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue