@adaptabletools/adaptable 20.1.4 → 20.1.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.
Files changed (36) hide show
  1. package/base.css +1 -0
  2. package/base.css.map +1 -1
  3. package/index.css +1 -0
  4. package/index.css.map +1 -1
  5. package/package.json +1 -1
  6. package/src/AdaptableInterfaces/IAdaptable.d.ts +3 -1
  7. package/src/AdaptableState/Common/AdaptableFilterState.d.ts +1 -1
  8. package/src/AdaptableState/Common/AdaptableSortState.d.ts +8 -3
  9. package/src/Api/CustomSortApi.d.ts +19 -9
  10. package/src/Api/GridApi.d.ts +3 -3
  11. package/src/Api/Implementation/CustomSortApiImpl.d.ts +3 -0
  12. package/src/Api/Implementation/CustomSortApiImpl.js +36 -0
  13. package/src/Api/Implementation/LayoutApiImpl.js +1 -1
  14. package/src/Api/Implementation/LayoutHelpers.d.ts +3 -3
  15. package/src/Api/Implementation/LayoutHelpers.js +126 -79
  16. package/src/Api/Implementation/StateApiImpl.d.ts +1 -2
  17. package/src/Api/Implementation/StateApiImpl.js +2 -4
  18. package/src/Api/Internal/EventInternalApi.d.ts +1 -1
  19. package/src/Api/Internal/EventInternalApi.js +11 -9
  20. package/src/Redux/ActionsReducers/LayoutRedux.js +24 -1
  21. package/src/Redux/Store/AdaptableStore.js +7 -4
  22. package/src/View/Components/FilterForm/ListBoxFilterForm.js +1 -1
  23. package/src/agGrid/AdaptableAgGrid.d.ts +7 -10
  24. package/src/agGrid/AdaptableAgGrid.js +80 -108
  25. package/src/components/ExpressionEditor/BaseEditorInput.js +2 -0
  26. package/src/components/Select/Select.d.ts +1 -0
  27. package/src/components/Select/Select.js +43 -17
  28. package/src/env.js +2 -2
  29. package/src/layout-manager/src/LayoutManagerModel.d.ts +29 -2
  30. package/src/layout-manager/src/index.d.ts +3 -0
  31. package/src/layout-manager/src/index.js +101 -30
  32. package/src/layout-manager/src/isLayoutEqual.js +11 -2
  33. package/src/layout-manager/src/normalizeLayoutModel.js +6 -0
  34. package/src/layout-manager/src/simplifyLayoutModel.js +3 -3
  35. package/src/metamodel/adaptable.metamodel.js +1 -1
  36. package/tsconfig.esm.tsbuildinfo +1 -1
@@ -217,15 +217,43 @@ export class LayoutManager extends LMEmitter {
217
217
  }
218
218
  this.triggerGridLayoutChange(layout);
219
219
  }
