Skip to content

Commit cf4bd5a

Browse files
committed
move to proxy
1 parent 6769ff3 commit cf4bd5a

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

packages/iris-grid/src/IrisGrid.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,6 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
13821382
getModelTotalsConfig = memoize(
13831383
(
13841384
columns: readonly DhType.Column[],
1385-
originalColumns: readonly DhType.Column[],
13861385
config: UIRollupConfig | undefined,
13871386
aggregationSettings: AggregationSettings
13881387
): UITotalsTableConfig | null => {
@@ -1391,18 +1390,6 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
13911390
return null;
13921391
}
13931392

1394-
// TODO: evaluate whether this should be moved to proxy model, since it should manage the model transition
1395-
// When a rollup is being removed the model `columns` still reflects the tree table's columns
1396-
// while the rollup config has already been cleared. Building a totals config with those stale
1397-
// column names would cause a server error.
1398-
if (
1399-
config != null &&
1400-
config.columns.length === 0 &&
1401-
columns !== originalColumns
1402-
) {
1403-
return null;
1404-
}
1405-
14061393
// Filter out aggregations without any columns actually selected
14071394
const aggregations = aggregationSettings.aggregations.filter(
14081395
agg => agg.selected.length > 0 || agg.invert
@@ -5248,7 +5235,6 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
52485235
)}
52495236
totalsConfig={this.getModelTotalsConfig(
52505237
model.columns,
5251-
model.originalColumns,
52525238
rollupConfig,
52535239
aggregationSettings
52545240
)}

packages/iris-grid/src/IrisGridProxyModel.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import IrisGridTableModel from './IrisGridTableModel';
1111
import IrisGridPartitionedTableModel from './IrisGridPartitionedTableModel';
1212
import IrisGridTreeTableModel from './IrisGridTreeTableModel';
1313
import IrisGridModel from './IrisGridModel';
14-
import { type ColumnName } from './CommonTypes';
14+
import { type ColumnName, type UITotalsTableConfig } from './CommonTypes';
1515
import { isIrisGridTableModelTemplate } from './IrisGridTableModelTemplate';
1616
import {
1717
type PartitionConfig,
@@ -431,6 +431,15 @@ class IrisGridProxyModel extends IrisGridModel implements PartitionedGridModel {
431431
this.setNextModel(modelPromise);
432432
}
433433

434+
set totalsConfig(totalsConfig: UITotalsTableConfig | null) {
435+
if (this.modelPromise != null) {
436+
// Model switch in progress. Don't forward, as the config may reference stale columns.
437+
// COLUMNS_CHANGED will reapply the correct config after.
438+
return;
439+
}
440+
this.model.totalsConfig = totalsConfig;
441+
}
442+
434443
get isFilterRequired(): boolean {
435444
return this.originalModel.isFilterRequired;
436445
}

0 commit comments

Comments
 (0)