@finos/legend-query-builder 4.14.26 → 4.14.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts +4 -0
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js +126 -37
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
- package/lib/index.css +17 -1
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts +12 -0
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +68 -4
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/package.json +3 -3
- package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +188 -11
- package/src/stores/QueryBuilderResultState.ts +82 -4
@@ -48,6 +48,7 @@ import { QUERY_BUILDER_EVENT } from '../__lib__/QueryBuilderEvent.js';
|
|
48
48
|
import { ExecutionPlanState } from './execution-plan/ExecutionPlanState.js';
|
49
49
|
import type { DataGridColumnState } from '@finos/legend-lego/data-grid';
|
50
50
|
import { downloadStream } from '@finos/legend-application';
|
51
|
+
import { QueryBuilderDataGridCustomAggregationFunction } from '../components/result/tds/QueryBuilderTDSGridResult.js';
|
51
52
|
|
52
53
|
export const DEFAULT_LIMIT = 1000;
|
53
54
|
|
@@ -83,8 +84,37 @@ type QueryBuilderDataGridConfig = {
|
|
83
84
|
isPivotModeEnabled: boolean | undefined;
|
84
85
|
isLocalModeEnabled: boolean | undefined;
|
85
86
|
previewLimit?: number | undefined;
|
87
|
+
weightedColumnPairs?: Map<string, string> | undefined;
|
86
88
|
};
|
87
89
|
|
90
|
+
export class QueryBuilderResultWavgAggregationState {
|
91
|
+
isApplyingWavg = false;
|
92
|
+
weightedColumnIdPairs: Map<string, string>;
|
93
|
+
|
94
|
+
constructor() {
|
95
|
+
makeObservable(this, {
|
96
|
+
isApplyingWavg: observable,
|
97
|
+
weightedColumnIdPairs: observable,
|
98
|
+
setIsApplyingWavg: action,
|
99
|
+
addWeightedColumnIdPair: action,
|
100
|
+
removeWeightedColumnIdPair: action,
|
101
|
+
});
|
102
|
+
this.weightedColumnIdPairs = new Map<string, string>();
|
103
|
+
}
|
104
|
+
|
105
|
+
setIsApplyingWavg(val: boolean): void {
|
106
|
+
this.isApplyingWavg = val;
|
107
|
+
}
|
108
|
+
|
109
|
+
addWeightedColumnIdPair(col: string, weightedColumnId: string): void {
|
110
|
+
this.weightedColumnIdPairs.set(col, weightedColumnId);
|
111
|
+
}
|
112
|
+
|
113
|
+
removeWeightedColumnIdPair(col: string): void {
|
114
|
+
this.weightedColumnIdPairs.delete(col);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
88
118
|
export class QueryBuilderResultState {
|
89
119
|
readonly queryBuilderState: QueryBuilderState;
|
90
120
|
readonly executionPlanState: ExecutionPlanState;
|
@@ -105,6 +135,7 @@ export class QueryBuilderResultState {
|
|
105
135
|
isSelectingCells: boolean;
|
106
136
|
|
107
137
|
gridConfig: QueryBuilderDataGridConfig | undefined;
|
138
|
+
wavgAggregationState: QueryBuilderResultWavgAggregationState | undefined;
|
108
139
|
|
109
140
|
constructor(queryBuilderState: QueryBuilderState) {
|
110
141
|
makeObservable(this, {
|
@@ -120,7 +151,9 @@ export class QueryBuilderResultState {
|
|
120
151
|
isSelectingCells: observable,
|
121
152
|
isQueryUsageViewerOpened: observable,
|
122
153
|
gridConfig: observable,
|
154
|
+
wavgAggregationState: observable,
|
123
155
|
setGridConfig: action,
|
156
|
+
setWavgAggregationState: action,
|
124
157
|
setIsSelectingCells: action,
|
125
158
|
setIsRunningQuery: action,
|
126
159
|
setExecutionResult: action,
|
@@ -153,6 +186,12 @@ export class QueryBuilderResultState {
|
|
153
186
|
this.gridConfig = val;
|
154
187
|
}
|
155
188
|
|
189
|
+
setWavgAggregationState(
|
190
|
+
val: QueryBuilderResultWavgAggregationState | undefined,
|
191
|
+
): void {
|
192
|
+
this.wavgAggregationState = val;
|
193
|
+
}
|
194
|
+
|
156
195
|
setIsSelectingCells(val: boolean): void {
|
157
196
|
this.isSelectingCells = val;
|
158
197
|
}
|
@@ -199,11 +238,50 @@ export class QueryBuilderResultState {
|
|
199
238
|
}
|
200
239
|
}
|
201
240
|
|
241
|
+
processWeightedColumnPairsMap(
|
242
|
+
config: QueryGridConfig,
|
243
|
+
): Map<string, string> | undefined {
|
244
|
+
if (config.weightedColumnPairs) {
|
245
|
+
const wavgColumns = config.columns
|
246
|
+
.filter(
|
247
|
+
(col) =>
|
248
|
+
(col as DataGridColumnState).aggFunc ===
|
249
|
+
QueryBuilderDataGridCustomAggregationFunction.WAVG,
|
250
|
+
)
|
251
|
+
.map((col) => (col as DataGridColumnState).colId);
|
252
|
+
const weightedColumnPairsMap = new Map<string, string>();
|
253
|
+
config.weightedColumnPairs.forEach((wc) => {
|
254
|
+
if (wc[0] && wc[1]) {
|
255
|
+
weightedColumnPairsMap.set(wc[0], wc[1]);
|
256
|
+
}
|
257
|
+
});
|
258
|
+
for (const wavgCol of weightedColumnPairsMap.keys()) {
|
259
|
+
if (!wavgColumns.includes(wavgCol)) {
|
260
|
+
weightedColumnPairsMap.delete(wavgCol);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
return weightedColumnPairsMap;
|
264
|
+
}
|
265
|
+
return undefined;
|
266
|
+
}
|
267
|
+
|
202
268
|
handlePreConfiguredGridConfig(config: QueryGridConfig): void {
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
269
|
+
let newConfig;
|
270
|
+
const weightedColumnPairsMap = this.processWeightedColumnPairsMap(config);
|
271
|
+
if (weightedColumnPairsMap) {
|
272
|
+
this.wavgAggregationState = new QueryBuilderResultWavgAggregationState();
|
273
|
+
this.wavgAggregationState.weightedColumnIdPairs = weightedColumnPairsMap;
|
274
|
+
newConfig = {
|
275
|
+
...config,
|
276
|
+
weightedColumnPairs: weightedColumnPairsMap,
|
277
|
+
columns: config.columns as DataGridColumnState[],
|
278
|
+
};
|
279
|
+
} else {
|
280
|
+
newConfig = {
|
281
|
+
...config,
|
282
|
+
columns: config.columns as DataGridColumnState[],
|
283
|
+
};
|
284
|
+
}
|
207
285
|
if (config.previewLimit) {
|
208
286
|
this.setPreviewLimit(config.previewLimit);
|
209
287
|
}
|