@finos/legend-data-cube 0.0.2 → 0.0.4

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.
Files changed (108) hide show
  1. package/lib/components/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -1
  2. package/lib/components/editor/DataCubeEditorColumnPropertiesPanel.js +7 -4
  3. package/lib/components/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -1
  4. package/lib/components/editor/DataCubeEditorGeneralPropertiesPanel.d.ts.map +1 -1
  5. package/lib/components/editor/DataCubeEditorGeneralPropertiesPanel.js +10 -15
  6. package/lib/components/editor/DataCubeEditorGeneralPropertiesPanel.js.map +1 -1
  7. package/lib/components/editor/DataCubeEditorSortsPanel.d.ts.map +1 -1
  8. package/lib/components/editor/DataCubeEditorSortsPanel.js +9 -9
  9. package/lib/components/editor/DataCubeEditorSortsPanel.js.map +1 -1
  10. package/lib/index.css +1 -1
  11. package/lib/package.json +1 -1
  12. package/lib/stores/core/DataCubeConfiguration.d.ts +13 -7
  13. package/lib/stores/core/DataCubeConfiguration.d.ts.map +1 -1
  14. package/lib/stores/core/DataCubeConfiguration.js +25 -15
  15. package/lib/stores/core/DataCubeConfiguration.js.map +1 -1
  16. package/lib/stores/core/DataCubeConfigurationBuilder.d.ts.map +1 -1
  17. package/lib/stores/core/DataCubeConfigurationBuilder.js +3 -2
  18. package/lib/stores/core/DataCubeConfigurationBuilder.js.map +1 -1
  19. package/lib/stores/core/DataCubeQueryBuilder.d.ts.map +1 -1
  20. package/lib/stores/core/DataCubeQueryBuilder.js +23 -17
  21. package/lib/stores/core/DataCubeQueryBuilder.js.map +1 -1
  22. package/lib/stores/core/DataCubeQueryBuilderUtils.js +2 -2
  23. package/lib/stores/core/DataCubeQueryBuilderUtils.js.map +1 -1
  24. package/lib/stores/core/DataCubeQueryEngine.d.ts +19 -11
  25. package/lib/stores/core/DataCubeQueryEngine.d.ts.map +1 -1
  26. package/lib/stores/core/DataCubeQueryEngine.js +21 -14
  27. package/lib/stores/core/DataCubeQueryEngine.js.map +1 -1
  28. package/lib/stores/core/DataCubeQuerySnapshot.d.ts +1 -1
  29. package/lib/stores/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -1
  30. package/lib/stores/core/DataCubeQuerySnapshotBuilder.js +131 -80
  31. package/lib/stores/core/DataCubeQuerySnapshotBuilder.js.map +1 -1
  32. package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.d.ts +6 -7
  33. package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.d.ts.map +1 -1
  34. package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.js +27 -91
  35. package/lib/stores/core/DataCubeQuerySnapshotBuilderUtils.js.map +1 -1
  36. package/lib/stores/core/DataCubeQuerySnapshotManager.js +1 -1
  37. package/lib/stores/core/DataCubeQuerySnapshotManager.js.map +1 -1
  38. package/lib/stores/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts +1 -2
  39. package/lib/stores/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts.map +1 -1
  40. package/lib/stores/editor/DataCubeEditorGeneralPropertiesPanelState.js +4 -6
  41. package/lib/stores/editor/DataCubeEditorGeneralPropertiesPanelState.js.map +1 -1
  42. package/lib/stores/editor/DataCubeEditorMutableConfiguration.d.ts +15 -8
  43. package/lib/stores/editor/DataCubeEditorMutableConfiguration.d.ts.map +1 -1
  44. package/lib/stores/editor/DataCubeEditorMutableConfiguration.js +50 -26
  45. package/lib/stores/editor/DataCubeEditorMutableConfiguration.js.map +1 -1
  46. package/lib/stores/editor/DataCubeEditorPivotLayoutPanelState.d.ts +30 -0
  47. package/lib/stores/editor/DataCubeEditorPivotLayoutPanelState.d.ts.map +1 -0
  48. package/lib/stores/editor/DataCubeEditorPivotLayoutPanelState.js +43 -0
  49. package/lib/stores/editor/DataCubeEditorPivotLayoutPanelState.js.map +1 -0
  50. package/lib/stores/editor/DataCubeEditorSortsPanelState.d.ts +3 -3
  51. package/lib/stores/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -1
  52. package/lib/stores/editor/DataCubeEditorSortsPanelState.js +11 -11
  53. package/lib/stores/editor/DataCubeEditorSortsPanelState.js.map +1 -1
  54. package/lib/stores/editor/DataCubeEditorState.d.ts +2 -0
  55. package/lib/stores/editor/DataCubeEditorState.d.ts.map +1 -1
  56. package/lib/stores/editor/DataCubeEditorState.js +5 -0
  57. package/lib/stores/editor/DataCubeEditorState.js.map +1 -1
  58. package/lib/stores/extend/DataCubeExtendManagerState.js +1 -1
  59. package/lib/stores/extend/DataCubeExtendManagerState.js.map +1 -1
  60. package/lib/stores/grid/DataCubeGridClientEngine.d.ts.map +1 -1
  61. package/lib/stores/grid/DataCubeGridClientEngine.js +41 -36
  62. package/lib/stores/grid/DataCubeGridClientEngine.js.map +1 -1
  63. package/lib/stores/grid/DataCubeGridConfigurationBuilder.d.ts.map +1 -1
  64. package/lib/stores/grid/DataCubeGridConfigurationBuilder.js +39 -3
  65. package/lib/stores/grid/DataCubeGridConfigurationBuilder.js.map +1 -1
  66. package/lib/stores/grid/DataCubeGridControllerState.d.ts +6 -3
  67. package/lib/stores/grid/DataCubeGridControllerState.d.ts.map +1 -1
  68. package/lib/stores/grid/DataCubeGridControllerState.js +35 -17
  69. package/lib/stores/grid/DataCubeGridControllerState.js.map +1 -1
  70. package/lib/stores/grid/DataCubeGridMenuBuilder.d.ts.map +1 -1
  71. package/lib/stores/grid/DataCubeGridMenuBuilder.js +52 -31
  72. package/lib/stores/grid/DataCubeGridMenuBuilder.js.map +1 -1
  73. package/lib/stores/grid/DataCubeGridQueryBuilder.d.ts.map +1 -1
  74. package/lib/stores/grid/DataCubeGridQueryBuilder.js +3 -3
  75. package/lib/stores/grid/DataCubeGridQueryBuilder.js.map +1 -1
  76. package/lib/stores/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -1
  77. package/lib/stores/grid/DataCubeGridQuerySnapshotBuilder.js +14 -7
  78. package/lib/stores/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -1
  79. package/lib/stores/grid/DataCubeGridState.d.ts.map +1 -1
  80. package/lib/stores/grid/DataCubeGridState.js +9 -5
  81. package/lib/stores/grid/DataCubeGridState.js.map +1 -1
  82. package/package.json +2 -2
  83. package/src/components/editor/DataCubeEditorColumnPropertiesPanel.tsx +11 -5
  84. package/src/components/editor/DataCubeEditorGeneralPropertiesPanel.tsx +94 -101
  85. package/src/components/editor/DataCubeEditorSortsPanel.tsx +12 -10
  86. package/src/stores/core/DataCubeConfiguration.ts +33 -15
  87. package/src/stores/core/DataCubeConfigurationBuilder.ts +3 -2
  88. package/src/stores/core/DataCubeQueryBuilder.ts +33 -20
  89. package/src/stores/core/DataCubeQueryBuilderUtils.ts +2 -2
  90. package/src/stores/core/DataCubeQueryEngine.ts +22 -12
  91. package/src/stores/core/DataCubeQuerySnapshot.ts +1 -1
  92. package/src/stores/core/DataCubeQuerySnapshotBuilder.ts +135 -120
  93. package/src/stores/core/DataCubeQuerySnapshotBuilderUtils.ts +33 -107
  94. package/src/stores/core/DataCubeQuerySnapshotManager.ts +1 -1
  95. package/src/stores/editor/DataCubeEditorGeneralPropertiesPanelState.ts +6 -9
  96. package/src/stores/editor/DataCubeEditorMutableConfiguration.ts +68 -28
  97. package/src/stores/editor/DataCubeEditorPivotLayoutPanelState.ts +71 -0
  98. package/src/stores/editor/DataCubeEditorSortsPanelState.ts +11 -11
  99. package/src/stores/editor/DataCubeEditorState.tsx +5 -0
  100. package/src/stores/extend/DataCubeExtendManagerState.tsx +1 -1
  101. package/src/stores/grid/DataCubeGridClientEngine.ts +52 -48
  102. package/src/stores/grid/DataCubeGridConfigurationBuilder.tsx +45 -4
  103. package/src/stores/grid/DataCubeGridControllerState.ts +44 -20
  104. package/src/stores/grid/DataCubeGridMenuBuilder.tsx +81 -52
  105. package/src/stores/grid/DataCubeGridQueryBuilder.ts +3 -7
  106. package/src/stores/grid/DataCubeGridQuerySnapshotBuilder.ts +20 -7
  107. package/src/stores/grid/DataCubeGridState.ts +9 -5
  108. package/tsconfig.json +1 -0
