fix(grid): preserve page size when reloading data after save
The reload event did not carry limit/offset, so buildTableSelectSql always fell back to its default LIMIT 100, resetting 1000-row pages back to 100 after every commit.
This commit is contained in:
parent
78184544cf
commit
9463ff07a7
10
src/App.vue
10
src/App.vue
|
|
@ -618,8 +618,14 @@ onUnmounted(() => {
|
|||
@editor-cursor-change="(p: number) => (cursorPos = p)"
|
||||
@format-error="toast(t('toolbar.formatSqlFailed'))"
|
||||
@reload="
|
||||
(sql?: string, searchText?: string, whereInput?: string, orderBy?: string) =>
|
||||
onReloadData(sql, searchText, whereInput, orderBy)
|
||||
(
|
||||
sql?: string,
|
||||
searchText?: string,
|
||||
whereInput?: string,
|
||||
orderBy?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
) => onReloadData(sql, searchText, whereInput, orderBy, limit, offset)
|
||||
"
|
||||
@paginate="onPaginate"
|
||||
@sort="onSort"
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string];
|
||||
reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number];
|
||||
paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string];
|
||||
sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string];
|
||||
}>();
|
||||
|
|
@ -857,6 +857,8 @@ const editor = useDataGridEditor({
|
|||
rowStatusFilter,
|
||||
initialEditColumn: firstVisibleColumnIndex,
|
||||
getRowItem,
|
||||
pageSize,
|
||||
currentPage,
|
||||
emit,
|
||||
});
|
||||
|
||||
|
|
@ -904,6 +906,8 @@ async function onToolbarRefresh() {
|
|||
searchText.value,
|
||||
whereFilterInput.value.trim() || undefined,
|
||||
orderByInput.value.trim() || undefined,
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -919,6 +923,8 @@ function onToolbarRollback() {
|
|||
searchText.value,
|
||||
whereFilterInput.value.trim() || undefined,
|
||||
orderByInput.value.trim() || undefined,
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const emit = defineEmits<{
|
|||
editorSelectionChange: [value: string];
|
||||
editorCursorChange: [pos: number];
|
||||
formatError: [];
|
||||
reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string];
|
||||
reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number];
|
||||
paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string];
|
||||
sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string];
|
||||
executeSql: [sql: string];
|
||||
|
|
@ -283,8 +283,14 @@ function onHandleCloseColumnPanel() {
|
|||
:table-meta="activeTab.tableMeta"
|
||||
:on-execute-sql="async (sql: string) => emit('executeSql', sql)"
|
||||
@reload="
|
||||
(sql?: string, searchText?: string, whereInput?: string, orderBy?: string) =>
|
||||
emit('reload', sql, searchText, whereInput, orderBy)
|
||||
(
|
||||
sql?: string,
|
||||
searchText?: string,
|
||||
whereInput?: string,
|
||||
orderBy?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
) => emit('reload', sql, searchText, whereInput, orderBy, limit, offset)
|
||||
"
|
||||
@paginate="
|
||||
(offset: number, limit: number, whereInput?: string, orderBy?: string) =>
|
||||
|
|
@ -381,8 +387,14 @@ function onHandleCloseColumnPanel() {
|
|||
:table-meta="activeTab.tableMeta"
|
||||
:on-execute-sql="async (sql: string) => emit('executeSql', sql)"
|
||||
@reload="
|
||||
(sql?: string, searchText?: string, whereInput?: string, orderBy?: string) =>
|
||||
emit('reload', sql, searchText, whereInput, orderBy)
|
||||
(
|
||||
sql?: string,
|
||||
searchText?: string,
|
||||
whereInput?: string,
|
||||
orderBy?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
) => emit('reload', sql, searchText, whereInput, orderBy, limit, offset)
|
||||
"
|
||||
@paginate="
|
||||
(offset: number, limit: number, whereInput?: string, orderBy?: string) =>
|
||||
|
|
|
|||
|
|
@ -51,12 +51,19 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
|
|||
await queryStore.executeTabSql(tab.id, sql);
|
||||
}
|
||||
|
||||
async function onReloadData(sql?: string, _searchText?: string, whereInput?: string, orderBy?: string) {
|
||||
async function onReloadData(
|
||||
sql?: string,
|
||||
_searchText?: string,
|
||||
whereInput?: string,
|
||||
orderBy?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
) {
|
||||
const tab = activeTab.value;
|
||||
if (!tab) return;
|
||||
if (tab.mode === "data" && tab.tableMeta) {
|
||||
tab.whereInput = whereInput ?? "";
|
||||
queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy }));
|
||||
queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy, limit, offset }));
|
||||
await queryStore.executeCurrentTab();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,18 @@ export interface UseDataGridEditorOptions {
|
|||
rowStatusFilter: Ref<RowStatusFilter>;
|
||||
initialEditColumn?: ComputedRef<number>;
|
||||
getRowItem: (rowId: number) => RowItem | undefined;
|
||||
pageSize: Ref<number>;
|
||||
currentPage: Ref<number>;
|
||||
emit: {
|
||||
(event: "reload", sql?: string, searchText?: string, whereInput?: string, orderBy?: string): void;
|
||||
(
|
||||
event: "reload",
|
||||
sql?: string,
|
||||
searchText?: string,
|
||||
whereInput?: string,
|
||||
orderBy?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
): void;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +101,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
|||
rowStatusFilter,
|
||||
initialEditColumn,
|
||||
getRowItem,
|
||||
pageSize,
|
||||
currentPage,
|
||||
emit,
|
||||
} = options;
|
||||
|
||||
|
|
@ -486,6 +498,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
|||
searchText.value,
|
||||
whereFilterInput.value.trim() || undefined,
|
||||
orderByInput.value.trim() || undefined,
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -571,6 +585,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
|||
searchText.value,
|
||||
whereFilterInput.value.trim() || undefined,
|
||||
orderByInput.value.trim() || undefined,
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue