diff --git a/src/components/Pagination.vue b/src/components/Pagination.vue index 8b6ead5..fdedf98 100644 --- a/src/components/Pagination.vue +++ b/src/components/Pagination.vue @@ -96,6 +96,10 @@ watch(searchString, async () => { }, 600); }); +watch(() => props.totalCount, async () => { + currentPage.value = 0; +}); + const emit = defineEmits({ submit(id: number) { return typeof id == "number"; @@ -151,7 +155,8 @@ const loadPage = (newPage: number | ".") => { if (pageEnd > entryCount.value) pageEnd = entryCount.value; let loadedElementCount = filterData(props.items, searchString.value, pageStart, pageEnd).length; - if (loadedElementCount < props.maxEntriesPerPage) + console.log(loadedElementCount, props.maxEntriesPerPage, pageStart, pageEnd) + if (loadedElementCount < props.maxEntriesPerPage && (pageEnd != props.totalCount || loadedElementCount == 0)) emit("loadData", pageStart, props.maxEntriesPerPage, searchString.value); currentPage.value = newPage; diff --git a/src/stores/admin/queryBuilder.ts b/src/stores/admin/queryBuilder.ts index d65e150..292ba38 100644 --- a/src/stores/admin/queryBuilder.ts +++ b/src/stores/admin/queryBuilder.ts @@ -32,8 +32,10 @@ export const useQueryBuilderStore = defineStore("queryBuilder", { }, sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) { this.queryError = ""; - this.data = []; - this.totalLength = 0; + if (offset == 0) { + this.data = []; + this.totalLength = 0; + } let queryToSend = query ?? this.query; if (queryToSend == undefined || queryToSend == "" || (typeof queryToSend != "string" && queryToSend.table == "")) return; @@ -44,7 +46,7 @@ export const useQueryBuilderStore = defineStore("queryBuilder", { }) .then((result) => { if (result.data.stats == "success") { - this.data = result.data.rows; + this.data = [...this.data, ...result.data.rows]; this.totalLength = result.data.total; this.loadingData = "fetched"; } else {