Skip to content

Commit

Permalink
fixed entriesloaded being changed in computed
Browse files Browse the repository at this point in the history
  • Loading branch information
Severino committed Oct 17, 2023
1 parent eaa0418 commit 734b49c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions resources/js/components/BibliographyTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@
const toast = useToast();
// FETCH
const chunkSize = 20
// FUNCTIONS
const setOrderColumn = column => {
if(state.orderColumn == column) {
Expand All @@ -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++;
}
});
Expand Down Expand Up @@ -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: '',
Expand Down Expand Up @@ -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);
})
Expand Down

0 comments on commit 734b49c

Please sign in to comment.