@finos/legend-query-builder 4.17.99 → 4.17.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSAsyncCellSelectionStats.d.ts +42 -0
- package/lib/components/result/tds/QueryBuilderTDSAsyncCellSelectionStats.d.ts.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSAsyncCellSelectionStats.js +212 -0
- package/lib/components/result/tds/QueryBuilderTDSAsyncCellSelectionStats.js.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStats.d.ts +66 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStats.d.ts.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStats.js +265 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStats.js.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.d.ts +28 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.d.ts.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.js +148 -0
- package/lib/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.js.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSGridKeyboardShortcuts.d.ts +19 -0
- package/lib/components/result/tds/QueryBuilderTDSGridKeyboardShortcuts.d.ts.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSGridKeyboardShortcuts.js +196 -0
- package/lib/components/result/tds/QueryBuilderTDSGridKeyboardShortcuts.js.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts +5 -0
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js +64 -87
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridShared.d.ts +26 -0
- package/lib/components/result/tds/QueryBuilderTDSGridShared.d.ts.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSGridShared.js +51 -0
- package/lib/components/result/tds/QueryBuilderTDSGridShared.js.map +1 -0
- package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.d.ts +5 -0
- package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +169 -60
- package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
- package/lib/data-access-overview.css +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +7 -1
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/package.json +5 -5
- package/src/components/result/QueryBuilderResultPanel.tsx +6 -2
- package/src/components/result/tds/QueryBuilderTDSAsyncCellSelectionStats.ts +254 -0
- package/src/components/result/tds/QueryBuilderTDSCellSelectionStats.ts +397 -0
- package/src/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.tsx +439 -0
- package/src/components/result/tds/QueryBuilderTDSGridKeyboardShortcuts.ts +270 -0
- package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +107 -112
- package/src/components/result/tds/QueryBuilderTDSGridShared.ts +76 -0
- package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +272 -99
- package/src/stores/QueryBuilderResultState.ts +10 -1
- package/tsconfig.json +5 -0
|
@@ -14,21 +14,23 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { WarningIcon, clsx } from '@finos/legend-art';
|
|
18
18
|
import { observer } from 'mobx-react-lite';
|
|
19
19
|
import type { QueryBuilderState } from '../../../stores/QueryBuilderState.js';
|
|
20
20
|
import {
|
|
21
21
|
DataGrid,
|
|
22
22
|
type DataGridColumnDefinition,
|
|
23
23
|
type DataGridCustomHeaderProps,
|
|
24
|
+
type DataGridGetContextMenuItemsParams,
|
|
25
|
+
type DataGridMenuItemDef,
|
|
26
|
+
type DataGridDefaultMenuItem,
|
|
24
27
|
} from '@finos/legend-lego/data-grid';
|
|
25
28
|
import {
|
|
26
29
|
getRowDataFromExecutionResult,
|
|
27
|
-
QueryBuilderGridResultContextMenu,
|
|
28
30
|
type IQueryRendererParamsWithGridType,
|
|
29
31
|
} from './QueryBuilderTDSResultShared.js';
|
|
30
|
-
import { QueryBuilderTDSState } from '../../../stores/fetch-structure/tds/QueryBuilderTDSState.js';
|
|
31
32
|
import { DEFAULT_LOCALE } from '../../../graph-manager/QueryBuilderConst.js';
|
|
33
|
+
import type { QueryBuilderResultState } from '../../../stores/QueryBuilderResultState.js';
|
|
32
34
|
import {
|
|
33
35
|
guaranteeNonNullable,
|
|
34
36
|
isBoolean,
|
|
@@ -36,6 +38,8 @@ import {
|
|
|
36
38
|
isString,
|
|
37
39
|
isValidURL,
|
|
38
40
|
} from '@finos/legend-shared';
|
|
41
|
+
import { useApplicationStore } from '@finos/legend-application';
|
|
42
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
39
43
|
import {
|
|
40
44
|
type TDSResultCellCoordinate,
|
|
41
45
|
type TDSResultCellData,
|
|
@@ -46,6 +50,9 @@ import {
|
|
|
46
50
|
PRIMITIVE_TYPE,
|
|
47
51
|
} from '@finos/legend-graph';
|
|
48
52
|
import { QUERY_BUILDER_TEST_ID } from '../../../__lib__/QueryBuilderTesting.js';
|
|
53
|
+
import { QueryBuilderTDSCellSelectionStatsBar } from './QueryBuilderTDSCellSelectionStatsBar.js';
|
|
54
|
+
import { useAsyncCellSelectionStats } from './QueryBuilderTDSAsyncCellSelectionStats.js';
|
|
55
|
+
import { buildTDSGridContextMenuItems } from './QueryBuilderTDSGridShared.js';
|
|
49
56
|
|
|
50
57
|
export const MAXIMUM_FRACTION_DIGITS = 4;
|
|
51
58
|
|
|
@@ -114,13 +121,8 @@ const QueryResultCellRenderer = observer(
|
|
|
114
121
|
(params: IQueryRendererParamsWithGridType) => {
|
|
115
122
|
const resultState = params.resultState;
|
|
116
123
|
const tdsExecutionResult = params.tdsExecutionResult;
|
|
117
|
-
const fetchStructureImplementation =
|
|
118
|
-
resultState.queryBuilderState.fetchStructureState.implementation;
|
|
119
|
-
const applicationStore = resultState.queryBuilderState.applicationStore;
|
|
120
124
|
const cellValue = params.value as TDSResultCellDataType;
|
|
121
125
|
const nodeRowIndex = guaranteeNonNullable(params.node.rowIndex);
|
|
122
|
-
const darkMode =
|
|
123
|
-
!applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled;
|
|
124
126
|
|
|
125
127
|
const formattedCellValue = (): TDSResultCellDataType => {
|
|
126
128
|
if (isNumber(cellValue)) {
|
|
@@ -321,104 +323,136 @@ const QueryResultCellRenderer = observer(
|
|
|
321
323
|
|
|
322
324
|
resultState.setMouseOverCell(resultState.selectedCells[0] ?? null);
|
|
323
325
|
};
|
|
324
|
-
const getContextMenuRenderer = (): React.ReactNode => {
|
|
325
|
-
if (fetchStructureImplementation instanceof QueryBuilderTDSState) {
|
|
326
|
-
const copyCellValue = applicationStore.guardUnhandledError(() =>
|
|
327
|
-
applicationStore.clipboardService.copyTextToClipboard(
|
|
328
|
-
fetchStructureImplementation.queryBuilderState.resultState.selectedCells
|
|
329
|
-
.map((cellData) => cellData.value)
|
|
330
|
-
.join(','),
|
|
331
|
-
),
|
|
332
|
-
);
|
|
333
|
-
const findRowFromRowIndex = (rowIndex: number): string => {
|
|
334
|
-
if (
|
|
335
|
-
!fetchStructureImplementation.queryBuilderState.resultState
|
|
336
|
-
.executionResult ||
|
|
337
|
-
!(
|
|
338
|
-
fetchStructureImplementation.queryBuilderState.resultState
|
|
339
|
-
.executionResult instanceof TDSExecutionResult
|
|
340
|
-
)
|
|
341
|
-
) {
|
|
342
|
-
return '';
|
|
343
|
-
}
|
|
344
|
-
// try to get the entire row value separated by comma
|
|
345
|
-
// rowData is in format of {columnName: value, columnName1: value, ...., rowNumber:value}
|
|
346
|
-
const valueArr: TDSResultCellDataType[] = [];
|
|
347
|
-
Object.entries(
|
|
348
|
-
params.api.getRenderedNodes().find((n) => n.rowIndex === rowIndex)
|
|
349
|
-
?.data as TDSRowDataType,
|
|
350
|
-
).forEach((entry) => {
|
|
351
|
-
if (entry[0] !== 'rowNumber') {
|
|
352
|
-
valueArr.push(entry[1]);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
return valueArr.join(',');
|
|
356
|
-
};
|
|
357
|
-
const copyRowValue = applicationStore.guardUnhandledError(() =>
|
|
358
|
-
applicationStore.clipboardService.copyTextToClipboard(
|
|
359
|
-
findRowFromRowIndex(
|
|
360
|
-
fetchStructureImplementation.queryBuilderState.resultState
|
|
361
|
-
.selectedCells[0]?.coordinates.rowIndex ?? 0,
|
|
362
|
-
),
|
|
363
|
-
),
|
|
364
|
-
);
|
|
365
|
-
return (
|
|
366
|
-
<QueryBuilderGridResultContextMenu
|
|
367
|
-
data={resultState.mousedOverCell}
|
|
368
|
-
tdsState={fetchStructureImplementation}
|
|
369
|
-
copyCellValueFunc={copyCellValue}
|
|
370
|
-
copyCellRowValueFunc={copyRowValue}
|
|
371
|
-
/>
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
return null;
|
|
375
|
-
};
|
|
376
326
|
|
|
377
327
|
return (
|
|
378
|
-
<
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
resultState.queryBuilderState.fetchStructureState
|
|
383
|
-
.implementation instanceof QueryBuilderTDSState
|
|
384
|
-
) ||
|
|
385
|
-
!resultState.queryBuilderState.isQuerySupported ||
|
|
386
|
-
!resultState.mousedOverCell
|
|
387
|
-
}
|
|
388
|
-
menuProps={{ elevation: 7 }}
|
|
389
|
-
className={clsx('query-builder__result__tds-grid', {
|
|
390
|
-
'ag-theme-balham': !darkMode,
|
|
391
|
-
'ag-theme-balham-dark': darkMode,
|
|
328
|
+
<div
|
|
329
|
+
className={clsx('query-builder__result__values__table__cell', {
|
|
330
|
+
'query-builder__result__values__table__cell--active':
|
|
331
|
+
cellInFilteredResults,
|
|
392
332
|
})}
|
|
333
|
+
onMouseDown={(event) => mouseDown(event)}
|
|
334
|
+
onMouseUp={(event) => mouseUp(event)}
|
|
335
|
+
onMouseOver={(event) => mouseOver(event)}
|
|
393
336
|
>
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
>
|
|
403
|
-
{cellValueUrlLink ? (
|
|
404
|
-
<a href={cellValueUrlLink} target="_blank" rel="noreferrer">
|
|
405
|
-
{cellValueUrlLink}
|
|
406
|
-
</a>
|
|
407
|
-
) : (
|
|
408
|
-
<span>{formattedCellValue()}</span>
|
|
409
|
-
)}
|
|
410
|
-
</div>
|
|
411
|
-
</ContextMenu>
|
|
337
|
+
{cellValueUrlLink ? (
|
|
338
|
+
<a href={cellValueUrlLink} target="_blank" rel="noreferrer">
|
|
339
|
+
{cellValueUrlLink}
|
|
340
|
+
</a>
|
|
341
|
+
) : (
|
|
342
|
+
<span>{formattedCellValue()}</span>
|
|
343
|
+
)}
|
|
344
|
+
</div>
|
|
412
345
|
);
|
|
413
346
|
},
|
|
414
347
|
);
|
|
415
348
|
|
|
349
|
+
// ---------------------------------------------------------------------------
|
|
350
|
+
// Simple-grid keyboard shortcut helpers (extracted to avoid >4-level nesting)
|
|
351
|
+
// ---------------------------------------------------------------------------
|
|
352
|
+
|
|
353
|
+
type SimpleGridRow = { values: (string | number | boolean | null)[] };
|
|
354
|
+
|
|
355
|
+
/** Build TDSResultCellData[] for all cells in the grid. */
|
|
356
|
+
const buildAllCells = (
|
|
357
|
+
columns: string[],
|
|
358
|
+
rows: SimpleGridRow[],
|
|
359
|
+
): TDSResultCellData[] => {
|
|
360
|
+
const cells: TDSResultCellData[] = [];
|
|
361
|
+
rows.forEach((row, rowIndex) => {
|
|
362
|
+
columns.forEach((colName, colIndex) => {
|
|
363
|
+
cells.push({
|
|
364
|
+
value: row.values[colIndex],
|
|
365
|
+
columnName: colName,
|
|
366
|
+
coordinates: { rowIndex, colIndex },
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
return cells;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/** Build TDSResultCellData[] for specific column indices across all rows. */
|
|
374
|
+
const buildColumnCells = (
|
|
375
|
+
columns: string[],
|
|
376
|
+
rows: SimpleGridRow[],
|
|
377
|
+
colIndices: number[],
|
|
378
|
+
): TDSResultCellData[] => {
|
|
379
|
+
const cells: TDSResultCellData[] = [];
|
|
380
|
+
rows.forEach((row, ri) => {
|
|
381
|
+
colIndices.forEach((ci) => {
|
|
382
|
+
cells.push({
|
|
383
|
+
value: row.values[ci],
|
|
384
|
+
columnName: columns[ci] ?? '',
|
|
385
|
+
coordinates: { rowIndex: ri, colIndex: ci },
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
return cells;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/** Build TDSResultCellData[] for specific row indices across all columns. */
|
|
393
|
+
const buildRowCells = (
|
|
394
|
+
columns: string[],
|
|
395
|
+
rows: SimpleGridRow[],
|
|
396
|
+
rowIndices: number[],
|
|
397
|
+
): TDSResultCellData[] => {
|
|
398
|
+
const cells: TDSResultCellData[] = [];
|
|
399
|
+
rowIndices.forEach((ri) => {
|
|
400
|
+
columns.forEach((cn, ci) => {
|
|
401
|
+
cells.push({
|
|
402
|
+
value: rows[ri]?.values[ci],
|
|
403
|
+
columnName: cn,
|
|
404
|
+
coordinates: { rowIndex: ri, colIndex: ci },
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
return cells;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
/** Resolve the distinct column indices to select for Ctrl+Space. */
|
|
412
|
+
const resolveColumnIndices = (
|
|
413
|
+
selectedCells: TDSResultCellData[],
|
|
414
|
+
fallbackColIndex: number,
|
|
415
|
+
): number[] =>
|
|
416
|
+
selectedCells.length > 0
|
|
417
|
+
? [...new Set(selectedCells.map((c) => c.coordinates.colIndex))]
|
|
418
|
+
: [fallbackColIndex];
|
|
419
|
+
|
|
420
|
+
/** Resolve the distinct row indices to select for Shift+Space. */
|
|
421
|
+
const resolveRowIndices = (
|
|
422
|
+
selectedCells: TDSResultCellData[],
|
|
423
|
+
fallbackRowIndex: number,
|
|
424
|
+
): number[] =>
|
|
425
|
+
selectedCells.length > 0
|
|
426
|
+
? [...new Set(selectedCells.map((c) => c.coordinates.rowIndex))]
|
|
427
|
+
: [fallbackRowIndex];
|
|
428
|
+
|
|
429
|
+
/** Apply a cell selection to the result state if non-empty. */
|
|
430
|
+
const applySelection = (
|
|
431
|
+
cells: TDSResultCellData[],
|
|
432
|
+
resultState: QueryBuilderResultState,
|
|
433
|
+
): void => {
|
|
434
|
+
if (cells.length > 0) {
|
|
435
|
+
resultState.setSelectedCells(cells);
|
|
436
|
+
resultState.setMouseOverCell(cells[0] ?? null);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
|
|
416
440
|
export const QueryBuilderTDSSimpleGridResult = observer(
|
|
417
441
|
(props: {
|
|
418
442
|
executionResult: TDSExecutionResult;
|
|
419
443
|
queryBuilderState: QueryBuilderState;
|
|
444
|
+
/**
|
|
445
|
+
* Whether to show the cell-selection summary statistics bar below the grid.
|
|
446
|
+
* Defaults to `true`.
|
|
447
|
+
*/
|
|
448
|
+
showSummaryStats?: boolean;
|
|
420
449
|
}) => {
|
|
421
|
-
const {
|
|
450
|
+
const {
|
|
451
|
+
executionResult,
|
|
452
|
+
queryBuilderState,
|
|
453
|
+
showSummaryStats = true,
|
|
454
|
+
} = props;
|
|
455
|
+
const applicationStore = useApplicationStore();
|
|
422
456
|
const resultState = queryBuilderState.resultState;
|
|
423
457
|
const darkMode =
|
|
424
458
|
!queryBuilderState.applicationStore.layoutService
|
|
@@ -441,13 +475,129 @@ export const QueryBuilderTDSSimpleGridResult = observer(
|
|
|
441
475
|
}) as DataGridColumnDefinition,
|
|
442
476
|
);
|
|
443
477
|
|
|
478
|
+
// Simple grid: no AG Grid cell-range API, so we keep selectedCells in
|
|
479
|
+
// MobX and pass a null gridApiRef. The hook falls back to reading from
|
|
480
|
+
// selectedCells directly when the gridApiRef is null.
|
|
481
|
+
const selectedCells = resultState.selectedCells;
|
|
482
|
+
const columnTypes = new Map<string, string | undefined>(
|
|
483
|
+
executionResult.builder.columns.map((c) => [c.name, c.type]),
|
|
484
|
+
);
|
|
485
|
+
const simpleGridApiRef = useRef<null>(null);
|
|
486
|
+
const cellSelectionStats = useAsyncCellSelectionStats(
|
|
487
|
+
selectedCells.length, // version counter — changes when selection changes
|
|
488
|
+
columnTypes,
|
|
489
|
+
simpleGridApiRef,
|
|
490
|
+
selectedCells, // fallback cells for when gridApiRef is null
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
const gridContainerRef = useRef<HTMLDivElement>(null);
|
|
494
|
+
// Track the last cell the user clicked so keyboard shortcuts know
|
|
495
|
+
// which row/column to act on (AG Grid internal focus is not used here
|
|
496
|
+
// because we move DOM focus to the container div, not into a grid cell).
|
|
497
|
+
const lastClickedCellRef = useRef<{
|
|
498
|
+
colName: string;
|
|
499
|
+
colIndex: number;
|
|
500
|
+
rowIndex: number;
|
|
501
|
+
} | null>(null);
|
|
502
|
+
|
|
503
|
+
// All keyboard shortcuts handled in the native capture-phase listener so
|
|
504
|
+
// they fire reliably when the container div has focus.
|
|
505
|
+
useEffect(() => {
|
|
506
|
+
const el = gridContainerRef.current;
|
|
507
|
+
if (!el) {
|
|
508
|
+
return undefined;
|
|
509
|
+
}
|
|
510
|
+
const handler = (e: KeyboardEvent): void => {
|
|
511
|
+
const columns = executionResult.result.columns;
|
|
512
|
+
const rows = executionResult.result.rows;
|
|
513
|
+
|
|
514
|
+
// Ctrl+A — select all cells
|
|
515
|
+
if (e.ctrlKey && e.code === 'KeyA') {
|
|
516
|
+
e.preventDefault();
|
|
517
|
+
// eslint-disable-next-line no-console
|
|
518
|
+
console.debug(
|
|
519
|
+
`[TDS Simple Grid] Ctrl+A → selecting all: ${rows.length} rows × ${columns.length} columns`,
|
|
520
|
+
);
|
|
521
|
+
const allCells = buildAllCells(columns, rows);
|
|
522
|
+
applySelection(allCells, resultState);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// Ctrl+Space — select entire columns for all columns in the current selection.
|
|
527
|
+
if (e.ctrlKey && e.code === 'Space') {
|
|
528
|
+
e.preventDefault();
|
|
529
|
+
const cell = lastClickedCellRef.current;
|
|
530
|
+
if (!cell) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const colIndices = resolveColumnIndices(
|
|
534
|
+
resultState.selectedCells,
|
|
535
|
+
cell.colIndex,
|
|
536
|
+
);
|
|
537
|
+
// eslint-disable-next-line no-console
|
|
538
|
+
console.debug(
|
|
539
|
+
`[TDS Simple Grid] Ctrl+Space → selecting ${colIndices.length} column(s), ${rows.length} rows`,
|
|
540
|
+
);
|
|
541
|
+
const newCells = buildColumnCells(columns, rows, colIndices);
|
|
542
|
+
applySelection(newCells, resultState);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// Shift+Space — select entire rows for all rows in the current selection.
|
|
547
|
+
if (e.shiftKey && e.code === 'Space') {
|
|
548
|
+
e.preventDefault();
|
|
549
|
+
const cell = lastClickedCellRef.current;
|
|
550
|
+
if (!cell) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const rowIndices = resolveRowIndices(
|
|
554
|
+
resultState.selectedCells,
|
|
555
|
+
cell.rowIndex,
|
|
556
|
+
);
|
|
557
|
+
// eslint-disable-next-line no-console
|
|
558
|
+
console.debug(
|
|
559
|
+
`[TDS Simple Grid] Shift+Space → selecting ${rowIndices.length} row(s), ${columns.length} columns`,
|
|
560
|
+
);
|
|
561
|
+
const newCells = buildRowCells(columns, rows, rowIndices);
|
|
562
|
+
applySelection(newCells, resultState);
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
el.addEventListener('keydown', handler, { capture: true });
|
|
566
|
+
return () =>
|
|
567
|
+
el.removeEventListener('keydown', handler, { capture: true });
|
|
568
|
+
}, [
|
|
569
|
+
executionResult.result.columns,
|
|
570
|
+
executionResult.result.rows,
|
|
571
|
+
resultState,
|
|
572
|
+
]);
|
|
573
|
+
|
|
574
|
+
const getContextMenuItems = useCallback(
|
|
575
|
+
(
|
|
576
|
+
params: DataGridGetContextMenuItemsParams<TDSRowDataType>,
|
|
577
|
+
): (DataGridDefaultMenuItem | DataGridMenuItemDef)[] =>
|
|
578
|
+
buildTDSGridContextMenuItems(
|
|
579
|
+
params,
|
|
580
|
+
applicationStore,
|
|
581
|
+
resultState,
|
|
582
|
+
queryBuilderState.applicationStore.alertUnhandledError,
|
|
583
|
+
),
|
|
584
|
+
[
|
|
585
|
+
applicationStore,
|
|
586
|
+
resultState,
|
|
587
|
+
queryBuilderState.applicationStore.alertUnhandledError,
|
|
588
|
+
],
|
|
589
|
+
);
|
|
590
|
+
|
|
444
591
|
return (
|
|
445
592
|
<div
|
|
446
593
|
data-testid={QUERY_BUILDER_TEST_ID.QUERY_BUILDER_RESULT_VALUES_TDS}
|
|
447
594
|
className="query-builder__result__values__table"
|
|
448
595
|
>
|
|
449
596
|
<div
|
|
597
|
+
ref={gridContainerRef}
|
|
598
|
+
tabIndex={-1}
|
|
450
599
|
className={clsx('query-builder__result__tds-grid', {
|
|
600
|
+
'query-builder__result__tds-grid--with-stats-bar': showSummaryStats,
|
|
451
601
|
'ag-theme-balham': !darkMode,
|
|
452
602
|
'ag-theme-balham-dark': darkMode,
|
|
453
603
|
})}
|
|
@@ -457,11 +607,6 @@ export const QueryBuilderTDSSimpleGridResult = observer(
|
|
|
457
607
|
gridOptions={{
|
|
458
608
|
suppressScrollOnNewData: true,
|
|
459
609
|
getRowId: (data) => `${data.data.rowNumber}`,
|
|
460
|
-
rowSelection: {
|
|
461
|
-
mode: 'multiRow',
|
|
462
|
-
checkboxes: false,
|
|
463
|
-
headerCheckbox: false,
|
|
464
|
-
},
|
|
465
610
|
}}
|
|
466
611
|
// NOTE: when column definition changed, we need to force refresh the cell to make sure the cell renderer is updated
|
|
467
612
|
// See https://stackoverflow.com/questions/56341073/how-to-refresh-an-ag-grid-when-a-change-occurs-inside-a-custom-cell-renderer-com
|
|
@@ -469,9 +614,37 @@ export const QueryBuilderTDSSimpleGridResult = observer(
|
|
|
469
614
|
params.api.refreshCells({ force: true });
|
|
470
615
|
}}
|
|
471
616
|
suppressFieldDotNotation={true}
|
|
472
|
-
suppressContextMenu={false}
|
|
473
617
|
columnDefs={colDefs}
|
|
618
|
+
getContextMenuItems={(params) => getContextMenuItems(params)}
|
|
619
|
+
onCellClicked={(event) => {
|
|
620
|
+
// Skip clicks originated from keyboard shortcuts (Ctrl/Shift+Space fires
|
|
621
|
+
// a synthetic click that would reset the range selection we just set).
|
|
622
|
+
const e = event.event as MouseEvent | undefined;
|
|
623
|
+
if (e?.ctrlKey || e?.shiftKey) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const colName = event.column.getColId();
|
|
627
|
+
const colIndex = executionResult.result.columns.indexOf(colName);
|
|
628
|
+
// eslint-disable-next-line no-console
|
|
629
|
+
console.debug(
|
|
630
|
+
`[TDS Simple Grid] onCellClicked: col=${colName} row=${event.rowIndex}`,
|
|
631
|
+
);
|
|
632
|
+
lastClickedCellRef.current = {
|
|
633
|
+
colName,
|
|
634
|
+
colIndex,
|
|
635
|
+
rowIndex: event.rowIndex ?? 0,
|
|
636
|
+
};
|
|
637
|
+
gridContainerRef.current?.focus({ preventScroll: true });
|
|
638
|
+
}}
|
|
474
639
|
/>
|
|
640
|
+
{showSummaryStats && cellSelectionStats !== undefined && (
|
|
641
|
+
<QueryBuilderTDSCellSelectionStatsBar
|
|
642
|
+
stats={cellSelectionStats.stats}
|
|
643
|
+
cellCount={cellSelectionStats.cellCount}
|
|
644
|
+
countReady={cellSelectionStats.countReady}
|
|
645
|
+
darkMode={darkMode}
|
|
646
|
+
/>
|
|
647
|
+
)}
|
|
475
648
|
</div>
|
|
476
649
|
</div>
|
|
477
650
|
);
|
|
@@ -224,7 +224,16 @@ export class QueryBuilderResultState {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
addSelectedCell(val: TDSResultCellData): void {
|
|
227
|
-
|
|
227
|
+
// Deduplicate by coordinates — Ctrl+clicking an already-selected cell
|
|
228
|
+
// must not inflate the count or corrupt statistics.
|
|
229
|
+
const alreadyPresent = this.selectedCells.some(
|
|
230
|
+
(c) =>
|
|
231
|
+
c.coordinates.rowIndex === val.coordinates.rowIndex &&
|
|
232
|
+
c.coordinates.colIndex === val.coordinates.colIndex,
|
|
233
|
+
);
|
|
234
|
+
if (!alreadyPresent) {
|
|
235
|
+
this.selectedCells.push(val);
|
|
236
|
+
}
|
|
228
237
|
}
|
|
229
238
|
|
|
230
239
|
setSelectedCells(val: TDSResultCellData[]): void {
|
package/tsconfig.json
CHANGED
|
@@ -62,6 +62,10 @@
|
|
|
62
62
|
"./src/components/QueryBuilderComponentElement.ts",
|
|
63
63
|
"./src/components/QueryBuilder_LegendApplicationPlugin.ts",
|
|
64
64
|
"./src/components/QuerySetupUtils.ts",
|
|
65
|
+
"./src/components/result/tds/QueryBuilderTDSAsyncCellSelectionStats.ts",
|
|
66
|
+
"./src/components/result/tds/QueryBuilderTDSCellSelectionStats.ts",
|
|
67
|
+
"./src/components/result/tds/QueryBuilderTDSGridKeyboardShortcuts.ts",
|
|
68
|
+
"./src/components/result/tds/QueryBuilderTDSGridShared.ts",
|
|
65
69
|
"./src/components/shared/CustomDatePickerHelper.ts",
|
|
66
70
|
"./src/components/shared/QueryBuilderFilterHelper.ts",
|
|
67
71
|
"./src/graph/QueryBuilderMetaModelConst.ts",
|
|
@@ -273,6 +277,7 @@
|
|
|
273
277
|
"./src/components/lineage/LineageViewer.tsx",
|
|
274
278
|
"./src/components/lineage/PropertyOwnerNode.tsx",
|
|
275
279
|
"./src/components/result/QueryBuilderResultPanel.tsx",
|
|
280
|
+
"./src/components/result/tds/QueryBuilderTDSCellSelectionStatsBar.tsx",
|
|
276
281
|
"./src/components/result/tds/QueryBuilderTDSGridResult.tsx",
|
|
277
282
|
"./src/components/result/tds/QueryBuilderTDSResultShared.tsx",
|
|
278
283
|
"./src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx",
|