From 734b49c9f40ad88f1745d5cc37cf5f7a26dcbb47 Mon Sep 17 00:00:00 2001 From: Severino Date: Tue, 17 Oct 2023 16:36:23 +0200 Subject: [PATCH] fixed entriesloaded being changed in computed --- resources/js/components/BibliographyTable.vue | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/resources/js/components/BibliographyTable.vue b/resources/js/components/BibliographyTable.vue index 140c2781a..b51f28b72 100644 --- a/resources/js/components/BibliographyTable.vue +++ b/resources/js/components/BibliographyTable.vue @@ -563,6 +563,8 @@ const toast = useToast(); // FETCH + const chunkSize = 20 + // FUNCTIONS const setOrderColumn = column => { if(state.orderColumn == column) { @@ -579,13 +581,13 @@ const getNextEntries = _ => { if(state.entriesLoaded === state.allEntries.length) return; - state.entriesLoaded = Math.min(state.entriesLoaded + state.chunkSize, state.allEntries.length); + state.entriesLoaded = Math.min(state.entriesLoaded + chunkSize, state.allEntries.length); }; const showNewItemModal = _ => { if(!can('bibliography_create')) return; showBibliographyEntry({fields: {}}, _ => { - if(state.allEntries.length < state.chunkSize) { + if(state.allEntries.length < chunkSize) { state.entriesLoaded++; } }); @@ -657,8 +659,7 @@ // DATA const state = reactive({ allEntries: computed(_ => store.getters.bibliography), - entriesLoaded: 0, - chunkSize: 20, + entriesLoaded: Math.min(chunkSize, store.getters.bibliography.length), orderColumn: 'author', orderType: 'asc', query: '', @@ -697,9 +698,7 @@ return false; }); } - if(state.entriesLoaded === 0) { - state.entriesLoaded = state.chunkSize; - } + const size = Math.min(state.entriesLoaded, filteredEntries.length); return _orderBy(filteredEntries, state.orderColumn, state.orderType).slice(0, size); })