@finos/legend-application-repl 0.0.58 → 0.0.59

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 (136) hide show
  1. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -1
  2. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js +3 -19
  3. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -1
  4. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts.map +1 -1
  5. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js +5 -7
  6. package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js.map +1 -1
  7. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts.map +1 -1
  8. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js +22 -12
  9. package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js.map +1 -1
  10. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts.map +1 -1
  11. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js +1 -1
  12. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js.map +1 -1
  13. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts.map +1 -1
  14. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js +6 -2
  15. package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js.map +1 -1
  16. package/lib/components/repl/Form.d.ts.map +1 -1
  17. package/lib/components/repl/Form.js +3 -2
  18. package/lib/components/repl/Form.js.map +1 -1
  19. package/lib/components/repl/PureCodeEditor.js +1 -1
  20. package/lib/components/repl/PureCodeEditor.js.map +1 -1
  21. package/lib/components/repl/SettingsPanel.d.ts.map +1 -1
  22. package/lib/components/repl/SettingsPanel.js +11 -8
  23. package/lib/components/repl/SettingsPanel.js.map +1 -1
  24. package/lib/index.css +2 -2
  25. package/lib/index.css.map +1 -1
  26. package/lib/package.json +1 -1
  27. package/lib/stores/dataCube/DataCubeEngine.d.ts +11 -8
  28. package/lib/stores/dataCube/DataCubeEngine.d.ts.map +1 -1
  29. package/lib/stores/dataCube/DataCubeEngine.js +24 -17
  30. package/lib/stores/dataCube/DataCubeEngine.js.map +1 -1
  31. package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts +12 -1
  32. package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts.map +1 -1
  33. package/lib/stores/dataCube/core/DataCubeConfiguration.js +13 -1
  34. package/lib/stores/dataCube/core/DataCubeConfiguration.js.map +1 -1
  35. package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
  36. package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +3 -6
  37. package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
  38. package/lib/stores/dataCube/core/DataCubeQueryBuilderUtils.d.ts +3 -1
  39. package/lib/stores/dataCube/core/DataCubeQueryBuilderUtils.d.ts.map +1 -1
  40. package/lib/stores/dataCube/core/DataCubeQueryBuilderUtils.js +25 -7
  41. package/lib/stores/dataCube/core/DataCubeQueryBuilderUtils.js.map +1 -1
  42. package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts +2 -0
  43. package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts.map +1 -1
  44. package/lib/stores/dataCube/core/DataCubeQueryEngine.js +12 -1
  45. package/lib/stores/dataCube/core/DataCubeQueryEngine.js.map +1 -1
  46. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +5 -8
  47. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
  48. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +3 -32
  49. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
  50. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -1
  51. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js +8 -10
  52. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js.map +1 -1
  53. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts +1 -3
  54. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts.map +1 -1
  55. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js +5 -32
  56. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js.map +1 -1
  57. package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts +8 -19
  58. package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts.map +1 -1
  59. package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js +44 -105
  60. package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js.map +1 -1
  61. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js +2 -2
  62. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js.map +1 -1
  63. package/lib/stores/dataCube/editor/DataCubeEditorHorizontalPivotsPanelState.d.ts +4 -1
  64. package/lib/stores/dataCube/editor/DataCubeEditorHorizontalPivotsPanelState.d.ts.map +1 -1
  65. package/lib/stores/dataCube/editor/DataCubeEditorHorizontalPivotsPanelState.js +19 -22
  66. package/lib/stores/dataCube/editor/DataCubeEditorHorizontalPivotsPanelState.js.map +1 -1
  67. package/lib/stores/dataCube/editor/DataCubeEditorMutableConfiguration.d.ts +2 -1
  68. package/lib/stores/dataCube/editor/DataCubeEditorMutableConfiguration.d.ts.map +1 -1
  69. package/lib/stores/dataCube/editor/DataCubeEditorMutableConfiguration.js +9 -4
  70. package/lib/stores/dataCube/editor/DataCubeEditorMutableConfiguration.js.map +1 -1
  71. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -1
  72. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js +9 -5
  73. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js.map +1 -1
  74. package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts +5 -2
  75. package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -1
  76. package/lib/stores/dataCube/editor/DataCubeEditorState.js +60 -56
  77. package/lib/stores/dataCube/editor/DataCubeEditorState.js.map +1 -1
  78. package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.d.ts.map +1 -1
  79. package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js +9 -11
  80. package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js.map +1 -1
  81. package/lib/stores/dataCube/extend/DataCubeExtendManagerState.d.ts +2 -1
  82. package/lib/stores/dataCube/extend/DataCubeExtendManagerState.d.ts.map +1 -1
  83. package/lib/stores/dataCube/extend/DataCubeExtendManagerState.js +6 -9
  84. package/lib/stores/dataCube/extend/DataCubeExtendManagerState.js.map +1 -1
  85. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
  86. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +20 -2
  87. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
  88. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.d.ts +13 -13
  89. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.d.ts.map +1 -1
  90. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js +78 -67
  91. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js.map +1 -1
  92. package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts +16 -14
  93. package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts.map +1 -1
  94. package/lib/stores/dataCube/grid/DataCubeGridControllerState.js +78 -49
  95. package/lib/stores/dataCube/grid/DataCubeGridControllerState.js.map +1 -1
  96. package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.d.ts.map +1 -1
  97. package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.js +65 -18
  98. package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.js.map +1 -1
  99. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts.map +1 -1
  100. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js +2 -8
  101. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js.map +1 -1
  102. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts +2 -0
  103. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -1
  104. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js +12 -5
  105. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -1
  106. package/package.json +4 -4
  107. package/src/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.tsx +10 -32
  108. package/src/components/dataCube/editor/DataCubeEditorColumnsPanel.tsx +9 -11
  109. package/src/components/dataCube/editor/DataCubeEditorColumnsSelector.tsx +22 -12
  110. package/src/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.tsx +1 -3
  111. package/src/components/dataCube/editor/DataCubeEditorSortsPanel.tsx +20 -1
  112. package/src/components/repl/Form.tsx +3 -2
  113. package/src/components/repl/PureCodeEditor.tsx +1 -1
  114. package/src/components/repl/SettingsPanel.tsx +37 -12
  115. package/src/stores/dataCube/DataCubeEngine.ts +28 -17
  116. package/src/stores/dataCube/core/DataCubeConfiguration.ts +13 -1
  117. package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +3 -8
  118. package/src/stores/dataCube/core/DataCubeQueryBuilderUtils.ts +34 -8
  119. package/src/stores/dataCube/core/DataCubeQueryEngine.ts +17 -1
  120. package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +6 -49
  121. package/src/stores/dataCube/core/DataCubeQuerySnapshotBuilder.ts +8 -9
  122. package/src/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.ts +8 -46
  123. package/src/stores/dataCube/editor/DataCubeEditorColumnsPanelState.ts +60 -141
  124. package/src/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.ts +2 -2
  125. package/src/stores/dataCube/editor/DataCubeEditorHorizontalPivotsPanelState.ts +34 -35
  126. package/src/stores/dataCube/editor/DataCubeEditorMutableConfiguration.ts +11 -4
  127. package/src/stores/dataCube/editor/DataCubeEditorSortsPanelState.ts +18 -13
  128. package/src/stores/dataCube/editor/DataCubeEditorState.tsx +88 -79
  129. package/src/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.ts +16 -12
  130. package/src/stores/dataCube/extend/DataCubeExtendManagerState.tsx +14 -19
  131. package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +22 -2
  132. package/src/stores/dataCube/grid/DataCubeGridConfigurationBuilder.tsx +113 -76
  133. package/src/stores/dataCube/grid/DataCubeGridControllerState.ts +134 -95
  134. package/src/stores/dataCube/grid/DataCubeGridMenuBuilder.tsx +80 -24
  135. package/src/stores/dataCube/grid/DataCubeGridQueryBuilder.ts +2 -7
  136. package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.ts +30 -5
