fix(grid): preserve column filters across tab eviction
This commit is contained in:
7 files changed
+87
-1
No files matched your search
@@ -68,4 +68,23 @@ describe("queryStore switchTab", () => {
|
||||
expect(queryStore.activeTabId).toBe(tabId);
|
||||
expect(settingsStore.settingsPageActive).toBe(false);
|
||||
});
|
||||
|
||||
it("stores local data-grid column filters on the tab result", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const queryStore = useQueryStore();
|
||||
const tabId = queryStore.createTab("pg-1", "app", "users", "data", "public");
|
||||
const tab = queryStore.tabs.find((item) => item.id === tabId)!;
|
||||
tab.result = {
|
||||
columns: ["id", "status"],
|
||||
rows: [[1, "active"]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
};
|
||||
|
||||
queryStore.updateDataGridLocalColumnFilters(tabId, { "1": ["str:active"] });
|
||||
expect(tab.result.local_column_filters).toEqual({ "1": ["str:active"] });
|
||||
|
||||
queryStore.updateDataGridLocalColumnFilters(tabId, {});
|
||||
expect(tab.result.local_column_filters).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -2089,6 +2089,16 @@ export const useQueryStore = defineStore("query", () => {
|
||||
}
|
||||
}
|
||||
|
||||
function updateDataGridLocalColumnFilters(id: string, filters: Record<string, string[]>) {
|
||||
const tab = tabs.value.find((item) => item.id === id);
|
||||
if (!tab?.result) return;
|
||||
if (Object.keys(filters).length === 0) {
|
||||
delete tab.result.local_column_filters;
|
||||
} else {
|
||||
tab.result.local_column_filters = Object.fromEntries(Object.entries(filters).map(([columnIndex, values]) => [columnIndex, [...values]]));
|
||||
}
|
||||
}
|
||||
|
||||
function setAutoCommit(id: string, autoCommit: boolean) {
|
||||
const tab = tabs.value.find((t) => t.id === id);
|
||||
if (tab) {
|
||||
@@ -4584,6 +4594,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
rollbackConnectionTransactions,
|
||||
rollbackDatabaseTransactions,
|
||||
updateSql,
|
||||
updateDataGridLocalColumnFilters,
|
||||
updateEditorViewport,
|
||||
updateEditorSelection,
|
||||
updateObjectBrowserViewport,
|
||||
|
||||
Reference in new issue
Block a user