@adaptabletools/adaptable 24.0.3 → 24.0.5
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 +1 -1
- package/src/AdaptableInterfaces/IAdaptable.d.ts +7 -0
- package/src/Api/AdaptableApi.d.ts +12 -0
- package/src/Api/GridApi.d.ts +13 -3
- package/src/Api/Implementation/AdaptableApiImpl.d.ts +1 -0
- package/src/Api/Implementation/AdaptableApiImpl.js +3 -0
- package/src/Api/Implementation/FlashingCellApiImpl.js +3 -8
- package/src/Api/Implementation/GridApiImpl.js +1 -1
- package/src/Api/Internal/AlertInternalApi.d.ts +7 -0
- package/src/Api/Internal/AlertInternalApi.js +42 -9
- package/src/Strategy/FlashingCellModule.js +2 -1
- package/src/Utilities/Helpers/CellValueHelper.d.ts +20 -0
- package/src/Utilities/Helpers/CellValueHelper.js +35 -0
- package/src/Utilities/Helpers/Layouts/LayoutHelper.d.ts +5 -0
- package/src/Utilities/Helpers/Layouts/LayoutHelper.js +33 -3
- package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +25 -1
- package/src/Utilities/Services/CalculatedColumnExpressionService.js +160 -42
- package/src/Utilities/Services/DataService.js +10 -6
- package/src/Utilities/Services/FlashingCellService.d.ts +12 -0
- package/src/Utilities/Services/FlashingCellService.js +40 -3
- package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +5 -0
- package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +5 -0
- package/src/Utilities/Services/QueryLanguageService.d.ts +6 -0
- package/src/Utilities/Services/QueryLanguageService.js +29 -1
- package/src/agGrid/AdaptableAgGrid.d.ts +81 -14
- package/src/agGrid/AdaptableAgGrid.js +523 -163
- package/src/agGrid/AgGridAdapter.d.ts +10 -1
- package/src/agGrid/AgGridAdapter.js +16 -0
- package/src/agGrid/AgGridOptionsService.js +5 -0
- package/src/env.js +2 -2
- package/src/layout-manager/src/index.d.ts +51 -10
- package/src/layout-manager/src/index.js +334 -91
- package/src/layout-manager/src/isLayoutEqual.js +4 -0
- package/src/layout-manager/src/rowGroupExpansionMatcher.d.ts +116 -0
- package/src/layout-manager/src/rowGroupExpansionMatcher.js +240 -0
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/vendor/components/Resizable/index.d.ts.map +1 -1
- package/vendor/components/Resizable/index.js +22 -10
- package/vendor/components/Resizable/index.js.map +1 -1
|
@@ -27,6 +27,7 @@ import { ValidationService } from '../Utilities/Services/ValidationService';
|
|
|
27
27
|
import { ModuleService } from '../Utilities/Services/ModuleService';
|
|
28
28
|
import { CalculatedColumnExpressionService } from '../Utilities/Services/CalculatedColumnExpressionService';
|
|
29
29
|
import { expandCellDataChangedInfosWithCalculatedColumns } from '../Utilities/Services/CalculatedColumnExpressionService';
|
|
30
|
+
import { areCellValuesEqual, getDataBackedColumns, } from '../Utilities/Helpers/CellValueHelper';
|
|
30
31
|
import { QueryLanguageService } from '../Utilities/Services/QueryLanguageService';
|
|
31
32
|
import { LiveRefreshService } from '../Utilities/Services/LiveRefreshService';
|
|
32
33
|
import { AlertLiveBindingService } from '../Utilities/Services/AlertLiveBindingService';
|
|
@@ -99,11 +100,13 @@ import { weightedAverage } from '../AdaptableState/Aggregations/weightedAverage'
|
|
|
99
100
|
import { ROW_SUMMARY_ROW_ID } from '../AdaptableState/Common/RowSummary';
|
|
100
101
|
import { FlashingCellService } from '../Utilities/Services/FlashingCellService';
|
|
101
102
|
import { AgGridExportAdapter } from './AgGridExportAdapter';
|
|
102
|
-
import { checkForDuplicateColumns, resetLayoutHelperErrorOnceMessages,
|
|
103
|
+
import { checkForDuplicateColumns, resetLayoutHelperErrorOnceMessages, isPivotLayout, layoutModelToLayoutState, layoutStateToLayoutModel, normalizeLayout, shouldUpdateRowGroupsExpandedState, } from '../Utilities/Helpers/Layouts/LayoutHelper';
|
|
103
104
|
import { applyAutoCreatedLayout, buildLayoutFromColDefs, resolveAutoCreateLayoutConfig, } from '../Utilities/Helpers/Layouts/AutoCreateLayoutHelper';
|
|
104
105
|
import { LayoutManager } from '../layout-manager/src';
|
|
105
106
|
import { rowGroupDisplayTypeToGridOption } from '../layout-manager/src/rowGroupDisplayType';
|
|
106
107
|
import { expandAllRowGroups } from '../layout-manager/src/expandAllRowGroups';
|
|
108
|
+
import { compileLayoutRowGroupExpansionMatcher, getLayoutModelGroupedColumns, getRowGroupNodePath, isPersistableGroupNode, isRowGroupExpandedByMatcher, } from '../layout-manager/src/rowGroupExpansionMatcher';
|
|
109
|
+
import { normalizeLayoutModel } from '../layout-manager/src/normalizeLayoutModel';
|
|
107
110
|
import { isPivotLayoutModel } from '../layout-manager/src/isPivotLayoutModel';
|
|
108
111
|
import { ACTION_COLUMN_TYPE, CALCULATED_COLUMN_TYPE, FDC3_COLUMN_TYPE, FREE_TEXT_COLUMN_TYPE, HIDDEN_COLUMN_TYPE, hiddenColDefConfig, PIVOT_AGGREGATION_TOTAL_COLUMN_TYPE, PIVOT_ANY_TOTAL_COLUMN_TYPE, PIVOT_COLUMN_TOTAL_COLUMN_TYPE, PIVOT_GRAND_TOTAL_COLUMN_TYPE, } from '../AdaptableState/Common/AdaptableColumn';
|
|
109
112
|
import { mergeDataTypeDefinitions } from './AgGridCellDataTypeHelper';
|
|
@@ -130,6 +133,9 @@ import { AdaptableFilterHandler } from './AdaptableFilterHandler';
|
|
|
130
133
|
import { getColumnFilterInListValues } from '../aql/columnFilterQl';
|
|
131
134
|
import { AgGridFloatingFilterAdapterFactory } from './AgGridFloatingFilterAdapter';
|
|
132
135
|
import { listenForDevTools } from '../setupDevTools';
|
|
136
|
+
const getChangedCellKey = (primaryKeyValue, columnId) => `${primaryKeyValue}\u0000${columnId}`;
|
|
137
|
+
const getPinnedCopySource = (rowNode) => rowNode?.rowPinned != null ? rowNode.pinnedSibling : undefined;
|
|
138
|
+
const hasLocalEventService = (rowNode) => !!rowNode.__localEventService;
|
|
133
139
|
export class AdaptableAgGrid {
|
|
134
140
|
logger;
|
|
135
141
|
lifecycleState;
|
|
@@ -170,7 +176,22 @@ export class AdaptableAgGrid {
|
|
|
170
176
|
LicenseService;
|
|
171
177
|
ChartingService;
|
|
172
178
|
isListeningToAgGridRowNodeEvents = false;
|
|
173
|
-
|
|
179
|
+
trackedRowData = new Map();
|
|
180
|
+
pendingAsyncRowNodes = new Map();
|
|
181
|
+
pendingAsyncTransactions = 0;
|
|
182
|
+
syncTransactionDepth = 0;
|
|
183
|
+
refilterAfterAsyncFlush = false;
|
|
184
|
+
reportedCellChanges = new Map();
|
|
185
|
+
isReportedCellChangesClearScheduled = false;
|
|
186
|
+
updateCellCapture;
|
|
187
|
+
postEditBatch;
|
|
188
|
+
pendingPinnedCopyRefreshes = new Map();
|
|
189
|
+
dataBackedColumnsCache;
|
|
190
|
+
isRowIdPrimaryKey = false;
|
|
191
|
+
primaryKeyLookup;
|
|
192
|
+
hasLoggedPrimaryKeyLookupFallback = false;
|
|
193
|
+
hasWarnedSameObjectUpdate = false;
|
|
194
|
+
rowGroupExpansionMatcherRef = { current: null };
|
|
174
195
|
debouncedSetSelectedRows;
|
|
175
196
|
debouncedSetSelectedCells;
|
|
176
197
|
agGridListenerKeydown;
|
|
@@ -368,6 +389,11 @@ export class AdaptableAgGrid {
|
|
|
368
389
|
colTypes: gridOptions.columnTypes,
|
|
369
390
|
defaultColDef: gridOptions.defaultColDef,
|
|
370
391
|
});
|
|
392
|
+
if (gridOptions.rowModelType === 'serverSide' && layoutModel) {
|
|
393
|
+
this.rowGroupExpansionMatcherRef.current = compileLayoutRowGroupExpansionMatcher(normalizeLayoutModel(layoutModel, {
|
|
394
|
+
isTree: !!gridOptions.treeData,
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
371
397
|
columnDefs = LayoutManager.getColumnDefsChangesForLayout(layoutModel, columnDefs) ?? columnDefs;
|
|
372
398
|
gridOptions.columnDefs = columnDefs;
|
|
373
399
|
gridOptions.initialState = initialGridState;
|
|
@@ -404,11 +430,13 @@ export class AdaptableAgGrid {
|
|
|
404
430
|
debugId: this.adaptableOptions.adaptableId,
|
|
405
431
|
initialRowSelection,
|
|
406
432
|
getRowSelectionCheckboxesOverride: () => this.getRowSelectionCheckboxesOverride(),
|
|
433
|
+
rowGroupExpansionMatcherRef: this.rowGroupExpansionMatcherRef,
|
|
407
434
|
});
|
|
408
435
|
this.silentUpdateCurrentLayoutModel(layoutModel);
|
|
409
436
|
if (isPivotLayoutModel(layoutModel)) {
|
|
410
437
|
this.layoutManager.setLayout(layoutModel, {
|
|
411
438
|
force: true,
|
|
439
|
+
skipApplyRowGroupsExpandedState: this.getAgGridRowModelType() === 'serverSide',
|
|
412
440
|
});
|
|
413
441
|
}
|
|
414
442
|
this.layoutManager.onChange((layoutModel) => {
|
|
@@ -455,7 +483,9 @@ export class AdaptableAgGrid {
|
|
|
455
483
|
this._prevLayout = currentLayout;
|
|
456
484
|
this.__prevLayoutForRefresh = currentLayout;
|
|
457
485
|
const layoutModelForApply = layoutStateToLayoutModel(currentLayout);
|
|
458
|
-
this.
|
|
486
|
+
if (this.getAgGridRowModelType() !== 'serverSide') {
|
|
487
|
+
this.layoutManager.applyRowGroupValues(layoutModelForApply.RowGroupValues, getLayoutModelGroupedColumns(layoutModelForApply));
|
|
488
|
+
}
|
|
459
489
|
this.layoutManager.applyColumnGroupCollapseExpandState(layoutModelForApply);
|
|
460
490
|
this.autoSizeLayoutIfNeeded();
|
|
461
491
|
this.ModuleService.createModuleUIItems();
|
|
@@ -893,6 +923,7 @@ export class AdaptableAgGrid {
|
|
|
893
923
|
if (StringExtensions.IsNullOrEmpty(primaryKey)) {
|
|
894
924
|
return original_getRowId;
|
|
895
925
|
}
|
|
926
|
+
this.isRowIdPrimaryKey = true;
|
|
896
927
|
if (this.hasAutogeneratedPrimaryKey) {
|
|
897
928
|
return (params) => {
|
|
898
929
|
if (Helper.objectNotExists(params.data[primaryKey])) {
|
|
@@ -957,6 +988,24 @@ export class AdaptableAgGrid {
|
|
|
957
988
|
}
|
|
958
989
|
return true;
|
|
959
990
|
});
|
|
991
|
+
if (gridOptions.rowModelType === 'serverSide') {
|
|
992
|
+
this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'isServerSideGroupOpenByDefault', (original_isServerSideGroupOpenByDefault) => {
|
|
993
|
+
return (params) => {
|
|
994
|
+
if (!params.rowNode.group) {
|
|
995
|
+
return original_isServerSideGroupOpenByDefault
|
|
996
|
+
? original_isServerSideGroupOpenByDefault(params)
|
|
997
|
+
: false;
|
|
998
|
+
}
|
|
999
|
+
const matcher = this.rowGroupExpansionMatcherRef.current;
|
|
1000
|
+
if (!matcher) {
|
|
1001
|
+
return original_isServerSideGroupOpenByDefault
|
|
1002
|
+
? original_isServerSideGroupOpenByDefault(params)
|
|
1003
|
+
: false;
|
|
1004
|
+
}
|
|
1005
|
+
return isRowGroupExpandedByMatcher(matcher, params.rowNode);
|
|
1006
|
+
};
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
960
1009
|
this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'aggFuncs', (original_aggFuncs) => {
|
|
961
1010
|
const aggregationFunctions = original_aggFuncs || {};
|
|
962
1011
|
aggregationFunctions[ONLY_AGG_FN_NAME] = (params) => {
|
|
@@ -1626,49 +1675,105 @@ export class AdaptableAgGrid {
|
|
|
1626
1675
|
}
|
|
1627
1676
|
if (event.type === 'dataChanged') {
|
|
1628
1677
|
const { node, oldData, newData } = event;
|
|
1629
|
-
|
|
1630
|
-
|
|
1678
|
+
const sourceNode = getPinnedCopySource(node);
|
|
1679
|
+
if (sourceNode && hasLocalEventService(sourceNode)) {
|
|
1680
|
+
this.applyPendingPinnedCopyRefresh(node);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
const rowNode = sourceNode ?? node;
|
|
1684
|
+
const isPendingAsyncRow = this.pendingAsyncRowNodes.has(rowNode);
|
|
1685
|
+
if (this.trackedRowData.has(rowNode)) {
|
|
1686
|
+
this.trackedRowData.set(rowNode, newData);
|
|
1687
|
+
}
|
|
1688
|
+
this.onRowDataChanged({
|
|
1689
|
+
rowNode,
|
|
1690
|
+
oldData,
|
|
1691
|
+
newData,
|
|
1692
|
+
deferRefilter: isPendingAsyncRow && !this.postEditBatch,
|
|
1693
|
+
});
|
|
1631
1694
|
return;
|
|
1632
1695
|
}
|
|
1633
1696
|
if (event.type === 'cellChanged') {
|
|
1634
1697
|
const { node, column, oldValue, newValue } = event;
|
|
1635
|
-
if (column) {
|
|
1636
|
-
|
|
1698
|
+
if (!column) {
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
const sourceNode = getPinnedCopySource(node);
|
|
1702
|
+
if (sourceNode && hasLocalEventService(sourceNode)) {
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
const rowNode = sourceNode ?? node;
|
|
1706
|
+
const colId = column.getColId();
|
|
1707
|
+
this.noteCellChangeReported(rowNode, colId);
|
|
1708
|
+
const reportedByRowNode = this.updateCellCapture?.reportedByRowNode;
|
|
1709
|
+
if (reportedByRowNode) {
|
|
1710
|
+
let colIds = reportedByRowNode.get(rowNode);
|
|
1711
|
+
if (!colIds) {
|
|
1712
|
+
colIds = new Set();
|
|
1713
|
+
reportedByRowNode.set(rowNode, colIds);
|
|
1714
|
+
}
|
|
1715
|
+
colIds.add(colId);
|
|
1637
1716
|
}
|
|
1717
|
+
this.onCellDataChanged({ rowNode, oldValue, newValue, colId });
|
|
1638
1718
|
}
|
|
1639
1719
|
}
|
|
1640
1720
|
onAgGridCellValueChanged(event) {
|
|
1641
1721
|
if (!this.isListeningToAgGridRowNodeEvents) {
|
|
1642
1722
|
return;
|
|
1643
1723
|
}
|
|
1644
|
-
if (this.offScreenRowUpdateTrackers.length > 0) {
|
|
1645
|
-
return;
|
|
1646
|
-
}
|
|
1647
1724
|
const node = event.node;
|
|
1648
1725
|
const column = event.column;
|
|
1649
1726
|
if (!node || !column) {
|
|
1650
1727
|
return;
|
|
1651
1728
|
}
|
|
1652
|
-
if (node
|
|
1729
|
+
if (getPinnedCopySource(node)) {
|
|
1653
1730
|
return;
|
|
1654
1731
|
}
|
|
1655
|
-
|
|
1732
|
+
const colId = column.getColId();
|
|
1733
|
+
if (this.takeCellChangeReported(node, colId)) {
|
|
1656
1734
|
return;
|
|
1657
1735
|
}
|
|
1658
1736
|
this.onCellDataChanged({
|
|
1659
1737
|
rowNode: node,
|
|
1660
1738
|
oldValue: event.oldValue,
|
|
1661
1739
|
newValue: event.newValue,
|
|
1662
|
-
colId
|
|
1740
|
+
colId,
|
|
1663
1741
|
});
|
|
1664
1742
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1743
|
+
onAgGridCellValueChangedDispatch(event) {
|
|
1744
|
+
this.updateCellCapture?.events.push(event);
|
|
1745
|
+
}
|
|
1746
|
+
noteCellChangeReported(rowNode, colId) {
|
|
1747
|
+
if (!this.isReportedCellChangesClearScheduled) {
|
|
1748
|
+
this.isReportedCellChangesClearScheduled = true;
|
|
1749
|
+
queueMicrotask(() => setTimeout(() => {
|
|
1750
|
+
this.isReportedCellChangesClearScheduled = false;
|
|
1751
|
+
this.reportedCellChanges.clear();
|
|
1752
|
+
}, 0));
|
|
1668
1753
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1754
|
+
let countByColId = this.reportedCellChanges.get(rowNode);
|
|
1755
|
+
if (!countByColId) {
|
|
1756
|
+
countByColId = new Map();
|
|
1757
|
+
this.reportedCellChanges.set(rowNode, countByColId);
|
|
1671
1758
|
}
|
|
1759
|
+
countByColId.set(colId, (countByColId.get(colId) ?? 0) + 1);
|
|
1760
|
+
}
|
|
1761
|
+
takeCellChangeReported(rowNode, colId) {
|
|
1762
|
+
const countByColId = this.reportedCellChanges.get(rowNode);
|
|
1763
|
+
const count = countByColId?.get(colId);
|
|
1764
|
+
if (!count) {
|
|
1765
|
+
return false;
|
|
1766
|
+
}
|
|
1767
|
+
if (count > 1) {
|
|
1768
|
+
countByColId.set(colId, count - 1);
|
|
1769
|
+
}
|
|
1770
|
+
else {
|
|
1771
|
+
countByColId.delete(colId);
|
|
1772
|
+
if (countByColId.size === 0) {
|
|
1773
|
+
this.reportedCellChanges.delete(rowNode);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
return true;
|
|
1672
1777
|
}
|
|
1673
1778
|
shouldAutoSizeLayout() {
|
|
1674
1779
|
const { layoutApi } = this.api;
|
|
@@ -1805,7 +1910,8 @@ export class AdaptableAgGrid {
|
|
|
1805
1910
|
}
|
|
1806
1911
|
}
|
|
1807
1912
|
isInPivotMode() {
|
|
1808
|
-
return (this.agGridModulesAdapter.isAgGridModuleRegistered('PivotModule')
|
|
1913
|
+
return ((this.agGridModulesAdapter.isAgGridModuleRegistered('PivotModule') ||
|
|
1914
|
+
this.agGridModulesAdapter.isAgGridModuleRegistered('ServerSideRowModelModule')) &&
|
|
1809
1915
|
this.agGridAdapter.getAgGridApi().isPivotMode());
|
|
1810
1916
|
}
|
|
1811
1917
|
deriveAdaptableColumnStateFromAgGrid() {
|
|
@@ -2268,7 +2374,9 @@ export class AdaptableAgGrid {
|
|
|
2268
2374
|
layout = this.api.layoutApi.getCurrentLayout();
|
|
2269
2375
|
}
|
|
2270
2376
|
const layoutModel = layoutStateToLayoutModel(layout);
|
|
2271
|
-
this.
|
|
2377
|
+
if (this.getAgGridRowModelType() !== 'serverSide') {
|
|
2378
|
+
this.layoutManager.applyRowGroupValues(layoutModel.RowGroupValues, getLayoutModelGroupedColumns(layoutModel));
|
|
2379
|
+
}
|
|
2272
2380
|
this.layoutManager.applyColumnGroupCollapseExpandState(layoutModel);
|
|
2273
2381
|
}
|
|
2274
2382
|
isGroupRowNode(rowNode) {
|
|
@@ -2308,83 +2416,123 @@ export class AdaptableAgGrid {
|
|
|
2308
2416
|
const agGridApi = this.agGridAdapter.getAgGridApi();
|
|
2309
2417
|
this.countTransactionForPerf(transaction);
|
|
2310
2418
|
if (isServerSideRowModel) {
|
|
2311
|
-
return
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
this.emitOffScreenRowUpdates(tracking, result?.update);
|
|
2317
|
-
return result;
|
|
2318
|
-
}
|
|
2319
|
-
finally {
|
|
2320
|
-
this.endOffScreenRowUpdateTracking(tracking);
|
|
2419
|
+
return this.runPostEditBatch(() => {
|
|
2420
|
+
const result = agGridApi.applyServerSideTransaction(transaction);
|
|
2421
|
+
this.addToPrimaryKeyLookup(result?.add);
|
|
2422
|
+
return result;
|
|
2423
|
+
});
|
|
2321
2424
|
}
|
|
2425
|
+
return this.runPostEditBatch(() => {
|
|
2426
|
+
this.trackRowUpdates(transaction.update);
|
|
2427
|
+
this.syncTransactionDepth++;
|
|
2428
|
+
try {
|
|
2429
|
+
const result = agGridApi.applyTransaction(transaction);
|
|
2430
|
+
this.postEditBatch.renderedRowIds = undefined;
|
|
2431
|
+
this.addToPrimaryKeyLookup(result?.add);
|
|
2432
|
+
this.reportTrackedRowUpdates(result?.update);
|
|
2433
|
+
return result;
|
|
2434
|
+
}
|
|
2435
|
+
finally {
|
|
2436
|
+
this.syncTransactionDepth--;
|
|
2437
|
+
this.releaseTrackedRows();
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2322
2440
|
}
|
|
2323
2441
|
applyAgGridTransactionAsync(transaction, callback) {
|
|
2324
2442
|
const isServerSideRowModel = this.getAgGridRowModelType() === 'serverSide';
|
|
2325
2443
|
const agGridApi = this.agGridAdapter.getAgGridApi();
|
|
2326
2444
|
this.countTransactionForPerf(transaction);
|
|
2327
2445
|
if (isServerSideRowModel) {
|
|
2328
|
-
return agGridApi.applyServerSideTransactionAsync(transaction,
|
|
2446
|
+
return agGridApi.applyServerSideTransactionAsync(transaction, (result) => {
|
|
2447
|
+
this.addToPrimaryKeyLookup(result?.add);
|
|
2448
|
+
callback(result);
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
const trackedNodes = this.trackRowUpdates(transaction.update);
|
|
2452
|
+
this.pendingAsyncTransactions++;
|
|
2453
|
+
for (const node of trackedNodes) {
|
|
2454
|
+
this.pendingAsyncRowNodes.set(node, (this.pendingAsyncRowNodes.get(node) ?? 0) + 1);
|
|
2329
2455
|
}
|
|
2330
|
-
const tracking = this.beginOffScreenRowUpdateTracking(transaction.update);
|
|
2331
2456
|
const wrappedCallback = (result) => {
|
|
2332
2457
|
try {
|
|
2333
|
-
this.
|
|
2458
|
+
this.runPostEditBatch(() => {
|
|
2459
|
+
if (this.refilterAfterAsyncFlush) {
|
|
2460
|
+
this.refilterAfterAsyncFlush = false;
|
|
2461
|
+
this.postEditBatch.needsRefilter = true;
|
|
2462
|
+
}
|
|
2463
|
+
this.addToPrimaryKeyLookup(result?.add);
|
|
2464
|
+
this.reportTrackedRowUpdates(result?.update);
|
|
2465
|
+
});
|
|
2334
2466
|
}
|
|
2335
2467
|
finally {
|
|
2336
|
-
this.
|
|
2468
|
+
this.pendingAsyncTransactions--;
|
|
2469
|
+
for (const node of trackedNodes) {
|
|
2470
|
+
const count = this.pendingAsyncRowNodes.get(node) ?? 0;
|
|
2471
|
+
if (count > 1) {
|
|
2472
|
+
this.pendingAsyncRowNodes.set(node, count - 1);
|
|
2473
|
+
}
|
|
2474
|
+
else {
|
|
2475
|
+
this.pendingAsyncRowNodes.delete(node);
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
this.releaseTrackedRows();
|
|
2337
2479
|
}
|
|
2338
2480
|
callback(result);
|
|
2339
2481
|
};
|
|
2340
2482
|
return agGridApi.applyTransactionAsync(transaction, wrappedCallback);
|
|
2341
2483
|
}
|
|
2342
|
-
|
|
2484
|
+
trackRowUpdates(updateRows) {
|
|
2343
2485
|
if (!updateRows?.length || !this.isListeningToAgGridRowNodeEvents) {
|
|
2344
|
-
return
|
|
2486
|
+
return [];
|
|
2345
2487
|
}
|
|
2346
2488
|
const primaryKey = this.adaptableOptions.primaryKey;
|
|
2347
|
-
const
|
|
2489
|
+
const trackedNodes = [];
|
|
2348
2490
|
for (const row of updateRows) {
|
|
2349
|
-
|
|
2491
|
+
const primaryKeyValue = row?.[primaryKey];
|
|
2492
|
+
if (primaryKeyValue == null) {
|
|
2350
2493
|
continue;
|
|
2351
2494
|
}
|
|
2352
|
-
const node = this.getRowNodeForPrimaryKey(
|
|
2353
|
-
if (node?.data) {
|
|
2354
|
-
|
|
2495
|
+
const node = this.getRowNodeForPrimaryKey(primaryKeyValue);
|
|
2496
|
+
if (!node?.data) {
|
|
2497
|
+
continue;
|
|
2355
2498
|
}
|
|
2499
|
+
if (node.data === row) {
|
|
2500
|
+
this.warnSameObjectUpdate();
|
|
2501
|
+
continue;
|
|
2502
|
+
}
|
|
2503
|
+
if (!this.trackedRowData.has(node)) {
|
|
2504
|
+
this.trackedRowData.set(node, node.data);
|
|
2505
|
+
}
|
|
2506
|
+
trackedNodes.push(node);
|
|
2356
2507
|
}
|
|
2357
|
-
|
|
2358
|
-
seenIds: new Set(),
|
|
2359
|
-
oldDataByPk,
|
|
2360
|
-
};
|
|
2361
|
-
this.offScreenRowUpdateTrackers.push(tracking);
|
|
2362
|
-
return tracking;
|
|
2363
|
-
}
|
|
2364
|
-
endOffScreenRowUpdateTracking(tracking) {
|
|
2365
|
-
if (!tracking) {
|
|
2366
|
-
return;
|
|
2367
|
-
}
|
|
2368
|
-
const index = this.offScreenRowUpdateTrackers.lastIndexOf(tracking);
|
|
2369
|
-
if (index >= 0) {
|
|
2370
|
-
this.offScreenRowUpdateTrackers.splice(index, 1);
|
|
2371
|
-
}
|
|
2508
|
+
return trackedNodes;
|
|
2372
2509
|
}
|
|
2373
|
-
|
|
2374
|
-
if (!
|
|
2510
|
+
reportTrackedRowUpdates(updatedNodes) {
|
|
2511
|
+
if (!updatedNodes?.length || this.trackedRowData.size === 0) {
|
|
2375
2512
|
return;
|
|
2376
2513
|
}
|
|
2377
2514
|
for (const node of updatedNodes) {
|
|
2378
|
-
|
|
2515
|
+
const reportedData = this.trackedRowData.get(node);
|
|
2516
|
+
if (reportedData === undefined || reportedData === node.data) {
|
|
2379
2517
|
continue;
|
|
2380
2518
|
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2519
|
+
this.trackedRowData.set(node, node.data);
|
|
2520
|
+
this.onRowDataChanged({ rowNode: node, oldData: reportedData, newData: node.data });
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
releaseTrackedRows() {
|
|
2524
|
+
if (this.syncTransactionDepth === 0 && this.pendingAsyncTransactions === 0) {
|
|
2525
|
+
this.trackedRowData.clear();
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
warnSameObjectUpdate() {
|
|
2529
|
+
if (this.hasWarnedSameObjectUpdate) {
|
|
2530
|
+
return;
|
|
2387
2531
|
}
|
|
2532
|
+
this.hasWarnedSameObjectUpdate = true;
|
|
2533
|
+
this.logger.consoleWarn('A row passed to updateGridData, addOrUpdateGridData or manageGridData is the same object as the row in the grid. ' +
|
|
2534
|
+
'Changes made to that object in place cannot be detected, so no Cell Changed Event, Flashing Cell or Alert is raised for them. ' +
|
|
2535
|
+
'Pass a new object for each updated row instead.');
|
|
2388
2536
|
}
|
|
2389
2537
|
updateRows(dataRows, dataUpdateConfig) {
|
|
2390
2538
|
if (this.hasAutogeneratedPrimaryKey) {
|
|
@@ -2589,15 +2737,71 @@ export class AdaptableAgGrid {
|
|
|
2589
2737
|
}
|
|
2590
2738
|
}
|
|
2591
2739
|
getRowNodeForPrimaryKey(primaryKeyValue) {
|
|
2592
|
-
if (
|
|
2593
|
-
return
|
|
2740
|
+
if (primaryKeyValue == null) {
|
|
2741
|
+
return undefined;
|
|
2594
2742
|
}
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2743
|
+
const rowNode = this.agGridAdapter
|
|
2744
|
+
.getAgGridApi()
|
|
2745
|
+
.getRowNode(typeof primaryKeyValue === 'number' ? `${primaryKeyValue}` : primaryKeyValue);
|
|
2746
|
+
if (rowNode && this.readPrimaryKeyValue(rowNode) == primaryKeyValue) {
|
|
2747
|
+
return rowNode;
|
|
2748
|
+
}
|
|
2749
|
+
if (this.isRowIdPrimaryKey &&
|
|
2750
|
+
this.getAgGridRowModelType() === 'clientSide' &&
|
|
2751
|
+
!this.agGridAdapter.getGridOption('treeData')) {
|
|
2752
|
+
return undefined;
|
|
2753
|
+
}
|
|
2754
|
+
return this.getRowNodeFromPrimaryKeyLookup(primaryKeyValue);
|
|
2755
|
+
}
|
|
2756
|
+
readPrimaryKeyValue(rowNode) {
|
|
2757
|
+
const value = rowNode.data?.[this.adaptableOptions.primaryKey];
|
|
2758
|
+
return value !== undefined ? value : this.getPrimaryKeyValueFromRowNode(rowNode);
|
|
2759
|
+
}
|
|
2760
|
+
getRowNodeFromPrimaryKeyLookup(primaryKeyValue) {
|
|
2761
|
+
const agGridApi = this.agGridAdapter.getAgGridApi();
|
|
2762
|
+
const key = String(primaryKeyValue);
|
|
2763
|
+
const lookup = this.primaryKeyLookup;
|
|
2764
|
+
const cached = lookup?.rowNodeByPrimaryKey.get(key);
|
|
2765
|
+
if (cached &&
|
|
2766
|
+
agGridApi.getRowNode(cached.id) === cached &&
|
|
2767
|
+
this.readPrimaryKeyValue(cached) == primaryKeyValue) {
|
|
2768
|
+
return cached;
|
|
2769
|
+
}
|
|
2770
|
+
if (lookup?.builtInTurn) {
|
|
2771
|
+
return undefined;
|
|
2772
|
+
}
|
|
2773
|
+
const rowNodeByPrimaryKey = new Map();
|
|
2774
|
+
agGridApi.forEachNode((rowNode) => {
|
|
2775
|
+
if (rowNode.data && !rowNode.group) {
|
|
2776
|
+
const value = this.readPrimaryKeyValue(rowNode);
|
|
2777
|
+
if (value != null) {
|
|
2778
|
+
rowNodeByPrimaryKey.set(String(value), rowNode);
|
|
2599
2779
|
}
|
|
2600
|
-
}
|
|
2780
|
+
}
|
|
2781
|
+
});
|
|
2782
|
+
const builtLookup = { rowNodeByPrimaryKey, builtInTurn: true };
|
|
2783
|
+
this.primaryKeyLookup = builtLookup;
|
|
2784
|
+
queueMicrotask(() => {
|
|
2785
|
+
builtLookup.builtInTurn = false;
|
|
2786
|
+
});
|
|
2787
|
+
const found = rowNodeByPrimaryKey.get(key);
|
|
2788
|
+
if (found && !this.hasLoggedPrimaryKeyLookupFallback) {
|
|
2789
|
+
this.hasLoggedPrimaryKeyLookupFallback = true;
|
|
2790
|
+
this.logger.consoleWarn(`The row id given by getRowId is not the primary key value ('${this.adaptableOptions.primaryKey}'), so rows are looked up by primary key through a slower search. ` +
|
|
2791
|
+
'Return the primary key value from getRowId to avoid it.');
|
|
2792
|
+
}
|
|
2793
|
+
return found;
|
|
2794
|
+
}
|
|
2795
|
+
addToPrimaryKeyLookup(addedRowNodes) {
|
|
2796
|
+
const lookup = this.primaryKeyLookup;
|
|
2797
|
+
if (!lookup || !addedRowNodes?.length) {
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
for (const rowNode of addedRowNodes) {
|
|
2801
|
+
const value = this.readPrimaryKeyValue(rowNode);
|
|
2802
|
+
if (value != null) {
|
|
2803
|
+
lookup.rowNodeByPrimaryKey.set(String(value), rowNode);
|
|
2804
|
+
}
|
|
2601
2805
|
}
|
|
2602
2806
|
}
|
|
2603
2807
|
hideColumn(columnId) {
|
|
@@ -3174,26 +3378,13 @@ export class AdaptableAgGrid {
|
|
|
3174
3378
|
return returnValues;
|
|
3175
3379
|
}
|
|
3176
3380
|
getRowNodesForPrimaryKeys(primaryKeyValues) {
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
});
|
|
3185
|
-
}
|
|
3186
|
-
else {
|
|
3187
|
-
primaryKeyValues.forEach((pkValue) => {
|
|
3188
|
-
let foundRow = false;
|
|
3189
|
-
this.agGridAdapter.getAgGridApi().forEachNode((rowNode) => {
|
|
3190
|
-
if (!foundRow && pkValue == this.getPrimaryKeyValueFromRowNode(rowNode)) {
|
|
3191
|
-
rowNodes.push(rowNode);
|
|
3192
|
-
foundRow = true;
|
|
3193
|
-
}
|
|
3194
|
-
});
|
|
3195
|
-
});
|
|
3196
|
-
}
|
|
3381
|
+
const rowNodes = [];
|
|
3382
|
+
primaryKeyValues.forEach((pkValue) => {
|
|
3383
|
+
const rowNode = this.getRowNodeForPrimaryKey(pkValue);
|
|
3384
|
+
if (rowNode) {
|
|
3385
|
+
rowNodes.push(rowNode);
|
|
3386
|
+
}
|
|
3387
|
+
});
|
|
3197
3388
|
return rowNodes;
|
|
3198
3389
|
}
|
|
3199
3390
|
getRowNodeByIndex(index) {
|
|
@@ -3208,7 +3399,38 @@ export class AdaptableAgGrid {
|
|
|
3208
3399
|
this.logger.warn(`updateCell() - rowNode not found for primaryKeyValue: ${cellUpdateRequest.primaryKeyValue}`);
|
|
3209
3400
|
return;
|
|
3210
3401
|
}
|
|
3211
|
-
|
|
3402
|
+
const outerCapture = this.updateCellCapture;
|
|
3403
|
+
const capture = {
|
|
3404
|
+
events: [],
|
|
3405
|
+
reportedByRowNode: new Map(),
|
|
3406
|
+
};
|
|
3407
|
+
this.updateCellCapture = capture;
|
|
3408
|
+
try {
|
|
3409
|
+
rowNode.setDataValue(cellUpdateRequest.columnId, cellUpdateRequest.newValue, 'edit');
|
|
3410
|
+
}
|
|
3411
|
+
finally {
|
|
3412
|
+
this.updateCellCapture = outerCapture;
|
|
3413
|
+
}
|
|
3414
|
+
if (!this.isListeningToAgGridRowNodeEvents) {
|
|
3415
|
+
return;
|
|
3416
|
+
}
|
|
3417
|
+
for (const event of capture.events) {
|
|
3418
|
+
const { node, column } = event;
|
|
3419
|
+
if (!node || !column || getPinnedCopySource(node)) {
|
|
3420
|
+
continue;
|
|
3421
|
+
}
|
|
3422
|
+
const colId = column.getColId();
|
|
3423
|
+
if (capture.reportedByRowNode.get(node)?.has(colId)) {
|
|
3424
|
+
continue;
|
|
3425
|
+
}
|
|
3426
|
+
this.noteCellChangeReported(node, colId);
|
|
3427
|
+
this.onCellDataChanged({
|
|
3428
|
+
rowNode: node,
|
|
3429
|
+
oldValue: event.oldValue,
|
|
3430
|
+
newValue: event.newValue,
|
|
3431
|
+
colId,
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3212
3434
|
}
|
|
3213
3435
|
forAllRowNodesDo(func, config) {
|
|
3214
3436
|
this.agGridAdapter.getAgGridApi().forEachNode((rowNode, rowIndex) => {
|
|
@@ -3564,24 +3786,24 @@ export class AdaptableAgGrid {
|
|
|
3564
3786
|
acc[key] = true;
|
|
3565
3787
|
return acc;
|
|
3566
3788
|
}, {});
|
|
3567
|
-
this.agGridAdapter.getAgGridApi()
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
}
|
|
3575
|
-
const nodeKey = nodePath
|
|
3576
|
-
.filter((x) => !!x)
|
|
3577
|
-
.reverse()
|
|
3578
|
-
.join(GROUP_PATH_SEPARATOR);
|
|
3789
|
+
const agGridApi = this.agGridAdapter.getAgGridApi();
|
|
3790
|
+
const inPivotMode = this.isInPivotMode();
|
|
3791
|
+
const allowUnbalanced = !!agGridApi.getGridOption('groupAllowUnbalanced');
|
|
3792
|
+
const nodesToExpand = [];
|
|
3793
|
+
agGridApi.forEachNode((node) => {
|
|
3794
|
+
if (isPersistableGroupNode(node, { inPivotMode, allowUnbalanced }) && !node.expanded) {
|
|
3795
|
+
const nodeKey = getRowGroupNodePath(node).join(GROUP_PATH_SEPARATOR);
|
|
3579
3796
|
if (expandedKeys[nodeKey]) {
|
|
3580
|
-
|
|
3797
|
+
nodesToExpand.push(node);
|
|
3581
3798
|
}
|
|
3582
3799
|
}
|
|
3583
3800
|
});
|
|
3584
|
-
|
|
3801
|
+
for (let i = 0; i < nodesToExpand.length; i++) {
|
|
3802
|
+
nodesToExpand[i].setExpanded(true);
|
|
3803
|
+
}
|
|
3804
|
+
if (this.getAgGridRowModelType() === 'clientSide') {
|
|
3805
|
+
agGridApi.onGroupExpandedOrCollapsed();
|
|
3806
|
+
}
|
|
3585
3807
|
}
|
|
3586
3808
|
}
|
|
3587
3809
|
getAgGridColumnForColumnId(columnId) {
|
|
@@ -3646,6 +3868,7 @@ export class AdaptableAgGrid {
|
|
|
3646
3868
|
this.layoutManager?.destroy();
|
|
3647
3869
|
this.layoutManager = null;
|
|
3648
3870
|
this.rowSelectionCheckboxesOverride = null;
|
|
3871
|
+
this.rowGroupExpansionMatcherRef.current = null;
|
|
3649
3872
|
const agGridApi = this.agGridAdapter?.getAgGridApi();
|
|
3650
3873
|
if (agGridApi && !agGridApi.isDestroyed()) {
|
|
3651
3874
|
agGridApi.removeEventListener('firstDataRendered', this.listenerFirstDataRendered);
|
|
@@ -3692,7 +3915,9 @@ export class AdaptableAgGrid {
|
|
|
3692
3915
|
'getRowStyle',
|
|
3693
3916
|
'gridId',
|
|
3694
3917
|
'isExternalFilterPresent',
|
|
3918
|
+
'isServerSideGroupOpenByDefault',
|
|
3695
3919
|
'sideBar',
|
|
3920
|
+
'ssrmExpandAllAffectsAllRows',
|
|
3696
3921
|
'statusBar',
|
|
3697
3922
|
'suppressAggFuncInHeader',
|
|
3698
3923
|
'defaultColDef',
|
|
@@ -3732,6 +3957,13 @@ export class AdaptableAgGrid {
|
|
|
3732
3957
|
this.agGridModulesAdapter?.destroy();
|
|
3733
3958
|
this.agGridModulesAdapter = null;
|
|
3734
3959
|
this.isListeningToAgGridRowNodeEvents = false;
|
|
3960
|
+
this.trackedRowData.clear();
|
|
3961
|
+
this.pendingAsyncRowNodes.clear();
|
|
3962
|
+
this.reportedCellChanges.clear();
|
|
3963
|
+
this.updateCellCapture = undefined;
|
|
3964
|
+
this.pendingPinnedCopyRefreshes.clear();
|
|
3965
|
+
this.primaryKeyLookup = undefined;
|
|
3966
|
+
this.dataBackedColumnsCache = undefined;
|
|
3735
3967
|
this.emitter.destroy();
|
|
3736
3968
|
this.emitter = null;
|
|
3737
3969
|
this.adaptableOptions = null;
|
|
@@ -3817,26 +4049,7 @@ export class AdaptableAgGrid {
|
|
|
3817
4049
|
}
|
|
3818
4050
|
updateLayoutInManagerAfterStoreHasChanged(layout = this.api.layoutApi.getCurrentLayout()) {
|
|
3819
4051
|
checkForDuplicateColumns(layout);
|
|
3820
|
-
const
|
|
3821
|
-
let shouldUpdateExpandState = isLayoutSwitch;
|
|
3822
|
-
if (!isLayoutSwitch && this._prevLayout) {
|
|
3823
|
-
if (layout.RowGroupValues?.RowGroupDefaultBehavior &&
|
|
3824
|
-
this._prevLayout?.RowGroupValues?.RowGroupDefaultBehavior !=
|
|
3825
|
-
layout.RowGroupValues?.RowGroupDefaultBehavior) {
|
|
3826
|
-
shouldUpdateExpandState = true;
|
|
3827
|
-
}
|
|
3828
|
-
else {
|
|
3829
|
-
const prevLayoutExceptionGroupKeys = getLayoutRowGroupValuesExceptionGroupKeys(this._prevLayout)
|
|
3830
|
-
.flat()
|
|
3831
|
-
.join(',');
|
|
3832
|
-
const currentLayoutExceptionGroupKeys = getLayoutRowGroupValuesExceptionGroupKeys(layout)
|
|
3833
|
-
.flat()
|
|
3834
|
-
.join(',');
|
|
3835
|
-
if (prevLayoutExceptionGroupKeys !== currentLayoutExceptionGroupKeys) {
|
|
3836
|
-
shouldUpdateExpandState = true;
|
|
3837
|
-
}
|
|
3838
|
-
}
|
|
3839
|
-
}
|
|
4052
|
+
const shouldUpdateExpandState = shouldUpdateRowGroupsExpandedState(this._prevLayout, layout);
|
|
3840
4053
|
const prevLayout = this._prevLayout;
|
|
3841
4054
|
this._prevLayout = layout;
|
|
3842
4055
|
const perfSetLayout = this.logger.beginPerf(`setLayout(${layout.Name})`);
|
|
@@ -3923,7 +4136,17 @@ export class AdaptableAgGrid {
|
|
|
3923
4136
|
}
|
|
3924
4137
|
return null;
|
|
3925
4138
|
}
|
|
3926
|
-
|
|
4139
|
+
getDataBackedColumns() {
|
|
4140
|
+
const columns = this.api.columnApi.getColumns();
|
|
4141
|
+
if (this.dataBackedColumnsCache?.columns !== columns) {
|
|
4142
|
+
this.dataBackedColumnsCache = {
|
|
4143
|
+
columns,
|
|
4144
|
+
dataBackedColumns: getDataBackedColumns(columns, !!this.agGridAdapter.getGridOption('suppressFieldDotNotation')),
|
|
4145
|
+
};
|
|
4146
|
+
}
|
|
4147
|
+
return this.dataBackedColumnsCache.dataBackedColumns;
|
|
4148
|
+
}
|
|
4149
|
+
onRowDataChanged({ rowNode, oldData, newData, deferRefilter = false, }) {
|
|
3927
4150
|
if (oldData == null || oldData == undefined) {
|
|
3928
4151
|
return;
|
|
3929
4152
|
}
|
|
@@ -3934,31 +4157,34 @@ export class AdaptableAgGrid {
|
|
|
3934
4157
|
if (primaryKeyValue == null) {
|
|
3935
4158
|
return;
|
|
3936
4159
|
}
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
oldValue: oldValue,
|
|
3945
|
-
newValue: newValue,
|
|
3946
|
-
column: this.api.columnApi.getColumnWithColumnId(key),
|
|
3947
|
-
primaryKeyValue: primaryKeyValue,
|
|
3948
|
-
rowNode: rowNode,
|
|
3949
|
-
trigger: 'tick',
|
|
3950
|
-
});
|
|
3951
|
-
if (this.isUndoChange(cellDataChangedInfo)) {
|
|
3952
|
-
cellDataChangedInfo.trigger = 'undo';
|
|
3953
|
-
}
|
|
3954
|
-
cellDataChangedInfos.push(cellDataChangedInfo);
|
|
3955
|
-
}
|
|
4160
|
+
const internalApi = this.api.internalApi;
|
|
4161
|
+
const cellDataChangedInfos = [];
|
|
4162
|
+
for (const { column, field, isNested } of this.getDataBackedColumns()) {
|
|
4163
|
+
const oldValue = isNested ? internalApi.getValueUsingField(oldData, field) : oldData[field];
|
|
4164
|
+
const newValue = isNested ? internalApi.getValueUsingField(newData, field) : newData?.[field];
|
|
4165
|
+
if (areCellValuesEqual(oldValue, newValue)) {
|
|
4166
|
+
continue;
|
|
3956
4167
|
}
|
|
3957
|
-
|
|
3958
|
-
|
|
4168
|
+
const cellDataChangedInfo = internalApi.buildCellDataChangedInfo({
|
|
4169
|
+
oldValue: oldValue,
|
|
4170
|
+
newValue: newValue,
|
|
4171
|
+
column,
|
|
4172
|
+
primaryKeyValue: primaryKeyValue,
|
|
4173
|
+
rowNode: rowNode,
|
|
4174
|
+
trigger: 'tick',
|
|
4175
|
+
});
|
|
4176
|
+
if (this.isUndoChange(cellDataChangedInfo)) {
|
|
4177
|
+
cellDataChangedInfo.trigger = 'undo';
|
|
4178
|
+
}
|
|
4179
|
+
cellDataChangedInfos.push(cellDataChangedInfo);
|
|
4180
|
+
}
|
|
4181
|
+
if (cellDataChangedInfos.length === 0) {
|
|
4182
|
+
return;
|
|
4183
|
+
}
|
|
4184
|
+
this.performPostEditChecks(rowNode, cellDataChangedInfos, { oldData, deferRefilter });
|
|
3959
4185
|
}
|
|
3960
4186
|
onCellDataChanged({ rowNode, oldValue, newValue, colId, }) {
|
|
3961
|
-
if (oldValue
|
|
4187
|
+
if (areCellValuesEqual(oldValue, newValue)) {
|
|
3962
4188
|
return;
|
|
3963
4189
|
}
|
|
3964
4190
|
const abColumn = this.api.columnApi.getColumnWithColumnId(colId);
|
|
@@ -3998,23 +4224,24 @@ export class AdaptableAgGrid {
|
|
|
3998
4224
|
const undoChange = this.api.internalApi.getDataService().extractUndoChange(dataChange);
|
|
3999
4225
|
return !!undoChange;
|
|
4000
4226
|
}
|
|
4001
|
-
performPostEditChecks(rowNode, cellDataChangedInfos) {
|
|
4227
|
+
performPostEditChecks(rowNode, cellDataChangedInfos, options) {
|
|
4002
4228
|
const recorder = getPerfRecorder(this.adaptableOptions?.adaptableId);
|
|
4003
4229
|
if (!recorder) {
|
|
4004
|
-
this.performPostEditChecksNow(rowNode, cellDataChangedInfos);
|
|
4230
|
+
this.performPostEditChecksNow(rowNode, cellDataChangedInfos, options);
|
|
4005
4231
|
return;
|
|
4006
4232
|
}
|
|
4007
4233
|
const start = performance.now();
|
|
4008
4234
|
try {
|
|
4009
|
-
this.performPostEditChecksNow(rowNode, cellDataChangedInfos);
|
|
4235
|
+
this.performPostEditChecksNow(rowNode, cellDataChangedInfos, options);
|
|
4010
4236
|
}
|
|
4011
4237
|
finally {
|
|
4012
4238
|
recorder.count('cellChanges', cellDataChangedInfos.length);
|
|
4013
4239
|
recorder.add('dataChange', 'dataChange', start, describeDataChangePerf);
|
|
4014
4240
|
}
|
|
4015
4241
|
}
|
|
4016
|
-
performPostEditChecksNow(rowNode, cellDataChangedInfos) {
|
|
4017
|
-
|
|
4242
|
+
performPostEditChecksNow(rowNode, cellDataChangedInfos, options) {
|
|
4243
|
+
const batch = this.postEditBatch;
|
|
4244
|
+
cellDataChangedInfos = expandCellDataChangedInfosWithCalculatedColumns(this.api, cellDataChangedInfos, options?.oldData);
|
|
4018
4245
|
cellDataChangedInfos.forEach((cellDataChangedInfo) => {
|
|
4019
4246
|
if (cellDataChangedInfo.trigger === 'undo') {
|
|
4020
4247
|
this.logger.info(`Data change reverted: column="${cellDataChangedInfo.column}", primaryKey="${cellDataChangedInfo.primaryKeyValue}", from=${cellDataChangedInfo.newValue} to=${cellDataChangedInfo.oldValue}`);
|
|
@@ -4022,7 +4249,12 @@ export class AdaptableAgGrid {
|
|
|
4022
4249
|
if (cellDataChangedInfo.trigger === 'edit' ||
|
|
4023
4250
|
cellDataChangedInfo.trigger === 'undo' ||
|
|
4024
4251
|
cellDataChangedInfo.trigger === 'tick') {
|
|
4025
|
-
|
|
4252
|
+
if (batch) {
|
|
4253
|
+
this.recordChangedCellForSelection(batch, cellDataChangedInfo);
|
|
4254
|
+
}
|
|
4255
|
+
else {
|
|
4256
|
+
this.checkIfChangedCellCurrentlySelected(cellDataChangedInfo);
|
|
4257
|
+
}
|
|
4026
4258
|
}
|
|
4027
4259
|
this.DataService.CreateCellDataChangedEvent(cellDataChangedInfo);
|
|
4028
4260
|
this.updateMinMaxCachedValueForColumn(cellDataChangedInfo);
|
|
@@ -4033,17 +4265,102 @@ export class AdaptableAgGrid {
|
|
|
4033
4265
|
const isGridFilterActive = !!gridFilterApi.getCurrentGridFilterExpression();
|
|
4034
4266
|
const isColumnFilterActive = colIds.some((colId) => columnFilterApi.isColumnFilterActiveForColumn(colId));
|
|
4035
4267
|
const shouldFilter = isGridFilterActive || isColumnFilterActive;
|
|
4036
|
-
if (shouldFilter) {
|
|
4268
|
+
if (!shouldFilter) {
|
|
4269
|
+
return;
|
|
4270
|
+
}
|
|
4271
|
+
if (batch) {
|
|
4272
|
+
batch.needsRefilter = true;
|
|
4273
|
+
}
|
|
4274
|
+
else if (options?.deferRefilter) {
|
|
4275
|
+
this.refilterAfterAsyncFlush = true;
|
|
4276
|
+
}
|
|
4277
|
+
else {
|
|
4037
4278
|
this.filterOnDataChange();
|
|
4038
4279
|
}
|
|
4039
4280
|
}
|
|
4281
|
+
runPostEditBatch(fn) {
|
|
4282
|
+
if (this.postEditBatch) {
|
|
4283
|
+
return fn();
|
|
4284
|
+
}
|
|
4285
|
+
const batch = {
|
|
4286
|
+
needsRefilter: false,
|
|
4287
|
+
refreshAllCells: false,
|
|
4288
|
+
allRowsColumnIds: new Set(),
|
|
4289
|
+
changedCellKeys: new Set(),
|
|
4290
|
+
changedRowKeys: new Set(),
|
|
4291
|
+
};
|
|
4292
|
+
this.postEditBatch = batch;
|
|
4293
|
+
try {
|
|
4294
|
+
return fn();
|
|
4295
|
+
}
|
|
4296
|
+
finally {
|
|
4297
|
+
this.postEditBatch = undefined;
|
|
4298
|
+
this.flushPostEditBatch(batch);
|
|
4299
|
+
}
|
|
4300
|
+
}
|
|
4301
|
+
flushPostEditBatch(batch) {
|
|
4302
|
+
if (!this.isListeningToAgGridRowNodeEvents) {
|
|
4303
|
+
return;
|
|
4304
|
+
}
|
|
4305
|
+
if (batch.refreshAllCells) {
|
|
4306
|
+
this.agGridAdapter.getAgGridApi().refreshCells({ force: true, suppressFlash: true });
|
|
4307
|
+
}
|
|
4308
|
+
else if (batch.allRowsColumnIds.size > 0) {
|
|
4309
|
+
this.refreshColumns([...batch.allRowsColumnIds], true, true);
|
|
4310
|
+
}
|
|
4311
|
+
if (batch.selection) {
|
|
4312
|
+
const { cells, rows } = batch.selection;
|
|
4313
|
+
if (batch.changedCellKeys.size > 0 &&
|
|
4314
|
+
cells.some((gridCell) => batch.changedCellKeys.has(getChangedCellKey(gridCell.primaryKeyValue, gridCell.column?.columnId)))) {
|
|
4315
|
+
this.debouncedSetSelectedCells();
|
|
4316
|
+
}
|
|
4317
|
+
if (batch.changedRowKeys.size > 0 &&
|
|
4318
|
+
rows.some((gridRow) => batch.changedRowKeys.has(String(gridRow.primaryKeyValue)))) {
|
|
4319
|
+
this.debouncedSetSelectedRows();
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
if (batch.needsRefilter) {
|
|
4323
|
+
this.filterOnDataChange();
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
recordChangedCellForSelection(batch, cellDataChangedInfo) {
|
|
4327
|
+
if (!batch.selection) {
|
|
4328
|
+
batch.selection = {
|
|
4329
|
+
cells: this.api.gridApi.getSelectedCellInfo()?.gridCells ?? [],
|
|
4330
|
+
rows: this.api.gridApi.getSelectedRowInfo()?.gridRows ?? [],
|
|
4331
|
+
};
|
|
4332
|
+
}
|
|
4333
|
+
const { cells, rows } = batch.selection;
|
|
4334
|
+
if (cells.length > 0) {
|
|
4335
|
+
batch.changedCellKeys.add(getChangedCellKey(cellDataChangedInfo.primaryKeyValue, cellDataChangedInfo.column?.columnId));
|
|
4336
|
+
}
|
|
4337
|
+
if (rows.length > 0) {
|
|
4338
|
+
batch.changedRowKeys.add(String(cellDataChangedInfo.primaryKeyValue));
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
isRowNodeRendered(rowNode) {
|
|
4342
|
+
if (rowNode.rowPinned != null) {
|
|
4343
|
+
return true;
|
|
4344
|
+
}
|
|
4345
|
+
const batch = this.postEditBatch;
|
|
4346
|
+
if (!batch) {
|
|
4347
|
+
return this.agGridAdapter.isVisibleNode(rowNode);
|
|
4348
|
+
}
|
|
4349
|
+
if (!batch.renderedRowIds) {
|
|
4350
|
+
batch.renderedRowIds = new Set(this.agGridAdapter
|
|
4351
|
+
.getAgGridApi()
|
|
4352
|
+
.getRenderedNodes()
|
|
4353
|
+
.map((renderedNode) => renderedNode.id));
|
|
4354
|
+
}
|
|
4355
|
+
return batch.renderedRowIds.has(rowNode.id);
|
|
4356
|
+
}
|
|
4040
4357
|
collectPostEditRefreshScope(rowNode, cellDataChangedInfos) {
|
|
4041
4358
|
const scope = {
|
|
4042
4359
|
wholeRow: false,
|
|
4043
4360
|
columnIds: new Set(),
|
|
4044
4361
|
allRowsColumnIds: new Set(),
|
|
4045
4362
|
};
|
|
4046
|
-
const isVisible = this.
|
|
4363
|
+
const isVisible = this.getRenderedCopiesOfRow(rowNode).length > 0;
|
|
4047
4364
|
if (isVisible && cellDataChangedInfos.length > 0) {
|
|
4048
4365
|
this.checkFormatColumnExpressionStyleChanges(scope, cellDataChangedInfos);
|
|
4049
4366
|
if (!scope.wholeRow) {
|
|
@@ -4087,22 +4404,65 @@ export class AdaptableAgGrid {
|
|
|
4087
4404
|
}
|
|
4088
4405
|
applyPostEditRefresh(rowNode, scope) {
|
|
4089
4406
|
const { wholeRow, columnIds, allRowsColumnIds } = scope;
|
|
4090
|
-
|
|
4407
|
+
const batch = this.postEditBatch;
|
|
4408
|
+
const pinnedSibling = rowNode.pinnedSibling;
|
|
4409
|
+
if (pinnedSibling &&
|
|
4410
|
+
pinnedSibling.data !== rowNode.data &&
|
|
4411
|
+
hasLocalEventService(pinnedSibling) &&
|
|
4412
|
+
(wholeRow || columnIds.size > 0 || allRowsColumnIds.size > 0)) {
|
|
4413
|
+
this.pendingPinnedCopyRefreshes.set(pinnedSibling, {
|
|
4414
|
+
wholeRow,
|
|
4415
|
+
columnIds: new Set([...columnIds, ...allRowsColumnIds]),
|
|
4416
|
+
});
|
|
4417
|
+
}
|
|
4418
|
+
if (batch && allRowsColumnIds.size > 0) {
|
|
4419
|
+
if (wholeRow) {
|
|
4420
|
+
batch.refreshAllCells = true;
|
|
4421
|
+
return;
|
|
4422
|
+
}
|
|
4423
|
+
allRowsColumnIds.forEach((columnId) => batch.allRowsColumnIds.add(columnId));
|
|
4424
|
+
}
|
|
4425
|
+
else if (allRowsColumnIds.size > 0 && wholeRow) {
|
|
4091
4426
|
this.agGridAdapter.getAgGridApi().refreshCells({ force: true, suppressFlash: true });
|
|
4092
4427
|
return;
|
|
4093
4428
|
}
|
|
4094
|
-
if (allRowsColumnIds.size > 0) {
|
|
4429
|
+
else if (allRowsColumnIds.size > 0) {
|
|
4095
4430
|
this.refreshColumns([...allRowsColumnIds, ...columnIds], true, true);
|
|
4096
4431
|
return;
|
|
4097
4432
|
}
|
|
4433
|
+
const rowNodes = this.getRenderedCopiesOfRow(rowNode).filter((node) => !this.pendingPinnedCopyRefreshes.has(node));
|
|
4434
|
+
this.refreshRenderedRows(rowNodes, wholeRow, columnIds);
|
|
4435
|
+
}
|
|
4436
|
+
applyPendingPinnedCopyRefresh(pinnedCopy) {
|
|
4437
|
+
const pending = this.pendingPinnedCopyRefreshes.get(pinnedCopy);
|
|
4438
|
+
if (!pending) {
|
|
4439
|
+
return;
|
|
4440
|
+
}
|
|
4441
|
+
this.pendingPinnedCopyRefreshes.delete(pinnedCopy);
|
|
4442
|
+
this.refreshRenderedRows([pinnedCopy], pending.wholeRow, pending.columnIds);
|
|
4443
|
+
}
|
|
4444
|
+
refreshRenderedRows(rowNodes, wholeRow, columnIds) {
|
|
4445
|
+
if (rowNodes.length === 0) {
|
|
4446
|
+
return;
|
|
4447
|
+
}
|
|
4098
4448
|
if (wholeRow) {
|
|
4099
|
-
this.
|
|
4449
|
+
this.redrawRows(rowNodes);
|
|
4100
4450
|
return;
|
|
4101
4451
|
}
|
|
4102
|
-
if (columnIds.size > 0
|
|
4103
|
-
this.
|
|
4452
|
+
if (columnIds.size > 0) {
|
|
4453
|
+
this.agGridAdapter.getAgGridApi().refreshCells({
|
|
4454
|
+
rowNodes,
|
|
4455
|
+
columns: Array.from(columnIds),
|
|
4456
|
+
force: true,
|
|
4457
|
+
suppressFlash: true,
|
|
4458
|
+
});
|
|
4104
4459
|
}
|
|
4105
4460
|
}
|
|
4461
|
+
getRenderedCopiesOfRow(rowNode) {
|
|
4462
|
+
const pinnedSibling = rowNode.pinnedSibling;
|
|
4463
|
+
const rowNodes = pinnedSibling ? [rowNode, pinnedSibling] : [rowNode];
|
|
4464
|
+
return rowNodes.filter((node) => this.isRowNodeRendered(node));
|
|
4465
|
+
}
|
|
4106
4466
|
checkStyledColumnComparisonChanges(dataChangedScope, cellDataChangedInfos) {
|
|
4107
4467
|
this.api.styledColumnApi.getStyledColumns().forEach((sc) => {
|
|
4108
4468
|
let columnComparison = this.api.styledColumnApi.internalApi.getColumnComparisonForStyledColumn(sc);
|