@adaptabletools/adaptable 20.0.10 → 20.0.12

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 (50) hide show
  1. package/agGrid.d.ts +3 -3
  2. package/agGrid.js +4 -4
  3. package/base.css +1 -0
  4. package/base.css.map +1 -1
  5. package/index.css +1 -0
  6. package/index.css.map +1 -1
  7. package/package.json +1 -1
  8. package/src/AdaptableOptions/ColumnOptions.d.ts +3 -3
  9. package/src/AdaptableState/Common/AdaptableColumn.d.ts +3 -3
  10. package/src/AdaptableState/Common/AdaptableColumn.js +9 -8
  11. package/src/AdaptableState/Common/AggregationColumns.d.ts +1 -1
  12. package/src/AdaptableState/LayoutState.d.ts +2 -2
  13. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -1
  14. package/src/Api/Implementation/ColumnApiImpl.js +5 -5
  15. package/src/Api/Implementation/LayoutHelpers.js +18 -32
  16. package/src/Api/Internal/ColumnInternalApi.js +5 -5
  17. package/src/Strategy/CalculatedColumnModule.d.ts +1 -1
  18. package/src/Strategy/CellSummaryModule.d.ts +1 -1
  19. package/src/Strategy/ChartingModule.d.ts +1 -1
  20. package/src/Strategy/ColumnFilterModule.d.ts +1 -1
  21. package/src/Strategy/ColumnInfoModule.d.ts +1 -1
  22. package/src/Strategy/FlashingCellModule.d.ts +1 -1
  23. package/src/Strategy/FormatColumnModule.d.ts +1 -1
  24. package/src/Strategy/FreeTextColumnModule.d.ts +1 -1
  25. package/src/Strategy/GridInfoModule.d.ts +1 -1
  26. package/src/Strategy/LayoutModule.d.ts +1 -1
  27. package/src/Strategy/PlusMinusModule.d.ts +1 -1
  28. package/src/Strategy/SettingsPanelModule.d.ts +1 -1
  29. package/src/Strategy/StyledColumnModule.d.ts +1 -1
  30. package/src/Strategy/SystemStatusModule.d.ts +1 -1
  31. package/src/Utilities/Helpers/AdaptableHelper.d.ts +1 -0
  32. package/src/Utilities/Helpers/AdaptableHelper.js +27 -1
  33. package/src/View/Layout/Wizard/sections/PivotAggregationsSection.js +21 -21
  34. package/src/agGrid/AdaptableAgGrid.js +15 -5
  35. package/src/agGrid/AgGridAdapter.js +4 -4
  36. package/src/env.js +2 -2
  37. package/src/layout-manager/src/LayoutManagerModel.d.ts +3 -3
  38. package/src/layout-manager/src/index.d.ts +5 -1
  39. package/src/layout-manager/src/index.js +48 -44
  40. package/src/layout-manager/src/isLayoutEqual.d.ts +8 -0
  41. package/src/layout-manager/src/isLayoutEqual.js +43 -2
  42. package/src/layout-manager/src/isPivotColumnTotal.d.ts +1 -0
  43. package/src/layout-manager/src/{isPivotGroupTotalColumn.js → isPivotColumnTotal.js} +1 -1
  44. package/src/layout-manager/src/isPivotGrandTotal.d.ts +2 -0
  45. package/src/layout-manager/src/{isPivotGrandTotalColumn.js → isPivotGrandTotal.js} +1 -1
  46. package/src/layout-manager/src/normalizeLayoutModel.js +24 -0
  47. package/src/layout-manager/src/simplifyLayoutModel.js +10 -1
  48. package/tsconfig.esm.tsbuildinfo +1 -1
  49. package/src/layout-manager/src/isPivotGrandTotalColumn.d.ts +0 -2
  50. package/src/layout-manager/src/isPivotGroupTotalColumn.d.ts +0 -1
