@adaptabletools/adaptable 20.0.11 → 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 (46) hide show
  1. package/agGrid.d.ts +3 -3
  2. package/agGrid.js +4 -4
  3. package/package.json +1 -1
  4. package/src/AdaptableOptions/ColumnOptions.d.ts +3 -3
  5. package/src/AdaptableState/Common/AdaptableColumn.d.ts +3 -3
  6. package/src/AdaptableState/Common/AdaptableColumn.js +9 -8
  7. package/src/AdaptableState/Common/AggregationColumns.d.ts +1 -1
  8. package/src/AdaptableState/LayoutState.d.ts +2 -2
  9. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -1
  10. package/src/Api/Implementation/ColumnApiImpl.js +5 -5
  11. package/src/Api/Implementation/LayoutHelpers.js +18 -32
  12. package/src/Api/Internal/ColumnInternalApi.js +5 -5
  13. package/src/Strategy/CalculatedColumnModule.d.ts +1 -1
  14. package/src/Strategy/CellSummaryModule.d.ts +1 -1
  15. package/src/Strategy/ChartingModule.d.ts +1 -1
  16. package/src/Strategy/ColumnFilterModule.d.ts +1 -1
  17. package/src/Strategy/ColumnInfoModule.d.ts +1 -1
  18. package/src/Strategy/FlashingCellModule.d.ts +1 -1
  19. package/src/Strategy/FormatColumnModule.d.ts +1 -1
  20. package/src/Strategy/FreeTextColumnModule.d.ts +1 -1
  21. package/src/Strategy/GridInfoModule.d.ts +1 -1
  22. package/src/Strategy/LayoutModule.d.ts +1 -1
  23. package/src/Strategy/PlusMinusModule.d.ts +1 -1
  24. package/src/Strategy/SettingsPanelModule.d.ts +1 -1
  25. package/src/Strategy/StyledColumnModule.d.ts +1 -1
  26. package/src/Strategy/SystemStatusModule.d.ts +1 -1
  27. package/src/Utilities/Helpers/AdaptableHelper.d.ts +1 -0
  28. package/src/Utilities/Helpers/AdaptableHelper.js +27 -1
  29. package/src/View/Layout/Wizard/sections/PivotAggregationsSection.js +21 -21
  30. package/src/agGrid/AdaptableAgGrid.js +3 -3
  31. package/src/agGrid/AgGridAdapter.js +4 -4
  32. package/src/env.js +2 -2
  33. package/src/layout-manager/src/LayoutManagerModel.d.ts +3 -3
  34. package/src/layout-manager/src/index.d.ts +5 -1
  35. package/src/layout-manager/src/index.js +48 -44
  36. package/src/layout-manager/src/isLayoutEqual.d.ts +8 -0
  37. package/src/layout-manager/src/isLayoutEqual.js +43 -2
  38. package/src/layout-manager/src/isPivotColumnTotal.d.ts +1 -0
  39. package/src/layout-manager/src/{isPivotGroupTotalColumn.js → isPivotColumnTotal.js} +1 -1
  40. package/src/layout-manager/src/isPivotGrandTotal.d.ts +2 -0
  41. package/src/layout-manager/src/{isPivotGrandTotalColumn.js → isPivotGrandTotal.js} +1 -1
  42. package/src/layout-manager/src/normalizeLayoutModel.js +24 -0
  43. package/src/layout-manager/src/simplifyLayoutModel.js +10 -1
  44. package/tsconfig.esm.tsbuildinfo +1 -1
  45. package/src/layout-manager/src/isPivotGrandTotalColumn.d.ts +0 -2
  46. package/src/layout-manager/src/isPivotGroupTotalColumn.d.ts +0 -1
@@ -5,7 +5,7 @@ import { AdaptableModuleView, IModule } from './Interface/IModule';
5
5
  import { AdaptableApi } from '../Api/AdaptableApi';
