feat(grid): option to open cell details in dialog

This commit is contained in:
lxk955 authored and GitHub committed 2026-10-04 10:10:36 +08:00
1 parent db150dfcab
commit 4b48809c84
20 files changed
+160 -2

No files matched your search

@@ -755,6 +755,7 @@ const editDefaultAutoKeepResults = ref(settingsStore.editorSettings.defaultAutoK
const editMultiStatementDefaultView = ref<MultiStatementDefaultView>(settingsStore.editorSettings.multiStatementDefaultView);
const editDataGridAutoTransposeSingleRow = ref(settingsStore.editorSettings.dataGridAutoTransposeSingleRow);
const editDataGridCellDetailButtonVisible = ref(settingsStore.editorSettings.dataGridCellDetailButtonVisible);
const editDataGridCellDetailDialogDefault = ref(settingsStore.editorSettings.dataGridCellDetailDialogDefault);
const editDataGridCrosshairHighlight = ref(settingsStore.editorSettings.dataGridCrosshairHighlight);
const editDataGridStripedRows = ref(settingsStore.editorSettings.dataGridStripedRows);
const editPageSize = ref(settingsStore.editorSettings.pageSize);
@@ -1113,6 +1114,7 @@ function currentEditorSettingsDraft(): EditorSettingsDraft {
multiStatementDefaultView: editMultiStatementDefaultView.value,
dataGridAutoTransposeSingleRow: editDataGridAutoTransposeSingleRow.value,
dataGridCellDetailButtonVisible: editDataGridCellDetailButtonVisible.value,
dataGridCellDetailDialogDefault: editDataGridCellDetailDialogDefault.value,
dataGridCrosshairHighlight: editDataGridCrosshairHighlight.value,
dataGridStripedRows: editDataGridStripedRows.value,
flatteningMultiLineText: editFlatteningMultiLineText.value,
@@ -1786,6 +1788,7 @@ function syncEditorSettingsDraftFromStore() {
editMultiStatementDefaultView.value = settingsStore.editorSettings.multiStatementDefaultView;
editDataGridAutoTransposeSingleRow.value = settingsStore.editorSettings.dataGridAutoTransposeSingleRow;
editDataGridCellDetailButtonVisible.value = settingsStore.editorSettings.dataGridCellDetailButtonVisible;
editDataGridCellDetailDialogDefault.value = settingsStore.editorSettings.dataGridCellDetailDialogDefault;
editDataGridCrosshairHighlight.value = settingsStore.editorSettings.dataGridCrosshairHighlight;
editDataGridStripedRows.value = settingsStore.editorSettings.dataGridStripedRows;
editFlatteningMultiLineText.value = settingsStore.editorSettings.flatteningMultiLineText;
@@ -1934,6 +1937,7 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = {
multiStatementDefaultView: editMultiStatementDefaultView,
dataGridAutoTransposeSingleRow: editDataGridAutoTransposeSingleRow,
dataGridCellDetailButtonVisible: editDataGridCellDetailButtonVisible,
dataGridCellDetailDialogDefault: editDataGridCellDetailDialogDefault,
dataGridCrosshairHighlight: editDataGridCrosshairHighlight,
dataGridStripedRows: editDataGridStripedRows,
pageSize: editPageSize,
@@ -2518,6 +2522,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
editMultiStatementDefaultView.value = DEFAULT_EDITOR_SETTINGS.multiStatementDefaultView;
editDataGridAutoTransposeSingleRow.value = DEFAULT_EDITOR_SETTINGS.dataGridAutoTransposeSingleRow;
editDataGridCellDetailButtonVisible.value = DEFAULT_EDITOR_SETTINGS.dataGridCellDetailButtonVisible;
editDataGridCellDetailDialogDefault.value = DEFAULT_EDITOR_SETTINGS.dataGridCellDetailDialogDefault;
editDataGridCrosshairHighlight.value = DEFAULT_EDITOR_SETTINGS.dataGridCrosshairHighlight;
editDataGridStripedRows.value = DEFAULT_EDITOR_SETTINGS.dataGridStripedRows;
editFlatteningMultiLineText.value = DEFAULT_EDITOR_SETTINGS.flatteningMultiLineText;
@@ -2634,6 +2639,7 @@ function resetAllDefaults() {
editMultiStatementDefaultView.value = DEFAULT_EDITOR_SETTINGS.multiStatementDefaultView;
editDataGridAutoTransposeSingleRow.value = DEFAULT_EDITOR_SETTINGS.dataGridAutoTransposeSingleRow;
editDataGridCellDetailButtonVisible.value = DEFAULT_EDITOR_SETTINGS.dataGridCellDetailButtonVisible;
editDataGridCellDetailDialogDefault.value = DEFAULT_EDITOR_SETTINGS.dataGridCellDetailDialogDefault;
editDataGridCrosshairHighlight.value = DEFAULT_EDITOR_SETTINGS.dataGridCrosshairHighlight;
editDataGridStripedRows.value = DEFAULT_EDITOR_SETTINGS.dataGridStripedRows;
editFlatteningMultiLineText.value = DEFAULT_EDITOR_SETTINGS.flatteningMultiLineText;
@@ -8735,6 +8741,17 @@ onUnmounted(() => {
</div>
<Switch id="data-grid-cell-detail-button-visible" v-model="editDataGridCellDetailButtonVisible" />
</div>
<div class="settings-item flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
<div class="space-y-1">
<Label for="data-grid-cell-detail-dialog-default">
{{ t("settings.dataGridCellDetailDialogDefault") }}
</Label>
<p class="text-xs text-muted-foreground">
{{ t("settings.dataGridCellDetailDialogDefaultDescription") }}
</p>
</div>
<Switch id="data-grid-cell-detail-dialog-default" v-model="editDataGridCellDetailDialogDefault" />
</div>
<div class="settings-item flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
<div class="space-y-1">
<Label for="data-grid-crosshair-highlight">
+13 -2
View File
@@ -434,6 +434,7 @@ const connectionStore = useConnectionStore();
const queryStore = useQueryStore();
const settingsStore = useSettingsStore();
const cellDetailButtonEnabled = computed(() => settingsStore.editorSettings.dataGridCellDetailButtonVisible);
const cellDetailDialogDefault = computed(() => settingsStore.editorSettings.dataGridCellDetailDialogDefault);
const dataGridCrosshairHighlight = computed(() => settingsStore.editorSettings.dataGridCrosshairHighlight);
const tableFontSize = computed(() => settingsStore.editorSettings.tableFontSize);
const rowNumberWidth = ref(DATA_GRID_ROW_NUM_WIDTH);
@@ -8487,7 +8488,12 @@ function showCellDetailsForVisibleCell(rowIndex: number, visibleColIdx: number,
clearRowSelection();
invalidateContextMenuTarget();
selectSingleCell(rowIndex, visibleColIdx);
showCellDetails(rowIndex, actualColIdx);
if (cellDetailDialogDefault.value) {
showCellDetail.value = false;
openCellDetailDialog(rowIndex, actualColIdx);
} else {
showCellDetails(rowIndex, actualColIdx);
}
}
function openCellDetailDialog(rowIndex: number, columnIndex: number) {
@@ -8616,7 +8622,12 @@ function showTransposeCellDetails(rowIndex: number, actualColIdx: number) {
invalidateContextMenuTarget();
selectSingleCell(rowIndex, visibleColIdx);
transposeRowIndex.value = rowIndex;
showCellDetails(rowIndex, actualColIdx);
if (cellDetailDialogDefault.value) {
showCellDetail.value = false;
openCellDetailDialog(rowIndex, actualColIdx);
} else {
showCellDetails(rowIndex, actualColIdx);
}
gridRef.value?.focus({ preventScroll: true });
}
@@ -0,0 +1,55 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
const dataGridSource = readFileSync(resolve(import.meta.dirname, "../DataGrid.vue"), "utf8");
const editorSettingsDialogSource = readFileSync(resolve(import.meta.dirname, "../../editor/EditorSettingsDialog.vue"), "utf8");
describe("DataGrid cell detail dialog default preference (#2303)", () => {
it("binds cellDetailDialogDefault to settingsStore.editorSettings.dataGridCellDetailDialogDefault", () => {
expect(dataGridSource).toMatch(/const cellDetailDialogDefault = computed\(\(\) => settingsStore\.editorSettings\.dataGridCellDetailDialogDefault\);/);
});
it("opens cell detail dialog directly when cellDetailDialogDefault is enabled in showCellDetailsForVisibleCell", () => {
expect(dataGridSource).toContain(
"function showCellDetailsForVisibleCell(rowIndex: number, visibleColIdx: number, actualColIdx: number) {\n" +
" clearRowSelection();\n" +
" invalidateContextMenuTarget();\n" +
" selectSingleCell(rowIndex, visibleColIdx);\n" +
" if (cellDetailDialogDefault.value) {\n" +
" showCellDetail.value = false;\n" +
" openCellDetailDialog(rowIndex, actualColIdx);\n" +
" } else {\n" +
" showCellDetails(rowIndex, actualColIdx);\n" +
" }\n" +
"}",
);
});
it("opens cell detail dialog directly when cellDetailDialogDefault is enabled in showTransposeCellDetails", () => {
expect(dataGridSource).toContain(
"function showTransposeCellDetails(rowIndex: number, actualColIdx: number) {\n" +
" const visibleColIdx = visibleColumnIndexes.value.indexOf(actualColIdx);\n" +
" if (visibleColIdx < 0) return;\n" +
" clearRowSelection();\n" +
" invalidateContextMenuTarget();\n" +
" selectSingleCell(rowIndex, visibleColIdx);\n" +
" transposeRowIndex.value = rowIndex;\n" +
" if (cellDetailDialogDefault.value) {\n" +
" showCellDetail.value = false;\n" +
" openCellDetailDialog(rowIndex, actualColIdx);\n" +
" } else {\n" +
" showCellDetails(rowIndex, actualColIdx);\n" +
" }\n" +
" gridRef.value?.focus({ preventScroll: true });\n" +
"}",
);
});
it("renders the dataGridCellDetailDialogDefault switch in EditorSettingsDialog", () => {
expect(editorSettingsDialogSource).toContain('id="data-grid-cell-detail-dialog-default"');
expect(editorSettingsDialogSource).toContain('v-model="editDataGridCellDetailDialogDefault"');
expect(editorSettingsDialogSource).toContain('t("settings.dataGridCellDetailDialogDefault")');
expect(editorSettingsDialogSource).toContain('t("settings.dataGridCellDetailDialogDefaultDescription")');
});
});