fix(grid): preserve table data pagination offset
This commit is contained in:
1 parent
4b00bf8215
commit
297e3d0752
4 files changed
+61
-4
No files matched your search
@@ -1681,6 +1681,7 @@ watch(
|
||||
pageSize.value = normalizedLimit;
|
||||
currentPage.value = Math.floor(offset / normalizedLimit) + 1;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
const canGoNextPage = computed(() => props.result.has_more === true || props.result.rows.length >= pageSize.value);
|
||||
const canJumpLastPage = computed(() => canGoNextPage.value && (!!props.tableMeta || !!props.countSql));
|
||||
|
||||
@@ -67,8 +67,11 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
|
||||
if (!tab) return;
|
||||
if (tab.mode === "data" && tab.tableMeta) {
|
||||
tab.whereInput = whereInput ?? "";
|
||||
queryStore.updateSql(tab.id, await buildTableSql(tab, { whereInput, orderBy, limit, offset }));
|
||||
await queryStore.executeCurrentTab();
|
||||
const pageLimit = limit ?? settingsStore.editorSettings.pageSize;
|
||||
const pageOffset = offset ?? 0;
|
||||
const nextSql = await buildTableSql(tab, { whereInput, orderBy, limit: pageLimit, offset: pageOffset });
|
||||
queryStore.updateSql(tab.id, nextSql);
|
||||
await queryStore.executeTabSql(tab.id, nextSql, { pagination: { limit: pageLimit, offset: pageOffset } });
|
||||
return;
|
||||
}
|
||||
if (tab.resultSortedSql) {
|
||||
@@ -111,7 +114,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
|
||||
tab.whereInput = whereInput ?? "";
|
||||
const sql = await buildTableSql(tab, { limit, offset, whereInput, orderBy });
|
||||
queryStore.updateSql(tab.id, sql);
|
||||
await queryStore.executeCurrentTab();
|
||||
await queryStore.executeTabSql(tab.id, sql, { pagination: { offset, limit } });
|
||||
}
|
||||
|
||||
async function onSort(column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string) {
|
||||
|
||||
@@ -674,7 +674,8 @@ export const useQueryStore = defineStore("query", () => {
|
||||
countSql = plan.countSql;
|
||||
useAgentResultSession = plan.useAgentResultSession;
|
||||
} else if (tab.mode === "data") {
|
||||
pageLimit = settingsStore.editorSettings.pageSize;
|
||||
pageLimit = options?.pagination?.limit ?? settingsStore.editorSettings.pageSize;
|
||||
pageOffset = options?.pagination?.offset ?? 0;
|
||||
}
|
||||
const mongoFind = conn?.db_type === "mongodb" ? parseMongoFindCommand(sql) : null;
|
||||
if (mongoFind) {
|
||||
|
||||
Reference in new issue
Block a user