6
6
  export declare class SystemStatusModule extends AdaptableModuleBase implements IModule {
7
7
  constructor(api: AdaptableApi);
8
- createColumnMenuItems(column: AdaptableColumn): import("../Utilities/MenuItem").MenuItemShowPopup<"calculated-column-edit" | "cell-summary-show" | "chart-show" | "column-group" | "column-filter-group" | "column-filter-bar-hide" | "column-filter-bar-show" | "column-filter-clear" | "column-filter-suspend" | "column-filter-unsuspend" | "column-info-show" | "custom-sort-add" | "custom-sort-edit" | "dashboard-group" | "dashboard-collapse" | "dashboard-configure" | "dashboard-dock" | "dashboard-expand" | "dashboard-float" | "dashboard-hide" | "dashboard-show" | "data-import" | "flashing-cell-add" | "flashing-cell-delete" | "format-column-add" | "format-column-edit" | "free-text-column-edit" | "grid-group" | "grid-info-show" | "layout-column-caption-change" | "layout-column-hide" | "layout-edit" | "layout-column-select" | "layout-column-select-preserve" | "layout-column-select-reset" | "layout-grid-select" | "plus-minus-add" | "settings-panel-open" | "styling-group" | "styled-column-badge-add" | "styled-column-badge-edit" | "styled-column-gradient-add" | "styled-column-gradient-edit" | "styled-column-percent-bar-add" | "styled-column-percent-bar-edit" | "styled-column-sparkline-add" | "styled-column-sparkline-edit" | "system-status-show" | "_navbar" | "separator">[];
8
+ createColumnMenuItems(column: AdaptableColumn): import("../Utilities/MenuItem").MenuItemShowPopup<"separator" | "calculated-column-edit" | "cell-summary-show" | "chart-show" | "column-group" | "column-filter-group" | "column-filter-bar-hide" | "column-filter-bar-show" | "column-filter-clear" | "column-filter-suspend" | "column-filter-unsuspend" | "column-info-show" | "custom-sort-add" | "custom-sort-edit" | "dashboard-group" | "dashboard-collapse" | "dashboard-configure" | "dashboard-dock" | "dashboard-expand" | "dashboard-float" | "dashboard-hide" | "dashboard-show" | "data-import" | "flashing-cell-add" | "flashing-cell-delete" | "format-column-add" | "format-column-edit" | "free-text-column-edit" | "grid-group" | "grid-info-show" | "layout-column-caption-change" | "layout-column-hide" | "layout-edit" | "layout-column-select" | "layout-column-select-preserve" | "layout-column-select-reset" | "layout-grid-select" | "plus-minus-add" | "settings-panel-open" | "styling-group" | "styled-column-badge-add" | "styled-column-badge-edit" | "styled-column-gradient-add" | "styled-column-gradient-edit" | "styled-column-percent-bar-add" | "styled-column-percent-bar-edit" | "styled-column-sparkline-add" | "styled-column-sparkline-edit" | "system-status-show" | "_navbar">[];
9
9
  createContextMenuItems(menuContext: ContextMenuContext): import("../Utilities/MenuItem").MenuItemShowPopup<"calculated-column-edit" | "cell-summary-show" | "column-group" | "column-filter-group" | "column-filter-clear" | "column-filter-suspend" | "column-filter-unsuspend" | "column-info-show" | "dashboard-group" | "dashboard-collapse" | "dashboard-configure" | "dashboard-dock" | "dashboard-expand" | "dashboard-float" | "dashboard-hide" | "dashboard-show" | "data-import" | "grid-group" | "grid-info-show" | "layout-edit" | "settings-panel-open" | "system-status-show" | "menu-group" | "alert-clear" | "bulk-update-apply" | "column-filter-on-cell-value" | "comment-add" | "comment-remove" | "edit-group" | "export-group" | "export-all-data" | "export-all-data-excel-download" | "export-all-data-visualexcel-download" | "export-all-data-csv" | "export-all-data-csv-download" | "export-all-data-csv-clipboard" | "export-all-data-json" | "export-all-data-json-download" | "export-all-data-json-clipboard" | "export-current-layout" | "export-current-layout-excel-download" | "export-current-layout-visualexcel-download" | "export-current-layout-csv" | "export-current-layout-csv-download" | "export-current-layout-csv-clipboard" | "export-current-layout-json" | "export-current-layout-json-download" | "export-current-layout-json-clipboard" | "export-selected-data" | "export-selected-data-excel-download" | "export-selected-data-visualexcel-download" | "export-selected-data-csv" | "export-selected-data-csv-download" | "export-selected-data-csv-clipboard" | "export-selected-data-json" | "export-selected-data-json-download" | "export-selected-data-json-clipboard" | "fdc3-broadcast" | "fdc3-raise-intent" | "flashing-cell-clear" | "flashing-row-clear" | "layout-aggregated-view" | "layout-auto-size" | "layout-clear-selection" | "layout-select-all" | "note-add" | "note-remove" | "smart-edit-apply">[];
10
10
  getViewProperties(): AdaptableModuleView;
11
11
  }
