@finos/legend-application-repl 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/dataCube/DataCube.js +3 -3
- package/lib/components/dataCube/DataCube.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditor.js +4 -4
- package/lib/components/dataCube/editor/DataCubeEditor.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js +3 -3
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js +10 -3
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts +3 -2
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js +23 -37
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js.map +1 -1
- package/lib/components/dataCube/editor/{DataCubeEditorVPivotsPanel.d.ts → DataCubeEditorHorizontalPivotsPanel.d.ts} +2 -2
- package/lib/components/dataCube/editor/DataCubeEditorHorizontalPivotsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/{DataCubeEditorHPivotsPanel.js → DataCubeEditorHorizontalPivotsPanel.js} +2 -2
- package/lib/components/dataCube/editor/DataCubeEditorHorizontalPivotsPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js +6 -6
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js.map +1 -1
- package/lib/components/dataCube/editor/{DataCubeEditorHPivotsPanel.d.ts → DataCubeEditorVerticalPivotsPanel.d.ts} +2 -2
- package/lib/components/dataCube/editor/DataCubeEditorVerticalPivotsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/{DataCubeEditorVPivotsPanel.js → DataCubeEditorVerticalPivotsPanel.js} +5 -7
- package/lib/components/dataCube/editor/DataCubeEditorVerticalPivotsPanel.js.map +1 -0
- package/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -1
- package/lib/components/dataCube/grid/DataCubeGrid.js +22 -3
- package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +17 -13
- package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -1
- package/lib/stores/dataCube/DataCubeState.js +2 -2
- package/lib/stores/dataCube/DataCubeState.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts +3 -1
- package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeConfiguration.js +4 -0
- package/lib/stores/dataCube/core/DataCubeConfiguration.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +15 -15
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts +22 -0
- package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryEngine.js +25 -0
- package/lib/stores/dataCube/core/DataCubeQueryEngine.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +5 -40
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +9 -54
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js +13 -7
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts +4 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js +20 -5
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts +45 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js +102 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts +26 -9
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js +50 -20
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts +2 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorPanelState.d.ts +2 -1
- package/lib/stores/dataCube/editor/DataCubeEditorPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts +12 -13
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js +23 -70
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts +11 -7
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorState.js +28 -13
- package/lib/stores/dataCube/editor/DataCubeEditorState.js.map +1 -1
- package/lib/stores/dataCube/editor/{DataCubeEditorHPivotPanelState.d.ts → DataCubeEditorVerticalPivotsPanelState.d.ts} +11 -4
- package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js +62 -0
- package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.d.ts +5 -3
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.js +8 -6
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts +8 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +9 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.d.ts +31 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.js +147 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.js.map +1 -0
- package/lib/stores/dataCube/grid/{DataCubeGridQuerySnapshotAnalyzer.d.ts → DataCubeGridConfigurationBuilder.d.ts} +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/{DataCubeGridQuerySnapshotAnalyzer.js → DataCubeGridConfigurationBuilder.js} +95 -68
- package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts +62 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.js +174 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.js.map +1 -0
- package/lib/{components/dataCube/grid/menu/DataCubeGridMenu.d.ts → stores/dataCube/grid/DataCubeGridMenuBuilder.d.ts} +3 -7
- package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.js +462 -0
- package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js +3 -3
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js +9 -8
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts +6 -2
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridState.js +8 -2
- package/lib/stores/dataCube/grid/DataCubeGridState.js.map +1 -1
- package/package.json +23 -19
- package/src/components/dataCube/DataCube.tsx +3 -3
- package/src/components/dataCube/editor/DataCubeEditor.tsx +17 -17
- package/src/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.tsx +5 -7
- package/src/components/dataCube/editor/DataCubeEditorColumnsPanel.tsx +42 -8
- package/src/components/dataCube/editor/DataCubeEditorColumnsSelector.tsx +38 -79
- package/src/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.tsx +3 -1
- package/src/components/dataCube/editor/{DataCubeEditorHPivotsPanel.tsx → DataCubeEditorHorizontalPivotsPanel.tsx} +1 -1
- package/src/components/dataCube/editor/DataCubeEditorSortsPanel.tsx +7 -9
- package/src/components/dataCube/editor/{DataCubeEditorVPivotsPanel.tsx → DataCubeEditorVerticalPivotsPanel.tsx} +6 -8
- package/src/components/dataCube/grid/DataCubeGrid.tsx +35 -8
- package/src/stores/dataCube/DataCubeState.ts +7 -5
- package/src/stores/dataCube/core/DataCubeConfiguration.ts +6 -0
- package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +16 -16
- package/src/stores/dataCube/core/DataCubeQueryEngine.ts +25 -0
- package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +19 -58
- package/src/stores/dataCube/core/DataCubeQuerySnapshotBuilder.ts +12 -7
- package/src/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.ts +37 -5
- package/src/stores/dataCube/editor/DataCubeEditorColumnsPanelState.ts +162 -0
- package/src/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.ts +98 -23
- package/src/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.ts +5 -1
- package/src/stores/dataCube/editor/DataCubeEditorPanelState.ts +5 -1
- package/src/stores/dataCube/editor/DataCubeEditorSortsPanelState.ts +48 -117
- package/src/stores/dataCube/editor/DataCubeEditorState.ts +33 -13
- package/src/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.ts +105 -0
- package/src/stores/dataCube/editor/DataCubeMutableConfiguration.ts +16 -7
- package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +9 -0
- package/src/stores/dataCube/grid/DataCubeGridClientExportEngine.ts +170 -0
- package/src/stores/dataCube/grid/{DataCubeGridQuerySnapshotAnalyzer.tsx → DataCubeGridConfigurationBuilder.tsx} +105 -77
- package/src/stores/dataCube/grid/DataCubeGridControllerState.ts +254 -0
- package/src/stores/dataCube/grid/DataCubeGridMenuBuilder.tsx +535 -0
- package/src/stores/dataCube/grid/DataCubeGridQueryBuilder.ts +3 -5
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.ts +12 -10
- package/src/stores/dataCube/grid/DataCubeGridState.ts +10 -3
- package/tsconfig.json +8 -6
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.d.ts.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.js.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.d.ts.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.js.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridMenu.d.ts.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridMenu.js +0 -413
- package/lib/components/dataCube/grid/menu/DataCubeGridMenu.js.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.d.ts +0 -19
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.d.ts.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.js +0 -83
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.js.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorHPivotPanelState.d.ts.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorHPivotPanelState.js +0 -30
- package/lib/stores/dataCube/editor/DataCubeEditorHPivotPanelState.js.map +0 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts.map +0 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js.map +0 -1
- package/src/components/dataCube/grid/menu/DataCubeGridMenu.tsx +0 -441
- package/src/components/dataCube/grid/menu/DataCubeGridSortsMenu.tsx +0 -119
- package/src/stores/dataCube/editor/DataCubeEditorHPivotPanelState.ts +0 -43
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
***************************************************************************************/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
DataCubeQuerySnapshotAggregateFunction,
|
|
26
|
-
DataCubeQuerySnapshotSortOperation,
|
|
27
25
|
_findCol,
|
|
28
26
|
type DataCubeQuerySnapshot,
|
|
29
27
|
type DataCubeQuerySnapshotColumn,
|
|
@@ -52,12 +50,13 @@ import {
|
|
|
52
50
|
INTERNAL__GRID_CLIENT_AUTO_RESIZE_PADDING,
|
|
53
51
|
INTERNAL__GRID_CLIENT_HEADER_HEIGHT,
|
|
54
52
|
INTERNAL__GRID_CLIENT_TOOLTIP_SHOW_DELAY,
|
|
53
|
+
INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
|
|
54
|
+
INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID,
|
|
55
55
|
} from './DataCubeGridClientEngine.js';
|
|
56
56
|
import { PRIMITIVE_TYPE } from '@finos/legend-graph';
|
|
57
57
|
import {
|
|
58
58
|
getQueryParameters,
|
|
59
59
|
getQueryParameterValue,
|
|
60
|
-
guaranteeNonNullable,
|
|
61
60
|
IllegalStateError,
|
|
62
61
|
isNonNullable,
|
|
63
62
|
isNumber,
|
|
@@ -68,17 +67,19 @@ import type {
|
|
|
68
67
|
DataCubeConfiguration,
|
|
69
68
|
} from '../core/DataCubeConfiguration.js';
|
|
70
69
|
import {
|
|
70
|
+
DataCubeAggregateFunction,
|
|
71
71
|
DataCubeColumnDataType,
|
|
72
72
|
DataCubeColumnPinPlacement,
|
|
73
73
|
DataCubeNumberScale,
|
|
74
74
|
DEFAULT_ROW_BUFFER,
|
|
75
75
|
DEFAULT_URL_LABEL_QUERY_PARAM,
|
|
76
76
|
getDataType,
|
|
77
|
+
DataCubeQuerySortOperation,
|
|
78
|
+
DataCubeColumnKind,
|
|
77
79
|
} from '../core/DataCubeQueryEngine.js';
|
|
78
80
|
import type { CustomLoadingCellRendererProps } from '@ag-grid-community/react';
|
|
79
81
|
import { DataCubeIcon } from '@finos/legend-art';
|
|
80
82
|
import type { DataCubeState } from '../DataCubeState.js';
|
|
81
|
-
import { buildGridMenu } from '../../../components/dataCube/grid/menu/DataCubeGridMenu.js';
|
|
82
83
|
|
|
83
84
|
// --------------------------------- UTILITIES ---------------------------------
|
|
84
85
|
|
|
@@ -103,7 +104,6 @@ function _cellDataType(column: DataCubeQuerySnapshotColumn) {
|
|
|
103
104
|
function _allowedAggFuncs(column: DataCubeQuerySnapshotColumn) {
|
|
104
105
|
switch (column.type) {
|
|
105
106
|
case PRIMITIVE_TYPE.STRING:
|
|
106
|
-
return [];
|
|
107
107
|
case PRIMITIVE_TYPE.DATE:
|
|
108
108
|
case PRIMITIVE_TYPE.DATETIME:
|
|
109
109
|
case PRIMITIVE_TYPE.STRICTDATE:
|
|
@@ -125,18 +125,18 @@ function _allowedAggFuncs(column: DataCubeQuerySnapshotColumn) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
function _aggFunc(
|
|
128
|
-
func:
|
|
128
|
+
func: DataCubeAggregateFunction,
|
|
129
129
|
): GridClientAggregateOperation {
|
|
130
130
|
switch (func) {
|
|
131
|
-
case
|
|
131
|
+
case DataCubeAggregateFunction.AVERAGE:
|
|
132
132
|
return GridClientAggregateOperation.AVERAGE;
|
|
133
|
-
case
|
|
133
|
+
case DataCubeAggregateFunction.COUNT:
|
|
134
134
|
return GridClientAggregateOperation.COUNT;
|
|
135
|
-
case
|
|
135
|
+
case DataCubeAggregateFunction.MAX:
|
|
136
136
|
return GridClientAggregateOperation.MAX;
|
|
137
|
-
case
|
|
137
|
+
case DataCubeAggregateFunction.MIN:
|
|
138
138
|
return GridClientAggregateOperation.MIN;
|
|
139
|
-
case
|
|
139
|
+
case DataCubeAggregateFunction.SUM:
|
|
140
140
|
return GridClientAggregateOperation.SUM;
|
|
141
141
|
default:
|
|
142
142
|
throw new IllegalStateError(`Unsupported aggregate function '${func}'`);
|
|
@@ -196,15 +196,14 @@ function DataCubeGridLoadingCellRenderer(
|
|
|
196
196
|
|
|
197
197
|
type ColumnData = {
|
|
198
198
|
snapshot: DataCubeQuerySnapshot;
|
|
199
|
-
column:
|
|
200
|
-
configuration:
|
|
201
|
-
gridConfiguration: DataCubeConfiguration;
|
|
199
|
+
column: DataCubeColumnConfiguration;
|
|
200
|
+
configuration: DataCubeConfiguration;
|
|
202
201
|
};
|
|
203
202
|
|
|
204
203
|
function getCellRenderer(columnData: ColumnData) {
|
|
205
|
-
const { column
|
|
204
|
+
const { column } = columnData;
|
|
206
205
|
const dataType = getDataType(column.type);
|
|
207
|
-
if (dataType === DataCubeColumnDataType.TEXT &&
|
|
206
|
+
if (dataType === DataCubeColumnDataType.TEXT && column.displayAsLink) {
|
|
208
207
|
return function LinkRenderer(params: ICellRendererParams) {
|
|
209
208
|
const isUrl = isValidUrl(params.value);
|
|
210
209
|
if (!isUrl) {
|
|
@@ -212,7 +211,7 @@ function getCellRenderer(columnData: ColumnData) {
|
|
|
212
211
|
}
|
|
213
212
|
const url = params.value as string;
|
|
214
213
|
const label = getQueryParameterValue(
|
|
215
|
-
|
|
214
|
+
column.linkLabelParameter ?? DEFAULT_URL_LABEL_QUERY_PARAM,
|
|
216
215
|
getQueryParameters(url, true),
|
|
217
216
|
);
|
|
218
217
|
return (
|
|
@@ -231,45 +230,39 @@ function getCellRenderer(columnData: ColumnData) {
|
|
|
231
230
|
}
|
|
232
231
|
|
|
233
232
|
function _displaySpec(columnData: ColumnData) {
|
|
234
|
-
const { column, configuration
|
|
233
|
+
const { column, configuration } = columnData;
|
|
235
234
|
const dataType = getDataType(column.type);
|
|
236
|
-
const fontFamily =
|
|
237
|
-
const fontSize =
|
|
238
|
-
const fontBold =
|
|
239
|
-
const fontItalic =
|
|
235
|
+
const fontFamily = column.fontFamily ?? configuration.fontFamily;
|
|
236
|
+
const fontSize = column.fontSize ?? configuration.fontSize;
|
|
237
|
+
const fontBold = column.fontBold ?? configuration.fontBold;
|
|
238
|
+
const fontItalic = column.fontItalic ?? configuration.fontItalic;
|
|
240
239
|
const fontStrikethrough =
|
|
241
|
-
|
|
242
|
-
const fontUnderline =
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
const textAlign = configuration.textAlign ?? gridConfiguration.textAlign;
|
|
240
|
+
column.fontStrikethrough ?? configuration.fontStrikethrough;
|
|
241
|
+
const fontUnderline = column.fontUnderline ?? configuration.fontUnderline;
|
|
242
|
+
const fontCase = column.fontCase ?? configuration.fontCase;
|
|
243
|
+
const textAlign = column.textAlign ?? configuration.textAlign;
|
|
246
244
|
const normalForegroundColor =
|
|
247
|
-
|
|
248
|
-
gridConfiguration.normalForegroundColor;
|
|
245
|
+
column.normalForegroundColor ?? configuration.normalForegroundColor;
|
|
249
246
|
const normalBackgroundColor =
|
|
250
|
-
|
|
251
|
-
gridConfiguration.normalBackgroundColor;
|
|
247
|
+
column.normalBackgroundColor ?? configuration.normalBackgroundColor;
|
|
252
248
|
const negativeForegroundColor =
|
|
253
|
-
|
|
254
|
-
gridConfiguration.negativeForegroundColor;
|
|
249
|
+
column.negativeForegroundColor ?? configuration.negativeForegroundColor;
|
|
255
250
|
const negativeBackgroundColor =
|
|
256
|
-
|
|
257
|
-
gridConfiguration.negativeBackgroundColor;
|
|
251
|
+
column.negativeBackgroundColor ?? configuration.negativeBackgroundColor;
|
|
258
252
|
const zeroForegroundColor =
|
|
259
|
-
|
|
253
|
+
column.zeroForegroundColor ?? configuration.zeroForegroundColor;
|
|
260
254
|
const zeroBackgroundColor =
|
|
261
|
-
|
|
255
|
+
column.zeroBackgroundColor ?? configuration.zeroBackgroundColor;
|
|
262
256
|
const errorForegroundColor =
|
|
263
|
-
|
|
264
|
-
gridConfiguration.errorForegroundColor;
|
|
257
|
+
column.errorForegroundColor ?? configuration.errorForegroundColor;
|
|
265
258
|
const errorBackgroundColor =
|
|
266
|
-
|
|
267
|
-
gridConfiguration.errorBackgroundColor;
|
|
259
|
+
column.errorBackgroundColor ?? configuration.errorBackgroundColor;
|
|
268
260
|
const cellRenderer = getCellRenderer(columnData);
|
|
269
261
|
return {
|
|
270
262
|
// setting the cell data type might helps guide the grid to render the cell properly
|
|
271
263
|
// and optimize the grid performance slightly by avoiding unnecessary type inference
|
|
272
264
|
cellDataType: _cellDataType(column),
|
|
265
|
+
hide: column.hideFromView,
|
|
273
266
|
valueFormatter:
|
|
274
267
|
dataType === DataCubeColumnDataType.NUMBER
|
|
275
268
|
? (params) => {
|
|
@@ -278,20 +271,20 @@ function _displaySpec(columnData: ColumnData) {
|
|
|
278
271
|
return null;
|
|
279
272
|
}
|
|
280
273
|
const showNegativeNumberInParens =
|
|
281
|
-
|
|
274
|
+
column.negativeNumberInParens && value < 0;
|
|
282
275
|
// 1. apply the number scale
|
|
283
|
-
const scaledNumber = scaleNumber(value,
|
|
276
|
+
const scaledNumber = scaleNumber(value, column.numberScale);
|
|
284
277
|
// 2. apply the number formatter
|
|
285
278
|
const formattedValue = (
|
|
286
279
|
showNegativeNumberInParens
|
|
287
280
|
? Math.abs(scaledNumber.value)
|
|
288
281
|
: scaledNumber.value
|
|
289
282
|
).toLocaleString(undefined, {
|
|
290
|
-
useGrouping:
|
|
291
|
-
...(
|
|
283
|
+
useGrouping: column.displayCommas,
|
|
284
|
+
...(column.decimals !== undefined
|
|
292
285
|
? {
|
|
293
|
-
minimumFractionDigits:
|
|
294
|
-
maximumFractionDigits:
|
|
286
|
+
minimumFractionDigits: column.decimals,
|
|
287
|
+
maximumFractionDigits: column.decimals,
|
|
295
288
|
}
|
|
296
289
|
: {}),
|
|
297
290
|
});
|
|
@@ -353,13 +346,12 @@ function _displaySpec(columnData: ColumnData) {
|
|
|
353
346
|
) => params.node.failedLoad,
|
|
354
347
|
[generateBackgroundColorUtilityClassName(errorBackgroundColor, 'error')]:
|
|
355
348
|
(params) => params.node.failedLoad,
|
|
356
|
-
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.BLUR]: () =>
|
|
357
|
-
configuration.blur,
|
|
349
|
+
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.BLUR]: () => column.blur,
|
|
358
350
|
},
|
|
359
351
|
cellRenderer: cellRenderer,
|
|
360
352
|
pinned:
|
|
361
|
-
|
|
362
|
-
?
|
|
353
|
+
column.pinned !== undefined
|
|
354
|
+
? column.pinned === DataCubeColumnPinPlacement.RIGHT
|
|
363
355
|
? GridClientPinnedAlignement.RIGHT
|
|
364
356
|
: GridClientPinnedAlignement.LEFT
|
|
365
357
|
: null,
|
|
@@ -371,7 +363,7 @@ function _displaySpec(columnData: ColumnData) {
|
|
|
371
363
|
}
|
|
372
364
|
|
|
373
365
|
function _sizeSpec(columnData: ColumnData) {
|
|
374
|
-
const {
|
|
366
|
+
const { column } = columnData;
|
|
375
367
|
return {
|
|
376
368
|
// NOTE: there is a problem with ag-grid when scrolling horizontally, the header row
|
|
377
369
|
// lags behind the data, it seems to be caused by synchronizing scroll not working properly
|
|
@@ -382,14 +374,14 @@ function _sizeSpec(columnData: ColumnData) {
|
|
|
382
374
|
// See https://issues.chromium.org/issues/40890343#comment11
|
|
383
375
|
//
|
|
384
376
|
// TODO: if we support column resize to fit content, should we disable this behavior?
|
|
385
|
-
resizable:
|
|
377
|
+
resizable: column.fixedWidth === undefined,
|
|
386
378
|
// suppressAutoSize: columnConfiguration.fixedWidth !== undefined,
|
|
387
|
-
width:
|
|
379
|
+
width: column.fixedWidth,
|
|
388
380
|
minWidth: Math.max(
|
|
389
|
-
|
|
381
|
+
column.minWidth ?? INTERNAL__GRID_CLIENT_COLUMN_MIN_WIDTH,
|
|
390
382
|
INTERNAL__GRID_CLIENT_COLUMN_MIN_WIDTH,
|
|
391
383
|
),
|
|
392
|
-
maxWidth:
|
|
384
|
+
maxWidth: column.maxWidth,
|
|
393
385
|
} as ColDef;
|
|
394
386
|
}
|
|
395
387
|
|
|
@@ -400,7 +392,7 @@ function _sortSpec(columnData: ColumnData) {
|
|
|
400
392
|
return {
|
|
401
393
|
sortable: true, // if this is pivot column, no sorting is allowed
|
|
402
394
|
sort: sortCol
|
|
403
|
-
? sortCol.operation ===
|
|
395
|
+
? sortCol.operation === DataCubeQuerySortOperation.ASCENDING
|
|
404
396
|
? GridClientSortDirection.ASCENDING
|
|
405
397
|
: GridClientSortDirection.DESCENDING
|
|
406
398
|
: null,
|
|
@@ -416,8 +408,8 @@ function _rowGroupSpec(columnData: ColumnData) {
|
|
|
416
408
|
const groupByCol = _findCol(data.groupBy?.columns, column.name);
|
|
417
409
|
const aggCol = _findCol(data.groupBy?.aggColumns, column.name);
|
|
418
410
|
return {
|
|
419
|
-
enableRowGroup:
|
|
420
|
-
enableValue:
|
|
411
|
+
enableRowGroup: column.kind === DataCubeColumnKind.DIMENSION,
|
|
412
|
+
enableValue: column.kind === DataCubeColumnKind.MEASURE,
|
|
421
413
|
rowGroup: Boolean(groupByCol),
|
|
422
414
|
// TODO: @akphi - add this from configuration object
|
|
423
415
|
aggFunc: aggCol
|
|
@@ -457,9 +449,11 @@ export function generateBaseGridOptions(dataCube: DataCubeState): GridOptions {
|
|
|
457
449
|
groupDisplayType: 'custom', // keeps the column set stable even when row grouping is used
|
|
458
450
|
suppressRowGroupHidesColumns: true, // keeps the column set stable even when row grouping is used
|
|
459
451
|
suppressAggFuncInHeader: true, // keeps the columns stable when aggregation is used
|
|
452
|
+
getChildCount: (data) =>
|
|
453
|
+
data[INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID],
|
|
460
454
|
// -------------------------------------- PIVOT --------------------------------------
|
|
461
455
|
// pivotPanelShow: "always"
|
|
462
|
-
// pivotMode:true,
|
|
456
|
+
// pivotMode:true, // TODO: need to make sure we don't hide away any columns when this is enabled
|
|
463
457
|
// -------------------------------------- SORT --------------------------------------
|
|
464
458
|
// Force multi-sorting since this is what the query supports anyway
|
|
465
459
|
alwaysMultiSort: true,
|
|
@@ -498,12 +492,14 @@ export function generateBaseGridOptions(dataCube: DataCubeState): GridOptions {
|
|
|
498
492
|
grid.setScrollHintText(`${start}-${end}/${rowCount}`);
|
|
499
493
|
event.api.hidePopupMenu(); // hide context-menu while scrolling
|
|
500
494
|
},
|
|
501
|
-
onBodyScrollEnd: () => grid.setScrollHintText(
|
|
495
|
+
onBodyScrollEnd: () => grid.setScrollHintText(undefined),
|
|
502
496
|
// -------------------------------------- CONTEXT MENU --------------------------------------
|
|
503
497
|
preventDefaultOnContextMenu: true, // prevent showing the browser's context menu
|
|
504
498
|
columnMenu: 'new', // ensure context menu works on header
|
|
505
|
-
|
|
506
|
-
|
|
499
|
+
// NOTE: dynamically generate the content of the context menu to make sure the items are not stale
|
|
500
|
+
getContextMenuItems: (params) =>
|
|
501
|
+
grid.controller.menuBuilder?.(params) ?? [],
|
|
502
|
+
getMainMenuItems: (params) => grid.controller.menuBuilder?.(params) ?? [],
|
|
507
503
|
// -------------------------------------- COLUMN SIZING --------------------------------------
|
|
508
504
|
autoSizePadding: INTERNAL__GRID_CLIENT_AUTO_RESIZE_PADDING,
|
|
509
505
|
autoSizeStrategy: {
|
|
@@ -514,12 +510,34 @@ export function generateBaseGridOptions(dataCube: DataCubeState): GridOptions {
|
|
|
514
510
|
tooltipShowDelay: INTERNAL__GRID_CLIENT_TOOLTIP_SHOW_DELAY,
|
|
515
511
|
tooltipInteraction: true,
|
|
516
512
|
// -------------------------------------- COLUMN MOVING --------------------------------------
|
|
517
|
-
suppressDragLeaveHidesColumns: true,
|
|
513
|
+
// suppressDragLeaveHidesColumns: true,
|
|
518
514
|
// -------------------------------------- SERVER SIDE ROW MODEL --------------------------------------
|
|
519
515
|
suppressScrollOnNewData: true,
|
|
520
516
|
suppressServerSideFullWidthLoadingRow: true, // make sure each column has its own loading indicator instead of the whole row
|
|
521
517
|
// -------------------------------------- SELECTION --------------------------------------
|
|
522
518
|
enableRangeSelection: true,
|
|
519
|
+
// -------------------------------------- SIDEBAR --------------------------------------
|
|
520
|
+
sideBar: {
|
|
521
|
+
toolPanels: [
|
|
522
|
+
{
|
|
523
|
+
id: 'columns',
|
|
524
|
+
labelDefault: 'Columns',
|
|
525
|
+
labelKey: 'columns',
|
|
526
|
+
iconKey: 'columns',
|
|
527
|
+
toolPanel: 'agColumnsToolPanel',
|
|
528
|
+
minWidth: INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
|
|
529
|
+
width: INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
|
|
530
|
+
toolPanelParams: {
|
|
531
|
+
suppressValues: true,
|
|
532
|
+
// TODO: enable when we support pivot
|
|
533
|
+
suppressPivotMode: true,
|
|
534
|
+
suppressPivots: true,
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
position: 'right',
|
|
539
|
+
},
|
|
540
|
+
// allowDragFromColumnsToolPanel: true,
|
|
523
541
|
// -------------------------------------- PERFORMANCE --------------------------------------
|
|
524
542
|
animateRows: false, // improve performance
|
|
525
543
|
suppressColumnMoveAnimation: true, // improve performance
|
|
@@ -531,7 +549,6 @@ export function generateGridOptionsFromSnapshot(
|
|
|
531
549
|
configuration: DataCubeConfiguration,
|
|
532
550
|
dataCube: DataCubeState,
|
|
533
551
|
): GridOptions {
|
|
534
|
-
const data = snapshot.data;
|
|
535
552
|
const gridOptions = {
|
|
536
553
|
/**
|
|
537
554
|
* NOTE: there is a strange issue where if we put dynamic configuration directly
|
|
@@ -557,19 +574,34 @@ export function generateGridOptionsFromSnapshot(
|
|
|
557
574
|
onColumnPinned: (event) => {
|
|
558
575
|
if (event.column) {
|
|
559
576
|
const column = event.column;
|
|
560
|
-
const columnConfiguration =
|
|
561
|
-
dataCube.editor.columnProperties.getColumnConfiguration(
|
|
562
|
-
column.getColId(),
|
|
563
|
-
);
|
|
564
577
|
const pinned = column.getPinned();
|
|
565
|
-
|
|
578
|
+
dataCube.grid.controller.pinColumn(
|
|
579
|
+
column.getColId(),
|
|
566
580
|
pinned === null
|
|
567
581
|
? undefined
|
|
568
582
|
: pinned === GridClientPinnedAlignement.LEFT
|
|
569
583
|
? DataCubeColumnPinPlacement.LEFT
|
|
570
584
|
: DataCubeColumnPinPlacement.RIGHT,
|
|
571
585
|
);
|
|
572
|
-
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
|
|
589
|
+
onColumnMoved: (event) => {
|
|
590
|
+
// make sure the move event is finished before syncing the changes
|
|
591
|
+
if (event.column && event.finished) {
|
|
592
|
+
dataCube.grid.controller.rearrangeColumns(
|
|
593
|
+
(event.api.getColumnDefs() ?? [])
|
|
594
|
+
.filter((col): col is ColDef => !('children' in col))
|
|
595
|
+
.map((col) => col.colId ?? ''),
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
onColumnVisible: (event) => {
|
|
601
|
+
if (event.column) {
|
|
602
|
+
const column = event.column;
|
|
603
|
+
const isVisible = column.isVisible();
|
|
604
|
+
dataCube.grid.controller.showColumn(column.getColId(), isVisible);
|
|
573
605
|
}
|
|
574
606
|
},
|
|
575
607
|
|
|
@@ -612,20 +644,16 @@ export function generateGridOptionsFromSnapshot(
|
|
|
612
644
|
sortable: false, // TODO: @akphi - we can support this in the configuration
|
|
613
645
|
} satisfies ColDef,
|
|
614
646
|
// TODO: handle pivot and column grouping
|
|
615
|
-
...
|
|
647
|
+
...configuration.columns.map((column) => {
|
|
616
648
|
const columnData = {
|
|
617
649
|
snapshot,
|
|
618
650
|
column,
|
|
619
|
-
configuration
|
|
620
|
-
configuration.columns.find((col) => col.name === column.name),
|
|
621
|
-
),
|
|
622
|
-
gridConfiguration: configuration,
|
|
651
|
+
configuration,
|
|
623
652
|
};
|
|
624
653
|
return {
|
|
625
654
|
headerName: column.name,
|
|
626
655
|
field: column.name,
|
|
627
656
|
menuTabs: [],
|
|
628
|
-
suppressMovable: true,
|
|
629
657
|
|
|
630
658
|
..._displaySpec(columnData),
|
|
631
659
|
..._sizeSpec(columnData),
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { guaranteeNonNullable, isNonNullable } from '@finos/legend-shared';
|
|
18
|
+
import { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
|
|
19
|
+
import type {
|
|
20
|
+
DataCubeQuerySnapshot,
|
|
21
|
+
DataCubeQuerySnapshotColumn,
|
|
22
|
+
DataCubeQuerySnapshotSortColumn,
|
|
23
|
+
} from '../core/DataCubeQuerySnapshot.js';
|
|
24
|
+
import { DataCubeQuerySnapshotSubscriber } from '../core/DataCubeQuerySnapshotSubscriber.js';
|
|
25
|
+
import {
|
|
26
|
+
type DataCubeQuerySortOperation,
|
|
27
|
+
type DataCubeColumnPinPlacement,
|
|
28
|
+
DataCubeColumnKind,
|
|
29
|
+
} from '../core/DataCubeQueryEngine.js';
|
|
30
|
+
import type {
|
|
31
|
+
GetContextMenuItemsParams,
|
|
32
|
+
GetMainMenuItemsParams,
|
|
33
|
+
MenuItemDef,
|
|
34
|
+
} from '@ag-grid-community/core';
|
|
35
|
+
import type { DataCubeState } from '../DataCubeState.js';
|
|
36
|
+
import { generateMenuBuilder } from './DataCubeGridMenuBuilder.js';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This state is responsible for capturing edition to the data cube query
|
|
40
|
+
* caused by interaction with the grid which is not captured by the server-side row model
|
|
41
|
+
* datasource, e.g. column pinning, column visibility changes, etc.
|
|
42
|
+
*
|
|
43
|
+
* NOTE: since typically, each grid action causes a new snapshot to be created,
|
|
44
|
+
* we MUST NEVER use the editor here, as it could potentially create illegal state
|
|
45
|
+
* while the editor is still in the middle of a modification that has not been applied.
|
|
46
|
+
*/
|
|
47
|
+
export class DataCubeGridControllerState extends DataCubeQuerySnapshotSubscriber {
|
|
48
|
+
configuration = new DataCubeConfiguration();
|
|
49
|
+
|
|
50
|
+
selectableColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
51
|
+
selectColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
52
|
+
|
|
53
|
+
verticalPivotableColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
54
|
+
verticalPivotedColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
55
|
+
|
|
56
|
+
sortableColumns: DataCubeQuerySnapshotColumn[] = [];
|
|
57
|
+
sortColumns: DataCubeQuerySnapshotSortColumn[] = [];
|
|
58
|
+
|
|
59
|
+
menuBuilder?:
|
|
60
|
+
| ((
|
|
61
|
+
params:
|
|
62
|
+
| GetContextMenuItemsParams<unknown, { dataCube: DataCubeState }>
|
|
63
|
+
| GetMainMenuItemsParams<unknown, { dataCube: DataCubeState }>,
|
|
64
|
+
) => (string | MenuItemDef)[])
|
|
65
|
+
| undefined;
|
|
66
|
+
|
|
67
|
+
getColumnConfiguration(colName: string | undefined) {
|
|
68
|
+
return this.configuration.columns.find((col) => col.name === colName);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
pinColumn(
|
|
72
|
+
colName: string | undefined,
|
|
73
|
+
placement: DataCubeColumnPinPlacement | undefined,
|
|
74
|
+
) {
|
|
75
|
+
const columnConfiguration = this.getColumnConfiguration(colName);
|
|
76
|
+
if (columnConfiguration) {
|
|
77
|
+
columnConfiguration.pinned = placement;
|
|
78
|
+
this.applyChanges();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
rearrangeColumns(columnByNames: string[]) {
|
|
83
|
+
this.configuration.columns = columnByNames
|
|
84
|
+
.map((colName) => this.getColumnConfiguration(colName))
|
|
85
|
+
.filter(isNonNullable);
|
|
86
|
+
this.selectColumns = this.configuration.columns
|
|
87
|
+
.map((column) =>
|
|
88
|
+
this.selectColumns.find((col) => col.name === column.name),
|
|
89
|
+
)
|
|
90
|
+
.filter(isNonNullable);
|
|
91
|
+
this.applyChanges();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
removeAllPins() {
|
|
95
|
+
this.configuration.columns.forEach((col) => (col.pinned = undefined));
|
|
96
|
+
this.applyChanges();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
showColumn(colName: string | undefined, isVisible: boolean): void {
|
|
100
|
+
const columnConfiguration = this.getColumnConfiguration(colName);
|
|
101
|
+
if (columnConfiguration) {
|
|
102
|
+
columnConfiguration.hideFromView = !isVisible;
|
|
103
|
+
this.applyChanges();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setVerticalPivotOnColumn(colName: string | undefined) {
|
|
108
|
+
const column = this.verticalPivotableColumns.find(
|
|
109
|
+
(col) => col.name === colName,
|
|
110
|
+
);
|
|
111
|
+
if (column) {
|
|
112
|
+
this.verticalPivotedColumns = [column];
|
|
113
|
+
this.applyChanges();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
addVerticalPivotOnColumn(colName: string | undefined) {
|
|
118
|
+
const column = this.verticalPivotableColumns.find(
|
|
119
|
+
(col) => col.name === colName,
|
|
120
|
+
);
|
|
121
|
+
if (column) {
|
|
122
|
+
this.verticalPivotedColumns = [...this.verticalPivotedColumns, column];
|
|
123
|
+
this.applyChanges();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
removeVerticalPivotOnColumn(colName: string | undefined) {
|
|
128
|
+
this.verticalPivotedColumns = this.verticalPivotedColumns.filter(
|
|
129
|
+
(col) => col.name === colName,
|
|
130
|
+
);
|
|
131
|
+
this.applyChanges();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
clearAllVerticalPivots() {
|
|
135
|
+
this.verticalPivotedColumns = [];
|
|
136
|
+
this.applyChanges();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getActionableSortColumn(
|
|
140
|
+
colName: string,
|
|
141
|
+
operation: DataCubeQuerySortOperation,
|
|
142
|
+
) {
|
|
143
|
+
const column = this.sortableColumns.find((col) => col.name === colName);
|
|
144
|
+
if (!column) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
const sortColumn = this.sortColumns.find((col) => col.name === colName);
|
|
148
|
+
if (sortColumn && sortColumn.operation !== operation) {
|
|
149
|
+
return sortColumn;
|
|
150
|
+
}
|
|
151
|
+
if (!sortColumn) {
|
|
152
|
+
return { ...column, operation };
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setSortByColumn(colName: string, operation: DataCubeQuerySortOperation) {
|
|
158
|
+
const column = this.getActionableSortColumn(colName, operation);
|
|
159
|
+
if (!column) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
column.operation = operation;
|
|
163
|
+
this.sortColumns = [column];
|
|
164
|
+
this.applyChanges();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
addSortByColumn(colName: string, operation: DataCubeQuerySortOperation) {
|
|
168
|
+
const column = this.getActionableSortColumn(colName, operation);
|
|
169
|
+
if (!column) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
column.operation = operation;
|
|
173
|
+
this.sortColumns = [...this.sortColumns, column];
|
|
174
|
+
this.applyChanges();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
clearSortByColumn(colName: string) {
|
|
178
|
+
this.sortColumns = this.sortColumns.filter((col) => col.name !== colName);
|
|
179
|
+
this.applyChanges();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
clearAllSorts() {
|
|
183
|
+
this.sortColumns = [];
|
|
184
|
+
this.applyChanges();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private applyChanges(): void {
|
|
188
|
+
const baseSnapshot = guaranteeNonNullable(this.getLatestSnapshot());
|
|
189
|
+
const snapshot = baseSnapshot.clone();
|
|
190
|
+
|
|
191
|
+
snapshot.data.selectColumns = this.selectColumns;
|
|
192
|
+
snapshot.data.sortColumns = this.sortColumns;
|
|
193
|
+
snapshot.data.configuration = DataCubeConfiguration.serialization.toJson(
|
|
194
|
+
this.configuration,
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
snapshot.data.groupBy = this.verticalPivotedColumns.length
|
|
198
|
+
? {
|
|
199
|
+
columns: this.verticalPivotedColumns,
|
|
200
|
+
aggColumns: this.configuration.columns
|
|
201
|
+
.filter(
|
|
202
|
+
(column) =>
|
|
203
|
+
column.kind === DataCubeColumnKind.MEASURE &&
|
|
204
|
+
column.aggregateFunction !== undefined &&
|
|
205
|
+
!this.verticalPivotedColumns.find(
|
|
206
|
+
(col) => col.name === column.name,
|
|
207
|
+
),
|
|
208
|
+
)
|
|
209
|
+
.map((column) => ({
|
|
210
|
+
name: column.name,
|
|
211
|
+
type: column.type,
|
|
212
|
+
function: guaranteeNonNullable(column.aggregateFunction),
|
|
213
|
+
})),
|
|
214
|
+
}
|
|
215
|
+
: undefined;
|
|
216
|
+
|
|
217
|
+
snapshot.finalize();
|
|
218
|
+
if (snapshot.hashCode !== baseSnapshot.hashCode) {
|
|
219
|
+
this.publishSnapshot(snapshot);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
override async applySnapshot(
|
|
224
|
+
snapshot: DataCubeQuerySnapshot,
|
|
225
|
+
previousSnapshot: DataCubeQuerySnapshot | undefined,
|
|
226
|
+
) {
|
|
227
|
+
const newSnapshot = snapshot.clone();
|
|
228
|
+
|
|
229
|
+
this.configuration = DataCubeConfiguration.serialization.fromJson(
|
|
230
|
+
snapshot.data.configuration,
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
this.selectableColumns = newSnapshot.stageCols('select');
|
|
234
|
+
this.selectColumns = newSnapshot.data.selectColumns;
|
|
235
|
+
|
|
236
|
+
this.sortableColumns = newSnapshot.stageCols('sort');
|
|
237
|
+
this.sortColumns = newSnapshot.data.sortColumns;
|
|
238
|
+
|
|
239
|
+
this.verticalPivotableColumns = newSnapshot
|
|
240
|
+
.stageCols('aggregation')
|
|
241
|
+
.filter(
|
|
242
|
+
(column) =>
|
|
243
|
+
this.getColumnConfiguration(column.name)?.kind ===
|
|
244
|
+
DataCubeColumnKind.DIMENSION,
|
|
245
|
+
);
|
|
246
|
+
this.verticalPivotedColumns = newSnapshot.data.groupBy?.columns ?? [];
|
|
247
|
+
|
|
248
|
+
this.menuBuilder = generateMenuBuilder(this);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
override async initialize() {
|
|
252
|
+
// do nothing
|
|
253
|
+
}
|
|
254
|
+
}
|