From 11694292daa1eae713e9c6b8c1a4facb9af81ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E9=A2=97=E7=BA=A2=E5=BF=83?= Date: Wed, 12 Aug 2026 22:22:33 +0800 Subject: [PATCH] feat(grid): preserve metadata in transpose view --- apps/desktop/src/components/grid/DataGrid.vue | 41 ++++++++++++++++--- .../DataGridTransposePresentation.spec.ts | 14 ++++--- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index d878f290dc..252fa0b9e1 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -30,6 +30,7 @@ import { SquareDashed, Check, CopyPlus, + Hash, KeyRound, Link2, ListTree, @@ -245,7 +246,7 @@ import { getTableStructureCapabilities } from "@/lib/table/tableStructureCapabil import { filterObjectBrowserTableColumns } from "@/lib/table/objectBrowserTableInfo"; import { gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp"; import { reserveDataGridHeaderLine } from "@/lib/dataGrid/dataGridHeaderLayout"; -import { buildColumnIndexMap, columnIndexMetadataRequestCurrent, columnIndexNameKey, columnIndexTableIdentity } from "@/lib/dataGrid/dataGridColumnIndexIcon"; +import { buildColumnIndexMap, columnIndexColorClass, columnIndexMetadataRequestCurrent, columnIndexNameKey, columnIndexTableIdentity, type ColumnIndexKind } from "@/lib/dataGrid/dataGridColumnIndexIcon"; import { supportsTableStructureEditing } from "@/lib/database/databaseCapabilities"; import { rememberDataGridConditionHistory } from "@/lib/dataGrid/dataGridConditionHistory"; import { restoreDataGridLocalColumnFilters, serializeDataGridLocalColumnFilters } from "@/lib/dataGrid/dataGridLocalColumnFilterState"; @@ -7911,6 +7912,9 @@ const transposeRows = computed(() => { displayValue: (value, _column, index) => formatCellCached(value, visibleColumnIndexes.value[index]), }); }); +const transposeReserveTypeLine = computed(() => showColumnTypesInHeader.value && transposeRows.value.some((row) => row.type)); +const transposeReserveCommentLine = computed(() => showColumnCommentsInHeader.value && transposeRows.value.some((row) => row.comment)); +const transposeRowHeight = computed(() => 30 + (transposeReserveTypeLine.value ? 14 : 0) + (transposeReserveCommentLine.value ? 14 : 0)); const isTransposeMode = computed(() => showTranspose.value && transposeRows.value.length > 0); const transposeTotalWidth = computed(() => { const recordIndexes = multiRowTranspose.value ? Array.from({ length: displayRowCount.value }, (_, i) => i) : activeTransposeRecordIndexes.value; @@ -7930,6 +7934,19 @@ function transposeFieldTitle(item: { column: string; type: string; comment?: str return details.join("\n"); } +function transposeColumnIndexKind(column: string): ColumnIndexKind | undefined { + if (!showIndexIndicatorsInHeader.value) return undefined; + const kind = columnIndexMap.value.get(columnIndexNameKey(column)); + return kind && kind !== "none" ? kind : undefined; +} + +function transposeColumnIndexText(kind: ColumnIndexKind): string { + if (kind === "primary") return t("grid.columnPrimaryIndex"); + if (kind === "unique") return t("grid.columnUniqueIndex"); + if (kind === "index") return t("grid.columnRegularIndex"); + return ""; +} + function updateTransposeViewport() { const el = transposeScrollElement(); if (!el) return; @@ -10055,7 +10072,7 @@ const gridContextMenuItems = computed(() => { '--transpose-field-w': `${transposePinnedWidth}px`, }" :items="transposeRows" - :item-size="30" + :item-size="transposeRowHeight" :buffer="400" key-field="id" @scroll="onTransposeScroll" @@ -10093,21 +10110,35 @@ const gridContextMenuItems = computed(() => {
- {{ item.column }} + + + + {{ item.column }} + + +