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

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.2",
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",
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: 1744635576553 || Date.now(),
4
+ VERSION: "20.0.4-canary.2" || '--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 {};
@@ -1102,6 +1102,7 @@ export class LayoutManager extends LMEmitter {
1102
1102
  return;
1103
1103
  }
1104
1104
  this.patchGrandTotalColumn(resulColDef);
1105
+ this.patchPivotGroupTotalColumn(resulColDef);
1105
1106
  });
1106
1107
  const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
1107
1108
  this.gridApi.setGridOption('processPivotResultColGroupDef', (colGroupDef) => {
@@ -1123,6 +1124,24 @@ export class LayoutManager extends LMEmitter {
1123
1124
  resultColDef.headerName = `Grand Total ${resultColDef.headerName}`;
1124
1125
  }
1125
1126
  }
1127
+ isPivotGroupTotalColumn(colDef) {
1128
+ // pivot group total are spanning cross all aggregations
1129
+ // therefore the last part of the colId is empty (hence the "dangling" underscore)
1130
+ return colDef.colId?.startsWith('pivot_') && colDef.colId?.endsWith('_');
1131
+ }
1132
+ patchPivotGroupTotalColumn(resultColDef) {
1133
+ if (!isPivotLayoutModel(this.currentLayout) || !this.currentLayout.PivotGroupTotalColumn) {
1134
+ return;
1135
+ }
1136
+ if (this.isPivotGroupTotalColumn(resultColDef)) {
1137
+ // resultColDef
1138
+ const colInfo = this.destructurePivotColumnId(resultColDef.colId);
1139
+ if (colInfo !== '!unknown!') {
1140
+ const currentPivotKey = colInfo.pivotKeys[colInfo.pivotKeys.length - 1];
1141
+ resultColDef.headerName = `${currentPivotKey} Total`;
1142
+ }
1143
+ }
1144
+ }
1126
1145
  patchPivotTotalColumn(colGroupDef) {
1127
1146
  const hasPivotTotalCols = (pivotLayout) => {
1128
1147
  return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
@@ -1180,16 +1199,12 @@ export class LayoutManager extends LMEmitter {
1180
1199
  ...pivotRowTotalColDefsAfter,
1181
1200
  ];
1182
1201
  }
1183
- getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1184
- const defaultHiddenConfig = {
1185
- visible: false,
1186
- };
1187
- const colId = colDef.colId;
1202
+ destructurePivotColumnId(colId = '') {
1188
1203
  // Split by underscore to get 4 parts
1189
1204
  const parts = colId.split('_');
1190
1205
  if (parts.length !== 4) {
1191
1206
  this.warn(`Unsupported format of pivot total column id: ${colId}`);
1192
- return defaultHiddenConfig;
1207
+ return '!unknown!';
1193
1208
  }
1194
1209
  // e.g.
1195
1210
  // pivot_country-sport-year_United States-Basketball_gold
@@ -1199,6 +1214,23 @@ export class LayoutManager extends LMEmitter {
1199
1214
  const [_pivotPrefix, pivotColsTxt, pivotKeysTxt, aggregationColumnId] = parts;
1200
1215
  const pivotColumnIds = pivotColsTxt.split('-');
1201
1216
  const pivotKeys = pivotKeysTxt.split('-');
1217
+ const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1218
+ return {
1219
+ pivotColumnIds,
1220
+ pivotKeys,
1221
+ pivotColumnId,
1222
+ aggregationColumnId,
1223
+ };
1224
+ }
1225
+ getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1226
+ const defaultHiddenConfig = {
1227
+ visible: false,
1228
+ };
1229
+ const colIdInfo = this.destructurePivotColumnId(colDef.colId);
1230
+ if (colIdInfo === '!unknown!') {
1231
+ return defaultHiddenConfig;
1232
+ }
1233
+ const { pivotColumnId, aggregationColumnId } = colIdInfo;
1202
1234
  const layoutAggCol = currentPivotLayout.PivotAggregationColumns?.find((col) => col.ColumnId === aggregationColumnId);
1203
1235
  if (!layoutAggCol) {
1204
1236
  this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
@@ -1208,7 +1240,6 @@ export class LayoutManager extends LMEmitter {
1208
1240
  if (!layoutPivotTotalColumn) {
1209
1241
  return defaultHiddenConfig;
1210
1242
  }
1211
- const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1212
1243
  if (Array.isArray(layoutPivotTotalColumn)) {
1213
1244
  const pivotSpecificConfig = layoutPivotTotalColumn.find((config) => config.PivotColumnId === pivotColumnId);
1214
1245
  return {