@finos/legend-application-repl 0.0.57 → 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 +18 -18
  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 +14 -14
  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 +24 -24
  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
@@ -14,12 +14,17 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { guaranteeNonNullable, isNonNullable } from '@finos/legend-shared';
17
+ import {
18
+ guaranteeNonNullable,
19
+ isNonNullable,
20
+ uniqBy,
21
+ } from '@finos/legend-shared';
18
22
  import { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
19
- import type {
20
- DataCubeQuerySnapshot,
21
- DataCubeQuerySnapshotColumn,
22
- DataCubeQuerySnapshotSortColumn,
23
+ import {
24
+ _toCol,
25
+ type DataCubeQuerySnapshot,
26
+ type DataCubeQuerySnapshotColumn,
27
+ type DataCubeQuerySnapshotSortColumn,
23
28
  } from '../core/DataCubeQuerySnapshot.js';
24
29
  import { DataCubeQuerySnapshotController } from '../core/DataCubeQuerySnapshotManager.js';
25
30
  import {
@@ -27,7 +32,8 @@ import {
27
32
  type DataCubeColumnPinPlacement,
28
33
  DataCubeColumnKind,
29
34
  DataCubeQueryFilterGroupOperator,
30
- PIVOT_COLUMN_NAME_VALUE_SEPARATOR,
35
+ isPivotResultColumnName,
36
+ getPivotResultColumnBaseColumnName,
31
37
  } from '../core/DataCubeQueryEngine.js';
32
38
  import type {
33
39
  GetContextMenuItemsParams,
@@ -139,7 +145,8 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
139
145
  // --------------------------------- COLUMNS ---------------------------------
140
146
 
141
147
  selectColumns: DataCubeQuerySnapshotColumn[] = [];
142
- extendedColumns: DataCubeQuerySnapshotColumn[] = [];
148
+ leafExtendedColumns: DataCubeQuerySnapshotColumn[] = [];
149
+ groupExtendedColumns: DataCubeQuerySnapshotColumn[] = [];
143
150
 
144
151
  pinColumn(
145
152
  colName: string | undefined,
@@ -153,20 +160,28 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
153
160
  }
154
161
 
155
162
  rearrangeColumns(columnByNames: string[]) {
156
- const columnConfigurations = columnByNames
163
+ // rearrange the column configurations and select columns
164
+ // anything that is not rearranged (e.g. due to pivot) will be
165
+ // pushed to the end
166
+ const rearrangedColumnConfigurations = columnByNames
157
167
  .map((colName) => this.getColumnConfiguration(colName))
158
168
  .filter(isNonNullable);
159
169
  this.configuration.columns = [
170
+ ...rearrangedColumnConfigurations,
160
171
  ...this.configuration.columns.filter(
161
- (col) => !columnConfigurations.includes(col),
172
+ (col) => !rearrangedColumnConfigurations.includes(col),
162
173
  ),
163
- ...columnConfigurations,
164
174
  ];
165
- this.selectColumns = this.configuration.columns
166
- .map((column) =>
167
- this.selectColumns.find((col) => col.name === column.name),
168
- )
175
+
176
+ const rearrangedSelectColumns = columnByNames
177
+ .map((colName) => this.selectColumns.find((col) => col.name === colName))
169
178
  .filter(isNonNullable);
179
+ this.selectColumns = [
180
+ ...rearrangedSelectColumns,
181
+ ...rearrangedSelectColumns.filter(
182
+ (col) => !rearrangedSelectColumns.includes(col),
183
+ ),
184
+ ];
170
185
  this.applyChanges();
171
186
  }
172
187
 
@@ -183,16 +198,35 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
183
198
  }
184
199
  }
185
200
 
201
+ private updateSelectColumns() {
202
+ this.selectColumns = uniqBy(
203
+ [
204
+ ...this.configuration.columns.filter((col) => col.isSelected),
205
+ ...this.horizontalPivotedColumns,
206
+ ...this.verticalPivotedColumns,
207
+ ],
208
+ (col) => col.name,
209
+ ).map((col) => _toCol(col));
210
+ }
211
+
186
212
  // --------------------------------- PIVOT ---------------------------------
187
213
 
188
- horizontalPivotableColumns: DataCubeQuerySnapshotColumn[] = [];
189
214
  horizontalPivotedColumns: DataCubeQuerySnapshotColumn[] = [];
190
215
  horizontalPivotCastColumns: DataCubeQuerySnapshotColumn[] = [];
191
216
 
192
- setHorizontalPivotOnColumn(colName: string | undefined) {
193
- const column = this.horizontalPivotableColumns.find(
194
- (col) => col.name === colName,
195
- );
217
+ getHorizontalPivotableColumn(colName: string) {
218
+ return this.configuration.columns
219
+ .filter(
220
+ (col) =>
221
+ col.kind === DataCubeColumnKind.DIMENSION &&
222
+ // exclude group-level extended columns
223
+ !this.groupExtendedColumns.find((column) => column.name === col.name),
224
+ )
225
+ .find((col) => col.name === colName);
226
+ }
227
+
228
+ setHorizontalPivotOnColumn(colName: string) {
229
+ const column = this.getHorizontalPivotableColumn(colName);
196
230
  if (column) {
197
231
  this.horizontalPivotedColumns = [column];
198
232
  /** TODO?: @datacube pivot - naively propagate this change, this might cause a bug so to be revisited */
@@ -204,10 +238,8 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
204
238
  }
205
239
  }
206
240
 
207
- addHorizontalPivotOnColumn(colName: string | undefined) {
208
- const column = this.horizontalPivotableColumns.find(
209
- (col) => col.name === colName,
210
- );
241
+ addHorizontalPivotOnColumn(colName: string) {
242
+ const column = this.getHorizontalPivotableColumn(colName);
211
243
  if (column) {
212
244
  this.horizontalPivotedColumns = [
213
245
  ...this.horizontalPivotedColumns,
@@ -227,12 +259,9 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
227
259
  this.applyChanges();
228
260
  }
229
261
 
230
- excludeColumnFromHorizontalPivot(colName: string | undefined) {
231
- if (colName?.includes(PIVOT_COLUMN_NAME_VALUE_SEPARATOR)) {
232
- const baseColumnName = colName.substring(
233
- colName.lastIndexOf(PIVOT_COLUMN_NAME_VALUE_SEPARATOR) +
234
- PIVOT_COLUMN_NAME_VALUE_SEPARATOR.length,
235
- );
262
+ excludeColumnFromHorizontalPivot(colName: string) {
263
+ if (isPivotResultColumnName(colName)) {
264
+ const baseColumnName = getPivotResultColumnBaseColumnName(colName);
236
265
  const columnConfiguration = this.getColumnConfiguration(baseColumnName);
237
266
  if (
238
267
  columnConfiguration &&
@@ -244,7 +273,7 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
244
273
  }
245
274
  }
246
275
 
247
- includeColumnInHorizontalPivot(colName: string | undefined) {
276
+ includeColumnInHorizontalPivot(colName: string) {
248
277
  const columnConfiguration = this.getColumnConfiguration(colName);
249
278
  if (columnConfiguration?.excludedFromHorizontalPivot) {
250
279
  columnConfiguration.excludedFromHorizontalPivot = false;
@@ -254,32 +283,44 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
254
283
 
255
284
  // --------------------------------- GROUP BY ---------------------------------
256
285
 
257
- verticalPivotableColumns: DataCubeQuerySnapshotColumn[] = [];
258
286
  verticalPivotedColumns: DataCubeQuerySnapshotColumn[] = [];
259
287
 
260
- setVerticalPivotOnColumn(colName: string | undefined) {
261
- const column = this.verticalPivotableColumns.find(
262
- (col) => col.name === colName,
263
- );
288
+ getVerticalPivotableColumn(colName: string) {
289
+ return this.configuration.columns
290
+ .filter(
291
+ (col) =>
292
+ col.kind === DataCubeColumnKind.DIMENSION &&
293
+ // exclude group-level extended columns
294
+ !this.groupExtendedColumns.find(
295
+ (column) => column.name === col.name,
296
+ ) &&
297
+ // exclude pivot columns
298
+ !this.horizontalPivotedColumns.find(
299
+ (column) => column.name === col.name,
300
+ ),
301
+ )
302
+ .find((col) => col.name === colName);
303
+ }
304
+
305
+ setVerticalPivotOnColumn(colName: string) {
306
+ const column = this.getVerticalPivotableColumn(colName);
264
307
  if (column) {
265
308
  this.verticalPivotedColumns = [column];
266
309
  this.applyChanges();
267
310
  }
268
311
  }
269
312
 
270
- addVerticalPivotOnColumn(colName: string | undefined) {
271
- const column = this.verticalPivotableColumns.find(
272
- (col) => col.name === colName,
273
- );
313
+ addVerticalPivotOnColumn(colName: string) {
314
+ const column = this.getVerticalPivotableColumn(colName);
274
315
  if (column) {
275
316
  this.verticalPivotedColumns = [...this.verticalPivotedColumns, column];
276
317
  this.applyChanges();
277
318
  }
278
319
  }
279
320
 
280
- removeVerticalPivotOnColumn(colName: string | undefined) {
321
+ removeVerticalPivotOnColumn(colName: string) {
281
322
  this.verticalPivotedColumns = this.verticalPivotedColumns.filter(
282
- (col) => col.name === colName,
323
+ (col) => col.name !== colName,
283
324
  );
284
325
  this.applyChanges();
285
326
  }
@@ -291,14 +332,25 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
291
332
 
292
333
  // --------------------------------- SORT ---------------------------------
293
334
 
294
- sortableColumns: DataCubeQuerySnapshotColumn[] = [];
295
335
  sortColumns: DataCubeQuerySnapshotSortColumn[] = [];
296
336
 
297
- getActionableSortColumn(
337
+ getSortableColumn(colName: string | undefined) {
338
+ if (!colName) {
339
+ return undefined;
340
+ }
341
+ return [
342
+ ...(this.horizontalPivotCastColumns.length
343
+ ? this.horizontalPivotCastColumns
344
+ : this.selectColumns),
345
+ ...this.groupExtendedColumns,
346
+ ].find((col) => col.name === colName);
347
+ }
348
+
349
+ private getActionableSortColumn(
298
350
  colName: string,
299
351
  operation: DataCubeQuerySortOperator,
300
352
  ) {
301
- const column = this.sortableColumns.find((col) => col.name === colName);
353
+ const column = this.getSortableColumn(colName);
302
354
  if (!column) {
303
355
  return undefined;
304
356
  }
@@ -344,38 +396,6 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
344
396
 
345
397
  // --------------------------------- MAIN ---------------------------------
346
398
 
347
- private applyChanges() {
348
- const baseSnapshot = guaranteeNonNullable(this.getLatestSnapshot());
349
- const snapshot = baseSnapshot.clone();
350
-
351
- snapshot.data.filter = this.filterTree.root
352
- ? buildFilterQuerySnapshot(this.filterTree.root)
353
- : undefined;
354
- snapshot.data.selectColumns = this.selectColumns;
355
- snapshot.data.sortColumns = this.sortColumns;
356
- snapshot.data.configuration = DataCubeConfiguration.serialization.toJson(
357
- this.configuration,
358
- );
359
-
360
- snapshot.data.pivot = this.horizontalPivotedColumns.length
361
- ? {
362
- columns: this.horizontalPivotedColumns,
363
- castColumns: this.horizontalPivotCastColumns,
364
- }
365
- : undefined;
366
-
367
- snapshot.data.groupBy = this.verticalPivotedColumns.length
368
- ? {
369
- columns: this.verticalPivotedColumns,
370
- }
371
- : undefined;
372
-
373
- snapshot.finalize();
374
- if (snapshot.hashCode !== baseSnapshot.hashCode) {
375
- this.publishSnapshot(snapshot);
376
- }
377
- }
378
-
379
399
  override async applySnapshot(
380
400
  snapshot: DataCubeQuerySnapshot,
381
401
  previousSnapshot: DataCubeQuerySnapshot | undefined,
@@ -397,33 +417,52 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotController
397
417
  : undefined;
398
418
 
399
419
  this.selectColumns = newSnapshot.data.selectColumns;
400
- this.extendedColumns = [
401
- ...newSnapshot.data.leafExtendedColumns,
402
- ...newSnapshot.data.groupExtendedColumns,
403
- ];
420
+ this.leafExtendedColumns = newSnapshot.data.leafExtendedColumns;
421
+ this.groupExtendedColumns = newSnapshot.data.groupExtendedColumns;
404
422
 
405
- this.horizontalPivotableColumns = newSnapshot
406
- .stageCols('pivot')
407
- .filter(
408
- (column) =>
409
- this.getColumnConfiguration(column.name)?.kind ===
410
- DataCubeColumnKind.DIMENSION,
411
- );
412
423
  this.horizontalPivotedColumns = newSnapshot.data.pivot?.columns ?? [];
413
424
  this.horizontalPivotCastColumns = newSnapshot.data.pivot?.castColumns ?? [];
414
425
 
415
- this.verticalPivotableColumns = newSnapshot
416
- .stageCols('group-by')
417
- .filter(
418
- (column) =>
419
- this.getColumnConfiguration(column.name)?.kind ===
420
- DataCubeColumnKind.DIMENSION,
421
- );
422
426
  this.verticalPivotedColumns = newSnapshot.data.groupBy?.columns ?? [];
423
427
 
424
- this.sortableColumns = newSnapshot.stageCols('sort');
425
428
  this.sortColumns = newSnapshot.data.sortColumns;
426
429
 
427
430
  this.menuBuilder = generateMenuBuilder(this);
428
431
  }
432
+
433
+ private applyChanges() {
434
+ const baseSnapshot = guaranteeNonNullable(this.getLatestSnapshot());
435
+ const snapshot = baseSnapshot.clone();
436
+
437
+ snapshot.data.configuration = DataCubeConfiguration.serialization.toJson(
438
+ this.configuration,
439
+ );
440
+
441
+ snapshot.data.filter = this.filterTree.root
442
+ ? buildFilterQuerySnapshot(this.filterTree.root)
443
+ : undefined;
444
+
445
+ this.updateSelectColumns();
446
+ snapshot.data.selectColumns = this.selectColumns;
447
+
448
+ snapshot.data.pivot = this.horizontalPivotedColumns.length
449
+ ? {
450
+ columns: this.horizontalPivotedColumns,
451
+ castColumns: this.horizontalPivotCastColumns,
452
+ }
453
+ : undefined;
454
+
455
+ snapshot.data.groupBy = this.verticalPivotedColumns.length
456
+ ? {
457
+ columns: this.verticalPivotedColumns,
458
+ }
459
+ : undefined;
460
+
461
+ snapshot.data.sortColumns = this.sortColumns;
462
+
463
+ snapshot.finalize();
464
+ if (snapshot.hashCode !== baseSnapshot.hashCode) {
465
+ this.publishSnapshot(snapshot);
466
+ }
467
+ }
429
468
  }
@@ -27,7 +27,8 @@ import {
27
27
  DataCubeColumnKind,
28
28
  type DataCubeOperationValue,
29
29
  DataCubeQueryFilterOperator,
30
- PIVOT_COLUMN_NAME_VALUE_SEPARATOR,
30
+ isPivotResultColumnName,
31
+ getPivotResultColumnBaseColumnName,
31
32
  } from '../core/DataCubeQueryEngine.js';
32
33
  import {
33
34
  guaranteeIsNumber,
@@ -176,19 +177,18 @@ export function generateMenuBuilder(
176
177
  const column = params.column ?? undefined;
177
178
  const columnName = column?.getColId();
178
179
  const columnConfiguration = controller.getColumnConfiguration(columnName);
179
- const baseColumnConfiguration = columnName?.includes(
180
- PIVOT_COLUMN_NAME_VALUE_SEPARATOR,
181
- )
182
- ? controller.getColumnConfiguration(
183
- columnName.substring(
184
- columnName.lastIndexOf(PIVOT_COLUMN_NAME_VALUE_SEPARATOR) +
185
- PIVOT_COLUMN_NAME_VALUE_SEPARATOR.length,
186
- ),
187
- )
188
- : undefined;
180
+ const baseColumnConfiguration =
181
+ columnName && isPivotResultColumnName(columnName)
182
+ ? controller.getColumnConfiguration(
183
+ getPivotResultColumnBaseColumnName(columnName),
184
+ )
185
+ : undefined;
189
186
  const isExtendedColumn =
190
187
  columnName &&
191
- controller.extendedColumns.find((col) => col.name === columnName);
188
+ [
189
+ ...controller.leafExtendedColumns,
190
+ ...controller.groupExtendedColumns,
191
+ ].find((col) => col.name === columnName);
192
192
  // NOTE: here we assume the value must be coming from the same column
193
193
  const value: unknown = 'value' in params ? params.value : undefined;
194
194
 
@@ -196,7 +196,7 @@ export function generateMenuBuilder(
196
196
  {
197
197
  name: 'Sort',
198
198
  subMenu: [
199
- ...(column && columnName
199
+ ...(column && columnName && controller.getSortableColumn(columnName)
200
200
  ? [
201
201
  {
202
202
  name: 'Ascending',
@@ -286,7 +286,7 @@ export function generateMenuBuilder(
286
286
  },
287
287
  ],
288
288
  },
289
- ];
289
+ ] satisfies (string | MenuItemDef)[];
290
290
 
291
291
  let newFilterMenu: MenuItemDef[] = [];
292
292
  if (columnConfiguration && column && value !== undefined) {
@@ -494,7 +494,8 @@ export function generateMenuBuilder(
494
494
  subMenu: [
495
495
  ...(column &&
496
496
  columnName &&
497
- columnConfiguration?.kind === DataCubeColumnKind.DIMENSION
497
+ columnConfiguration?.kind === DataCubeColumnKind.DIMENSION &&
498
+ controller.getVerticalPivotableColumn(columnName)
498
499
  ? [
499
500
  {
500
501
  name: `Vertical Pivot on ${column.getColId()}`,
@@ -518,6 +519,13 @@ export function generateMenuBuilder(
518
519
  controller.removeVerticalPivotOnColumn(columnName),
519
520
  },
520
521
  'separator',
522
+ ]
523
+ : []),
524
+ ...(column &&
525
+ columnName &&
526
+ columnConfiguration?.kind === DataCubeColumnKind.DIMENSION &&
527
+ controller.getHorizontalPivotableColumn(columnName)
528
+ ? [
521
529
  {
522
530
  name: `Horizontal Pivot on ${column.getColId()}`,
523
531
  action: () =>
@@ -673,25 +681,73 @@ export function generateMenuBuilder(
673
681
  {
674
682
  name: `Auto-size All Columns`,
675
683
  action: () =>
676
- params.api.autoSizeColumns(
677
- controller.configuration.columns
678
- .filter((col) => col.fixedWidth === undefined)
684
+ params.api.autoSizeColumns([
685
+ ...controller.configuration.columns
686
+ .filter(
687
+ (col) =>
688
+ col.fixedWidth === undefined &&
689
+ col.isSelected &&
690
+ !col.hideFromView,
691
+ )
679
692
  .map((col) => col.name),
680
- ),
693
+ ...controller.horizontalPivotCastColumns
694
+ .map((col) => {
695
+ if (isPivotResultColumnName(col.name)) {
696
+ const colConf = controller.configuration.columns.find(
697
+ (c) =>
698
+ c.name ===
699
+ getPivotResultColumnBaseColumnName(col.name),
700
+ );
701
+ if (
702
+ colConf &&
703
+ colConf.fixedWidth === undefined &&
704
+ colConf.isSelected &&
705
+ !colConf.hideFromView
706
+ ) {
707
+ return col.name;
708
+ }
709
+ }
710
+ return undefined;
711
+ })
712
+ .filter(isNonNullable),
713
+ ]),
681
714
  },
682
715
  {
683
716
  name: `Minimize All Columns`,
684
717
  action: () => {
685
- params.api.setColumnWidths(
686
- // TODO: take care of pivot columns
687
- controller.configuration.columns
718
+ params.api.setColumnWidths([
719
+ ...controller.configuration.columns
688
720
  .filter((col) => col.fixedWidth === undefined)
689
721
  .map((col) => ({
690
722
  key: col.name,
691
723
  newWidth:
692
724
  columnConfiguration?.minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,
693
725
  })),
694
- );
726
+ ...controller.horizontalPivotCastColumns
727
+ .map((col) => {
728
+ if (isPivotResultColumnName(col.name)) {
729
+ const colConf = controller.configuration.columns.find(
730
+ (c) =>
731
+ c.name ===
732
+ getPivotResultColumnBaseColumnName(col.name),
733
+ );
734
+ if (
735
+ colConf &&
736
+ colConf.fixedWidth === undefined &&
737
+ colConf.isSelected &&
738
+ !colConf.hideFromView
739
+ ) {
740
+ return {
741
+ key: col.name,
742
+ newWidth:
743
+ colConf.minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,
744
+ };
745
+ }
746
+ }
747
+ return undefined;
748
+ })
749
+ .filter(isNonNullable),
750
+ ]);
695
751
  },
696
752
  },
697
753
  {
@@ -795,6 +851,6 @@ export function generateMenuBuilder(
795
851
  editor.display.open();
796
852
  },
797
853
  },
798
- ];
854
+ ] satisfies (string | MenuItemDef)[];
799
855
  };
800
856
  }
@@ -35,6 +35,7 @@ import {
35
35
  _function,
36
36
  _lambda,
37
37
  _var,
38
+ _functionCompositionUnProcessor,
38
39
  } from '../core/DataCubeQueryBuilderUtils.js';
39
40
  import {
40
41
  INTERNAL__GRID_CLIENT_MISSING_VALUE,
@@ -76,13 +77,7 @@ export function generateRowGroupingDrilldownExecutableQueryPostProcessor(
76
77
  filterOperations: DataCubeQueryFilterOperation[],
77
78
  aggregateOperations: DataCubeQueryAggregateOperation[],
78
79
  ) => {
79
- const _unprocess = (funcMapKey: keyof DataCubeQueryFunctionMap) => {
80
- const func = funcMap[funcMapKey];
81
- if (func) {
82
- sequence.splice(sequence.indexOf(func), 1);
83
- funcMap[funcMapKey] = undefined;
84
- }
85
- };
80
+ const _unprocess = _functionCompositionUnProcessor(sequence, funcMap);
86
81
  const data = snapshot.data;
87
82
 
88
83
  if (funcMap.groupBy) {
@@ -23,14 +23,30 @@
23
23
 
24
24
  import type { IServerSideGetRowsRequest } from '@ag-grid-community/core';
25
25
  import {
26
+ _toCol,
26
27
  type DataCubeQuerySnapshot,
27
- _getCol,
28
28
  } from '../core/DataCubeQuerySnapshot.js';
29
29
  import {
30
30
  GridClientSortDirection,
31
31
  INTERNAL__GRID_CLIENT_TREE_COLUMN_ID,
32
32
  } from './DataCubeGridClientEngine.js';
33
- import { DataCubeQuerySortOperator } from '../core/DataCubeQueryEngine.js';
33
+ import {
34
+ DataCubeQuerySortOperator,
35
+ getPivotResultColumnBaseColumnName,
36
+ isPivotResultColumnName,
37
+ } from '../core/DataCubeQueryEngine.js';
38
+ import { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
39
+ import { guaranteeNonNullable } from '@finos/legend-shared';
40
+
41
+ export function getColumnConfiguration(
42
+ colName: string,
43
+ configuration: DataCubeConfiguration,
44
+ ) {
45
+ return guaranteeNonNullable(
46
+ configuration.columns.find((col) => col.name === colName),
47
+ `Can't find configuration for column '${colName}'`,
48
+ );
49
+ }
34
50
 
35
51
  // --------------------------------- MAIN ---------------------------------
36
52
 
@@ -39,14 +55,16 @@ export function buildQuerySnapshot(
39
55
  baseSnapshot: DataCubeQuerySnapshot,
40
56
  ) {
41
57
  const snapshot = baseSnapshot.clone();
58
+ const configuration = DataCubeConfiguration.serialization.fromJson(
59
+ snapshot.data.configuration,
60
+ );
42
61
 
43
62
  // --------------------------------- GROUP BY ---------------------------------
44
63
 
45
64
  if (request.rowGroupCols.length) {
46
- const availableCols = baseSnapshot.stageCols('group-by');
47
65
  const newGroupByColumns = request.rowGroupCols.map((col) => ({
48
66
  name: col.id,
49
- type: _getCol(availableCols, col.id).type,
67
+ type: getColumnConfiguration(col.id, configuration).type,
50
68
  }));
51
69
  snapshot.data.groupBy = {
52
70
  columns: newGroupByColumns,
@@ -65,7 +83,14 @@ export function buildQuerySnapshot(
65
83
  // the tree-group, all group-by columns will be sorted in that direction
66
84
  .filter((item) => item.colId !== INTERNAL__GRID_CLIENT_TREE_COLUMN_ID)
67
85
  .map((item) => ({
68
- ..._getCol(baseSnapshot.stageCols('sort'), item.colId),
86
+ ..._toCol(
87
+ getColumnConfiguration(
88
+ isPivotResultColumnName(item.colId)
89
+ ? getPivotResultColumnBaseColumnName(item.colId)
90
+ : item.colId,
91
+ configuration,
92
+ ),
93
+ ),
69
94
  operation:
70
95
  item.sort === GridClientSortDirection.ASCENDING
71
96
  ? DataCubeQuerySortOperator.ASCENDING