@@ -2,13 +2,17 @@ import { debounce, DeepMap } from '@infinite-table/infinite-react';
2
2
  import { isPivotLayoutModel } from './isPivotLayoutModel';
3
3
  import { LMEmitter } from './LMEmitter';
4
4
  import { GROUP_COLUMN_ID__MULTI_PREFIX, GROUP_COLUMN_ID__SINGLE, normalizeLayoutModel, normalizePivotLayoutModel, normalizeTableLayoutModel, } from './normalizeLayoutModel';
5
- import { isLayoutEqual } from './isLayoutEqual';
5
+ import { isLayoutEqual, getChanges } from './isLayoutEqual';
6
6
  import { simplifyLayoutModel, simplifyPivotLayoutModel, simplifyTableLayoutModel, } from './simplifyLayoutModel';
7
7
  import { sortColumnIdsByOrder } from './sortColumnIdsByOrder';
8
8
  import { destructurePivotColumnId } from './destructurePivotColumnId';
9
9
  import { isPivotAggTotalColumn } from './isPivotAggTotalColumn';
10
- import { isPivotGrandTotalColumn } from './isPivotGrandTotalColumn';
11
- import { isPivotGroupTotalColumn } from './isPivotGroupTotalColumn';
10
+ import { isPivotGrandTotal } from './isPivotGrandTotal';
11
+ import { isPivotColumnTotal } from './isPivotColumnTotal';
12
+ export const PIVOT_ANY_TOTAL_COL_TYPE = 'pivotAnyTotal';
13
+ export const PIVOT_GRAND_TOTAL_COL_TYPE = 'pivotGrandTotal';
14
+ export const PIVOT_COLUMN_TOTAL_COL_TYPE = 'pivotColumnTotal';
15
+ export const PIVOT_AGGREGATION_TOTAL_COL_TYPE = 'pivotAggregationTotal';
12
16
  function flattenColDefs(colDefs) {
13
17
  const res = [];
14
18
  const iteration = (c) => {
@@ -224,7 +228,7 @@ export class LayoutManager extends LMEmitter {
224
228
  // emit an event that the layout has changed from the grid
225
229
  this.emitSync('gridLayoutChanged', layout);
226
230
  const log = this.debugger.extend('gridLayoutChanged');
227
- log('current grid layout:', JSON.stringify(layout, null, 2), '\nprev layout:\n', prevLayout ? JSON.stringify(prevLayout, null, 2) : 'no prev layout');
231
+ 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));
228
232
  }