220
- triggerGridLayoutChange(layout) {
220
+ triggerGridLayoutChange(layout, prevLayout = this._prevFiredLayout, options) {
221
221
  layout = simplifyLayoutModel(layout);
222
- const prevLayout = this._prevFiredLayout;
222
+ prevLayout = prevLayout ? simplifyLayoutModel(prevLayout) : undefined;
223
+ const shouldSkipTriggerChange = options?.skipTriggerChange === true;
223
224
  this._prevFiredLayout = layout;
224
225
  this.currentLayout = layout;
225
- // emit an event that the layout has changed from the grid
226
- this.emitSync('gridLayoutChanged', layout);
227
- const log = this.debugger.extend('gridLayoutChanged');
228
- log('current grid layout:', JSON.stringify(layout, null, 2), '\nprev layout:\n', prevLayout ? JSON.stringify(prevLayout, null, 2) : 'no prev layout', '\nchanges from prev to current:\n', getChanges(prevLayout, layout));
226
+ if ((!prevLayout?.RowGroupedColumns || !prevLayout?.RowGroupedColumns.length) &&
227
+ layout.RowGroupedColumns &&
228
+ layout.RowGroupedColumns.length > 0 &&
229
+ layout.RowGroupValues) {
230
+ // most likely the user has changed grouping via some AG Grid action
231
+ // and we need to make sure the expand/collapse state is applied
232
+ // but we want to suspend the listener
233
+ // as it would re-trigger another change
234
+ const unsupress = this.suspendAgGridListener();
235
+ this.applyRowGroupValues(layout.RowGroupValues);
236
+ unsupress();
237
+ }
238
+ if ((!prevLayout?.RowGroupedColumns || !prevLayout?.RowGroupedColumns.length) &&
239
+ layout.RowGroupedColumns &&
240
+ layout.RowGroupedColumns.length > 0 &&
241
+ layout.RowGroupValues) {
242
+ // most likely the user has changed grouping via some AG Grid action
243
+ // and we need to make sure the expand/collapse state is applied
244
+ // but we want to suspend the listener
245
+ // as it would re-trigger another change
246
+ const unsupress = this.suspendAgGridListener();
247
+ this.applyRowGroupValues(layout.RowGroupValues);
248
+ unsupress();
249
+ }
250
+ if (!shouldSkipTriggerChange) {
251
+ // emit an event that the layout has changed from the grid
252
+ this.emitSync('gridLayoutChanged', layout);
253
+ const log = this.debugger.extend('gridLayoutChanged');
254
+ const changes = getChanges(prevLayout, layout);
255
+ log('current grid layout:', JSON.stringify(layout, null, 2), '\nprev layout:\n', prevLayout ? JSON.stringify(prevLayout, null, 2) : 'no prev layout', '\nchanges from prev to current:\n', changes);
256
+ }
229
257
  }
230
258
  onChange(fn) {
231
259
  return this.on('gridLayoutChanged', fn);
@@ -260,6 +288,17 @@ export class LayoutManager extends LMEmitter {
260
288
  }
261
289
  delete layout.TableColumns;
262
290
  const pivotLayout = {
291
+ Ignore_Name: layout.Ignore_Name,
292
+ Ignore_GridFilter: layout.Ignore_GridFilter,
293
+ Ignore_ColumnFilters: layout.Ignore_ColumnFilters,
294
+ Ignore_ColumnHeaders: layout.Ignore_ColumnHeaders,
295
+ Ignore_AutoSizeColumns: layout.Ignore_AutoSizeColumns,
296
+ Ignore_RowSummaries: layout.Ignore_RowSummaries,
297
+ Ignore_IsReadOnly: layout.Ignore_IsReadOnly,
298
+ Ignore_Tags: layout.Ignore_Tags,
299
+ Ignore_Source: layout.Ignore_Source,
300
+ Ignore_AdaptableVersion: layout.Ignore_AdaptableVersion,
301
+ Ignore_Uuid: layout.Ignore_Uuid,
263
302
  PivotColumns,
264
303
  ColumnPinning: layout.ColumnPinning,
265
304
  ColumnSorts: layout.ColumnSorts,
@@ -423,6 +462,10 @@ export class LayoutManager extends LMEmitter {
423
462
  });
424
463
  }
425
464
  if (RowGroupedColumns && RowGroupedColumns.length) {
465
+ // if it's a new grouping, try and take it
466
+ const isGroupingNew = RowGroupedColumns &&
467
+ !this.currentLayout?.RowGroupedColumns &&
468
+ !this.currentLayout?.PivotGroupedColumns;
426
469
  if (this.currentLayout?.RowGroupValues) {
427
470
  const currentRowGroupValues = this.currentLayout.RowGroupValues;
428
471
  if (currentRowGroupValues.RowGroupDisplay === 'always-collapsed') {
@@ -436,18 +479,22 @@ export class LayoutManager extends LMEmitter {
436
479
  };
437
480
  }
438
481
  else if (currentRowGroupValues.RowGroupDisplay === 'collapsed') {
439
- const ExpandedValues = this.getRowGroupNodePathsAs({
440
- expanded: true,
441
- });
482
+ const ExpandedValues = isGroupingNew
483
+ ? currentRowGroupValues.Values || []
484
+ : this.getRowGroupNodePathsAs({
485
+ expanded: true,
486
+ });
442
487
  RowGroupValues = {
443
488
  RowGroupDisplay: 'collapsed',
444
489
  Values: ExpandedValues,
445
490
  };
446
491
  }
447
492
  else if (currentRowGroupValues.RowGroupDisplay === 'expanded') {
448
- const CollapsedValues = this.getRowGroupNodePathsAs({
449
- expanded: false,
450
- });
493
+ const CollapsedValues = isGroupingNew
494
+ ? currentRowGroupValues.Values || []
495
+ : this.getRowGroupNodePathsAs({
496
+ expanded: false,
497
+ });
451
498
  RowGroupValues = {
452
499
  RowGroupDisplay: 'expanded',
453
500
  Values: CollapsedValues,
@@ -455,7 +502,23 @@ export class LayoutManager extends LMEmitter {
455
502
  }
456
503
  }
457
504
  }
505
+ else {
506
+ if (this.currentLayout?.RowGroupValues) {
507
+ RowGroupValues = this.currentLayout.RowGroupValues;
508
+ }
509
+ }
458
510
  const layout = simplifyTableLayoutModel({
511
+ Ignore_Name: this.currentLayout?.Ignore_Name || 'Default',
512
+ Ignore_GridFilter: this.currentLayout?.Ignore_GridFilter,
513
+ Ignore_ColumnFilters: this.currentLayout?.Ignore_ColumnFilters,
514
+ Ignore_ColumnHeaders: this.currentLayout?.Ignore_ColumnHeaders,
515
+ Ignore_AutoSizeColumns: this.currentLayout?.Ignore_AutoSizeColumns,
516
+ Ignore_RowSummaries: this.currentLayout?.Ignore_RowSummaries,
517
+ Ignore_IsReadOnly: this.currentLayout?.Ignore_IsReadOnly,
518
+ Ignore_Tags: this.currentLayout?.Ignore_Tags,
519
+ Ignore_Source: this.currentLayout?.Ignore_Source,
520
+ Ignore_AdaptableVersion: this.currentLayout?.Ignore_AdaptableVersion,
521
+ Ignore_Uuid: this.currentLayout?.Ignore_Uuid,
459
522
  TableColumns: TableColumns,
460
523
  ColumnVisibility,
461
524
  ColumnWidths: ColumnWidths,
@@ -668,18 +731,39 @@ export class LayoutManager extends LMEmitter {
668
731
  }
669
732
  setLayout(layout, options) {
670
733
  layout = normalizeLayoutModel(layout, { isTree: this.isTreeMode() });
734
+ const shouldSkipTriggerChange = options?.skipTriggerChange === true;
671
735
  const shouldSkipEqualityCheck = options?.force === true;
672
736
  if (!shouldSkipEqualityCheck && isLayoutEqual(this.currentLayout, layout)) {
673
737
  return false;
674
738
  }
739
+ const prevCurrent = this.currentLayout;
675
740
  this.silentSetCurrentLayout(layout);
676
741
  this.applyLayout(layout, options);
677
- this.triggerGridLayoutChange(layout);
742
+ this.triggerGridLayoutChange(layout, prevCurrent, {
743
+ skipTriggerChange: shouldSkipTriggerChange,
744
+ });
678
745
  return true;
679
746
  }
680
747
  isCurrentLayoutPivot() {
681
748
  return this.currentLayout && isPivotLayoutModel(this.currentLayout);
682
749
  }
750
+ suspendAgGridListener() {
751
+ if (this.supressGlobalAgGridEventTimeoutId) {
752
+ clearTimeout(this.supressGlobalAgGridEventTimeoutId);
753
+ this.supressGlobalAgGridEventTimeoutId = null;
754
+ }
755
+ this.suppressGlobalAgGridEventListener = true;
756
+ return () => this.resumeAgGridListener();
757
+ }
758
+ resumeAgGridListener(options) {
759
+ if (options?.immediate) {
760
+ this.suppressGlobalAgGridEventListener = false;
761
+ return;
762
+ }
763
+ this.supressGlobalAgGridEventTimeoutId = setTimeout(() => {
764
+ this.suppressGlobalAgGridEventListener = false;
765
+ }, 0);
766
+ }
683
767
  applyLayout(layout, options) {
684
768
  this.warn('applyLayout', layout);
685
769
  // we want to do this supress/unsupress thing
@@ -688,16 +772,7 @@ export class LayoutManager extends LMEmitter {
688
772
  // yes, we do check for same layout and bail out if it is the same
689
773
  // but we still want to avoid this unnecessary initial loop
690
774
  // which may cause more adaptable work
691
- if (this.supressGlobalAgGridEventTimeoutId) {
692
- clearTimeout(this.supressGlobalAgGridEventTimeoutId);
693
- this.supressGlobalAgGridEventTimeoutId = null;
694
- }
695
- const unsuppress = () => {
696
- this.supressGlobalAgGridEventTimeoutId = setTimeout(() => {
697
- this.suppressGlobalAgGridEventListener = false;
698
- }, 0);
699
- };
700
- this.suppressGlobalAgGridEventListener = true;
775
+ const resume = this.suspendAgGridListener();
701
776
  const pivotMode = this.gridApi.isPivotMode();
702
777
  if (!!layout.SuppressAggFuncInHeader !== !!this.gridApi.getGridOption('suppressAggFuncInHeader')) {
703
778
  this.gridApi.setGridOption('suppressAggFuncInHeader', !!layout.SuppressAggFuncInHeader);
@@ -721,7 +796,7 @@ export class LayoutManager extends LMEmitter {
721
796
  perfApplyPivot.end();
722
797
  }
723
798
  finally {
724
- unsuppress();
799
+ resume();
725
800
  }
726
801
  return;
727
802
  }
@@ -734,7 +809,7 @@ export class LayoutManager extends LMEmitter {
734
809
  perfApplyTable.end();
735
810
  }
736
811
  finally {
737
- unsuppress();
812
+ resume();
738
813
  }
739
814
  }
740
815
  applyTableLayout(layout, options) {
@@ -821,7 +896,7 @@ export class LayoutManager extends LMEmitter {
821
896
  }
822
897
  computeColumnStateForPivotLayout(layout) {
823
898
  let columnState = {};
824
- const pivotColumnsToIndexes = layout.PivotColumns.reduce((acc, colId, index) => {
899
+ const pivotColumnsToIndexes = (layout.PivotColumns || []).reduce((acc, colId, index) => {
825
900
  acc[colId] = index;
826
901
  return acc;
827
902
  }, {});
@@ -834,10 +909,6 @@ export class LayoutManager extends LMEmitter {
834
909
  ...layout.PivotColumns,
835
910
  ...(layout.PivotAggregationColumns || []).map((col) => col.ColumnId),
836
911
  ], this.gridApi.getColumnDefs());
837
- const pivotAggsToIndexes = layout.PivotAggregationColumns.reduce((acc, { ColumnId }, index) => {
838
- acc[ColumnId] = index;
839
- return acc;
840
- }, {});
841
912
  columnState.state = columnIds.map((columnId) => {
842
913
  const pivotIndex = pivotColumnsToIndexes[columnId];
843
914
  const rowGroupIndex = rowGroupColumnIndexes[columnId];
@@ -47,8 +47,17 @@ export function isTableLayoutEqual(l1, l2) {
47
47
  }
48
48
  //#clearIgnoredProperties
49
49
  function clearIgnoredProperties(layout) {
50
- delete layout.GridFilter;
51
- delete layout.ColumnFilters;
50
+ delete layout.Ignore_GridFilter;
51
+ delete layout.Ignore_ColumnFilters;
52
+ delete layout.Ignore_Name;
53
+ delete layout.Ignore_ColumnHeaders;
54
+ delete layout.Ignore_AutoSizeColumns;
55
+ delete layout.Ignore_RowSummaries;
56
+ delete layout.Ignore_IsReadOnly;
57
+ delete layout.Ignore_Tags;
58
+ delete layout.Ignore_Source;
59
+ delete layout.Ignore_AdaptableVersion;
60
+ delete layout.Ignore_Uuid;
52
61
  }
53
62
  export function isPivotLayoutEqual(l1, l2) {
54
63
  l1 = normalizePivotLayoutModel(l1);
@@ -13,6 +13,9 @@ export function normalizeTableLayoutModel(layout, options) {
13
13
  if (!layout.TableAggregationColumns) {
14
14
  layout.TableAggregationColumns = [];
15
15
  }
16
+ if (!layout.Ignore_ColumnFilters) {
17
+ layout.Ignore_ColumnFilters = [];
18
+ }
16
19
  if (!layout.ColumnSorts) {
17
20
  layout.ColumnSorts = [];
18
21
  }
@@ -113,6 +116,9 @@ export function normalizePivotLayoutModel(layout) {
113
116
  if (!layout.ColumnVisibility) {
114
117
  layout.ColumnVisibility = {};
115
118
  }
119
+ if (!layout.Ignore_ColumnFilters) {
120
+ layout.Ignore_ColumnFilters = [];
121
+ }
116
122
  if (!layout.PivotAggregationColumns) {
117
123
  layout.PivotAggregationColumns = [];
118
124
  }
@@ -11,6 +11,9 @@ export function simplifyTableLayoutModel(layout) {
11
11
  if (layout.ColumnSorts && !layout.ColumnSorts.length) {
12
12
  delete layout.ColumnSorts;
13
13
  }
14
+ if (layout.Ignore_ColumnFilters && !layout.Ignore_ColumnFilters) {
15
+ delete layout.Ignore_ColumnFilters;
16
+ }
14
17
  if (layout.RowGroupedColumns && !layout.RowGroupedColumns.length) {
15
18
  delete layout.RowGroupedColumns;
16
19
  }
@@ -72,9 +75,6 @@ export function simplifyPivotLayoutModel(layout) {
72
75
  if (layout.ColumnSorts && !layout.ColumnSorts.length) {
73
76
  delete layout.ColumnSorts;
74
77
  }
75
- if (!layout.PivotGroupedColumns && layout.RowGroupValues) {
76
- delete layout.RowGroupValues;
77
- }
78
78
  if (layout.GrandTotalRow === undefined) {
79
79
  delete layout.GrandTotalRow;
80
80
  }