feat(mongo): refine document browsing and structured filter experience

This commit is contained in:
zipg authored and GitHub committed 2026-08-08 11:36:57 +08:00
1 parent 0107d5fafb
commit e49d86b101
22 files changed
+1031 -171

No files matched your search

@@ -18,7 +18,7 @@ vi.mock("@/stores/productionSafetyStore", () => ({
useProductionSafetyStore: () => ({}),
}));
function createEditor(sourceColumns?: Array<string | undefined>) {
function createEditor(sourceColumns?: Array<string | undefined>, confirmDangerousRowDeletion = true) {
let editor: ReturnType<typeof useDataGridEditor>;
const result = ref<{ columns: string[]; rows: CellValue[][] }>({
columns: ["first", "hidden", "last"],
@@ -48,6 +48,7 @@ function createEditor(sourceColumns?: Array<string | undefined>) {
currentWhereInput: computed(() => undefined),
orderByInput: ref(""),
rowStatusFilter: ref("all"),
confirmDangerousRowDeletion: computed(() => confirmDangerousRowDeletion),
pageSize: ref(100),
currentPage: ref(1),
getRowItem: (rowId) => {
@@ -82,6 +83,29 @@ function createEditor(sourceColumns?: Array<string | undefined>) {
return editor;
}
describe("useDataGridEditor row deletion confirmation", () => {
it("keeps the row pending until confirmation when confirmation is enabled", () => {
const editor = createEditor(undefined, true);
editor.requestDeleteRow(-1);
expect(editor.showDeleteRowConfirm.value).toBe(true);
expect(editor.newRows.value).toHaveLength(1);
editor.confirmDeleteRow();
expect(editor.newRows.value).toHaveLength(0);
});
it("applies row deletion immediately when confirmation is disabled", () => {
const editor = createEditor(undefined, false);
editor.requestDeleteRow(-1);
expect(editor.showDeleteRowConfirm.value).toBe(false);
expect(editor.newRows.value).toHaveLength(0);
});
});
describe("useDataGridEditor appendPastedRowsToNewRow", () => {
beforeEach(() => {
mocks.getConfig.mockReturnValue({ id: "connection-1", db_type: "postgres" });
@@ -96,6 +96,7 @@ export interface UseDataGridEditorOptions {
orderByInput: Ref<string>;
rowStatusFilter: Ref<RowStatusFilter>;
dataGridQuickEntryEnabled?: ComputedRef<boolean>;
confirmDangerousRowDeletion?: ComputedRef<boolean>;
initialEditColumn?: ComputedRef<number>;
getRowItem: (rowId: number) => RowItem | undefined;
pageSize: Ref<number>;
@@ -202,6 +203,7 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
orderByInput,
rowStatusFilter,
dataGridQuickEntryEnabled = computed(() => false),
confirmDangerousRowDeletion = computed(() => true),
initialEditColumn,
getRowItem,
pageSize,
@@ -1200,11 +1202,19 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
const pendingDeleteRowIds = ref<number[]>([]);
function requestDeleteRow(rowId: number) {
if (!confirmDangerousRowDeletion.value) {
applyDeleteRow(rowId);
return;
}
pendingDeleteRowId.value = rowId;
showDeleteRowConfirm.value = true;
}
function requestDeleteRows(rowIds: number[]) {
if (!confirmDangerousRowDeletion.value) {
applyDeleteRows(rowIds);
return;
}
pendingDeleteRowIds.value = rowIds;
showDeleteRowConfirm.value = true;
}