229
233
  onChange(fn) {
230
234
  return this.on('gridLayoutChanged', fn);
@@ -264,13 +268,13 @@ export class LayoutManager extends LMEmitter {
264
268
  if (layout.SuppressAggFuncInHeader) {
265
269
  pivotLayout.SuppressAggFuncInHeader = layout.SuppressAggFuncInHeader;
266
270
  }
267
- const grandTotalColumn = this.gridApi.getGridOption('pivotRowTotals');
268
- if (grandTotalColumn) {
269
- pivotLayout.GrandTotalColumn = grandTotalColumn;
271
+ const pivotGrandTotal = this.gridApi.getGridOption('pivotRowTotals');
272
+ if (pivotGrandTotal) {
273
+ pivotLayout.PivotGrandTotal = pivotGrandTotal;
270
274
  }
271
- const pivotGroupTotalColumn = this.gridApi.getGridOption('pivotColumnGroupTotals');
272
- if (pivotGroupTotalColumn) {
273
- pivotLayout.PivotGroupTotalColumn = pivotGroupTotalColumn;
275
+ const pivotColumnTotal = this.gridApi.getGridOption('pivotColumnGroupTotals');
276
+ if (pivotColumnTotal) {
277
+ pivotLayout.PivotColumnTotal = pivotColumnTotal;
274
278
  }
275
279
  return simplifyPivotLayoutModel(pivotLayout);
276
280
  }
@@ -1048,29 +1052,29 @@ export class LayoutManager extends LMEmitter {
1048
1052
  */
1049
1053
  // is common to both Table and Pivot and is applied in applyLayout()
1050
1054
  /**
1051
- * GrandTotalColumn
1055
+ * PivotGrandTotal
1052
1056
  */
1053
- if (layout.GrandTotalColumn) {
1054
- const grandTotalColumn = layout.GrandTotalColumn === true || layout.GrandTotalColumn === 'before'
1057
+ if (layout.PivotGrandTotal) {
1058
+ const pivotGrandTotal = layout.PivotGrandTotal === true || layout.PivotGrandTotal === 'before'
1055
1059
  ? 'before'
1056
- : layout.GrandTotalColumn === 'after'
1060
+ : layout.PivotGrandTotal === 'after'
1057
1061
  ? 'after'
1058
1062
  : null;
1059
- this.gridApi.setGridOption('pivotRowTotals', grandTotalColumn);
1063
+ this.gridApi.setGridOption('pivotRowTotals', pivotGrandTotal);
1060
1064
  }
1061
1065
  else {
1062
1066
  this.gridApi.setGridOption('pivotRowTotals', null);
1063
1067
  }
1064
1068
  /**
1065
- * PivotGroupTotalColumn
1069
+ * PivotColumnTotal
1066
1070
  */
1067
- if (layout.PivotGroupTotalColumn) {
1068
- const pivotGroupTotalColumn = layout.PivotGroupTotalColumn === true || layout.PivotGroupTotalColumn === 'before'
1071
+ if (layout.PivotColumnTotal) {
1072
+ const pivotColumnTotal = layout.PivotColumnTotal === true || layout.PivotColumnTotal === 'before'
1069
1073
  ? 'before'
1070
- : layout.PivotGroupTotalColumn === 'after'
1074
+ : layout.PivotColumnTotal === 'after'
1071
1075
  ? 'after'
1072
1076
  : null;
1073
- this.gridApi.setGridOption('pivotColumnGroupTotals', pivotGroupTotalColumn);
1077
+ this.gridApi.setGridOption('pivotColumnGroupTotals', pivotColumnTotal);
1074
1078
  }
1075
1079
  else {
1076
1080
  this.gridApi.setGridOption('pivotColumnGroupTotals', null);
@@ -1126,11 +1130,11 @@ export class LayoutManager extends LMEmitter {
1126
1130
  if (!isPivotLayoutModel(this.currentLayout)) {
1127
1131
  return;
1128
1132
  }
1129
- if (isPivotGrandTotalColumn(colDef)) {
1130
- this.patchColDefType(colDef, ['pivotTotalColumn', 'pivotGrandTotalColumn']);
1133
+ if (isPivotGrandTotal(colDef)) {
1134
+ this.patchColDefType(colDef, [PIVOT_ANY_TOTAL_COL_TYPE, PIVOT_GRAND_TOTAL_COL_TYPE]);
1131
1135
  }
1132
- if (isPivotGroupTotalColumn(colDef.colId)) {
1133
- this.patchColDefType(colDef, ['pivotTotalColumn', 'pivotGroupTotalColumn']);
1136
+ if (isPivotColumnTotal(colDef.colId)) {
1137
+ this.patchColDefType(colDef, [PIVOT_ANY_TOTAL_COL_TYPE, PIVOT_COLUMN_TOTAL_COL_TYPE]);
1134
1138
  }
1135
1139
  });
1136
1140
  const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
@@ -1139,28 +1143,28 @@ export class LayoutManager extends LMEmitter {
1139
1143
  if (!isPivotLayoutModel(this.currentLayout)) {
1140
1144
  return;
1141
1145
  }
1142
- this.patchPivotTotalColumn(colGroupDef);
1146
+ this.patchPivotAggregationTotal(colGroupDef);
1143
1147
  });
1144
1148
  }
1145
- patchPivotTotalColumn(colGroupDef) {
1146
- const hasPivotTotalCols = (pivotLayout) => {
1147
- return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
1149
+ patchPivotAggregationTotal(colGroupDef) {
1150
+ const hasPivotAggTotals = (pivotLayout) => {
1151
+ return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.Total);
1148
1152
  };
1149
- if (!isPivotLayoutModel(this.currentLayout) || !hasPivotTotalCols(this.currentLayout)) {
1153
+ if (!isPivotLayoutModel(this.currentLayout) || !hasPivotAggTotals(this.currentLayout)) {
1150
1154
  return;
1151
1155
  }
1152
- const pivotRowTotalColDefsBefore = [];
1153
- const pivotRowTotalColDefsAfter = [];
1154
- const pivotTotalColDefsBefore = [];
1155
- const pivotTotalColDefsAfter = [];
1156
+ const pivotGrandTotalsBefore = [];
1157
+ const pivotGrandTotalsAfter = [];
1158
+ const pivotAggTotalsBefore = [];
1159
+ const pivotAggTotalsAfter = [];
1156
1160
  const normalColDefs = [];
1157
1161
  colGroupDef.children.forEach((colDef) => {
1158
- if (isPivotGrandTotalColumn(colDef)) {
1162
+ if (isPivotGrandTotal(colDef)) {
1159
1163
  if (this.gridApi.getGridOption('pivotRowTotals') === 'after') {
1160
- pivotRowTotalColDefsAfter.push(colDef);
1164
+ pivotGrandTotalsAfter.push(colDef);
1161
1165
  }
1162
1166
  else {
1163
- pivotRowTotalColDefsBefore.push(colDef);
1167
+ pivotGrandTotalsBefore.push(colDef);
1164
1168
  }
1165
1169
  return;
1166
1170
  }
@@ -1169,7 +1173,7 @@ export class LayoutManager extends LMEmitter {
1169
1173
  this.warn(`Pivot total column ${colDef.colId} is not prefixed with 'pivot_', skipping...`);
1170
1174
  return;
1171
1175
  }
1172
- this.patchColDefType(colDef, ['pivotTotalColumn', 'pivotAggregationTotalColumn']);
1176
+ this.patchColDefType(colDef, [PIVOT_ANY_TOTAL_COL_TYPE, PIVOT_AGGREGATION_TOTAL_COL_TYPE]);
1173
1177
  // we do this for all total cols, but we will hide the ones that are not visible
1174
1178
  colDef.columnGroupShow = undefined;
1175
1179
  const totalColConfig = this.getPivotTotalColumnConfig(colDef, this.currentLayout);
@@ -1178,10 +1182,10 @@ export class LayoutManager extends LMEmitter {
1178
1182
  }
1179
1183
  else {
1180
1184
  if (totalColConfig.position === 'after') {
1181
- pivotTotalColDefsAfter.push(colDef);
1185
+ pivotAggTotalsAfter.push(colDef);
1182
1186
  }
1183
1187
  else {
1184
- pivotTotalColDefsBefore.push(colDef);
1188
+ pivotAggTotalsBefore.push(colDef);
1185
1189
  }
1186
1190
  }
1187
1191
  }
@@ -1190,11 +1194,11 @@ export class LayoutManager extends LMEmitter {
1190
1194
  }
1191
1195
  });
1192
1196
  colGroupDef.children = [
1193
- ...pivotRowTotalColDefsBefore,
1194
- ...pivotTotalColDefsBefore,
1197
+ ...pivotGrandTotalsBefore,
1198
+ ...pivotAggTotalsBefore,
1195
1199
  ...normalColDefs,
1196
- ...pivotTotalColDefsAfter,
1197
- ...pivotRowTotalColDefsAfter,
1200
+ ...pivotAggTotalsAfter,
1201
+ ...pivotGrandTotalsAfter,
1198
1202
  ];
1199
1203
  }
1200
1204
  getPivotTotalColumnConfig(colDef, currentPivotLayout) {
@@ -1214,7 +1218,7 @@ export class LayoutManager extends LMEmitter {
1214
1218
  this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
1215
1219
  return defaultHiddenConfig;
1216
1220
  }
1217
- const layoutPivotTotalColumn = layoutAggCol.TotalColumn;
1221
+ const layoutPivotTotalColumn = layoutAggCol.Total;
1218
1222
  if (!layoutPivotTotalColumn) {
1219
1223
  return defaultHiddenConfig;
1220
1224
  }
@@ -1,4 +1,12 @@
1
1
  import { PivotLayoutModel, TableLayoutModel } from './LayoutManagerModel';
2
+ declare const logger: import("@infinite-table/infinite-react").DebugLogger;
3
+ export declare const getChanges: (l1: any, l2: any) => {
4
+ key: string;
5
+ value1: any;
6
+ value2: any;
7
+ }[];
8
+ export declare const logChanges: (l1: any, l2: any, log?: typeof logger) => void;
2
9
  export declare function isTableLayoutEqual(l1: TableLayoutModel, l2: TableLayoutModel): boolean;
3
10
  export declare function isPivotLayoutEqual(l1: PivotLayoutModel, l2: PivotLayoutModel): boolean;
4
11
  export declare function isLayoutEqual(l1: TableLayoutModel | PivotLayoutModel, l2: TableLayoutModel | PivotLayoutModel): boolean;
12
+ export {};
@@ -1,15 +1,56 @@
1
1
  import isDeepEqual from 'lodash/isEqual';
2
+ import { debug as debugFactory } from '@infinite-table/infinite-react';
2
3
  import { isPivotLayoutModel } from './isPivotLayoutModel';
3
4
  import { normalizePivotLayoutModel, normalizeTableLayoutModel } from './normalizeLayoutModel';
5
+ const logger = debugFactory(`LayoutManager:Diffing`);
6
+ export const getChanges = (l1, l2) => {
7
+ if (!l1 || typeof l1 !== 'object' || !l2 || typeof l2 !== 'object') {
8
+ return [
9
+ {
10
+ key: 'missing',
11
+ value1: l1,
12
+ value2: l2,
13
+ },
14
+ ];
15
+ }
16
+ const k1 = Object.keys(l1);
17
+ const k2 = Object.keys(l2);
18
+ const allKeys = new Set([...k1, ...k2]);
19
+ const changes = [];
20
+ for (const key of allKeys) {
21
+ if (!isDeepEqual(l1[key], l2[key])) {
22
+ changes.push({ key, value1: l1[key], value2: l2[key] });
23
+ }
24
+ }
25
+ return changes;
26
+ };
27
+ export const logChanges = (l1, l2, log) => {
28
+ log = log || logger;
29
+ const changes = getChanges(l1, l2);
30
+ log('---');
31
+ log('Layouts are not equal.');
32
+ log('Layout 1', l1);
33
+ log('Layout 2', l2);
34
+ log('Differences:', changes);
35
+ log('---');
36
+ };
4
37
  export function isTableLayoutEqual(l1, l2) {
5
38
  l1 = normalizeTableLayoutModel(l1);
6
39
  l2 = normalizeTableLayoutModel(l2);
7
- return isDeepEqual(l1, l2);
40
+ const res = isDeepEqual(l1, l2);
41
+ if (!res) {
42
+ logChanges(l1, l2);
43
+ }
44
+ return res;
8
45
  }
9
46
  export function isPivotLayoutEqual(l1, l2) {
10
47
  l1 = normalizePivotLayoutModel(l1);
11
48
  l2 = normalizePivotLayoutModel(l2);
12
- return isDeepEqual(l1, l2);
49
+ const res = isDeepEqual(l1, l2);
50
+ if (!res) {
51
+ logChanges(l1, l2);
52
+ }
53
+ return res;
13
54
  }
14
55
  export function isLayoutEqual(l1, l2) {
15
56
  if (isPivotLayoutModel(l1) != isPivotLayoutModel(l2)) {
@@ -0,0 +1 @@
1
+ export declare function isPivotColumnTotal(colId: string): boolean;
@@ -1,4 +1,4 @@
1
- export function isPivotGroupTotalColumn(colId) {
1
+ export function isPivotColumnTotal(colId) {
2
2
  // pivot group total are spanning cross all aggregations
3
3
  // therefore the last part of the colId is empty (hence the "dangling" underscore)
4
4
  return colId?.startsWith('pivot_') && colId?.endsWith('_');
@@ -0,0 +1,2 @@
1
+ import { ColDef, ColGroupDef } from 'ag-grid-enterprise';
2
+ export declare function isPivotGrandTotal(colDef: ColDef | ColGroupDef): boolean;
@@ -1,3 +1,3 @@
1
- export function isPivotGrandTotalColumn(colDef) {
1
+ export function isPivotGrandTotal(colDef) {
2
2
  return colDef?.colId?.startsWith('PivotRowTotal_pivot_');
3
3
  }
@@ -25,6 +25,14 @@ export function normalizeTableLayoutModel(layout, options) {
25
25
  if (!layout.RowGroupedColumns) {
26
26
  layout.RowGroupedColumns = [];
27
27
  }
28
+ if (!('SuppressAggFuncInHeader' in layout)) {
29
+ // make it an own property
30
+ layout.SuppressAggFuncInHeader = undefined;
31
+ }
32
+ if (!('GrandTotalRow' in layout)) {
33
+ // make it an own property
34
+ layout.GrandTotalRow = undefined;
35
+ }
28
36
  const ColumnOrderSet = new Set(layout.TableColumns);
29
37
  if (layout.RowGroupedColumns && layout.RowGroupedColumns.length && layout.TableColumns) {
30
38
  // the layout.TableColumns might not include the group columns
@@ -131,6 +139,22 @@ export function normalizePivotLayoutModel(layout) {
131
139
  RowGroupDisplay: 'always-collapsed',
132
140
  };
133
141
  }
142
+ if (!('SuppressAggFuncInHeader' in layout)) {
143
+ // make it an own property
144
+ layout.SuppressAggFuncInHeader = undefined;
145
+ }
146
+ if (!('GrandTotalRow' in layout)) {
147
+ // make it an own property
148
+ layout.GrandTotalRow = undefined;
149
+ }
150
+ if (!('PivotGrandTotal' in layout)) {
151
+ // make it an own property
152
+ layout.PivotGrandTotal = undefined;
153
+ }
154
+ if (!('PivotColumnTotal' in layout)) {
155
+ // make it an own property
156
+ layout.PivotColumnTotal = undefined;
157
+ }
134
158
  return layout;
135
159
  }
136
160
  export function normalizeLayoutModel(layout, options) {
@@ -53,7 +53,7 @@ export function simplifyTableLayoutModel(layout) {
53
53
  });
54
54
  layout.RowGroupDisplayType = displayType;
55
55
  }
56
- if (!layout.GrandTotalRow) {
56
+ if (layout.GrandTotalRow === undefined) {
57
57
  delete layout.GrandTotalRow;
58
58
  }
59
59
  return layout;
@@ -75,6 +75,15 @@ export function simplifyPivotLayoutModel(layout) {
75
75
  if (!layout.PivotGroupedColumns && layout.RowGroupValues) {
76
76
  delete layout.RowGroupValues;
77
77
  }
78
+ if (layout.GrandTotalRow === undefined) {
79
+ delete layout.GrandTotalRow;
80
+ }
81
+ if (layout.PivotColumnTotal === undefined) {
82
+ delete layout.PivotColumnTotal;
83
+ }
84
+ if (layout.PivotGrandTotal === undefined) {
85
+ delete layout.PivotGrandTotal;
86
+ }
78
87
  return layout;
79
88
  }
80
89
  export function simplifyLayoutModel(layout) {