@adaptabletools/adaptable 21.0.8 → 21.0.9

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": "21.0.8",
3
+ "version": "21.0.9",
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",
@@ -41,10 +41,15 @@ const ColumnRow = (props) => {
41
41
  const adaptable = useAdaptable();
42
42
  const aggValue = props.layout?.TableAggregationColumns?.find((agg) => agg.ColumnId === props.column.columnId)?.AggFunc;
43
43
  const adaptableAggFunctions = [];
44
- if (props.column.dataType === 'number') {
44
+ if (props.column.dataType === 'number' && props.column.aggregatable) {
45
45
  adaptableAggFunctions.push(WEIGHTED_AVERAGE_AGG_FN_NAME);
46
46
  }
47
- const aggOptions = [...props.column.availableAggregationFunctions, ...adaptableAggFunctions].map((fnName) => {
47
+ // props.column.availableAggregationFunctions is null for non-aggregatable columns
48
+ // but we want to support non-aggregatable columns that are specified to be aggregated by default
49
+ // so we need to allow this. as soon as they will be unchecked from aggregation, they will no longer be displayed in the aggregation wizard.
50
+ // but until the user checks them off, we want to allow them.
51
+ const availableAggregationFunctions = props.column.availableAggregationFunctions || [];
52
+ const aggOptions = [...new Set([...availableAggregationFunctions, ...adaptableAggFunctions])].map((fnName) => {
48
53
  return {
49
54
  label: fnName,
50
55
  onClick: () => {
@@ -135,9 +140,17 @@ export const AggregationsSection = (props) => {
135
140
  const allAggregableColumns = adaptable.api.columnApi.getAggregatableColumns();
136
141
  const allColumns = adaptable.api.columnApi.getUIAvailableColumns();
137
142
  const numberColumns = adaptable.api.columnApi.getNumericColumns();
138
- const sortedAggregableColumns = React.useMemo(() => {
139
- return ArrayExtensions.sortArrayWithOrder(allAggregableColumns.map((col) => col.columnId), (layout.TableAggregationColumns ?? []).map((agg) => agg.ColumnId), { sortUnorderedItems: false }).map((colId) => adaptable.api.columnApi.getColumnWithColumnId(colId));
140
- }, [layout, allAggregableColumns]);
143
+ const allAggregatableColumnIds = allAggregableColumns.map((col) => col.columnId);
144
+ (layout.TableAggregationColumns || []).forEach((agg) => {
145
+ // we need to also display the columns currently aggregated,
146
+ // even if they are not aggregatable
147
+ if (!allAggregatableColumnIds.includes(agg.ColumnId)) {
148
+ allAggregatableColumnIds.push(agg.ColumnId);
149
+ }
150
+ });
151
+ const sortedAggregableColumns = ArrayExtensions.sortArrayWithOrder(allAggregatableColumnIds, (layout.TableAggregationColumns ?? []).map((agg) => agg.ColumnId), { sortUnorderedItems: false })
152
+ .map((colId) => adaptable.api.columnApi.getColumnWithColumnId(colId))
153
+ .filter(Boolean);
141
154
  const handleColumnsSelectionChange = React.useCallback((columnIds) => {
142
155
  const currentAggsMap = (layout.TableAggregationColumns || []).reduce((acc, { ColumnId, AggFunc }) => {
143
156
  acc[ColumnId] = AggFunc;
@@ -608,7 +608,10 @@ export class AgGridAdapter {
608
608
  return false;
609
609
  }
610
610
  getColumnAggregationFunctions(colDef) {
611
- return colDef.allowedAggFuncs || ['sum', 'min', 'max', 'count', 'avg', 'first', 'last']; // those are the default fns aggrid supports out-of-the-box
611
+ const result = colDef.allowedAggFuncs || ['sum', 'min', 'max', 'count', 'avg', 'first', 'last']; // those are the default fns aggrid supports out-of-the-box
612
+ const gridOptionsAggFuncs = this.adaptableApi.agGridApi.getGridOption('aggFuncs') || {};
613
+ result.push(...Object.keys(gridOptionsAggFuncs));
614
+ return [...new Set(result)];
612
615
  }
613
616
  isTreeColumn(isGeneratedRowGroupColumn) {
614
617
  return this.adaptableApi.gridApi.isTreeDataGrid() ? isGeneratedRowGroupColumn : false;
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: 1761108086778 || Date.now(),
4
- VERSION: "21.0.8" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1761300024312 || Date.now(),
4
+ VERSION: "21.0.9" || '--current-version--',
5
5
  };
@@ -94,7 +94,7 @@ function isGridLayoutSame(options) {
94
94
  if (!!gridLayout != !!layout) {
95
95
  return false;
96
96
  }
97
- return isLayoutEqual(gridLayout, layout);
97
+ return isLayoutEqual(normalizeLayoutModel(gridLayout), normalizeLayoutModel(layout));
98
98
  }
99
99
  function getDefaultColumnSizeStateForColDef(colId, colDef, options) {
100
100
  if (!colDef) {
@@ -312,7 +312,7 @@ export class LayoutManager extends LMEmitter {
312
312
  // emit an event that the layout has changed from the grid
313
313
  this.emitSync('gridLayoutChanged', layout);
314
314
  const log = this.debugger.extend('gridLayoutChanged');
315
- const changes = getChanges(prevLayout, layout);
315
+ const changes = getChanges(normalizeLayoutModel(prevLayout), normalizeLayoutModel(layout));
316
316
  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', changes);
317
317
  }
318
318
  }
@@ -333,8 +333,6 @@ export class LayoutManager extends LMEmitter {
333
333
  getPivotLayoutModelFromGrid() {
334
334
  const pivotResultColumns = this.gridApi.getPivotResultColumns() || [];
335
335
  const pivotResultColumnsSet = new Set(pivotResultColumns.map((col) => col.getColId()));
336
- const rowGroupColumns = this.gridApi.getRowGroupColumns() || [];
337
- const rowGroupColumnsSet = new Set(rowGroupColumns.map((col) => col.getColId()));
338
336
  const prevLayout = this.currentLayout;
339
337
  const columnState = this.gridApi
340
338
  .getColumnState()
@@ -362,7 +360,7 @@ export class LayoutManager extends LMEmitter {
362
360
  // since having normal table columns here will break the equality check
363
361
  // so we only want to keep the group columns and the pivot result columns
364
362
  Object.keys(ColumnVisibility).forEach((colId) => {
365
- const isInLayout = pivotResultColumnsSet.has(colId) || rowGroupColumnsSet.has(colId);
363
+ const isInLayout = pivotResultColumnsSet.has(colId) || colId.startsWith(AUTO_GROUP_COLUMN_ID__SINGLE);
366
364
  if (!isInLayout) {
367
365
  delete ColumnVisibility[colId];
368
366
  }
@@ -2,6 +2,9 @@ import { isPivotLayoutModel } from './isPivotLayoutModel';
2
2
  export const AUTO_GROUP_COLUMN_ID__SINGLE = 'ag-Grid-AutoColumn';
3
3
  export const AUTO_GROUP_COLUMN_ID__MULTI_PREFIX = 'ag-Grid-AutoColumn-';
4
4
  export function normalizeTableLayoutModel(layout, options) {
5
+ if (!layout) {
6
+ return;
7
+ }
5
8
  layout = structuredClone(layout);
6
9
  if (!layout.ColumnVisibility) {
7
10
  layout.ColumnVisibility = {};