@@ -19,9 +19,10 @@ import type { DataCubeState } from '../DataCubeState.js';
19
19
  import type { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
20
20
  import {
21
21
  DataCubeColumnKind,
22
- PIVOT_COLUMN_NAME_VALUE_SEPARATOR,
22
+ isPivotResultColumnName,
23
23
  } from '../core/DataCubeQueryEngine.js';
24
24
  import {
25
+ _toCol,
25
26
  type DataCubeQuerySnapshot,
26
27
  type DataCubeQuerySnapshotColumn,
27
28
  } from '../core/DataCubeQuerySnapshot.js';
@@ -31,6 +32,7 @@ import {
31
32
  } from './DataCubeEditorColumnsSelectorState.js';
32
33
  import type { DataCubeQueryEditorPanelState } from './DataCubeEditorPanelState.js';
33
34
  import type { DataCubeEditorState } from './DataCubeEditorState.js';
35
+ import { uniqBy } from '@finos/legend-shared';
34
36
 
35
37
  export class DataCubeEditorHorizontalPivotColumnsSelectorState extends DataCubeEditorColumnsSelectorState<DataCubeEditorColumnsSelectorColumnState> {
36
38
  override cloneColumn(
@@ -42,15 +44,14 @@ export class DataCubeEditorHorizontalPivotColumnsSelectorState extends DataCubeE
42
44
  );
43
45
  }
44
46
 
45
- override get availableColumns(): DataCubeEditorColumnsSelectorColumnState[] {
46
- return this.editor.columns.selector.selectedColumns
47
+ override get availableColumns() {
48
+ return this.editor.columnProperties.columns
47
49
  .filter(
48
- (column) =>
49
- this.editor.columnProperties.getColumnConfiguration(column.name)
50
- ?.kind === DataCubeColumnKind.DIMENSION &&
50
+ (col) =>
51
+ col.kind === DataCubeColumnKind.DIMENSION &&
51
52
  // exclude group-level extended columns
52
- !this.editor.columns.groupExtendColumns.find(
53
- (col) => col.name === column.name,
53
+ !this.editor.groupExtendColumns.find(
54
+ (column) => column.name === col.name,
54
55
  ),
55
56
  )
56
57
  .map(
@@ -89,37 +90,37 @@ export class DataCubeEditorHorizontalPivotsPanelState
89
90
 
90
91
  get pivotResultColumns(): DataCubeQuerySnapshotColumn[] {
91
92
  return this.castColumns
92
- .filter((col) => col.name.includes(PIVOT_COLUMN_NAME_VALUE_SEPARATOR))
93
- .map((col) => ({ name: col.name, type: col.type }));
93
+ .filter((col) => isPivotResultColumnName(col.name))
94
+ .map((col) => _toCol(col));
94
95
  }
95
96
 
97
+ /**
98
+ * Due to the nature of pivot() operation, some base columns (i.e. source columns and leaf-level columns)
99
+ * will be "consumed" and not available for subsequent operations (e.g. sort, groupBy, etc.).
100
+ */
96
101
  get columnsConsumedByPivot(): DataCubeQuerySnapshotColumn[] {
97
102
  if (!this.selector.selectedColumns.length) {
98
103
  return [];
99
104
  }
100
- return [
101
- ...this.selector.selectedColumns,
102
- ...this.editor.columnProperties.columns.filter(
103
- (col) =>
104
- col.kind === DataCubeColumnKind.MEASURE &&
105
- !col.excludedFromHorizontalPivot,
106
- ),
107
- /** TODO: @datacube pivot - need to include columns used in complex aggregates (such as weighted-average) */
108
- ].map((col) => ({ name: col.name, type: col.type }));
105
+ return uniqBy(
106
+ [
107
+ ...this.selector.selectedColumns,
108
+ ...this.editor.columnProperties.columns.filter(
109
+ (col) =>
110
+ col.isSelected &&
111
+ col.kind === DataCubeColumnKind.MEASURE &&
112
+ !col.excludedFromHorizontalPivot,
113
+ ),
114
+ /** TODO: @datacube pivot - need to include columns used in complex aggregates (such as weighted-average) */
115
+ ],
116
+ (col) => col.name,
117
+ ).map((col) => _toCol(col));
109
118
  }
110
119
 
111
120
  setCastColumns(value: DataCubeQuerySnapshotColumn[]) {
112
121
  this.castColumns = value;
113
122
  }
114
123
 
115
- adaptPropagatedChanges() {
116
- this.selector.setSelectedColumns(
117
- this.selector.selectedColumns.filter((column) =>
118
- this.selector.availableColumns.find((col) => col.name === column.name),
119
- ),
120
- );
121
- }
122
-
123
124
  propagateChanges() {
124
125
  this.editor.verticalPivots.adaptPropagatedChanges();
125
126
  this.editor.sorts.adaptPropagatedChanges();
@@ -144,15 +145,13 @@ export class DataCubeEditorHorizontalPivotsPanelState
144
145
  ) {
145
146
  newSnapshot.data.pivot = this.selector.selectedColumns.length
146
147
  ? {
147
- columns: this.selector.selectedColumns.map((column) => ({
148
- name: column.name,
149
- type: column.type,
150
- })),
151
- castColumns: this.castColumns.map((column) => ({
152
- name: column.name,
153
- type: column.type,
154
- })),
148
+ columns: this.selector.selectedColumns.map((col) => _toCol(col)),
149
+ castColumns: this.castColumns.map((col) => _toCol(col)),
155
150
  }
156
151
  : undefined;
152
+ newSnapshot.data.selectColumns = uniqBy(
153
+ [...newSnapshot.data.selectColumns, ...this.selector.selectedColumns],
154
+ (col) => col.name,
155
+ ).map((col) => _toCol(col));
157
156
  }
158
157
  }
@@ -143,12 +143,15 @@ export class DataCubeEditorMutableColumnConfiguration extends DataCubeColumnConf
143
143
  errorBackgroundColor: observable,
144
144
  setErrorBackgroundColor: action,
145
145
 
146
- blur: observable,
147
- setBlur: action,
146
+ isSelected: observable,
147
+ setIsSelected: action,
148
148
 
149
149
  hideFromView: observable,
150
150
  setHideFromView: action,
151
151
 
152
+ blur: observable,
153
+ setBlur: action,
154
+
152
155
  fixedWidth: observable,
153
156
  setFixedWidth: action,
154
157
 
@@ -334,14 +337,18 @@ export class DataCubeEditorMutableColumnConfiguration extends DataCubeColumnConf
334
337
  this.errorBackgroundColor = value;
335
338
  }
336
339
 
337
- setBlur(value: boolean) {
338
- this.blur = value;
340
+ setIsSelected(value: boolean) {
341
+ this.isSelected = value;
339
342
  }
340
343
 
341
344
  setHideFromView(value: boolean) {
342
345
  this.hideFromView = value;
343
346
  }
344
347
 
348
+ setBlur(value: boolean) {
349
+ this.blur = value;
350
+ }
351
+
345
352
  setFixedWidth(value: number | undefined) {
346
353
  this.fixedWidth = value;
347
354
  }
@@ -25,6 +25,7 @@ import {
25
25
  } from './DataCubeEditorColumnsSelectorState.js';
26
26
  import type { DataCubeEditorState } from './DataCubeEditorState.js';
27
27
  import type { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
28
+ import { uniqBy } from '@finos/legend-shared';
28
29
 
29
30
  export class DataCubeEditorSortColumnState extends DataCubeEditorColumnsSelectorColumnState {
30
31
  operation: string;
@@ -55,19 +56,23 @@ export class DataCubeEditorSortColumnsSelectorState extends DataCubeEditorColumn
55
56
  }
56
57
 
57
58
  override get availableColumns() {
58
- return [
59
- ...this.editor.horizontalPivots.pivotResultColumns,
60
- ...this.editor.columns.selector.selectedColumns.filter(
61
- (column) =>
62
- !this.editor.columns.groupExtendColumns.find(
63
- (col) => col.name === column.name,
64
- ) &&
65
- !this.editor.horizontalPivots.columnsConsumedByPivot.find(
66
- (col) => col.name === column.name,
67
- ),
68
- ),
69
- ...this.editor.columns.groupExtendColumns,
70
- ].map(
59
+ return uniqBy(
60
+ [
61
+ ...this.editor.horizontalPivots.pivotResultColumns,
62
+ ...[
63
+ ...this.editor.columns.selector.selectedColumns,
64
+ ...this.editor.horizontalPivots.selector.selectedColumns,
65
+ ...this.editor.verticalPivots.selector.selectedColumns,
66
+ ].filter(
67
+ (column) =>
68
+ !this.editor.horizontalPivots.columnsConsumedByPivot.find(
69
+ (col) => col.name === column.name,
70
+ ),
71
+ ),
72
+ ...this.editor.groupExtendColumns,
73
+ ],
74
+ (col) => col.name,
75
+ ).map(
71
76
  (col) =>
72
77
  new DataCubeEditorSortColumnState(
73
78
  col.name,
@@ -18,7 +18,12 @@ import { action, makeObservable, observable } from 'mobx';
18
18
  import type { DataCubeState } from '../DataCubeState.js';
19
19
  import { DataCubeEditorSortsPanelState } from './DataCubeEditorSortsPanelState.js';
20
20
  import { DataCubeQuerySnapshotController } from '../core/DataCubeQuerySnapshotManager.js';
21
- import { type DataCubeQuerySnapshot } from '../core/DataCubeQuerySnapshot.js';
21
+ import {
22
+ _toCol,
23
+ type DataCubeQuerySnapshot,
24
+ type DataCubeQuerySnapshotColumn,
25
+ type DataCubeQuerySnapshotExtendedColumn,
26
+ } from '../core/DataCubeQuerySnapshot.js';
22
27
  import {
23
28
  ActionState,
24
29
  assertErrorThrown,
@@ -67,6 +72,10 @@ export class DataCubeEditorState extends DataCubeQuerySnapshotController {
67
72
 
68
73
  currentTab = DataCubeEditorTab.GENERAL_PROPERTIES;
69
74
 
75
+ sourceColumns: DataCubeQuerySnapshotColumn[] = [];
76
+ leafExtendColumns: DataCubeQuerySnapshotExtendedColumn[] = [];
77
+ groupExtendColumns: DataCubeQuerySnapshotExtendedColumn[] = [];
78
+
70
79
  constructor(dataCube: DataCubeState) {
71
80
  super(dataCube);
72
81
 
@@ -74,6 +83,11 @@ export class DataCubeEditorState extends DataCubeQuerySnapshotController {
74
83
  currentTab: observable,
75
84
  setCurrentTab: action,
76
85
 
86
+ sourceColumns: observable.ref,
87
+ leafExtendColumns: observable.ref,
88
+ groupExtendColumns: observable.ref,
89
+
90
+ applySnapshot: action,
77
91
  applyChanges: action,
78
92
  });
79
93
 
@@ -96,104 +110,99 @@ export class DataCubeEditorState extends DataCubeQuerySnapshotController {
96
110
  this.currentTab = val;
97
111
  }
98
112
 
113
+ override async applySnapshot(
114
+ snapshot: DataCubeQuerySnapshot,
115
+ previousSnapshot: DataCubeQuerySnapshot | undefined,
116
+ ) {
117
+ this.sourceColumns = snapshot.data.sourceColumns;
118
+ this.leafExtendColumns = snapshot.data.leafExtendedColumns;
119
+ this.groupExtendColumns = snapshot.data.groupExtendedColumns;
120
+
121
+ const configuration = DataCubeConfiguration.serialization.fromJson(
122
+ snapshot.data.configuration,
123
+ );
124
+ this.generalProperties.applySnaphot(snapshot, configuration);
125
+ this.columnProperties.applySnaphot(snapshot, configuration);
126
+
127
+ this.columns.applySnaphot(snapshot, configuration);
128
+ this.horizontalPivots.applySnaphot(snapshot, configuration);
129
+ this.verticalPivots.applySnaphot(snapshot, configuration);
130
+ this.sorts.applySnaphot(snapshot, configuration);
131
+ }
132
+
99
133
  async applyChanges(options?: { closeAfterApply?: boolean | undefined }) {
134
+ const task = this.dataCube.newTask('Validate query');
100
135
  this.finalizationState.inProgress();
101
136
 
102
137
  const baseSnapshot = guaranteeNonNullable(this.getLatestSnapshot());
103
138
  const newSnapshot = baseSnapshot.clone();
104
139
 
105
- // NOTE: column selection must be processed first so necessary
106
- // prunings can be done to make sure other panel stats are in sync
107
- // with the current column selection
108
- this.columns.buildSnapshot(newSnapshot, baseSnapshot);
109
- this.horizontalPivots.buildSnapshot(newSnapshot, baseSnapshot);
110
- this.verticalPivots.buildSnapshot(newSnapshot, baseSnapshot);
111
- this.sorts.buildSnapshot(newSnapshot, baseSnapshot);
112
-
113
140
  // grid configuration must be processed before processing columns' configuration
114
141
  // to properly generate the container configuration
115
142
  this.generalProperties.buildSnapshot(newSnapshot, baseSnapshot);
116
143
  this.columnProperties.buildSnapshot(newSnapshot, baseSnapshot);
117
144
 
118
- newSnapshot.finalize();
119
- if (newSnapshot.hashCode === baseSnapshot.hashCode) {
120
- if (options?.closeAfterApply) {
121
- this.display.close();
122
- }
123
- this.finalizationState.complete();
124
- return;
125
- }
126
-
127
- // NOTE: Compile the query to validate. This is a helpful check for a lot of different scenarios
128
- // where the consistency of the query might be thrown off by changes from various parts that the
129
- // editor does not have full control over (i.e. extended columns, pivot cast columns, etc.)
130
- // e.g. when a column that group-level extended columns' expressions depend on has been unselected.
131
- try {
132
- const tempSnapshot = newSnapshot.clone();
133
- // NOTE: in order to obtain the actual pivot result columns information, we need to execute
134
- // the query which is expensive in certain cases, so here, we just compute the "optimistic" set
135
- // of pivot result columns for casting to guarantee validation is not thronn off.
136
- if (tempSnapshot.data.pivot) {
137
- tempSnapshot.data.pivot.castColumns =
138
- this.sorts.selector.availableColumns
139
- .filter(
140
- (col) =>
141
- !tempSnapshot.data.groupExtendedColumns.find(
142
- (column) => column.name === col.name,
143
- ),
144
- )
145
- .map((col) => ({
146
- name: col.name,
147
- type: col.type,
148
- }));
149
- }
150
- await this.dataCube.engine.getQueryRelationType(
151
- _lambda(
152
- [],
153
- [
154
- buildExecutableQuery(
155
- tempSnapshot,
156
- this.dataCube.engine.filterOperations,
157
- this.dataCube.engine.aggregateOperations,
158
- ),
159
- ],
160
- ),
161
- );
162
- } catch (error) {
163
- assertErrorThrown(error);
164
- this.dataCube.repl.alertError(error, {
165
- message: `Query Validation Failure: ${error.message}`,
166
- });
167
- return;
168
- } finally {
169
- this.finalizationState.complete();
170
- }
145
+ // NOTE: column selection must be processed first since the snapshot
146
+ // processing of other parts of the query can be affected by column selection.
147
+ this.columns.buildSnapshot(newSnapshot, baseSnapshot);
148
+ this.horizontalPivots.buildSnapshot(newSnapshot, baseSnapshot);
149
+ this.verticalPivots.buildSnapshot(newSnapshot, baseSnapshot);
150
+ this.sorts.buildSnapshot(newSnapshot, baseSnapshot);
171
151
 
172
152
  // finalize
173
153
  newSnapshot.finalize();
174
154
  if (newSnapshot.hashCode !== baseSnapshot.hashCode) {
155
+ // NOTE: Compile the query to validate. This is a helpful check for a lot of different scenarios
156
+ // where the consistency of the query might be thrown off by changes from various parts that the
157
+ // editor does not have full control over (i.e. extended columns, pivot cast columns, etc.)
158
+ // e.g. when a column that group-level extended columns' expressions depend on has been unselected.
159
+ try {
160
+ const tempSnapshot = newSnapshot.clone();
161
+ // NOTE: in order to obtain the actual pivot result columns information, we need to execute
162
+ // the query which is expensive in certain cases, so here, we just compute the "optimistic" set
163
+ // of pivot result columns for casting to guarantee validation is not thronn off.
164
+ if (tempSnapshot.data.pivot) {
165
+ tempSnapshot.data.pivot.castColumns =
166
+ this.sorts.selector.availableColumns
167
+ .filter(
168
+ (col) =>
169
+ !tempSnapshot.data.groupExtendedColumns.find(
170
+ (column) => column.name === col.name,
171
+ ),
172
+ )
173
+ .map((col) => _toCol(col));
174
+ }
175
+ await this.dataCube.engine.getQueryRelationType(
176
+ _lambda(
177
+ [],
178
+ [
179
+ buildExecutableQuery(
180
+ tempSnapshot,
181
+ this.dataCube.engine.filterOperations,
182
+ this.dataCube.engine.aggregateOperations,
183
+ ),
184
+ ],
185
+ ),
186
+ );
187
+ } catch (error) {
188
+ assertErrorThrown(error);
189
+ this.dataCube.repl.alertError(error, {
190
+ message: `Query Validation Failure: ${error.message}`,
191
+ });
192
+ this.dataCube.endTask(task);
193
+ return;
194
+ } finally {
195
+ this.finalizationState.complete();
196
+ }
197
+
175
198
  this.publishSnapshot(newSnapshot);
199
+ } else {
200
+ this.finalizationState.complete();
176
201
  }
177
202
 
178
203
  if (options?.closeAfterApply) {
179
204
  this.display.close();
180
205
  }
181
- }
182
-
183
- override async applySnapshot(
184
- snapshot: DataCubeQuerySnapshot,
185
- previousSnapshot: DataCubeQuerySnapshot | undefined,
186
- ) {
187
- const configuration = DataCubeConfiguration.serialization.fromJson(
188
- snapshot.data.configuration,
189
- );
190
-
191
- this.columns.applySnaphot(snapshot, configuration);
192
- this.horizontalPivots.applySnaphot(snapshot, configuration);
193
- this.verticalPivots.applySnaphot(snapshot, configuration);
194
- this.sorts.applySnaphot(snapshot, configuration);
195
-
196
- this.generalProperties.applySnaphot(snapshot, configuration);
197
- this.columnProperties.applySnaphot(snapshot, configuration);
206
+ this.dataCube.endTask(task);
198
207
  }
199
208
  }
@@ -14,10 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { uniqBy } from '@finos/legend-shared';
17
18
  import type { DataCubeState } from '../DataCubeState.js';
18
19
  import type { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
19
20
  import { DataCubeColumnKind } from '../core/DataCubeQueryEngine.js';
20
- import { type DataCubeQuerySnapshot } from '../core/DataCubeQuerySnapshot.js';
21
+ import {
22
+ _toCol,
23
+ type DataCubeQuerySnapshot,
24
+ } from '../core/DataCubeQuerySnapshot.js';
21
25
  import {
22
26
  DataCubeEditorColumnsSelectorColumnState,
23
27
  DataCubeEditorColumnsSelectorState,
@@ -35,18 +39,17 @@ export class DataCubeEditorVerticalPivotColumnsSelectorState extends DataCubeEdi
35
39
  );
36
40
  }
37
41
 
38
- override get availableColumns(): DataCubeEditorColumnsSelectorColumnState[] {
39
- return this.editor.columns.selector.selectedColumns
42
+ override get availableColumns() {
43
+ return this.editor.columnProperties.columns
40
44
  .filter(
41
45
  (column) =>
42
- this.editor.columnProperties.getColumnConfiguration(column.name)
43
- ?.kind === DataCubeColumnKind.DIMENSION &&
46
+ column.kind === DataCubeColumnKind.DIMENSION &&
44
47
  // exclude group-level extended columns
45
- !this.editor.columns.groupExtendColumns.find(
48
+ !this.editor.groupExtendColumns.find(
46
49
  (col) => col.name === column.name,
47
50
  ) &&
48
- // prune available columns if h-pivot is present
49
- !this.editor.horizontalPivots.columnsConsumedByPivot.find(
51
+ // exclude pivot columns
52
+ !this.editor.horizontalPivots.selector.selectedColumns.find(
50
53
  (col) => col.name === column.name,
51
54
  ),
52
55
  )
@@ -96,11 +99,12 @@ export class DataCubeEditorVerticalPivotsPanelState
96
99
  ) {
97
100
  newSnapshot.data.groupBy = this.selector.selectedColumns.length
98
101
  ? {
99
- columns: this.selector.selectedColumns.map((column) => ({
100
- name: column.name,
101
- type: column.type,
102
- })),
102
+ columns: this.selector.selectedColumns.map((col) => _toCol(col)),
103
103
  }
104
104
  : undefined;
105
+ newSnapshot.data.selectColumns = uniqBy(
106
+ [...newSnapshot.data.selectColumns, ...this.selector.selectedColumns],
107
+ (col) => col.name,
108
+ ).map((col) => _toCol(col));
105
109
  }
106
110
  }
@@ -15,10 +15,11 @@
15
15
  */
16
16
 
17
17
  import { action, computed, makeObservable, observable } from 'mobx';
18
- import type {
19
- DataCubeQuerySnapshot,
20
- DataCubeQuerySnapshotColumn,
21
- DataCubeQuerySnapshotExtendedColumn,
18
+ import {
19
+ _toCol,
20
+ type DataCubeQuerySnapshot,
21
+ type DataCubeQuerySnapshotColumn,
22
+ type DataCubeQuerySnapshotExtendedColumn,
22
23
  } from '../core/DataCubeQuerySnapshot.js';
23
24
  import { deleteEntry, guaranteeNonNullable, noop } from '@finos/legend-shared';
24
25
  import type { DataCubeState } from '../DataCubeState.js';
@@ -53,11 +54,14 @@ export class DataCubeQueryExtendedColumnState {
53
54
  */
54
55
  export class DataCubeExtendManagerState extends DataCubeQuerySnapshotController {
55
56
  configuration = new DataCubeConfiguration();
56
- columnConfigurations: DataCubeColumnConfiguration[] = [];
57
57
 
58
+ columnConfigurations: DataCubeColumnConfiguration[] = [];
59
+ selectedColumns: DataCubeQuerySnapshotColumn[] = [];
58
60
  sourceColumns: DataCubeQuerySnapshotColumn[] = [];
61
+
59
62
  leafExtendedColumns: DataCubeQueryExtendedColumnState[] = [];
60
63
  groupExtendedColumns: DataCubeQueryExtendedColumnState[] = [];
64
+
61
65
  newColumnEditors: DataCubeNewColumnState[] = [];
62
66
  // TODO: existingColumnEditors
63
67
 
@@ -65,8 +69,10 @@ export class DataCubeExtendManagerState extends DataCubeQuerySnapshotController
65
69
  super(dataCube);
66
70
 
67
71
  makeObservable(this, {
68
- sourceColumns: observable.ref,
69
72
  columnConfigurations: observable.struct,
73
+ selectedColumns: observable.struct,
74
+ sourceColumns: observable.ref,
75
+
70
76
  leafExtendedColumns: observable,
71
77
  groupExtendedColumns: observable,
72
78
 
@@ -113,6 +119,7 @@ export class DataCubeExtendManagerState extends DataCubeQuerySnapshotController
113
119
 
114
120
  this.columnConfigurations.push(columnConfiguration);
115
121
  deleteEntry(this.newColumnEditors, editor);
122
+ this.selectedColumns.push(_toCol(column));
116
123
  this.applyChanges();
117
124
  }
118
125
 
@@ -154,19 +161,7 @@ export class DataCubeExtendManagerState extends DataCubeQuerySnapshotController
154
161
  newSnapshot.data.groupExtendedColumns = this.groupExtendedColumns.map(
155
162
  (col) => col.data,
156
163
  );
157
- // update the selected columns
158
- // NOTE: group-level extended columns cannot be selected!
159
- newSnapshot.data.selectColumns = this.columnConfigurations
160
- .map((col) => ({
161
- name: col.name,
162
- type: col.type,
163
- }))
164
- .filter(
165
- (col) =>
166
- !newSnapshot.data.groupExtendedColumns.find(
167
- (c) => c.name === col.name,
168
- ),
169
- );
164
+ newSnapshot.data.selectColumns = [...this.selectedColumns];
170
165
 
171
166
  // TODO: support edition, so v-pivots/h-pivots or column configuration that
172
167
  // depends on columns with name/type changed should be updated
@@ -181,6 +181,7 @@ export function computeHashCodeForDataFetchManualTrigger(
181
181
  return hashObject(
182
182
  pruneObject({
183
183
  ...snapshot.data,
184
+ name: undefined,
184
185
  configuration: {
185
186
  initialExpandLevel: configuration.initialExpandLevel,
186
187
  showRootAggregation: configuration.showRootAggregation,
@@ -397,6 +398,17 @@ export class DataCubeGridClientServerSideDataSource
397
398
  this.rowCount = (params.request.startRow ?? 0) + rowData.length;
398
399
  });
399
400
  }
401
+
402
+ // toggle no-rows overlay
403
+ if (
404
+ params.request.groupKeys.length === 0 &&
405
+ params.request.startRow === 0 &&
406
+ rowData.length === 0
407
+ ) {
408
+ this.grid.client.showNoRowsOverlay();
409
+ } else {
410
+ this.grid.client.hideOverlay();
411
+ }
400
412
  } else {
401
413
  // NOTE: When pagination is disabled and the user currently scrolls to somewhere in the grid, as data is fetched
402
414
  // and the operation does not force a scroll top (for example, grouping will always force scrolling to the
@@ -412,7 +424,8 @@ export class DataCubeGridClientServerSideDataSource
412
424
  // behavior by forcing a scroll top for every data fetch and also reset the cache block size to the default value to save memory
413
425
  if (rowData.length > INTERNAL__GRID_CLIENT_MAX_CACHE_BLOCK_SIZE) {
414
426
  if (
415
- !this.grid.dataCube.repl.dataCubeEngine.disableLargeDatasetWarning
427
+ !this.grid.dataCube.repl.dataCubeEngine
428
+ .gridClientSuppressLargeDatasetWarning
416
429
  ) {
417
430
  this.grid.dataCube.repl.alert({
418
431
  message: `Large dataset (>${INTERNAL__GRID_CLIENT_MAX_CACHE_BLOCK_SIZE} rows) detected!`,
@@ -429,7 +442,7 @@ export class DataCubeGridClientServerSideDataSource
429
442
  label: 'Dismiss Warning',
430
443
  handler: () => {
431
444
  // this.grid.setPaginationEnabled(true);
432
- this.grid.dataCube.repl.dataCubeEngine.setDisableLargeDatasetWarning(
445
+ this.grid.dataCube.repl.dataCubeEngine.setGridClientSuppressLargeDatasetWarning(
433
446
  true,
434
447
  );
435
448
  },
@@ -456,6 +469,13 @@ export class DataCubeGridClientServerSideDataSource
456
469
  this.rowCount = rowData.length;
457
470
  });
458
471
  }
472
+
473
+ // toggle no-rows overlay
474
+ if (params.request.groupKeys.length === 0 && rowData.length === 0) {
475
+ this.grid.client.showNoRowsOverlay();
476
+ } else {
477
+ this.grid.client.hideOverlay();
478
+ }
459
479
  }
460
480
  } catch (error) {
461
481
  assertErrorThrown(error);