@adaptabletools/adaptable 20.0.4-canary.1 → 20.0.4-canary.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "20.0.4-canary.1",
3
+ "version": "20.0.4-canary.3",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -333,12 +333,21 @@ export const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
333
333
  if (layoutModel.GrandTotalRow) {
334
334
  pivotLayout.GrandTotalRow = layoutModel.GrandTotalRow;
335
335
  }
336
+ else {
337
+ delete pivotLayout.GrandTotalRow;
338
+ }
336
339
  if (layoutModel.GrandTotalColumn) {
337
340
  pivotLayout.GrandTotalColumn = layoutModel.GrandTotalColumn;
338
341
  }
342
+ else {
343
+ delete pivotLayout.GrandTotalColumn;
344
+ }
339
345
  if (layoutModel.PivotGroupTotalColumn) {
340
346
  pivotLayout.PivotGroupTotalColumn = layoutModel.PivotGroupTotalColumn;
341
347
  }
348
+ else {
349
+ delete pivotLayout.PivotGroupTotalColumn;
350
+ }
342
351
  if (layoutModel.PivotAggregationColumns) {
343
352
  pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => ({
344
353
  ColumnId,
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: 1744398186764 || Date.now(),
4
- VERSION: "20.0.4-canary.1" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1744658441173 || Date.now(),
4
+ VERSION: "20.0.4-canary.3" || '--current-version--',
5
5
  };
@@ -75,7 +75,10 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
75
75
  private setupPivotTotals;
76
76
  private isPivotRowTotalColDef;
77
77
  private patchGrandTotalColumn;
78
+ private isPivotGroupTotalColumn;
79
+ private patchPivotGroupTotalColumn;
78
80
  private patchPivotTotalColumn;
81
+ private destructurePivotColumnId;
79
82
  private getPivotTotalColumnConfig;
80
83
  }
81
84
  export {};
@@ -256,6 +256,18 @@ export class LayoutManager extends LMEmitter {
256
256
  PivotAggregationColumns: layout.TableAggregationColumns,
257
257
  PivotExpandLevel: prevLayout?.PivotExpandLevel ?? -1,
258
258
  };
259
+ const grandTotalRow = this.gridApi.getGridOption('grandTotalRow');
260
+ if (grandTotalRow) {
261
+ pivotLayout.GrandTotalRow = grandTotalRow;
262
+ }
263
+ const grandTotalColumn = this.gridApi.getGridOption('pivotRowTotals');
264
+ if (grandTotalColumn) {
265
+ pivotLayout.GrandTotalColumn = grandTotalColumn;
266
+ }
267
+ const pivotGroupTotalColumn = this.gridApi.getGridOption('pivotColumnGroupTotals');
268
+ if (pivotGroupTotalColumn) {
269
+ pivotLayout.PivotGroupTotalColumn = pivotGroupTotalColumn;
270
+ }
259
271
  return simplifyPivotLayoutModel(pivotLayout);
260
272
  }
261
273
  getTableLayoutModelFromGrid() {
@@ -1102,6 +1114,7 @@ export class LayoutManager extends LMEmitter {
1102
1114
  return;
1103
1115
  }
1104
1116
  this.patchGrandTotalColumn(resulColDef);
1117
+ this.patchPivotGroupTotalColumn(resulColDef);
1105
1118
  });
1106
1119
  const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
