@adaptabletools/adaptable 20.0.11 → 20.0.13
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/agGrid.d.ts +3 -3
- package/agGrid.js +4 -4
- package/package.json +1 -1
- package/src/AdaptableOptions/ColumnOptions.d.ts +3 -3
- package/src/AdaptableState/Common/AdaptableColumn.d.ts +3 -3
- package/src/AdaptableState/Common/AdaptableColumn.js +9 -8
- package/src/AdaptableState/Common/AggregationColumns.d.ts +3 -2
- package/src/AdaptableState/Common/AggregationColumns.js +0 -3
- package/src/AdaptableState/LayoutState.d.ts +6 -2
- package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -1
- package/src/Api/Implementation/ColumnApiImpl.js +5 -5
- package/src/Api/Implementation/LayoutHelpers.js +18 -32
- package/src/Api/Internal/ColumnInternalApi.js +5 -5
- package/src/Strategy/CalculatedColumnModule.d.ts +1 -1
- package/src/Strategy/CellSummaryModule.d.ts +1 -1
- package/src/Strategy/ChartingModule.d.ts +1 -1
- package/src/Strategy/ColumnFilterModule.d.ts +1 -1
- package/src/Strategy/ColumnInfoModule.d.ts +1 -1
- package/src/Strategy/FlashingCellModule.d.ts +1 -1
- package/src/Strategy/FormatColumnModule.d.ts +1 -1
- package/src/Strategy/FreeTextColumnModule.d.ts +1 -1
- package/src/Strategy/GridInfoModule.d.ts +1 -1
- package/src/Strategy/LayoutModule.d.ts +1 -1
- package/src/Strategy/PlusMinusModule.d.ts +1 -1
- package/src/Strategy/SettingsPanelModule.d.ts +1 -1
- package/src/Strategy/StyledColumnModule.d.ts +1 -1
- package/src/Strategy/SystemStatusModule.d.ts +1 -1
- package/src/Utilities/Helpers/AdaptableHelper.d.ts +1 -0
- package/src/Utilities/Helpers/AdaptableHelper.js +27 -1
- package/src/View/Layout/Wizard/sections/PivotAggregationsSection.js +23 -23
- package/src/agGrid/AdaptableAgGrid.js +8 -4
- package/src/agGrid/AgGridAdapter.js +4 -4
- package/src/agGrid/AgGridColumnAdapter.js +21 -3
- package/src/env.js +2 -2
- package/src/layout-manager/src/LayoutManagerModel.d.ts +3 -3
- package/src/layout-manager/src/index.d.ts +5 -1
- package/src/layout-manager/src/index.js +48 -44
- package/src/layout-manager/src/isLayoutEqual.d.ts +8 -0
- package/src/layout-manager/src/isLayoutEqual.js +43 -2
- package/src/layout-manager/src/isPivotColumnTotal.d.ts +1 -0
- package/src/layout-manager/src/{isPivotGroupTotalColumn.js → isPivotColumnTotal.js} +1 -1
- package/src/layout-manager/src/isPivotGrandTotal.d.ts +2 -0
- package/src/layout-manager/src/{isPivotGrandTotalColumn.js → isPivotGrandTotal.js} +1 -1
- package/src/layout-manager/src/normalizeLayoutModel.js +24 -0
- package/src/layout-manager/src/simplifyLayoutModel.js +10 -1
- package/src/metamodel/adaptable.metamodel.d.ts +4 -4
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/types.d.ts +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/src/layout-manager/src/isPivotGrandTotalColumn.d.ts +0 -2
- package/src/layout-manager/src/isPivotGroupTotalColumn.d.ts +0 -1
|
@@ -13,7 +13,7 @@ export declare class StyledColumnModule extends AdaptableModuleBase implements I
|
|
|
13
13
|
}): AdaptableObject[];
|
|
14
14
|
getExplicitlyReferencedColumnIds(styledColumn: StyledColumn): string[];
|
|
15
15
|
hasNamedQueryReferences(): boolean;
|
|
16
|
-
createColumnMenuItems(column: AdaptableColumn): AdaptableMenuItem<"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"
|
|
16
|
+
createColumnMenuItems(column: AdaptableColumn): AdaptableMenuItem<"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">[];
|
|
17
17
|
private getGlyphForStyledColumn;
|
|
18
18
|
getTeamSharingAction(): TeamSharingImportInfo<StyledColumn>;
|
|
19
19
|
toView(styledColumn: StyledColumn): AdaptableObjectView;
|
|
@@ -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"
|
|
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
|
|
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
|
-
|
|
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?.
|
|
138
|
-
? currentAggCol.
|
|
137
|
+
const currentTotal = currentAggCol?.Total
|
|
138
|
+
? currentAggCol.Total === true || currentAggCol.Total === 'before'
|
|
139
139
|
? 'Before'
|
|
140
|
-
: currentAggCol.
|
|
140
|
+
: currentAggCol.Total === 'after'
|
|
141
141
|
? 'After'
|
|
142
|
-
: Array.isArray(currentAggCol.
|
|
142
|
+
: Array.isArray(currentAggCol.Total)
|
|
143
143
|
? 'Pivot Specific'
|
|
144
144
|
: 'Off'
|
|
145
145
|
: 'Off';
|
|
146
|
-
const hasPivotSpecificTotals = Array.isArray(currentAggCol?.
|
|
147
|
-
const pivotSpecificTotals = Array.isArray(currentAggCol?.
|
|
148
|
-
? currentAggCol.
|
|
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,
|
|
162
|
+
return { ...aggCol, Total: updatedTotals };
|
|
163
163
|
}
|
|
164
164
|
return aggCol;
|
|
165
165
|
});
|
|
@@ -179,7 +179,7 @@ const PivotColumnRow = (props) => {
|
|
|
179
179
|
' ',
|
|
180
180
|
React.createElement(DropdownButton, { columns: ['label'], items: numericColumnsOptions, ml: 2 }, weightName))),
|
|
181
181
|
aggValue && (React.createElement(Flex, { backgroundColor: "primary", ml: 3, alignItems: "center" },
|
|
182
|
-
React.createElement(Text, null, "Total
|
|
182
|
+
React.createElement(Text, null, "Total"),
|
|
183
183
|
' ',
|
|
184
184
|
React.createElement(DropdownButton, { columns: ['label'], items: totalOptions, ml: 2 }, currentTotal)))),
|
|
185
185
|
hasPivotSpecificTotals && (React.createElement(Flex, { ml: 2, pl: 2, flexWrap: "wrap", flex: "1 1 auto", alignItems: "center", style: {
|
|
@@ -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)?.
|
|
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.
|
|
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['
|
|
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
|
|
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.
|
|
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
|
|
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,
|
|
@@ -333,29 +333,29 @@ export const PivotAggregationsSection = (props) => {
|
|
|
333
333
|
GrandTotalRow: value,
|
|
334
334
|
});
|
|
335
335
|
}, isClearable: true })),
|
|
336
|
-
React.createElement(FormRow, { label: 'Grand Total
|
|
336
|
+
React.createElement(FormRow, { label: 'Pivot Grand Total' },
|
|
337
337
|
React.createElement(Select, { style: { width: 120 }, options: ['before', 'after'].map((position) => {
|
|
338
338
|
return {
|
|
339
339
|
label: StringExtensions.CapitaliseFirstLetter(position),
|
|
340
340
|
value: position,
|
|
341
341
|
};
|
|
342
|
-
}), placeholder: "Off", value: layout.
|
|
342
|
+
}), placeholder: "Off", value: layout.PivotGrandTotal, onChange: (value) => {
|
|
343
343
|
props.onChange({
|
|
344
344
|
...layout,
|
|
345
|
-
|
|
345
|
+
PivotGrandTotal: value,
|
|
346
346
|
});
|
|
347
347
|
}, isClearable: true })),
|
|
348
|
-
React.createElement(FormRow, { label: 'Pivot
|
|
348
|
+
React.createElement(FormRow, { label: 'Pivot Column Total' }, 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.
|
|
353
|
+
}), placeholder: "Off", value: layout.PivotColumnTotal, onChange: (value) => {
|
|
354
354
|
props.onChange({
|
|
355
355
|
...layout,
|
|
356
|
-
|
|
356
|
+
PivotColumnTotal: value,
|
|
357
357
|
});
|
|
358
|
-
}, isClearable: true })) : (React.createElement(Text, { marginLeft: 1, style: { fontStyle: 'italic' } },
|
|
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 }))));
|
|
@@ -93,7 +93,7 @@ import { AgGridExportAdapter } from './AgGridExportAdapter';
|
|
|
93
93
|
import { checkForDuplicateColumns, isPivotLayout, layoutModelToLayoutState, layoutStateToLayoutModel, normalizeLayout, } from '../Api/Implementation/LayoutHelpers';
|
|
94
94
|
import { LayoutManager } from '../layout-manager/src';
|
|
95
95
|
import { isPivotLayoutModel } from '../layout-manager/src/isPivotLayoutModel';
|
|
96
|
-
import { ACTION_COLUMN_TYPE, CALCULATED_COLUMN_TYPE, FDC3_COLUMN_TYPE, FREE_TEXT_COLUMN_TYPE, } from '../AdaptableState/Common/AdaptableColumn';
|
|
96
|
+
import { ACTION_COLUMN_TYPE, CALCULATED_COLUMN_TYPE, FDC3_COLUMN_TYPE, FREE_TEXT_COLUMN_TYPE, PIVOT_AGGREGATION_TOTAL_COLUMN_TYPE, PIVOT_ANY_TOTAL_COLUMN_TYPE, PIVOT_COLUMN_TOTAL_COLUMN_TYPE, PIVOT_GRAND_TOTAL_COLUMN_TYPE, } from '../AdaptableState/Common/AdaptableColumn';
|
|
97
97
|
import { agGridDataTypeDefinitions } from './agGridDataTypeDefinitions';
|
|
98
98
|
import { AgGridThemeAdapter } from './AgGridThemeAdapter';
|
|
99
99
|
import { mapOldTypeToDataType } from '../migration/VersionUpgrade20';
|
|
@@ -1076,6 +1076,10 @@ You need to define at least one Layout!`);
|
|
|
1076
1076
|
[FREE_TEXT_COLUMN_TYPE]: {},
|
|
1077
1077
|
[ACTION_COLUMN_TYPE]: {},
|
|
1078
1078
|
[FDC3_COLUMN_TYPE]: {},
|
|
1079
|
+
[PIVOT_ANY_TOTAL_COLUMN_TYPE]: {},
|
|
1080
|
+
[PIVOT_GRAND_TOTAL_COLUMN_TYPE]: {},
|
|
1081
|
+
[PIVOT_COLUMN_TOTAL_COLUMN_TYPE]: {},
|
|
1082
|
+
[PIVOT_AGGREGATION_TOTAL_COLUMN_TYPE]: {},
|
|
1079
1083
|
};
|
|
1080
1084
|
const patchedColumnTypes = Object.assign({}, providedColumnTypes, adaptableSpecialColumnTypes);
|
|
1081
1085
|
const customColumnTypes = this.api.columnApi.getColumnTypes() ?? [];
|
|
@@ -3334,14 +3338,14 @@ You need to define at least one Layout!`);
|
|
|
3334
3338
|
if (!isPivotLayout(layout)) {
|
|
3335
3339
|
return false;
|
|
3336
3340
|
}
|
|
3337
|
-
if (layout.
|
|
3341
|
+
if (layout.PivotGrandTotal) {
|
|
3338
3342
|
return true;
|
|
3339
3343
|
}
|
|
3340
|
-
if (layout.
|
|
3344
|
+
if (layout.PivotColumnTotal) {
|
|
3341
3345
|
return true;
|
|
3342
3346
|
}
|
|
3343
3347
|
if (layout.PivotAggregationColumns) {
|
|
3344
|
-
return layout.PivotAggregationColumns.some((col) => !!col.
|
|
3348
|
+
return layout.PivotAggregationColumns.some((col) => !!col.Total);
|
|
3345
3349
|
}
|
|
3346
3350
|
};
|
|
3347
3351
|
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 {
|
|
10
|
-
import {
|
|
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 (
|
|
614
|
-
|
|
613
|
+
return (isPivotGrandTotal(colDef.colId) ||
|
|
614
|
+
isPivotColumnTotal(colDef.colId) ||
|
|
615
615
|
isPivotAggTotalColumn(colDef));
|
|
616
616
|
}
|
|
617
617
|
isColumnFilterable(colDef) {
|
|
@@ -202,14 +202,32 @@ export class AgGridColumnAdapter {
|
|
|
202
202
|
const quickSearchStyle = this.getQuickSearchCellStyle();
|
|
203
203
|
const hasQuickSearchStyle = quickSearchStyle != undefined;
|
|
204
204
|
const cellStyle = (params) => {
|
|
205
|
-
const
|
|
205
|
+
const columnId = params.column.getColId();
|
|
206
|
+
const gridCell = this.adaptableApi.gridApi.getGridCellFromRowNode(params.node, columnId);
|
|
206
207
|
if (!gridCell || !gridCell.column) {
|
|
207
208
|
return {};
|
|
208
209
|
}
|
|
209
210
|
const isQuickSearchActive = hasQuickSearchStyle && this.isQuickSearchActive(gridCell, params);
|
|
210
|
-
|
|
211
|
+
let baseStyles = {};
|
|
212
|
+
// this is required because otherwise, when AG Grid filters, it refershed the pivotResultColDef and the base styles get lost
|
|
213
|
+
// if pivot result col: inherit styles from base column
|
|
214
|
+
if (this.adaptableApi.columnApi.isPivotResultColumn(columnId)) {
|
|
215
|
+
const baseColumn = params.column.getColDef()?.pivotValueColumn;
|
|
216
|
+
if (baseColumn) {
|
|
217
|
+
const baseColDefCellStyle = baseColumn?.getColDef()?.cellStyle;
|
|
218
|
+
const baseColParams = { ...params, column: baseColumn };
|
|
219
|
+
baseStyles =
|
|
220
|
+
typeof baseColDefCellStyle === 'function'
|
|
221
|
+
? baseColDefCellStyle(baseColParams)
|
|
222
|
+
: baseColDefCellStyle;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// inherit styles from user provided colDef property
|
|
227
|
+
baseStyles = typeof userCellStyle === 'function' ? userCellStyle(params) : userCellStyle;
|
|
228
|
+
}
|
|
211
229
|
const result = {
|
|
212
|
-
...
|
|
230
|
+
...baseStyles,
|
|
213
231
|
...this.getReadOnlyCellStyle(gridCell, params),
|
|
214
232
|
...this.getEditableCellStyle(gridCell, params),
|
|
215
233
|
...this.getEditedCellStyle(gridCell, params),
|
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:
|
|
4
|
-
VERSION: "20.0.
|
|
3
|
+
PUBLISH_TIMESTAMP: 1746196666403 || Date.now(),
|
|
4
|
+
VERSION: "20.0.13" || '--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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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 {
|
|
11
|
-
import {
|
|
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
|
|
268
|
-
if (
|
|
269
|
-
pivotLayout.
|
|
271
|
+
const pivotGrandTotal = this.gridApi.getGridOption('pivotRowTotals');
|
|
272
|
+
if (pivotGrandTotal) {
|
|
273
|
+
pivotLayout.PivotGrandTotal = pivotGrandTotal;
|
|
270
274
|
}
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
pivotLayout.
|
|
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
|
-
*
|
|
1055
|
+
* PivotGrandTotal
|
|
1052
1056
|
*/
|
|
1053
|
-
if (layout.
|
|
1054
|
-
const
|
|
1057
|
+
if (layout.PivotGrandTotal) {
|
|
1058
|
+
const pivotGrandTotal = layout.PivotGrandTotal === true || layout.PivotGrandTotal === 'before'
|
|
1055
1059
|
? 'before'
|
|
1056
|
-
: layout.
|
|
1060
|
+
: layout.PivotGrandTotal === 'after'
|
|
1057
1061
|
? 'after'
|
|
1058
1062
|
: null;
|
|
1059
|
-
this.gridApi.setGridOption('pivotRowTotals',
|
|
1063
|
+
this.gridApi.setGridOption('pivotRowTotals', pivotGrandTotal);
|
|
1060
1064
|
}
|
|
1061
1065
|
else {
|
|
1062
1066
|
this.gridApi.setGridOption('pivotRowTotals', null);
|
|
1063
1067
|
}
|
|
1064
1068
|
/**
|
|
1065
|
-
*
|
|
1069
|
+
* PivotColumnTotal
|
|
1066
1070
|
*/
|
|
1067
|
-
if (layout.
|
|
1068
|
-
const
|
|
1071
|
+
if (layout.PivotColumnTotal) {
|
|
1072
|
+
const pivotColumnTotal = layout.PivotColumnTotal === true || layout.PivotColumnTotal === 'before'
|
|
1069
1073
|
? 'before'
|
|
1070
|
-
: layout.
|
|
1074
|
+
: layout.PivotColumnTotal === 'after'
|
|
1071
1075
|
? 'after'
|
|
1072
1076
|
: null;
|
|
1073
|
-
this.gridApi.setGridOption('pivotColumnGroupTotals',
|
|
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 (
|
|
1130
|
-
this.patchColDefType(colDef, [
|
|
1133
|
+
if (isPivotGrandTotal(colDef)) {
|
|
1134
|
+
this.patchColDefType(colDef, [PIVOT_ANY_TOTAL_COL_TYPE, PIVOT_GRAND_TOTAL_COL_TYPE]);
|
|
1131
1135
|
}
|
|
1132
|
-
if (
|
|
1133
|
-
this.patchColDefType(colDef, [
|
|
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.
|
|
1146
|
+
this.patchPivotAggregationTotal(colGroupDef);
|
|
1143
1147
|
});
|
|
1144
1148
|
}
|
|
1145
|
-
|
|
1146
|
-
const
|
|
1147
|
-
return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.
|
|
1149
|
+
patchPivotAggregationTotal(colGroupDef) {
|
|
1150
|
+
const hasPivotAggTotals = (pivotLayout) => {
|
|
1151
|
+
return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.Total);
|
|
1148
1152
|
};
|
|
1149
|
-
if (!isPivotLayoutModel(this.currentLayout) || !
|
|
1153
|
+
if (!isPivotLayoutModel(this.currentLayout) || !hasPivotAggTotals(this.currentLayout)) {
|
|
1150
1154
|
return;
|
|
1151
1155
|
}
|
|
1152
|
-
const
|
|
1153
|
-
const
|
|
1154
|
-
const
|
|
1155
|
-
const
|
|
1156
|
+
const pivotGrandTotalsBefore = [];
|
|
1157
|
+
const pivotGrandTotalsAfter = [];
|
|
1158
|
+
const pivotAggTotalsBefore = [];
|
|
1159
|
+
const pivotAggTotalsAfter = [];
|
|
1156
1160
|
const normalColDefs = [];
|
|
1157
1161
|
colGroupDef.children.forEach((colDef) => {
|
|
1158
|
-
if (
|
|
1162
|
+
if (isPivotGrandTotal(colDef)) {
|
|
1159
1163
|
if (this.gridApi.getGridOption('pivotRowTotals') === 'after') {
|
|
1160
|
-
|
|
1164
|
+
pivotGrandTotalsAfter.push(colDef);
|
|
1161
1165
|
}
|
|
1162
1166
|
else {
|
|
1163
|
-
|
|
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, [
|
|
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
|
-
|
|
1185
|
+
pivotAggTotalsAfter.push(colDef);
|
|
1182
1186
|
}
|
|
1183
1187
|
else {
|
|
1184
|
-
|
|
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
|
-
...
|
|
1194
|
-
...
|
|
1197
|
+
...pivotGrandTotalsBefore,
|
|
1198
|
+
...pivotAggTotalsBefore,
|
|
1195
1199
|
...normalColDefs,
|
|
1196
|
-
...
|
|
1197
|
-
...
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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;
|