@@ -4,6 +4,7 @@ import { AccessLevel } from '../../AdaptableState/Common/Entitlement';
4
4
  export declare function addUuidsToInitialState(initialState: InitialState): InitialState;
5
5
  export declare function getAccessLevelForObject(adaptableObject: AdaptableObject, moduleAccessLevel: AccessLevel): AccessLevel;
6
6
  export declare function addAdaptableObjectPrimitives<T extends AdaptableObject>(adaptableObject: T): T;
7
+ export declare function removeAdaptableObjectPrimitivesInlineDeep(target: any): any;
7
8
  export declare function removeAdaptableObjectPrimitivesInline(target: any): any;
8
9
  export declare function removeAdaptableObjectPrimitives<T extends AdaptableObject>(adaptableObject: T): T;
9
10
  export declare function isAdaptableObject(object: unknown): object is AdaptableObject;
@@ -43,8 +43,34 @@ export function addAdaptableObjectPrimitives(adaptableObject) {
43
43
  adaptableObject.AdaptableVersion = GET_CURRENT_VERSION();
44
44
  return adaptableObject;
45
45
  }
46
+ export function removeAdaptableObjectPrimitivesInlineDeep(target) {
47
+ if (!target) {
48
+ return target;
49
+ }
50
+ if (Array.isArray(target)) {
51
+ target.forEach(removeAdaptableObjectPrimitivesInlineDeep);
52
+ return target;
53
+ }
54
+ if (typeof target !== 'object') {
55
+ return target;
56
+ }
57
+ delete target.Source;
58
+ delete target.Uuid;
59
+ delete target.AdaptableVersion;
60
+ for (const key in target) {
61
+ removeAdaptableObjectPrimitivesInlineDeep(target[key]);
62
+ }
63
+ return target;
64
+ }
46
65
  export function removeAdaptableObjectPrimitivesInline(target) {
47
- if (!target || typeof target !== 'object') {
66
+ if (!target) {
67
+ return target;
68
+ }
69
+ if (Array.isArray(target)) {
70
+ target.forEach(removeAdaptableObjectPrimitivesInline);
71
+ return target;
72
+ }
73
+ if (typeof target !== 'object') {
48
74
  return target;
49
75
  }
50
76
  delete target.Source;
@@ -124,7 +124,7 @@ const PivotColumnRow = (props) => {
124
124
  }
125
125
  return {
126
126
  ...aggCol,
127
- TotalColumn: updatedTotalColumn,
127
+ Total: updatedTotalColumn,
128
128
  };
129
129
  }
130
130
  return aggCol;
@@ -134,18 +134,18 @@ const PivotColumnRow = (props) => {
134
134
  };
135
135
  });
136
136
  const currentAggCol = props.layout.PivotAggregationColumns?.find((aggCol) => aggCol.ColumnId === props.column.columnId);
137
- const currentTotal = currentAggCol?.TotalColumn
138
- ? currentAggCol.TotalColumn === true || currentAggCol.TotalColumn === 'before'
137
+ const currentTotal = currentAggCol?.Total
138
+ ? currentAggCol.Total === true || currentAggCol.Total === 'before'
139
139
  ? 'Before'
140
- : currentAggCol.TotalColumn === 'after'
140
+ : currentAggCol.Total === 'after'
141
141
  ? 'After'
