feat(grid): support selecting multiple fields for sorting
This commit is contained in:
1 parent
c840206b25
commit
a1e2d39ed3
37 files changed
+2033
-48
No files matched your search
@@ -30,6 +30,23 @@ describe("restoredDataTabReloadFilters", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("recombines the persisted structured ORDER BY with the manual input for restored tabs", () => {
|
||||
expect(
|
||||
restoredDataTabReloadFilters({
|
||||
whereInput: "status = 'active'",
|
||||
orderByInput: '"name" ASC',
|
||||
structuredOrderByInput: '"age" DESC, "created_at" ASC',
|
||||
}),
|
||||
).toEqual({
|
||||
whereInput: "status = 'active'",
|
||||
orderBy: '"name" ASC, "age" DESC, "created_at" ASC',
|
||||
});
|
||||
expect(restoredDataTabReloadFilters({ whereInput: undefined, orderByInput: undefined, structuredOrderByInput: '"age" DESC' })).toEqual({
|
||||
whereInput: undefined,
|
||||
orderBy: '"age" DESC',
|
||||
});
|
||||
});
|
||||
|
||||
it("reports blank filters as absent so the reload does not emit an empty WHERE/ORDER BY", () => {
|
||||
expect(restoredDataTabReloadFilters({ whereInput: "", orderByInput: undefined })).toEqual({ whereInput: undefined, orderBy: undefined });
|
||||
expect(restoredDataTabReloadFilters({ whereInput: " ", orderByInput: " " })).toEqual({ whereInput: undefined, orderBy: undefined });
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { combineDataGridOrderByInputs } from "@/composables/useDataGridSortBuilder";
|
||||
import type { QueryTab } from "@/types/database";
|
||||
|
||||
type RefreshableDataTab = Pick<QueryTab, "mode" | "result" | "isExecuting">;
|
||||
@@ -6,7 +7,7 @@ export function canReloadUnavailableDataTab(tab: RefreshableDataTab): boolean {
|
||||
return tab.mode === "data" && !tab.result && !tab.isExecuting;
|
||||
}
|
||||
|
||||
type RestoredDataTabFilters = Pick<QueryTab, "whereInput" | "orderByInput">;
|
||||
type RestoredDataTabFilters = Pick<QueryTab, "whereInput" | "orderByInput" | "structuredOrderByInput">;
|
||||
|
||||
// 恢复的数据标签页没有 result,刷新走的是 DataGrid 之外那条不带参数的 reload 入口。
|
||||
// onReloadData 把缺省的 whereInput/orderBy 当成“用户已清空”(DataGrid 清空筛选时
|
||||
@@ -15,6 +16,6 @@ type RestoredDataTabFilters = Pick<QueryTab, "whereInput" | "orderByInput">;
|
||||
export function restoredDataTabReloadFilters(tab: RestoredDataTabFilters): { whereInput?: string; orderBy?: string } {
|
||||
return {
|
||||
whereInput: tab.whereInput?.trim() || undefined,
|
||||
orderBy: tab.orderByInput?.trim() || undefined,
|
||||
orderBy: combineDataGridOrderByInputs(tab.orderByInput, tab.structuredOrderByInput),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user