@adaptabletools/adaptable 24.0.4 → 24.0.6
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/package.json +2 -3
- package/src/AdaptableState/Uuid.d.ts +1 -1
- package/src/AdaptableState/Uuid.js +38 -2
- package/src/Utilities/Helpers/Layouts/LayoutHelper.d.ts +5 -0
- package/src/Utilities/Helpers/Layouts/LayoutHelper.js +33 -3
- package/src/agGrid/AdaptableAgGrid.d.ts +1 -0
- package/src/agGrid/AdaptableAgGrid.js +55 -38
- package/src/agGrid/AgGridOptionsService.js +5 -0
- package/src/components/utils/uuid.d.ts +1 -2
- package/src/components/utils/uuid.js +1 -2
- package/src/env.js +2 -2
- package/src/layout-manager/src/index.d.ts +51 -10
- package/src/layout-manager/src/index.js +334 -91
- package/src/layout-manager/src/isLayoutEqual.js +4 -0
- package/src/layout-manager/src/rowGroupExpansionMatcher.d.ts +116 -0
- package/src/layout-manager/src/rowGroupExpansionMatcher.js +240 -0
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/vendor/components/Resizable/index.d.ts.map +1 -1
- package/vendor/components/Resizable/index.js +22 -10
- package/vendor/components/Resizable/index.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { debounce
|
|
1
|
+
import { debounce } from '@infinite-table/infinite-react';
|
|
2
2
|
import { isPivotLayoutModel } from './isPivotLayoutModel';
|
|
3
3
|
import { LMEmitter } from './LMEmitter';
|
|
4
4
|
import { AUTO_GROUP_COLUMN_ID__MULTI_PREFIX, AUTO_GROUP_COLUMN_ID__SINGLE, normalizeLayoutModel, normalizePivotLayoutModel, normalizeTableLayoutModel, } from './normalizeLayoutModel';
|
|
@@ -11,6 +11,7 @@ import { isPivotAggTotalColumn } from './isPivotAggTotalColumn';
|
|
|
11
11
|
import { isPivotGrandTotal } from './isPivotGrandTotal';
|
|
12
12
|
import { isPivotColumnTotal } from './isPivotColumnTotal';
|
|
13
13
|
import { expandAllRowGroups } from './expandAllRowGroups';
|
|
14
|
+
import { compileLayoutRowGroupExpansionMatcher, compileRowGroupExpansionMatcher, getLayoutModelGroupedColumns, getRowGroupNodePath, isPersistableGroupNode, isRowGroupExpandedByMatcher, isRowGroupOpenedEventRedundant, mergeRowGroupExceptionPaths, patchRowGroupExceptionPaths, subtractRowGroupExceptionPaths, } from './rowGroupExpansionMatcher';
|
|
14
15
|
import { getMarker } from '../../devTools';
|
|
15
16
|
export const PIVOT_ANY_TOTAL_COL_TYPE = 'pivotAnyTotal';
|
|
16
17
|
export const PIVOT_GRAND_TOTAL_COL_TYPE = 'pivotGrandTotal';
|
|
@@ -85,7 +86,7 @@ function isGridLayoutSame(options) {
|
|
|
85
86
|
if (!!gridLayout != !!layout) {
|
|
86
87
|
return false;
|
|
87
88
|
}
|
|
88
|
-
return isLayoutEqual(
|
|
89
|
+
return isLayoutEqual(gridLayout, layout);
|
|
89
90
|
}
|
|
90
91
|
function getDefaultColumnSizeStateForColDef(colId, colDef, options) {
|
|
91
92
|
if (!colDef) {
|
|
@@ -154,8 +155,14 @@ export class LayoutManager extends LMEmitter {
|
|
|
154
155
|
layoutManagerDebugId;
|
|
155
156
|
initialRowSelection;
|
|
156
157
|
getRowSelectionCheckboxesOverride;
|
|
158
|
+
rowGroupExpansionMatcherRef = { current: null };
|
|
159
|
+
rowModelType;
|
|
160
|
+
pendingSsrmExpansionBatch = null;
|
|
161
|
+
ssrmExpansionFlushScheduled = false;
|
|
162
|
+
gridLayoutChangedLogger;
|
|
157
163
|
constructor(options) {
|
|
158
164
|
super({ debugId: options.debugId });
|
|
165
|
+
this.gridLayoutChangedLogger = this.infoLogger.extend('gridLayoutChanged');
|
|
159
166
|
this.layoutChangeDebounce = options.layoutChangeDebounce ?? 0;
|
|
160
167
|
if (this.layoutChangeDebounce) {
|
|
161
168
|
this.onGridLayoutChanged = debounce(this.onGridLayoutChanged, {
|
|
@@ -175,6 +182,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
175
182
|
return;
|
|
176
183
|
}
|
|
177
184
|
super.destroy();
|
|
185
|
+
this.pendingSsrmExpansionBatch = null;
|
|
178
186
|
if (this.setGridOption_default) {
|
|
179
187
|
this.gridApi.setGridOption = this.setGridOption_default;
|
|
180
188
|
}
|
|
@@ -209,6 +217,93 @@ export class LayoutManager extends LMEmitter {
|
|
|
209
217
|
};
|
|
210
218
|
this.gridApi.setGridOption = setGridOption;
|
|
211
219
|
}
|
|
220
|
+
scheduleSsrmExpansionFlush() {
|
|
221
|
+
if (this.ssrmExpansionFlushScheduled) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this.ssrmExpansionFlushScheduled = true;
|
|
225
|
+
queueMicrotask(() => {
|
|
226
|
+
this.ssrmExpansionFlushScheduled = false;
|
|
227
|
+
this.flushPendingSsrmExpansionBatch();
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
applyExpansionTogglesToPaths(paths, toggles, rowGroupDisplay) {
|
|
231
|
+
let nextPaths = paths;
|
|
232
|
+
for (let i = 0; i < toggles.length; i++) {
|
|
233
|
+
const { path, expanded } = toggles[i];
|
|
234
|
+
const shouldInclude = rowGroupDisplay === 'collapsed' ? expanded : !expanded;
|
|
235
|
+
nextPaths = patchRowGroupExceptionPaths(nextPaths, path, shouldInclude);
|
|
236
|
+
}
|
|
237
|
+
return nextPaths;
|
|
238
|
+
}
|
|
239
|
+
patchCurrentLayoutGroupKeysForPreviousGrouping(batch, prevGroupedCols) {
|
|
240
|
+
const currentRowGroupValues = this.currentLayout?.RowGroupValues;
|
|
241
|
+
if (!currentRowGroupValues ||
|
|
242
|
+
(currentRowGroupValues.RowGroupDisplay !== 'collapsed' &&
|
|
243
|
+
currentRowGroupValues.RowGroupDisplay !== 'expanded') ||
|
|
244
|
+
!Array.isArray(currentRowGroupValues.GroupKeys)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const prevGroupedKey = prevGroupedCols.join(',');
|
|
248
|
+
const matchingIndex = currentRowGroupValues.GroupKeys.findIndex((item) => (item.RowGroupedColumns || []).join(',') === prevGroupedKey);
|
|
249
|
+
if (matchingIndex === -1) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const rowGroupDisplay = currentRowGroupValues.RowGroupDisplay;
|
|
253
|
+
const currentPaths = currentRowGroupValues.GroupKeys[matchingIndex].Values || [];
|
|
254
|
+
let nextPaths = currentPaths;
|
|
255
|
+
if (batch.kind === 'toggles') {
|
|
256
|
+
nextPaths = this.applyExpansionTogglesToPaths(currentPaths, batch.toggles, rowGroupDisplay);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
const clearsAll = ((rowGroupDisplay === 'collapsed' && batch.source === 'collapseAll') ||
|
|
260
|
+
(rowGroupDisplay === 'expanded' && batch.source === 'expandAll')) &&
|
|
261
|
+
this.gridApi.getGridOption('ssrmExpandAllAffectsAllRows') !== false;
|
|
262
|
+
nextPaths = clearsAll ? [] : currentPaths;
|
|
263
|
+
nextPaths = this.applyExpansionTogglesToPaths(nextPaths, batch.postBulkToggles, rowGroupDisplay);
|
|
264
|
+
}
|
|
265
|
+
if (nextPaths === currentPaths) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const nextGroupKeys = currentRowGroupValues.GroupKeys.map((item, index) => index === matchingIndex
|
|
269
|
+
? { RowGroupedColumns: item.RowGroupedColumns, Values: nextPaths }
|
|
270
|
+
: item);
|
|
271
|
+
this.currentLayout = {
|
|
272
|
+
...this.currentLayout,
|
|
273
|
+
RowGroupValues: rowGroupDisplay === 'collapsed'
|
|
274
|
+
? { RowGroupDisplay: 'collapsed', GroupKeys: nextGroupKeys }
|
|
275
|
+
: { RowGroupDisplay: 'expanded', GroupKeys: nextGroupKeys },
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
flushPendingSsrmExpansionBatch() {
|
|
279
|
+
const batch = this.pendingSsrmExpansionBatch;
|
|
280
|
+
this.pendingSsrmExpansionBatch = null;
|
|
281
|
+
if (!batch ||
|
|
282
|
+
!this.currentLayout ||
|
|
283
|
+
this.destroyed ||
|
|
284
|
+
!this.gridApi ||
|
|
285
|
+
this.gridApi.isDestroyed()) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const currentGroupedCols = getLayoutModelGroupedColumns(this.currentLayout) || [];
|
|
289
|
+
const gridGroupedCols = (this.gridApi.getRowGroupColumns() || []).map((c) => c.getColId());
|
|
290
|
+
if (currentGroupedCols.join(',') !== gridGroupedCols.join(',')) {
|
|
291
|
+
this.patchCurrentLayoutGroupKeysForPreviousGrouping(batch, currentGroupedCols);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const type = batch.kind === 'bulk' ? 'expandOrCollapseAll' : 'rowGroupOpened';
|
|
295
|
+
const triggerEvent = {
|
|
296
|
+
type,
|
|
297
|
+
ssrmExpansionBatch: batch,
|
|
298
|
+
};
|
|
299
|
+
const gridLayout = this.getLayoutModelFromGrid(triggerEvent);
|
|
300
|
+
if (!isGridLayoutSame({
|
|
301
|
+
layoutFromGrid: gridLayout,
|
|
302
|
+
layoutFromModel: this.currentLayout,
|
|
303
|
+
})) {
|
|
304
|
+
this.onGridLayoutChanged(gridLayout);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
212
307
|
globalAgGridEventListener = (type, event) => {
|
|
213
308
|
if (this.destroyed || this.suppressGlobalAgGridEventListener) {
|
|
214
309
|
return;
|
|
@@ -220,13 +315,88 @@ export class LayoutManager extends LMEmitter {
|
|
|
220
315
|
if (type === 'displayedColumnsChanged' && event.source === 'uiColumnDragged') {
|
|
221
316
|
return;
|
|
222
317
|
}
|
|
318
|
+
if (type === 'rowGroupOpened') {
|
|
319
|
+
const node = event?.node;
|
|
320
|
+
const inPivotMode = this.isInPivotMode();
|
|
321
|
+
const allowUnbalanced = !!this.gridApi.getGridOption('groupAllowUnbalanced');
|
|
322
|
+
if (!isPersistableGroupNode(node, { inPivotMode, allowUnbalanced })) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (this.currentLayout) {
|
|
326
|
+
const rowGroupDisplay = this.currentLayout.RowGroupValues?.RowGroupDisplay;
|
|
327
|
+
if (rowGroupDisplay !== 'expanded' && rowGroupDisplay !== 'collapsed') {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (this.isServerSideRowModel() &&
|
|
331
|
+
!this.layoutChangeDebounce &&
|
|
332
|
+
!this.pendingSsrmExpansionBatch &&
|
|
333
|
+
isRowGroupOpenedEventRedundant({
|
|
334
|
+
node,
|
|
335
|
+
expanded: !!event?.expanded,
|
|
336
|
+
rowGroupDisplay,
|
|
337
|
+
matcher: this.rowGroupExpansionMatcherRef.current,
|
|
338
|
+
inPivotMode,
|
|
339
|
+
allowUnbalanced,
|
|
340
|
+
})) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else if (type === 'expandOrCollapseAll' && this.currentLayout) {
|
|
346
|
+
const rowGroupDisplay = this.currentLayout.RowGroupValues?.RowGroupDisplay;
|
|
347
|
+
if (rowGroupDisplay !== 'expanded' && rowGroupDisplay !== 'collapsed') {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (this.isServerSideRowModel() &&
|
|
352
|
+
this.currentLayout &&
|
|
353
|
+
(type === 'rowGroupOpened' || type === 'expandOrCollapseAll')) {
|
|
354
|
+
this.warn(`globalAgGridEventListener-${type}`, event);
|
|
355
|
+
if (type === 'expandOrCollapseAll') {
|
|
356
|
+
this.pendingSsrmExpansionBatch = {
|
|
357
|
+
kind: 'bulk',
|
|
358
|
+
source: event?.source,
|
|
359
|
+
postBulkToggles: [],
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
const toggle = {
|
|
364
|
+
path: getRowGroupNodePath(event.node),
|
|
365
|
+
expanded: !!event.expanded,
|
|
366
|
+
};
|
|
367
|
+
if (!this.pendingSsrmExpansionBatch) {
|
|
368
|
+
this.pendingSsrmExpansionBatch = {
|
|
369
|
+
kind: 'toggles',
|
|
370
|
+
toggles: [toggle],
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
else if (this.pendingSsrmExpansionBatch.kind === 'toggles') {
|
|
374
|
+
this.pendingSsrmExpansionBatch.toggles.push(toggle);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.pendingSsrmExpansionBatch.postBulkToggles.push(toggle);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
this.scheduleSsrmExpansionFlush();
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (this.pendingSsrmExpansionBatch) {
|
|
384
|
+
this.flushPendingSsrmExpansionBatch();
|
|
385
|
+
if (this.destroyed ||
|
|
386
|
+
this.suppressGlobalAgGridEventListener ||
|
|
387
|
+
!this.gridApi ||
|
|
388
|
+
this.gridApi.isDestroyed()) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
223
392
|
this.warn(`globalAgGridEventListener-${type}`, event);
|
|
393
|
+
const triggerEvent = { type, event };
|
|
224
394
|
if (!this.currentLayout) {
|
|
225
|
-
const gridLayout = this.getLayoutModelFromGrid();
|
|
395
|
+
const gridLayout = this.getLayoutModelFromGrid(triggerEvent);
|
|
226
396
|
this.onGridLayoutChanged(gridLayout);
|
|
227
397
|
return;
|
|
228
398
|
}
|
|
229
|
-
const gridLayout = this.getLayoutModelFromGrid();
|
|
399
|
+
const gridLayout = this.getLayoutModelFromGrid(triggerEvent);
|
|
230
400
|
if (!isGridLayoutSame({
|
|
231
401
|
layoutFromGrid: gridLayout,
|
|
232
402
|
layoutFromModel: this.currentLayout,
|
|
@@ -243,7 +413,9 @@ export class LayoutManager extends LMEmitter {
|
|
|
243
413
|
this.warn('onColumnDefsChanged');
|
|
244
414
|
this.indexColumns();
|
|
245
415
|
if (this.currentLayout) {
|
|
246
|
-
this.applyLayout(this.currentLayout
|
|
416
|
+
this.applyLayout(this.currentLayout, {
|
|
417
|
+
skipApplyRowGroupsExpandedState: this.isServerSideRowModel(),
|
|
418
|
+
});
|
|
247
419
|
}
|
|
248
420
|
this.emitSync('columnDefsChanged', colDefs);
|
|
249
421
|
};
|
|
@@ -278,6 +450,25 @@ export class LayoutManager extends LMEmitter {
|
|
|
278
450
|
if (this._prevFiredLayout && isLayoutEqual(layout, this._prevFiredLayout)) {
|
|
279
451
|
return;
|
|
280
452
|
}
|
|
453
|
+
const groupedColumns = getLayoutModelGroupedColumns(layout);
|
|
454
|
+
const prevGroupedColumns = getLayoutModelGroupedColumns(this.currentLayout ?? this._prevFiredLayout);
|
|
455
|
+
const didGroupingChange = (prevGroupedColumns || []).join(',') !== (groupedColumns || []).join(',');
|
|
456
|
+
if (groupedColumns && groupedColumns.length > 0 && didGroupingChange) {
|
|
457
|
+
const effectiveRowGroupValues = layout.RowGroupValues ??
|
|
458
|
+
(this.isServerSideRowModel() ? { RowGroupDisplay: 'always-collapsed' } : undefined);
|
|
459
|
+
if (effectiveRowGroupValues) {
|
|
460
|
+
const unsuppress = this.suspendAgGridListener();
|
|
461
|
+
this.applyRowGroupValues(effectiveRowGroupValues, groupedColumns);
|
|
462
|
+
unsuppress();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
else if (this.isServerSideRowModel()) {
|
|
466
|
+
const effectiveRowGroupValues = layout.RowGroupValues ??
|
|
467
|
+
(groupedColumns?.length ? { RowGroupDisplay: 'always-collapsed' } : undefined);
|
|
468
|
+
this.rowGroupExpansionMatcherRef.current = groupedColumns?.length
|
|
469
|
+
? compileRowGroupExpansionMatcher(effectiveRowGroupValues, groupedColumns)
|
|
470
|
+
: null;
|
|
471
|
+
}
|
|
281
472
|
this.triggerGridLayoutChange(layout);
|
|
282
473
|
}
|
|
283
474
|
triggerGridLayoutChange(layout, prevLayout = this._prevFiredLayout, options) {
|
|
@@ -286,19 +477,10 @@ export class LayoutManager extends LMEmitter {
|
|
|
286
477
|
const shouldSkipTriggerChange = options?.skipTriggerChange === true;
|
|
287
478
|
this._prevFiredLayout = layout;
|
|
288
479
|
this.currentLayout = layout;
|
|
289
|
-
if (layout.RowGroupedColumns &&
|
|
290
|
-
layout.RowGroupedColumns.length > 0 &&
|
|
291
|
-
(prevLayout?.RowGroupedColumns || []).join(',') !== layout.RowGroupedColumns.join(',') &&
|
|
292
|
-
layout.RowGroupValues) {
|
|
293
|
-
const unsupress = this.suspendAgGridListener();
|
|
294
|
-
this.applyRowGroupValues(layout.RowGroupValues, layout.RowGroupedColumns);
|
|
295
|
-
unsupress();
|
|
296
|
-
}
|
|
297
480
|
if (!shouldSkipTriggerChange) {
|
|
298
481
|
this.emitSync('gridLayoutChanged', layout);
|
|
299
|
-
const log = this.infoLogger.extend('gridLayoutChanged');
|
|
300
482
|
const changes = getChanges(normalizeLayoutModel(prevLayout), normalizeLayoutModel(layout));
|
|
301
|
-
|
|
483
|
+
this.gridLayoutChangedLogger('current grid layout:', layout, '\nprev layout:\n', prevLayout ?? 'no prev layout', '\nchanges from prev to current:\n', changes);
|
|
302
484
|
}
|
|
303
485
|
}
|
|
304
486
|
onChange(fn) {
|
|
@@ -313,13 +495,16 @@ export class LayoutManager extends LMEmitter {
|
|
|
313
495
|
if (options.getRowSelectionCheckboxesOverride !== undefined) {
|
|
314
496
|
this.getRowSelectionCheckboxesOverride = options.getRowSelectionCheckboxesOverride;
|
|
315
497
|
}
|
|
498
|
+
if (options.rowGroupExpansionMatcherRef !== undefined) {
|
|
499
|
+
this.rowGroupExpansionMatcherRef = options.rowGroupExpansionMatcherRef;
|
|
500
|
+
}
|
|
316
501
|
}
|
|
317
|
-
getLayoutModelFromGrid() {
|
|
502
|
+
getLayoutModelFromGrid(triggerEvent) {
|
|
318
503
|
return this.isInPivotMode()
|
|
319
|
-
? this.getPivotLayoutModelFromGrid()
|
|
320
|
-
: this.getTableLayoutModelFromGrid();
|
|
504
|
+
? this.getPivotLayoutModelFromGrid(triggerEvent)
|
|
505
|
+
: this.getTableLayoutModelFromGrid(triggerEvent);
|
|
321
506
|
}
|
|
322
|
-
getPivotLayoutModelFromGrid() {
|
|
507
|
+
getPivotLayoutModelFromGrid(triggerEvent) {
|
|
323
508
|
const pivotResultColumns = this.gridApi.getPivotResultColumns() || [];
|
|
324
509
|
const pivotResultColumnsSet = new Set(pivotResultColumns.map((col) => col.getColId()));
|
|
325
510
|
const prevLayout = this.currentLayout;
|
|
@@ -327,9 +512,8 @@ export class LayoutManager extends LMEmitter {
|
|
|
327
512
|
.getColumnState()
|
|
328
513
|
.filter((col) => !pivotResultColumnsSet.has(col.colId));
|
|
329
514
|
const PivotColumns = this.gridApi.getPivotColumns().map((col) => col.getColId());
|
|
330
|
-
const layout = this.getUndecidedLayoutModelFromGrid(columnState);
|
|
515
|
+
const layout = this.getUndecidedLayoutModelFromGrid(columnState, triggerEvent);
|
|
331
516
|
let ColumnSizing = layout.ColumnSizing || {};
|
|
332
|
-
let ColumnVisibility = { ...layout.ColumnVisibility };
|
|
333
517
|
const storePivotResultColumns = !!prevLayout?.PivotResultColumnsOrder;
|
|
334
518
|
pivotResultColumns.forEach((col) => {
|
|
335
519
|
const colId = col.getColId();
|
|
@@ -344,15 +528,6 @@ export class LayoutManager extends LMEmitter {
|
|
|
344
528
|
if (!Object.keys(ColumnSizing).length) {
|
|
345
529
|
ColumnSizing = undefined;
|
|
346
530
|
}
|
|
347
|
-
Object.keys(ColumnVisibility).forEach((colId) => {
|
|
348
|
-
const isInLayout = pivotResultColumnsSet.has(colId) || colId.startsWith(AUTO_GROUP_COLUMN_ID__SINGLE);
|
|
349
|
-
if (!isInLayout) {
|
|
350
|
-
delete ColumnVisibility[colId];
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
if (!Object.keys(ColumnVisibility).length) {
|
|
354
|
-
ColumnVisibility = undefined;
|
|
355
|
-
}
|
|
356
531
|
delete layout.TableColumns;
|
|
357
532
|
const pivotLayout = {
|
|
358
533
|
Name: layout.Name,
|
|
@@ -367,11 +542,11 @@ export class LayoutManager extends LMEmitter {
|
|
|
367
542
|
Ignore_Source: layout.Ignore_Source,
|
|
368
543
|
Ignore_AdaptableVersion: layout.Ignore_AdaptableVersion,
|
|
369
544
|
Ignore_Uuid: layout.Ignore_Uuid,
|
|
545
|
+
Ignore_OpenCharts: layout.Ignore_OpenCharts,
|
|
370
546
|
PivotColumns,
|
|
371
547
|
ColumnPinning: layout.ColumnPinning,
|
|
372
548
|
ColumnSorts: layout.ColumnSorts,
|
|
373
549
|
ColumnSizing,
|
|
374
|
-
ColumnVisibility,
|
|
375
550
|
RowGroupValues: layout.RowGroupValues,
|
|
376
551
|
ColumnGroupValues: layout.ColumnGroupValues,
|
|
377
552
|
PivotGroupedColumns: layout.RowGroupedColumns,
|
|
@@ -399,13 +574,25 @@ export class LayoutManager extends LMEmitter {
|
|
|
399
574
|
}
|
|
400
575
|
return simplifyPivotLayoutModel(pivotLayout);
|
|
401
576
|
}
|
|
402
|
-
getTableLayoutModelFromGrid() {
|
|
403
|
-
return this.getUndecidedLayoutModelFromGrid(this.gridApi.getColumnState());
|
|
577
|
+
getTableLayoutModelFromGrid(triggerEvent) {
|
|
578
|
+
return this.getUndecidedLayoutModelFromGrid(this.gridApi.getColumnState(), triggerEvent);
|
|
404
579
|
}
|
|
405
580
|
isTreeMode() {
|
|
406
581
|
return this.gridApi.getGridOption('treeData');
|
|
407
582
|
}
|
|
408
|
-
|
|
583
|
+
getRowModelType() {
|
|
584
|
+
if (this.rowModelType === undefined) {
|
|
585
|
+
this.rowModelType = this.gridApi.getGridOption('rowModelType') ?? 'clientSide';
|
|
586
|
+
}
|
|
587
|
+
return this.rowModelType;
|
|
588
|
+
}
|
|
589
|
+
isServerSideRowModel() {
|
|
590
|
+
return this.getRowModelType() === 'serverSide';
|
|
591
|
+
}
|
|
592
|
+
isClientSideRowModel() {
|
|
593
|
+
return this.getRowModelType() === 'clientSide';
|
|
594
|
+
}
|
|
595
|
+
getUndecidedLayoutModelFromGrid(columnState, triggerEvent) {
|
|
409
596
|
let TableColumns = columnState.map((c) => c.colId);
|
|
410
597
|
let ColumnSorts = [];
|
|
411
598
|
const RowGroupedColumns = [];
|
|
@@ -570,8 +757,10 @@ export class LayoutManager extends LMEmitter {
|
|
|
570
757
|
else if (currentRowGroupValues.RowGroupDisplay === 'collapsed') {
|
|
571
758
|
const ExpandedValues = isGroupingNew
|
|
572
759
|
? currentRowGroupValuesGroupKeys || []
|
|
573
|
-
: this.
|
|
574
|
-
|
|
760
|
+
: this.getNextRowGroupExceptionPaths({
|
|
761
|
+
rowGroupDisplay: 'collapsed',
|
|
762
|
+
currentPaths: currentRowGroupValuesGroupKeys || [],
|
|
763
|
+
triggerEvent,
|
|
575
764
|
});
|
|
576
765
|
if (Array.isArray(currentRowGroupValues.GroupKeys)) {
|
|
577
766
|
RowGroupValues = {
|
|
@@ -597,8 +786,10 @@ export class LayoutManager extends LMEmitter {
|
|
|
597
786
|
else if (currentRowGroupValues.RowGroupDisplay === 'expanded') {
|
|
598
787
|
const CollapsedValues = isGroupingNew
|
|
599
788
|
? currentRowGroupValuesGroupKeys || []
|
|
600
|
-
: this.
|
|
601
|
-
|
|
789
|
+
: this.getNextRowGroupExceptionPaths({
|
|
790
|
+
rowGroupDisplay: 'expanded',
|
|
791
|
+
currentPaths: currentRowGroupValuesGroupKeys || [],
|
|
792
|
+
triggerEvent,
|
|
602
793
|
});
|
|
603
794
|
if (Array.isArray(currentRowGroupValues.GroupKeys)) {
|
|
604
795
|
RowGroupValues = {
|
|
@@ -683,6 +874,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
683
874
|
Ignore_Source: this.currentLayout?.Ignore_Source,
|
|
684
875
|
Ignore_AdaptableVersion: this.currentLayout?.Ignore_AdaptableVersion,
|
|
685
876
|
Ignore_Uuid: this.currentLayout?.Ignore_Uuid,
|
|
877
|
+
Ignore_OpenCharts: this.currentLayout?.Ignore_OpenCharts,
|
|
686
878
|
TableColumns: TableColumns,
|
|
687
879
|
ColumnVisibility,
|
|
688
880
|
ColumnSizing,
|
|
@@ -951,18 +1143,28 @@ export class LayoutManager extends LMEmitter {
|
|
|
951
1143
|
}
|
|
952
1144
|
this.currentLayout = layout;
|
|
953
1145
|
this._prevFiredLayout = layout;
|
|
1146
|
+
if (this.isServerSideRowModel()) {
|
|
1147
|
+
this.rowGroupExpansionMatcherRef.current = compileLayoutRowGroupExpansionMatcher(layout);
|
|
1148
|
+
}
|
|
954
1149
|
}
|
|
955
1150
|
setLayout(layout, options) {
|
|
956
1151
|
layout = normalizeLayoutModel(layout, { isTree: this.isTreeMode() });
|
|
957
1152
|
const shouldSkipTriggerChange = options?.skipTriggerChange === true;
|
|
958
|
-
const
|
|
1153
|
+
const hasPendingSsrmExpansionBatch = !options?.skipApplyRowGroupsExpandedState && !!this.pendingSsrmExpansionBatch;
|
|
1154
|
+
if (hasPendingSsrmExpansionBatch) {
|
|
1155
|
+
this.pendingSsrmExpansionBatch = null;
|
|
1156
|
+
}
|
|
1157
|
+
const shouldSkipEqualityCheck = options?.force === true || hasPendingSsrmExpansionBatch;
|
|
959
1158
|
if (!shouldSkipEqualityCheck && isLayoutEqual(this.currentLayout, layout)) {
|
|
960
1159
|
this.silentSetCurrentLayout(layout);
|
|
961
1160
|
return false;
|
|
962
1161
|
}
|
|
963
1162
|
const prevCurrent = this.currentLayout;
|
|
964
1163
|
this.silentSetCurrentLayout(layout);
|
|
965
|
-
this.applyLayout(layout,
|
|
1164
|
+
this.applyLayout(layout, {
|
|
1165
|
+
...options,
|
|
1166
|
+
matcherAlreadySynced: true,
|
|
1167
|
+
});
|
|
966
1168
|
this.triggerGridLayoutChange(layout, prevCurrent, {
|
|
967
1169
|
skipTriggerChange: shouldSkipTriggerChange,
|
|
968
1170
|
});
|
|
@@ -990,6 +1192,9 @@ export class LayoutManager extends LMEmitter {
|
|
|
990
1192
|
}
|
|
991
1193
|
applyLayout(layout, options) {
|
|
992
1194
|
this.warn('applyLayout', layout);
|
|
1195
|
+
if (!options?.skipApplyRowGroupsExpandedState) {
|
|
1196
|
+
this.pendingSsrmExpansionBatch = null;
|
|
1197
|
+
}
|
|
993
1198
|
const resume = this.suspendAgGridListener();
|
|
994
1199
|
const pivotMode = this.isInPivotMode();
|
|
995
1200
|
if (!!layout.SuppressAggFuncInHeader !== !!this.gridApi.getGridOption('suppressAggFuncInHeader')) {
|
|
@@ -1238,81 +1443,116 @@ export class LayoutManager extends LMEmitter {
|
|
|
1238
1443
|
this.gridApi.setGridOption('groupDisplayType', displayTypeFromLayout);
|
|
1239
1444
|
}
|
|
1240
1445
|
}
|
|
1446
|
+
if (!options?.skipApplyRowGroupsExpandedState && !options?.matcherAlreadySynced) {
|
|
1447
|
+
this.syncServerSideRowGroupExpansionMatcher(layout.RowGroupValues, layout.RowGroupedColumns);
|
|
1448
|
+
}
|
|
1241
1449
|
this.gridApi.applyColumnState(this.computeColumnStateForTableLayout(layout));
|
|
1242
|
-
if (
|
|
1243
|
-
this.
|
|
1450
|
+
if (!options?.skipApplyRowGroupsExpandedState) {
|
|
1451
|
+
this.applyLayoutRowGroupExpansion(layout.RowGroupValues, layout.RowGroupedColumns);
|
|
1244
1452
|
}
|
|
1245
1453
|
this.applyColumnGroupCollapseExpandState(layout);
|
|
1246
1454
|
});
|
|
1247
1455
|
}
|
|
1456
|
+
getNextRowGroupExceptionPaths(options) {
|
|
1457
|
+
const { rowGroupDisplay, currentPaths, triggerEvent } = options;
|
|
1458
|
+
const targetExpandedState = rowGroupDisplay === 'collapsed';
|
|
1459
|
+
if (!this.isServerSideRowModel()) {
|
|
1460
|
+
return this.getRowGroupNodePathsAs({ expanded: targetExpandedState });
|
|
1461
|
+
}
|
|
1462
|
+
const batch = triggerEvent?.ssrmExpansionBatch;
|
|
1463
|
+
if (!batch) {
|
|
1464
|
+
return currentPaths;
|
|
1465
|
+
}
|
|
1466
|
+
if (batch.kind === 'toggles') {
|
|
1467
|
+
return this.applyExpansionTogglesToPaths(currentPaths, batch.toggles, rowGroupDisplay);
|
|
1468
|
+
}
|
|
1469
|
+
let nextPaths;
|
|
1470
|
+
if ((rowGroupDisplay === 'collapsed' && batch.source === 'collapseAll') ||
|
|
1471
|
+
(rowGroupDisplay === 'expanded' && batch.source === 'expandAll')) {
|
|
1472
|
+
nextPaths =
|
|
1473
|
+
this.gridApi.getGridOption('ssrmExpandAllAffectsAllRows') === false
|
|
1474
|
+
? subtractRowGroupExceptionPaths(currentPaths, this.getAllLoadedRowGroupNodePaths())
|
|
1475
|
+
: [];
|
|
1476
|
+
}
|
|
1477
|
+
else {
|
|
1478
|
+
nextPaths = mergeRowGroupExceptionPaths(currentPaths, this.getRowGroupNodePathsAs({ expanded: targetExpandedState }));
|
|
1479
|
+
}
|
|
1480
|
+
return this.applyExpansionTogglesToPaths(nextPaths, batch.postBulkToggles, rowGroupDisplay);
|
|
1481
|
+
}
|
|
1482
|
+
getAllLoadedRowGroupNodePaths() {
|
|
1483
|
+
const inPivotMode = this.isInPivotMode();
|
|
1484
|
+
const allowUnbalanced = !!this.gridApi.getGridOption('groupAllowUnbalanced');
|
|
1485
|
+
const result = [];
|
|
1486
|
+
this.gridApi.forEachNode((node) => {
|
|
1487
|
+
if (isPersistableGroupNode(node, { inPivotMode, allowUnbalanced })) {
|
|
1488
|
+
result.push(getRowGroupNodePath(node));
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
return result;
|
|
1492
|
+
}
|
|
1248
1493
|
getRowGroupNodePathsAs(options) {
|
|
1249
1494
|
const expanded = options.expanded === true;
|
|
1495
|
+
const inPivotMode = this.isInPivotMode();
|
|
1496
|
+
const allowUnbalanced = !!this.gridApi.getGridOption('groupAllowUnbalanced');
|
|
1250
1497
|
const result = [];
|
|
1251
1498
|
this.gridApi.forEachNode((node) => {
|
|
1252
|
-
if (node
|
|
1499
|
+
if (isPersistableGroupNode(node, { inPivotMode, allowUnbalanced })) {
|
|
1253
1500
|
const nodeExpanded = !!node.expanded;
|
|
1254
1501
|
if (expanded === nodeExpanded) {
|
|
1255
|
-
|
|
1256
|
-
let currentNode = node;
|
|
1257
|
-
do {
|
|
1258
|
-
nodePath.unshift(currentNode.key);
|
|
1259
|
-
currentNode = currentNode.parent;
|
|
1260
|
-
} while (currentNode.parent);
|
|
1261
|
-
result.push(nodePath);
|
|
1502
|
+
result.push(getRowGroupNodePath(node));
|
|
1262
1503
|
}
|
|
1263
1504
|
}
|
|
1264
1505
|
});
|
|
1265
1506
|
return result;
|
|
1266
1507
|
}
|
|
1508
|
+
syncServerSideRowGroupExpansionMatcher(RowGroupValues, rowGroupedColumns) {
|
|
1509
|
+
if (!this.isServerSideRowModel()) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
this.rowGroupExpansionMatcherRef.current = rowGroupedColumns?.length
|
|
1513
|
+
? compileRowGroupExpansionMatcher(RowGroupValues, rowGroupedColumns)
|
|
1514
|
+
: null;
|
|
1515
|
+
}
|
|
1516
|
+
applyLayoutRowGroupExpansion(RowGroupValues, rowGroupedColumns) {
|
|
1517
|
+
if (this.isServerSideRowModel()) {
|
|
1518
|
+
if (rowGroupedColumns?.length) {
|
|
1519
|
+
this.gridApi.resetRowGroupExpansion();
|
|
1520
|
+
}
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
if (rowGroupedColumns?.length && RowGroupValues) {
|
|
1524
|
+
this.applyRowGroupValues(RowGroupValues, rowGroupedColumns);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1267
1527
|
applyRowGroupValues(RowGroupValues, rowGroupedColumns) {
|
|
1268
|
-
if (
|
|
1528
|
+
if (this.isServerSideRowModel()) {
|
|
1529
|
+
this.syncServerSideRowGroupExpansionMatcher(RowGroupValues, rowGroupedColumns);
|
|
1530
|
+
if (rowGroupedColumns?.length && RowGroupValues) {
|
|
1531
|
+
this.gridApi.resetRowGroupExpansion();
|
|
1532
|
+
}
|
|
1269
1533
|
return;
|
|
1270
1534
|
}
|
|
1271
|
-
|
|
1535
|
+
const matcher = compileRowGroupExpansionMatcher(RowGroupValues, rowGroupedColumns);
|
|
1536
|
+
if (!matcher) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
if (matcher.mode === 'always-expanded') {
|
|
1272
1540
|
expandAllRowGroups(this.gridApi);
|
|
1273
1541
|
return;
|
|
1274
1542
|
}
|
|
1275
|
-
if (
|
|
1543
|
+
if (matcher.mode === 'always-collapsed') {
|
|
1276
1544
|
this.gridApi.collapseAll();
|
|
1277
1545
|
return;
|
|
1278
1546
|
}
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
return
|
|
1284
|
-
});
|
|
1285
|
-
if (matchingRowGroupColumnValues) {
|
|
1286
|
-
currentRowGroupedValues = matchingRowGroupColumnValues.Values;
|
|
1287
|
-
}
|
|
1288
|
-
else {
|
|
1289
|
-
currentRowGroupedValues = [];
|
|
1547
|
+
const inPivotMode = this.isInPivotMode();
|
|
1548
|
+
const allowUnbalanced = !!this.gridApi.getGridOption('groupAllowUnbalanced');
|
|
1549
|
+
this.gridApi.forEachNode((node) => {
|
|
1550
|
+
if (!isPersistableGroupNode(node, { inPivotMode, allowUnbalanced })) {
|
|
1551
|
+
return;
|
|
1290
1552
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
currentRowGroupedValues.forEach((rowGroupValue) => {
|
|
1295
|
-
deepMap.set(rowGroupValue, true);
|
|
1296
|
-
});
|
|
1297
|
-
this.gridApi.forEachNode((node) => {
|
|
1298
|
-
if (!node.group) {
|
|
1299
|
-
return;
|
|
1300
|
-
}
|
|
1301
|
-
if (node.group) {
|
|
1302
|
-
const nodePath = [];
|
|
1303
|
-
let currentNode = node;
|
|
1304
|
-
do {
|
|
1305
|
-
nodePath.unshift(currentNode.key);
|
|
1306
|
-
currentNode = currentNode.parent;
|
|
1307
|
-
} while (currentNode.parent);
|
|
1308
|
-
const shouldBeExpanded = defaultExpanded
|
|
1309
|
-
?
|
|
1310
|
-
!deepMap.has(nodePath)
|
|
1311
|
-
:
|
|
1312
|
-
deepMap.has(nodePath);
|
|
1313
|
-
node.expanded = shouldBeExpanded;
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1553
|
+
node.expanded = isRowGroupExpandedByMatcher(matcher, node);
|
|
1554
|
+
});
|
|
1555
|
+
if (this.isClientSideRowModel()) {
|
|
1316
1556
|
this.gridApi.onGroupExpandedOrCollapsed();
|
|
1317
1557
|
}
|
|
1318
1558
|
}
|
|
@@ -1570,6 +1810,9 @@ export class LayoutManager extends LMEmitter {
|
|
|
1570
1810
|
this.gridApi.setGridOption('groupDisplayType', displayTypeFromLayout);
|
|
1571
1811
|
}
|
|
1572
1812
|
}
|
|
1813
|
+
if (!options?.skipApplyRowGroupsExpandedState && !options?.matcherAlreadySynced) {
|
|
1814
|
+
this.syncServerSideRowGroupExpansionMatcher(layout.RowGroupValues, layout.PivotGroupedColumns);
|
|
1815
|
+
}
|
|
1573
1816
|
const columnState = this.computeColumnStateForPivotLayout(layout);
|
|
1574
1817
|
const aggregationsMapForOrder = (layout.PivotAggregationColumns || []).map((_, index) => layout.PivotAggregationColumns.slice(0, index));
|
|
1575
1818
|
aggregationsMapForOrder.forEach((agg) => {
|
|
@@ -1595,8 +1838,8 @@ export class LayoutManager extends LMEmitter {
|
|
|
1595
1838
|
}
|
|
1596
1839
|
}
|
|
1597
1840
|
this.applyColumnGroupCollapseExpandState(layout);
|
|
1598
|
-
if (
|
|
1599
|
-
this.
|
|
1841
|
+
if (!options?.skipApplyRowGroupsExpandedState) {
|
|
1842
|
+
this.applyLayoutRowGroupExpansion(layout.RowGroupValues, layout.PivotGroupedColumns);
|
|
1600
1843
|
}
|
|
1601
1844
|
});
|
|
1602
1845
|
}
|
|
@@ -26,6 +26,9 @@ export const getChanges = (l1, l2) => {
|
|
|
26
26
|
};
|
|
27
27
|
export const logChanges = (l1, l2, log) => {
|
|
28
28
|
log = log || logger;
|
|
29
|
+
if (log.enabled === false) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
29
32
|
const changes = getChanges(l1, l2);
|
|
30
33
|
log('---');
|
|
31
34
|
log('Layouts are not equal.');
|
|
@@ -57,6 +60,7 @@ function clearIgnoredProperties(layout) {
|
|
|
57
60
|
delete layout.Ignore_Metadata;
|
|
58
61
|
delete layout.Ignore_AdaptableVersion;
|
|
59
62
|
delete layout.Ignore_Uuid;
|
|
63
|
+
delete layout.Ignore_OpenCharts;
|
|
60
64
|
}
|
|
61
65
|
export function isPivotLayoutEqual(l1, l2) {
|
|
62
66
|
l1 = normalizePivotLayoutModel(l1);
|