142
- : Array.isArray(currentAggCol.TotalColumn)
142
+ : Array.isArray(currentAggCol.Total)
143
143
  ? 'Pivot Specific'
144
144
  : 'Off'
145
145
  : 'Off';
146
- const hasPivotSpecificTotals = Array.isArray(currentAggCol?.TotalColumn);
147
- const pivotSpecificTotals = Array.isArray(currentAggCol?.TotalColumn)
148
- ? currentAggCol.TotalColumn
146
+ const hasPivotSpecificTotals = Array.isArray(currentAggCol?.Total);
147
+ const pivotSpecificTotals = Array.isArray(currentAggCol?.Total)
148
+ ? currentAggCol.Total
149
149
  : props.layout.PivotColumns?.map((pivotColId) => ({
150
150
  PivotColumnId: pivotColId,
151
151
  ShowTotal: false,
@@ -159,7 +159,7 @@ const PivotColumnRow = (props) => {
159
159
  }
160
160
  return total;
161
161
  });
162
- return { ...aggCol, TotalColumn: updatedTotals };
162
+ return { ...aggCol, Total: updatedTotals };
163
163
  }
164
164
  return aggCol;
165
165
  });
@@ -251,7 +251,7 @@ export const PivotAggregationsSection = (props) => {
251
251
  ColumnId: colId,
252
252
  AggFunc: currentAggColumns.find((x) => x.ColumnId === colId)?.AggFunc ??
253
253
  adaptable.api.columnApi.getDefaultAggFunc(colId),
254
- TotalColumn: currentAggColumns.find((x) => x.ColumnId === colId)?.TotalColumn,
254
+ TotalColumn: currentAggColumns.find((x) => x.ColumnId === colId)?.Total,
255
255
  };
256
256
  });
257
257
  props.onChange({
@@ -260,9 +260,9 @@ export const PivotAggregationsSection = (props) => {
260
260
  });
261
261
  }, [layout]);