1107
1120
  this.gridApi.setGridOption('processPivotResultColGroupDef', (colGroupDef) => {
@@ -1123,6 +1136,24 @@ export class LayoutManager extends LMEmitter {
1123
1136
  resultColDef.headerName = `Grand Total ${resultColDef.headerName}`;
1124
1137
  }
1125
1138
  }
1139
+ isPivotGroupTotalColumn(colDef) {
1140
+ // pivot group total are spanning cross all aggregations
1141
+ // therefore the last part of the colId is empty (hence the "dangling" underscore)
1142
+ return colDef.colId?.startsWith('pivot_') && colDef.colId?.endsWith('_');
1143
+ }
1144
+ patchPivotGroupTotalColumn(resultColDef) {
1145
+ if (!isPivotLayoutModel(this.currentLayout) || !this.currentLayout.PivotGroupTotalColumn) {
1146
+ return;
1147
+ }
1148
+ if (this.isPivotGroupTotalColumn(resultColDef)) {
1149
+ // resultColDef
1150
+ const colInfo = this.destructurePivotColumnId(resultColDef.colId);
1151
+ if (colInfo !== '!unknown!') {
1152
+ const currentPivotKey = colInfo.pivotKeys[colInfo.pivotKeys.length - 1];
1153
+ resultColDef.headerName = `${currentPivotKey} Total`;
1154
+ }
1155
+ }
1156
+ }
1126
1157
  patchPivotTotalColumn(colGroupDef) {
1127
1158
  const hasPivotTotalCols = (pivotLayout) => {
1128
1159
  return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
@@ -1146,6 +1177,7 @@ export class LayoutManager extends LMEmitter {
1146
1177
  else {
1147
1178
  pivotRowTotalColDefsBefore.push(colDef);
1148
1179
  }
1180
+ return;
1149
1181
  }
1150
1182
  if (isPivotTotalColDef(colDef)) {
1151
1183
  if (!colDef.colId.startsWith('pivot_')) {
@@ -1180,16 +1212,12 @@ export class LayoutManager extends LMEmitter {
1180
1212
  ...pivotRowTotalColDefsAfter,
1181
1213
  ];
1182
1214
  }
1183
- getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1184
- const defaultHiddenConfig = {
1185
- visible: false,
1186
- };
1187
- const colId = colDef.colId;
1215
+ destructurePivotColumnId(colId = '') {
1188
1216
  // Split by underscore to get 4 parts
1189
1217
  const parts = colId.split('_');
1190
1218
  if (parts.length !== 4) {
1191
1219
  this.warn(`Unsupported format of pivot total column id: ${colId}`);
1192
- return defaultHiddenConfig;
1220
+ return '!unknown!';
1193
1221
  }
1194
1222
  // e.g.
1195
1223
  // pivot_country-sport-year_United States-Basketball_gold
@@ -1199,6 +1227,23 @@ export class LayoutManager extends LMEmitter {
1199
1227
  const [_pivotPrefix, pivotColsTxt, pivotKeysTxt, aggregationColumnId] = parts;
1200
1228
  const pivotColumnIds = pivotColsTxt.split('-');
1201
1229
  const pivotKeys = pivotKeysTxt.split('-');
1230
+ const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1231
+ return {
1232
+ pivotColumnIds,
1233
+ pivotKeys,
1234
+ pivotColumnId,
1235
+ aggregationColumnId,
1236
+ };
1237
+ }
1238
+ getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1239
+ const defaultHiddenConfig = {
1240
+ visible: false,
1241
+ };
1242
+ const colIdInfo = this.destructurePivotColumnId(colDef.colId);
1243
+ if (colIdInfo === '!unknown!') {
1244
+ return defaultHiddenConfig;
1245
+ }
1246
+ const { pivotColumnId, aggregationColumnId } = colIdInfo;
1202
1247
  const layoutAggCol = currentPivotLayout.PivotAggregationColumns?.find((col) => col.ColumnId === aggregationColumnId);
1203
1248
  if (!layoutAggCol) {
1204
1249
  this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
@@ -1208,7 +1253,6 @@ export class LayoutManager extends LMEmitter {
1208
1253
  if (!layoutPivotTotalColumn) {
1209
1254
  return defaultHiddenConfig;
1210
1255
  }
1211
- const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1212
1256
  if (Array.isArray(layoutPivotTotalColumn)) {
1213
1257
  const pivotSpecificConfig = layoutPivotTotalColumn.find((config) => config.PivotColumnId === pivotColumnId);
1214
1258
  return {