@@ -17,6 +17,7 @@
17
17
  import {
18
18
  guaranteeNonNullable,
19
19
  isNonNullable,
20
+ uniq,
20
21
  uniqBy,
21
22
  } from '@finos/legend-shared';
22
23
  import { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
@@ -28,7 +29,7 @@ import {
28
29
  } from '../core/DataCubeQuerySnapshot.js';
29
30
  import { DataCubeQuerySnapshotController } from '../core/DataCubeQuerySnapshotManager.js';
30
31
  import {
31
- type DataCubeQuerySortOperator,
32
+ type DataCubeQuerySortDirection,
32
33
  type DataCubeColumnPinPlacement,
33
34
  DataCubeColumnKind,
34
35
  DataCubeQueryFilterGroupOperator,
@@ -50,6 +51,7 @@ import {
50
51
  type DataCubeFilterEditorTree,
51
52
  type DataCubeFilterEditorTreeNode,
52
53
  } from '../core/filter/DataCubeQueryFilterEditorState.js';
54
+ import { _pruneExpandedPaths } from '../core/DataCubeQuerySnapshotBuilderUtils.js';
53
55
 
54
56
  /**
55
57
  * This query editor state is responsible for capturing updates to the data cube query
@@ -244,11 +246,8 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
244
246
  if (isPivotResultColumnName(colName)) {
245
247
  const baseColumnName = getPivotResultColumnBaseColumnName(colName);
246
248
  const columnConfiguration = this.getColumnConfiguration(baseColumnName);
247
- if (
248
- columnConfiguration &&
249
- !columnConfiguration.excludedFromHorizontalPivot
250
- ) {
251
- columnConfiguration.excludedFromHorizontalPivot = true;
249
+ if (columnConfiguration && !columnConfiguration.excludedFromPivot) {
250
+ columnConfiguration.excludedFromPivot = true;
252
251
  this.applyChanges();
253
252
  }
254
253
  }
@@ -256,8 +255,8 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
256
255
 
257
256
  includeColumnInHorizontalPivot(colName: string) {
258
257
  const columnConfiguration = this.getColumnConfiguration(colName);
259
- if (columnConfiguration?.excludedFromHorizontalPivot) {
260
- columnConfiguration.excludedFromHorizontalPivot = false;
258
+ if (columnConfiguration?.excludedFromPivot) {
259
+ columnConfiguration.excludedFromPivot = false;
261
260
  this.applyChanges();
262
261
  }
263
262
  }
@@ -311,6 +310,26 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
311
310
  this.applyChanges();
312
311
  }
313
312
 
313
+ collapseAllPaths() {
314
+ this.view.grid.client.collapseAll();
315
+ this.configuration.pivotLayout.expandedPaths = [];
316
+ this.applyChanges();
317
+ }
318
+
319
+ expandPath(path: string) {
320
+ this.configuration.pivotLayout.expandedPaths = uniq([
321
+ ...this.configuration.pivotLayout.expandedPaths,
322
+ path,
323
+ ]).sort();
324
+ this.applyChanges();
325
+ }
326
+
327
+ collapsePath(path: string) {
328
+ this.configuration.pivotLayout.expandedPaths =
329
+ this.configuration.pivotLayout.expandedPaths.filter((p) => p !== path);
330
+ this.applyChanges();
331
+ }
332
+
314
333
  // --------------------------------- SORT ---------------------------------
315
334
 
316
335
  sortColumns: DataCubeQuerySnapshotSortColumn[] = [];
@@ -329,38 +348,38 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
329
348
 
330
349
  private getActionableSortColumn(
331
350
  colName: string,
332
- operation: DataCubeQuerySortOperator,
351
+ direction: DataCubeQuerySortDirection,
333
352
  ) {
334
353
  const column = this.getSortableColumn(colName);
335
354
  if (!column) {
336
355
  return undefined;
337
356
  }
338
357
  const sortColumn = this.sortColumns.find((col) => col.name === colName);
339
- if (sortColumn && sortColumn.operation !== operation) {
358
+ if (sortColumn && sortColumn.direction !== direction) {
340
359
  return sortColumn;
341
360
  }
342
361
  if (!sortColumn) {
343
- return { ...column, operation };
362
+ return { ...column, direction };
344
363
  }
345
364
  return undefined;
346
365
  }
347
366
 
348
- setSortByColumn(colName: string, operation: DataCubeQuerySortOperator) {
349
- const column = this.getActionableSortColumn(colName, operation);
367
+ setSortByColumn(colName: string, direction: DataCubeQuerySortDirection) {
368
+ const column = this.getActionableSortColumn(colName, direction);
350
369
  if (!column) {
351
370
  return;
352
371
  }
353
- column.operation = operation;
372
+ column.direction = direction;
354
373
  this.sortColumns = [column];
355
374
  this.applyChanges();
356
375
  }
357
376
 
358
- addSortByColumn(colName: string, operation: DataCubeQuerySortOperator) {
359
- const column = this.getActionableSortColumn(colName, operation);
377
+ addSortByColumn(colName: string, direction: DataCubeQuerySortDirection) {
378
+ const column = this.getActionableSortColumn(colName, direction);
360
379
  if (!column) {
361
380
  return;
362
381
  }
363
- column.operation = operation;
382
+ column.direction = direction;
364
383
  this.sortColumns = [...this.sortColumns, column];
365
384
  this.applyChanges();
366
385
  }
@@ -411,11 +430,16 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
411
430
  this.menuBuilder = generateMenuBuilder(this);
412
431
  }
413
432
 
414
- private propagateChanges() {
433
+ private propagateChanges(baseSnapshot: DataCubeQuerySnapshot) {
415
434
  this.verticalPivotColumns = this.verticalPivotColumns.filter(
416
435
  (col) =>
417
436
  !this.horizontalPivotColumns.find((column) => column.name === col.name),
418
437
  );
438
+ this.configuration.pivotLayout.expandedPaths = _pruneExpandedPaths(
439
+ baseSnapshot.data.groupBy?.columns ?? [],
440
+ this.verticalPivotColumns,
441
+ this.configuration.pivotLayout.expandedPaths,
442
+ );
419
443
 
420
444
  this.selectColumns = uniqBy(
421
445
  [
@@ -459,11 +483,11 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
459
483
  }
460
484
 
461
485
  private applyChanges() {
462
- this.propagateChanges();
463
-
464
486
  const baseSnapshot = guaranteeNonNullable(this.getLatestSnapshot());
465
487
  const snapshot = baseSnapshot.clone();
466
488
 
489
+ this.propagateChanges(baseSnapshot);
490
+
467
491
  snapshot.data.configuration = DataCubeConfiguration.serialization.toJson(
468
492
  this.configuration,
469
493
  );
@@ -21,7 +21,7 @@ import type {
21
21
  } from '@ag-grid-community/core';
22
22
  import { WIP_GridMenuItem } from '../../components/grid/DataCubeGridShared.js';
23
23
  import {
24
- DataCubeQuerySortOperator,
24
+ DataCubeQuerySortDirection,
25
25
  DataCubeColumnPinPlacement,
26
26
  DEFAULT_COLUMN_MIN_WIDTH,
27
27
  DataCubeColumnKind,
@@ -39,6 +39,7 @@ import type { DataCubeGridControllerState } from './DataCubeGridControllerState.
39
39
  import {
40
40
  DataCubeGridClientExportFormat,
41
41
  INTERNAL__GRID_CLIENT_MISSING_VALUE,
42
+ INTERNAL__GRID_CLIENT_TREE_COLUMN_ID,
42
43
  } from './DataCubeGridClientEngine.js';
43
44
  import { PRIMITIVE_TYPE } from '@finos/legend-graph';
44
45
  import type { DataCubeColumnConfiguration } from '../core/DataCubeConfiguration.js';
@@ -204,7 +205,7 @@ export function generateMenuBuilder(
204
205
  action: () =>
205
206
  controller.setSortByColumn(
206
207
  columnName,
207
- DataCubeQuerySortOperator.ASCENDING,
208
+ DataCubeQuerySortDirection.ASCENDING,
208
209
  ),
209
210
  },
210
211
  {
@@ -218,7 +219,7 @@ export function generateMenuBuilder(
218
219
  action: () =>
219
220
  controller.setSortByColumn(
220
221
  columnName,
221
- DataCubeQuerySortOperator.DESCENDING,
222
+ DataCubeQuerySortDirection.DESCENDING,
222
223
  ),
223
224
  },
224
225
  {
@@ -241,13 +242,13 @@ export function generateMenuBuilder(
241
242
  controller.sortColumns.find(
242
243
  (col) =>
243
244
  col.name === columnName &&
244
- col.operation === DataCubeQuerySortOperator.ASCENDING,
245
+ col.direction === DataCubeQuerySortDirection.ASCENDING,
245
246
  ),
246
247
  ),
247
248
  action: () =>
248
249
  controller.addSortByColumn(
249
250
  columnName,
250
- DataCubeQuerySortOperator.ASCENDING,
251
+ DataCubeQuerySortDirection.ASCENDING,
251
252
  ),
252
253
  },
253
254
  {
@@ -262,13 +263,13 @@ export function generateMenuBuilder(
262
263
  controller.sortColumns.find(
263
264
  (col) =>
264
265
  col.name === columnName &&
265
- col.operation === DataCubeQuerySortOperator.DESCENDING,
266
+ col.direction === DataCubeQuerySortDirection.DESCENDING,
266
267
  ),
267
268
  ),
268
269
  action: () =>
269
270
  controller.addSortByColumn(
270
271
  columnName,
271
- DataCubeQuerySortOperator.DESCENDING,
272
+ DataCubeQuerySortDirection.DESCENDING,
272
273
  ),
273
274
  },
274
275
  {
@@ -290,56 +291,73 @@ export function generateMenuBuilder(
290
291
  ] satisfies (string | MenuItemDef)[];
291
292
 
292
293
  let newFilterMenu: MenuItemDef[] = [];
293
- if (columnConfiguration && column && value !== undefined) {
294
- if (value !== INTERNAL__GRID_CLIENT_MISSING_VALUE) {
295
- const filterValue = toFilterValue(value, columnConfiguration);
296
- const filterOperations = getColumnFilterOperations(columnConfiguration);
294
+ if (column && value !== undefined) {
295
+ let _columnConfiguration = columnConfiguration;
296
+ if (
297
+ column.getColId() === INTERNAL__GRID_CLIENT_TREE_COLUMN_ID &&
298
+ controller.verticalPivotColumns.length &&
299
+ 'node' in params &&
300
+ params.node
301
+ ) {
302
+ const groupByColumn =
303
+ controller.verticalPivotColumns[params.node.level];
304
+ _columnConfiguration = controller.getColumnConfiguration(
305
+ groupByColumn?.name,
306
+ );
307
+ }
308
+
309
+ if (_columnConfiguration) {
310
+ if (value !== INTERNAL__GRID_CLIENT_MISSING_VALUE) {
311
+ const filterValue = toFilterValue(value, _columnConfiguration);
312
+ const filterOperations =
313
+ getColumnFilterOperations(_columnConfiguration);
297
314
 
298
- if (
299
- filterOperations.length &&
300
- filterOperations.includes(DataCubeQueryFilterOperator.EQUAL)
301
- ) {
302
- const moreFilterOperations = filterOperations.filter(
303
- (op) => op !== DataCubeQueryFilterOperator.EQUAL,
304
- );
315
+ if (
316
+ filterOperations.length &&
317
+ filterOperations.includes(DataCubeQueryFilterOperator.EQUAL)
318
+ ) {
319
+ const moreFilterOperations = filterOperations.filter(
320
+ (op) => op !== DataCubeQueryFilterOperator.EQUAL,
321
+ );
305
322
 
323
+ newFilterMenu = [
324
+ buildNewFilterConditionMenuItem(
325
+ _columnConfiguration,
326
+ DataCubeQueryFilterOperator.EQUAL,
327
+ filterValue,
328
+ controller,
329
+ ),
330
+ moreFilterOperations.length
331
+ ? {
332
+ name: `More Filters on ${columnName}...`,
333
+ subMenu: moreFilterOperations.map((operator) =>
334
+ buildNewFilterConditionMenuItem(
335
+ _columnConfiguration,
336
+ operator,
337
+ filterValue,
338
+ controller,
339
+ ),
340
+ ),
341
+ }
342
+ : undefined,
343
+ ].filter(isNonNullable);
344
+ }
345
+ } else {
306
346
  newFilterMenu = [
307
347
  buildNewFilterConditionMenuItem(
308
- columnConfiguration,
309
- DataCubeQueryFilterOperator.EQUAL,
310
- filterValue,
348
+ _columnConfiguration,
349
+ DataCubeQueryFilterOperator.IS_NULL,
350
+ undefined,
311
351
  controller,
312
352
  ),
313
- moreFilterOperations.length
314
- ? {
315
- name: `More Filters on ${columnName}...`,
316
- subMenu: moreFilterOperations.map((operator) =>
317
- buildNewFilterConditionMenuItem(
318
- columnConfiguration,
319
- operator,
320
- filterValue,
321
- controller,
322
- ),
323
- ),
324
- }
325
- : undefined,
326
- ].filter(isNonNullable);
353
+ buildNewFilterConditionMenuItem(
354
+ _columnConfiguration,
355
+ DataCubeQueryFilterOperator.IS_NOT_NULL,
356
+ undefined,
357
+ controller,
358
+ ),
359
+ ];
327
360
  }
328
- } else {
329
- newFilterMenu = [
330
- buildNewFilterConditionMenuItem(
331
- columnConfiguration,
332
- DataCubeQueryFilterOperator.IS_NULL,
333
- undefined,
334
- controller,
335
- ),
336
- buildNewFilterConditionMenuItem(
337
- columnConfiguration,
338
- DataCubeQueryFilterOperator.IS_NOT_NULL,
339
- undefined,
340
- controller,
341
- ),
342
- ];
343
361
  }
344
362
  }
345
363
 
@@ -548,7 +566,7 @@ export function generateMenuBuilder(
548
566
  ...(column &&
549
567
  columnName &&
550
568
  baseColumnConfiguration?.kind === DataCubeColumnKind.MEASURE &&
551
- !baseColumnConfiguration.excludedFromHorizontalPivot &&
569
+ !baseColumnConfiguration.excludedFromPivot &&
552
570
  controller.horizontalPivotColumns.length !== 0 // pivot must be active
553
571
  ? [
554
572
  {
@@ -562,7 +580,7 @@ export function generateMenuBuilder(
562
580
  ...(column &&
563
581
  columnName &&
564
582
  columnConfiguration?.kind === DataCubeColumnKind.MEASURE &&
565
- columnConfiguration.excludedFromHorizontalPivot &&
583
+ columnConfiguration.excludedFromPivot &&
566
584
  controller.horizontalPivotColumns.length !== 0 // pivot must be active
567
585
  ? [
568
586
  {
@@ -804,6 +822,17 @@ export function generateMenuBuilder(
804
822
  disabled: !columnConfiguration,
805
823
  action: () => controller.showColumn(columnName, false),
806
824
  },
825
+ ...(columnName === INTERNAL__GRID_CLIENT_TREE_COLUMN_ID
826
+ ? [
827
+ 'separator',
828
+ {
829
+ name: 'Collapse All',
830
+ action: () => {
831
+ controller.collapseAllPaths();
832
+ },
833
+ },
834
+ ]
835
+ : []),
807
836
  'separator',
808
837
  {
809
838
  name: 'Heatmap',
@@ -14,11 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {
18
- PRIMITIVE_TYPE,
19
- type V1_AppliedFunction,
20
- extractElementNameFromPath as _name,
21
- } from '@finos/legend-graph';
17
+ import { PRIMITIVE_TYPE, type V1_AppliedFunction } from '@finos/legend-graph';
22
18
  import { type DataCubeQuerySnapshot } from '../core/DataCubeQuerySnapshot.js';
23
19
  import {
24
20
  DataCubeQueryFilterGroupOperator,
@@ -90,7 +86,7 @@ export function generateRowGroupingDrilldownExecutableQueryPostProcessor(
90
86
  sequence.splice(
91
87
  sequence.indexOf(funcMap.groupBy),
92
88
  0,
93
- _function(_name(DataCubeFunction.FILTER), [
89
+ _function(DataCubeFunction.FILTER, [
94
90
  _lambda(
95
91
  [_var()],
96
92
  [
@@ -171,7 +167,7 @@ export function generateRowGroupingDrilldownExecutableQueryPostProcessor(
171
167
  0,
172
168
  drilldownValues.length + 1,
173
169
  );
174
- const groupByFunc = _function(_name(DataCubeFunction.GROUP_BY), [
170
+ const groupByFunc = _function(DataCubeFunction.GROUP_BY, [
175
171
  _cols(groupByColumns.map((col) => _colSpec(col.name))),
176
172
  _cols([
177
173
  ..._groupByAggCols(
@@ -31,12 +31,13 @@ import {
31
31
  INTERNAL__GRID_CLIENT_TREE_COLUMN_ID,
32
32
  } from './DataCubeGridClientEngine.js';
33
33
  import {
34
- DataCubeQuerySortOperator,
34
+ DataCubeQuerySortDirection,
35
35
  getPivotResultColumnBaseColumnName,
36
36
  isPivotResultColumnName,
37
37
  } from '../core/DataCubeQueryEngine.js';
38
38
  import { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
39
39
  import { guaranteeNonNullable, uniqBy } from '@finos/legend-shared';
40
+ import { _pruneExpandedPaths } from '../core/DataCubeQuerySnapshotBuilderUtils.js';
40
41
 
41
42
  export function getColumnConfiguration(
42
43
  colName: string,
@@ -81,7 +82,9 @@ export function buildQuerySnapshot(
81
82
  columns: request.pivotCols.map((col) =>
82
83
  _toCol(getColumnConfiguration(col.id, configuration)),
83
84
  ),
84
- castColumns: [],
85
+ // NOTE: since we re-fetch the cast columns anyway in this flow, we just
86
+ // reuse the current cast columns
87
+ castColumns: baseSnapshot.data.pivot?.castColumns ?? [],
85
88
  }
86
89
  : undefined;
87
90
 
@@ -98,11 +101,11 @@ export function buildQuerySnapshot(
98
101
  // --------------------------------- SORT ---------------------------------
99
102
 
100
103
  snapshot.data.sortColumns = request.sortModel
101
- // Make sure the tree group is not being sorted since it's a synthetic column
104
+ // Make sure the tree column is not being sorted since it's a synthetic column
102
105
  // the sorting state of this special column is `synthesized` by ag-grid
103
106
  // so when all group by columns are sorted in the same direction, the tree group
104
107
  // column will be sorted in that direction, and vice versa, when user sorts
105
- // the tree-group, all group-by columns will be sorted in that direction
108
+ // the tree column, all groupBy columns will be sorted in that direction
106
109
  .filter((item) => item.colId !== INTERNAL__GRID_CLIENT_TREE_COLUMN_ID)
107
110
  .map((item) => ({
108
111
  ..._toCol(
@@ -113,12 +116,22 @@ export function buildQuerySnapshot(
113
116
  configuration,
114
117
  ),
115
118
  ),
116
- operation:
119
+ direction:
117
120
  item.sort === GridClientSortDirection.ASCENDING
118
- ? DataCubeQuerySortOperator.ASCENDING
119
- : DataCubeQuerySortOperator.DESCENDING,
121
+ ? DataCubeQuerySortDirection.ASCENDING
122
+ : DataCubeQuerySortDirection.DESCENDING,
120
123
  }));
121
124
 
125
+ // --------------------------------- CONFIGURATION ---------------------------------
126
+
127
+ configuration.pivotLayout.expandedPaths = _pruneExpandedPaths(
128
+ baseSnapshot.data.groupBy?.columns ?? [],
129
+ snapshot.data.groupBy?.columns ?? [],
130
+ configuration.pivotLayout.expandedPaths,
131
+ );
132
+ snapshot.data.configuration =
133
+ DataCubeConfiguration.serialization.toJson(configuration);
134
+
122
135
  // --------------------------------- FINALIZE ---------------------------------
123
136
 
124
137
  return snapshot;
@@ -66,7 +66,7 @@ export class DataCubeGridState extends DataCubeQuerySnapshotController {
66
66
  makeObservable(this, {
67
67
  clientDataSource: observable,
68
68
 
69
- queryConfiguration: observable,
69
+ queryConfiguration: observable.ref,
70
70
 
71
71
  rowLimit: observable,
72
72
 
@@ -118,19 +118,23 @@ export class DataCubeGridState extends DataCubeQuerySnapshotController {
118
118
  snapshot: DataCubeQuerySnapshot,
119
119
  previousSnapshot: DataCubeQuerySnapshot | undefined,
120
120
  ) {
121
- const queryConfiguration = DataCubeConfiguration.serialization.fromJson(
121
+ const configuration = DataCubeConfiguration.serialization.fromJson(
122
122
  snapshot.data.configuration,
123
123
  );
124
- this.queryConfiguration = queryConfiguration;
124
+ this.queryConfiguration = configuration;
125
125
  this.rowLimit = snapshot.data.limit;
126
126
 
127
127
  const gridOptions = generateGridOptionsFromSnapshot(
128
128
  snapshot,
129
- queryConfiguration,
129
+ configuration,
130
130
  this.view,
131
131
  );
132
+ if (this.view.engine.enableDebugMode) {
133
+ this.view.application.debugProcess(`New Grid Options`, gridOptions);
134
+ }
132
135
  this.client.updateGridOptions({
133
136
  ...gridOptions,
137
+ rowBuffer: this.view.engine.gridClientRowBuffer,
134
138
  // NOTE: ag-grid uses the cache block size as page size, so it's important to set this
135
139
  // in corresponding to the pagination setting, else it would cause unexpected scrolling behavior
136
140
  cacheBlockSize: this.isPaginationEnabled
@@ -147,7 +151,7 @@ export class DataCubeGridState extends DataCubeQuerySnapshotController {
147
151
  type: 'equals',
148
152
  filter: computeHashCodeForDataFetchManualTrigger(
149
153
  snapshot,
150
- queryConfiguration,
154
+ configuration,
151
155
  ),
152
156
  },
153
157
  });
package/tsconfig.json CHANGED
@@ -71,6 +71,7 @@
71
71
  "./src/stores/editor/DataCubeEditorHorizontalPivotsPanelState.ts",
72
72
  "./src/stores/editor/DataCubeEditorMutableConfiguration.ts",
73
73
  "./src/stores/editor/DataCubeEditorPanelState.ts",
74
+ "./src/stores/editor/DataCubeEditorPivotLayoutPanelState.ts",
74
75
  "./src/stores/editor/DataCubeEditorSortsPanelState.ts",
75
76
  "./src/stores/editor/DataCubeEditorVerticalPivotsPanelState.ts",
76
77
  "./src/stores/engine/DataCubeEngine.ts",