262
262
  const handleAggregationChange = React.useCallback((pivotAggregationColumns) => {
263
- if (pivotAggregationColumns.some((aggCol) => aggCol.TotalColumn !== false || aggCol.TotalColumn !== null)) {
263
+ if (pivotAggregationColumns.some((aggCol) => aggCol.Total !== false || aggCol.Total !== null)) {
264
264
  // if any Aggregation Column has a Total Column, we need to disable the Pivot Group Total Column
265
- delete layout['PivotGroupTotalColumn'];
265
+ delete layout['PivotColumnTotal'];
266
266
  }
267
267
  props.onChange({
268
268
  ...layout,
@@ -296,7 +296,7 @@ export const PivotAggregationsSection = (props) => {
296
296
  SuppressAggFuncInHeader: checked,
297
297
  });
298
298
  };
299
- const checkIfPivotGroupTotalColumnEnabled = () => {
299
+ const checkIfPivotColumnTotalEnabled = () => {
300
300
  // check that all AggregationColumns have identical AggFuncs
301
301
  const aggregationColumns = layout.PivotAggregationColumns;
302
302
  if (!aggregationColumns || aggregationColumns.length === 0) {
@@ -307,13 +307,13 @@ export const PivotAggregationsSection = (props) => {
307
307
  return 'Requires identical aggregation on all columns';
308
308
  }
309
309
  // check that no Aggregation Total Column is enabled
310
- const hasAggregationTotalColumn = aggregationColumns.some((aggCol) => aggCol.TotalColumn !== false && aggCol.TotalColumn != null);
310
+ const hasAggregationTotalColumn = aggregationColumns.some((aggCol) => aggCol.Total !== false && aggCol.Total != null);
311
311
  if (hasAggregationTotalColumn) {
312
312
  return 'Can only be enabled when no Aggregation Total Column is present';
313
313
  }
314
314
  return true;
315
315
  };
316
- const isPivotGroupTotalColumnEnabled = checkIfPivotGroupTotalColumnEnabled();
316
+ const isPivotColumnTotalEnabled = checkIfPivotColumnTotalEnabled();
317
317
  return (React.createElement(Tabs, { style: { height: '100%' } },
318
318
  React.createElement(Tabs.Tab, null, "Column Aggregations"),
319
319
  React.createElement(Tabs.Content, null,
@@ -339,23 +339,23 @@ export const PivotAggregationsSection = (props) => {
339
339
  label: StringExtensions.CapitaliseFirstLetter(position),
340
340
  value: position,
341
341
  };
342
- }), placeholder: "Off", value: layout.GrandTotalColumn, onChange: (value) => {
342
+ }), placeholder: "Off", value: layout.PivotGrandTotal, onChange: (value) => {
343
343
  props.onChange({
344
344
  ...layout,
345
- GrandTotalColumn: value,
345
+ PivotGrandTotal: value,
346
346
  });
347
347
  }, isClearable: true })),
348
- React.createElement(FormRow, { label: 'Pivot Group Total Column' }, isPivotGroupTotalColumnEnabled === true ? (React.createElement(Select, { style: { width: 120 }, options: ['before', 'after'].map((position) => {
348
+ React.createElement(FormRow, { label: 'Pivot Group Total Column' }, isPivotColumnTotalEnabled === true ? (React.createElement(Select, { style: { width: 120 }, options: ['before', 'after'].map((position) => {
349
349
  return {
350
350
  label: StringExtensions.CapitaliseFirstLetter(position),
351
351
  value: position,
352
352
  };
353
- }), placeholder: "Off", value: layout.PivotGroupTotalColumn, onChange: (value) => {
353
+ }), placeholder: "Off", value: layout.PivotColumnTotal, onChange: (value) => {
354
354
  props.onChange({
355
355
  ...layout,
356
- PivotGroupTotalColumn: value,
356
+ PivotColumnTotal: value,
357
357
  });
358
- }, isClearable: true })) : (React.createElement(Text, { marginLeft: 1, style: { fontStyle: 'italic' } }, isPivotGroupTotalColumnEnabled))))),
358
+ }, isClearable: true })) : (React.createElement(Text, { marginLeft: 1, style: { fontStyle: 'italic' } }, isPivotColumnTotalEnabled))))),
359
359
  React.createElement(ValueSelector, { showFilterInput: true, showSelectedOnlyPosition: "top", filter: columnFilter, toIdentifier: (option) => `${option.columnId}`, toLabel: (option) => option.friendlyName ?? option.columnId, toListLabel: (column) => (React.createElement(PivotColumnRow, { onChangeAggFunction: handleAggregationChange, layout: layout, column: column, aggregationColumnsMap: aggregationColumnsMap, numberColumns: numberColumns })), options: sortedAggregableColumns, value: (layout.PivotAggregationColumns || []).map((col) => col.ColumnId), allowReorder: true, xSelectedLabel: () => {
360
360
  return `Active aggregations:`;
361
361
  }, onChange: handleColumnsSelectionChange }))));
@@ -3334,14 +3334,14 @@ You need to define at least one Layout!`);
3334
3334
  if (!isPivotLayout(layout)) {
3335
3335
  return false;
3336
3336
  }
3337
- if (layout.GrandTotalColumn) {
3337
+ if (layout.PivotGrandTotal) {
3338
3338
  return true;
3339
3339
  }
3340
- if (layout.PivotGroupTotalColumn) {
3340
+ if (layout.PivotColumnTotal) {
3341
3341
  return true;
3342
3342
  }
3343
3343
  if (layout.PivotAggregationColumns) {
3344
- return layout.PivotAggregationColumns.some((col) => !!col.TotalColumn);
3344
+ return layout.PivotAggregationColumns.some((col) => !!col.Total);
3345
3345
  }
3346
3346
  };
3347
3347
  return hasPivotTotals(one) || hasPivotTotals(other);
@@ -6,8 +6,8 @@ import ArrayExtensions from '../Utilities/Extensions/ArrayExtensions';
6
6
  import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
7
7
  import { ALL_AG_GRID_MODULES } from './agGridModules';
8
8
  import { agGridDataTypeDefinitions, ALL_ADAPTABLE_DATA_TYPES } from './agGridDataTypeDefinitions';
9
- import { isPivotGrandTotalColumn } from '../Api/Implementation/ColumnApiImpl';
10
- import { isPivotGroupTotalColumn } from '../layout-manager/src/isPivotGroupTotalColumn';
9
+ import { isPivotGrandTotal } from '../Api/Implementation/ColumnApiImpl';
10
+ import { isPivotColumnTotal } from '../layout-manager/src/isPivotColumnTotal';
11
11
  import { isPivotAggTotalColumn } from '../layout-manager/src/isPivotAggTotalColumn';
12
12
  // AG GRID obfuscates its internals, this is (currently) the best way to get hold of its internal services
13
13
  const DANGER_AG_GRID_BEANS_MAP = {};
@@ -610,8 +610,8 @@ export class AgGridAdapter {
610
610
  return this.adaptableApi.actionColumnApi.getActionColumnForColumnId(colDef.colId) != null;
611
611
  }
612
612
  isPivotTotalColumn(colDef) {
613
- return (isPivotGrandTotalColumn(colDef.colId) ||
614
- isPivotGroupTotalColumn(colDef.colId) ||
613
+ return (isPivotGrandTotal(colDef.colId) ||
614
+ isPivotColumnTotal(colDef.colId) ||
615
615
  isPivotAggTotalColumn(colDef));
616
616
  }
617
617
  isColumnFilterable(colDef) {
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
3
- PUBLISH_TIMESTAMP: 1746021643656 || Date.now(),
4
- VERSION: "20.0.11" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1746136567034 || Date.now(),
4
+ VERSION: "20.0.12" || '--current-version--',
5
5
  };
@@ -72,7 +72,7 @@ export type AggregationColumnsModelItem = {
72
72
  };
73
73
  export type AggregationColumnsModel = AggregationColumnsModelItem[];
74
74
  export type PivotAggregationColumnsModel = (AggregationColumnsModelItem & {
75
- TotalColumn?: boolean | 'before' | 'after' | {
75
+ Total?: boolean | 'before' | 'after' | {
76
76
  PivotColumnId: string;
77
77
  ShowTotal?: boolean | 'before' | 'after';
78
78
  }[];
@@ -116,10 +116,10 @@ export interface PivotLayoutModel extends BaseLayoutModel {
116
116
  /**
117
117
  * Display Total of all Pivot Columns before or after the Pivot Columns
118
118
  */
119
- GrandTotalColumn?: 'before' | 'after' | boolean;
119
+ PivotGrandTotal?: 'before' | 'after' | boolean;
120
120
  /**
121
121
  * Display automatically calculated Totals within EACH Pivot Column Group, in the position specified
122
122
  */
123
- PivotGroupTotalColumn?: 'before' | 'after' | boolean;
123
+ PivotColumnTotal?: 'before' | 'after' | boolean;
124
124
  }
125
125
  export type LayoutModel = TableLayoutModel | PivotLayoutModel;
@@ -1,6 +1,10 @@
1
1
  import { ColumnState, GridApi, GridOptions, GridState } from 'ag-grid-enterprise';
2
2
  import { PivotLayoutModel, TableLayoutModel } from './LayoutManagerModel';
3
3
  import { LMEmitter } from './LMEmitter';
4
+ export declare const PIVOT_ANY_TOTAL_COL_TYPE = "pivotAnyTotal";
5
+ export declare const PIVOT_GRAND_TOTAL_COL_TYPE = "pivotGrandTotal";
6
+ export declare const PIVOT_COLUMN_TOTAL_COL_TYPE = "pivotColumnTotal";
7
+ export declare const PIVOT_AGGREGATION_TOTAL_COL_TYPE = "pivotAggregationTotal";
4
8
  export type LayoutManagerOptions = {
5
9
  gridApi: GridApi;
6
10
  debugId: string;
@@ -74,7 +78,7 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
74
78
  private withSuppressColumnAnimation;
75
79
  private patchColDefType;
76
80
  private setupPivotTotals;
77
- private patchPivotTotalColumn;
81
+ private patchPivotAggregationTotal;
78
82
  private getPivotTotalColumnConfig;
79
83
  }
80
84
  export {};
@@ -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) {