@adaptabletools/adaptable 20.1.7 → 20.2.0-canary.0

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.
Files changed (66) hide show
  1. package/base.css +27 -0
  2. package/base.css.map +1 -1
  3. package/index.css +22 -0
  4. package/index.css.map +1 -1
  5. package/package.json +2 -2
  6. package/src/AdaptableInterfaces/IAdaptable.d.ts +1 -0
  7. package/src/AdaptableOptions/DefaultAdaptableOptions.js +2 -1
  8. package/src/AdaptableOptions/ExportOptions.d.ts +91 -8
  9. package/src/AdaptableOptions/QuickSearchOptions.d.ts +1 -6
  10. package/src/AdaptableState/FormatColumnState.d.ts +8 -0
  11. package/src/AdaptableState/LayoutState.d.ts +15 -2
  12. package/src/AdaptableState/QuickSearchState.d.ts +8 -0
  13. package/src/Api/ColumnApi.d.ts +5 -0
  14. package/src/Api/ExportApi.d.ts +23 -7
  15. package/src/Api/Implementation/ColumnApiImpl.d.ts +2 -2
  16. package/src/Api/Implementation/ColumnApiImpl.js +15 -30
  17. package/src/Api/Implementation/ExportApiImpl.d.ts +11 -4
  18. package/src/Api/Implementation/ExportApiImpl.js +51 -9
  19. package/src/Api/Implementation/LayoutApiImpl.d.ts +1 -0
  20. package/src/Api/Implementation/LayoutApiImpl.js +9 -0
  21. package/src/Api/Implementation/LayoutHelpers.js +44 -0
  22. package/src/Api/Implementation/QuickSearchApiImpl.d.ts +4 -0
  23. package/src/Api/Implementation/QuickSearchApiImpl.js +12 -0
  24. package/src/Api/Internal/AlertInternalApi.js +1 -1
  25. package/src/Api/Internal/ExportInternalApi.d.ts +3 -8
  26. package/src/Api/Internal/ExportInternalApi.js +1 -74
  27. package/src/Api/Internal/ExpressionInternalApi.d.ts +1 -1
  28. package/src/Api/Internal/ExpressionInternalApi.js +1 -32
  29. package/src/Api/Internal/FormatColumnInternalApi.d.ts +2 -1
  30. package/src/Api/Internal/FormatColumnInternalApi.js +62 -0
  31. package/src/Api/LayoutApi.d.ts +6 -2
  32. package/src/Api/QuickSearchApi.d.ts +16 -0
  33. package/src/Redux/Store/AdaptableStore.js +3 -2
  34. package/src/Utilities/Constants/GeneralConstants.js +2 -1
  35. package/src/View/Components/Forms/AdaptableFormControlTextClear.d.ts +1 -0
  36. package/src/View/Components/Forms/AdaptableFormControlTextClear.js +1 -0
  37. package/src/View/Dashboard/Dashboard.js +2 -4
  38. package/src/View/Layout/Wizard/sections/AggregationsSection.js +2 -2
  39. package/src/View/Layout/Wizard/sections/PivotAggregationsSection.js +2 -2
  40. package/src/View/Layout/Wizard/sections/PivotRowGroupingSection.js +6 -1
  41. package/src/View/Layout/Wizard/sections/RowGroupingSection.d.ts +4 -0
  42. package/src/View/Layout/Wizard/sections/RowGroupingSection.js +22 -19
  43. package/src/View/QuickSearch/QuickSearchInput.js +6 -1
  44. package/src/View/QuickSearch/QuickSearchPopup.js +2 -3
  45. package/src/agGrid/AdaptableAgGrid.d.ts +2 -0
  46. package/src/agGrid/AdaptableAgGrid.js +123 -44
  47. package/src/agGrid/AgGridAdapter.d.ts +4 -1
  48. package/src/agGrid/AgGridAdapter.js +90 -13
  49. package/src/agGrid/AgGridColumnAdapter.d.ts +4 -0
  50. package/src/agGrid/AgGridColumnAdapter.js +144 -37
  51. package/src/agGrid/AgGridExportAdapter.d.ts +6 -1
  52. package/src/agGrid/AgGridExportAdapter.js +110 -17
  53. package/src/agGrid/FloatingFilterWrapper.js +30 -4
  54. package/src/env.js +2 -2
  55. package/src/layout-manager/src/LayoutManagerModel.d.ts +16 -2
  56. package/src/layout-manager/src/index.d.ts +1 -1
  57. package/src/layout-manager/src/index.js +135 -20
  58. package/src/layout-manager/src/normalizeLayoutModel.d.ts +2 -4
  59. package/src/layout-manager/src/normalizeLayoutModel.js +12 -16
  60. package/src/layout-manager/src/simplifyLayoutModel.js +15 -3
  61. package/src/metamodel/adaptable.metamodel.d.ts +71 -0
  62. package/src/metamodel/adaptable.metamodel.js +1 -1
  63. package/src/types.d.ts +1 -1
  64. package/tsconfig.esm.tsbuildinfo +1 -1
  65. package/src/Utilities/buildSortedColumnStateForLayout.d.ts +0 -7
  66. package/src/Utilities/buildSortedColumnStateForLayout.js +0 -131
@@ -403,7 +403,8 @@ export class AdaptableAgGrid {
403
403
  perfInitAgGrid.end();
404
404
  // we need to intercept several AG Grid Api methods and trigger Adaptable state changes
405
405
  this.agGridAdapter.setAgGridApi(agGridApi);
406
- this.agGridAdapter.monkeyPatchingGridOptionsUpdates(agGridApi);
406
+ this.agGridAdapter.monkeyPatchingGridOptionsUpdates();
407
+ this.agGridAdapter.monkeyPatchingAggColumnFilters();
407
408
  this.lifecycleState = 'agGridReady';
408
409
  this.logger.info(`Registered AG Grid modules: `, this.agGridAdapter.getAgGridRegisteredModuleNames().sort());
409
410
  /**
@@ -418,12 +419,22 @@ export class AdaptableAgGrid {
418
419
  // TODO AFL MIG: we could just patch the defautl Layout on init? instead
419
420
  this.checkShouldClearExistingFiltersOrSearches();
420
421
  this.applyFiltering();
422
+ // apply quick search if there is one
423
+ // yes, we could have put this on the gridOptions.findSearchValue
424
+ // but we need to wait for setupColumns to run first so as to correctly
425
+ // determine on which columns the quick search should be applied or not
426
+ // and also to setup the quick search style
427
+ const quickSearchState = this.api.stateApi.getQuickSearchState();
428
+ if (quickSearchState.QuickSearchText) {
429
+ this.setAgGridFindSearchValue(quickSearchState.QuickSearchText);
430
+ }
421
431
  this.addGridEventListeners();
422
432
  this.temporaryAdaptableStateUpdates();
423
433
  this.redrawBody();
424
434
  this.refreshHeader();
425
435
  const currentLayout = this.api.layoutApi.getCurrentLayout();
426
436
  checkForDuplicateColumns(currentLayout);
437
+ this.__prevLayoutForRefresh = currentLayout;
427
438
  if (isPivotLayout(currentLayout)) {
428
439
  // this is very very strange!
429
440
  // for some projects, if the initial layout is pivot, the columnDefs of the pivot resutl columns are NOT derived correctly from the main colDefs
@@ -437,7 +448,9 @@ export class AdaptableAgGrid {
437
448
  // see test /tests/pages/quick-search/pivot-search.spec.ts
438
449
  this.updateColumnModelAndRefreshGrid();
439
450
  }
440
- this.layoutManager.applyRowGroupValues(layoutStateToLayoutModel(currentLayout).RowGroupValues);
451
+ const layoutModelForApply = layoutStateToLayoutModel(currentLayout);
452
+ this.layoutManager.applyRowGroupValues(layoutModelForApply.RowGroupValues);
453
+ this.layoutManager.applyColumnGroupCollapseExpandState(layoutModelForApply);
441
454
  this.autoSizeLayoutIfNeeded();
442
455
  this.ModuleService.createModuleUIItems();
443
456
  const adaptableContainerElem = this.getAdaptableContainerElement();
@@ -761,10 +774,14 @@ You need to define at least one Layout!`);
761
774
  if (!this.isAvailable) {
762
775
  return true;
763
776
  }
764
- const isColumnFiltersActive = ArrayExtensions.IsNotNullOrEmpty(this.api.filterApi.columnFilterApi.getActiveColumnFilters());
765
777
  const isGridFilterActive = StringExtensions.IsNotNullOrEmpty(this.api.filterApi.gridFilterApi.getCurrentGridFilterExpression());
766
- return (isColumnFiltersActive ||
767
- isGridFilterActive ||
778
+ const isTableColumnFiltersActive = ArrayExtensions.IsNotNullOrEmpty(this.api.filterApi.columnFilterApi
779
+ .getActiveColumnFilters()
780
+ .filter((columnFilter) => !this.api.columnApi.isPivotResultColumn(columnFilter.ColumnId)));
781
+ return (isGridFilterActive ||
782
+ // only Table ColumnFilters are handled here
783
+ // see #doAggregateFiltersPassMonkeyPatcher for filtering Pivot Columns
784
+ isTableColumnFiltersActive ||
768
785
  // it means that userPropertyValue will be called so we re-init that collection
769
786
  (original_isExternalFilterPresent ? original_isExternalFilterPresent(params) : false));
770
787
  };
@@ -777,10 +794,20 @@ You need to define at least one Layout!`);
777
794
  if (!this.isAvailable) {
778
795
  return true;
779
796
  }
780
- // Note: not sure we need this check as doubtful AG Grid ever passes in a Group Row node to filter...
781
- // But if it does, then we might change this IF we allow Column filtering (but not Grid Filters) for Group nodes
782
797
  if (this.isGroupRowNode(node)) {
783
- return true;
798
+ if (this.api.gridApi.isTreeDataGrid()) {
799
+ if (node.data == undefined) {
800
+ // Filler Groups are not filterable
801
+ // see https://www.ag-grid.com/javascript-data-grid/tree-data-paths/#filler-groups
802
+ return false;
803
+ }
804
+ }
805
+ else {
806
+ // for non-Tree Data Grids, we don't filter Group Rows
807
+ // not sure if that's 100% correct, but we did it like this in the past
808
+ // so we keep it like this for now until bugs are reported
809
+ return true;
810
+ }
784
811
  }
785
812
  // first assess if the Row i s filterable - if not, then return true so it appears in Grid
786
813
  const isRowFilterable = this.api.optionsApi.getFilterOptions().isRowFilterable;
@@ -816,11 +843,15 @@ You need to define at least one Layout!`);
816
843
  }
817
844
  }
818
845
  // finally we evaluate column filters
819
- const columnFilters = this.api.filterApi.columnFilterApi.getActiveColumnFilters();
846
+ const tableColumnFilters = this.api.filterApi.columnFilterApi
847
+ .getActiveColumnFilters()
848
+ .filter((columnFilter) => !this.api.columnApi.isPivotResultColumn(columnFilter.ColumnId));
820
849
  try {
821
- if (columnFilters.length > 0) {
822
- for (const columnFilter of columnFilters) {
823
- const evaluateColumnFilterOnClient = this.api.expressionApi.internalApi.evaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, columnFilter.Predicates);
850
+ // only Table ColumnFilters are handled here
851
+ // see #doAggregateFiltersPassMonkeyPatcher for filtering Pivot Columns
852
+ if (tableColumnFilters.length > 0) {
853
+ for (const columnFilter of tableColumnFilters) {
854
+ const evaluateColumnFilterOnClient = this.api.expressionApi.internalApi.shouldEvaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, columnFilter.Predicates);
824
855
  if (evaluateColumnFilterOnClient) {
825
856
  const columnFilterEvaluationResult = this.api.filterApi.columnFilterApi.internalApi.evaluateColumnFilter(columnFilter, node);
826
857
  if (!columnFilterEvaluationResult) {
@@ -1043,18 +1074,6 @@ You need to define at least one Layout!`);
1043
1074
  // this array reference will be used for the entire AG Grid session
1044
1075
  return this.agGridExportAdapter.DANGER_excelStyles;
1045
1076
  });
1046
- /**
1047
- * `processPivotResultColDef`
1048
- */
1049
- this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'processPivotResultColDef', (original_processPivotResultColDef) => {
1050
- return (colDef) => {
1051
- if (this.adaptableOptions.filterOptions.useAdaptableFiltering) {
1052
- colDef.floatingFilter = false;
1053
- colDef.filter = false;
1054
- }
1055
- original_processPivotResultColDef?.(colDef);
1056
- };
1057
- });
1058
1077
  /**
1059
1078
  * `maintainColumnOrder`
1060
1079
  */
@@ -1095,6 +1114,12 @@ You need to define at least one Layout!`);
1095
1114
  const revertedDateTypeDefinitions = agGridDataTypeDefinitions;
1096
1115
  return revertedDateTypeDefinitions;
1097
1116
  });
1117
+ this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'findOptions', (original_findOptions) => {
1118
+ return {
1119
+ ...original_findOptions,
1120
+ caseSensitive: !!this.adaptableOptions.quickSearchOptions.isQuickSearchCaseSensitive,
1121
+ };
1122
+ });
1098
1123
  }
1099
1124
  /**
1100
1125
  * Either initializes the AG Grid instance or delegates it to the framework wrappers (React/Anglar)
@@ -1296,6 +1321,17 @@ You need to define at least one Layout!`);
1296
1321
  }
1297
1322
  this.autoSizeLayoutIfNeeded();
1298
1323
  }));
1324
+ /**
1325
+ * Use Case: A format column that has ColumnGroupState needs to be re-evaluated
1326
+ * whenever a column group is expanded or collapsed
1327
+ */
1328
+ this.agGridAdapter.getAgGridApi().addEventListener('columnGroupOpened', (this.listenerColumnGroupOpened = () => {
1329
+ if (this.api.formatColumnApi.getActiveFormatColumns().some((fc) => {
1330
+ return fc.ColumnGroupState != null;
1331
+ })) {
1332
+ this.updateColumnModelAndRefreshGrid();
1333
+ }
1334
+ }));
1299
1335
  /**
1300
1336
  * Use Case: A pivot column has changed
1301
1337
  * Action: Autosize pivot columns (if autosize pivot in Layout is true)
@@ -1558,13 +1594,9 @@ You need to define at least one Layout!`);
1558
1594
  const autoGroupColumns = gridApi
1559
1595
  .getAllGridColumns()
1560
1596
  .filter((column) => this.api.columnApi.isAutoRowGroupColumn(column.getColId()));
1561
- if (pivotResultColumns.length) {
1562
- agGridCols = [...agGridCols, ...pivotResultColumns, ...autoGroupColumns];
1563
- }
1597
+ agGridCols = [...autoGroupColumns, ...agGridCols, ...pivotResultColumns];
1564
1598
  }
1565
- const columnGroupChildren = gridApi
1566
- // TODO AFL MIG: check why this assertion is here
1567
- .getAllDisplayedColumnGroups();
1599
+ const columnGroupChildren = gridApi.getAllDisplayedColumnGroups();
1568
1600
  const groupsCount = {};
1569
1601
  const colsToGroups = (columnGroupChildren ?? []).reduce((acc, columnGroup) => {
1570
1602
  if (!columnGroup.getProvidedColumnGroup?.()?.getColGroupDef()) {
@@ -1635,13 +1667,18 @@ You need to define at least one Layout!`);
1635
1667
  let _rawValue;
1636
1668
  let _displayValue;
1637
1669
  let _normalisedValue;
1638
- let _isPivotCell;
1639
1670
  let _isRowGroupCell;
1671
+ const _isPivotCell = this.api.columnApi.isPivotResultColumn(columnId);
1640
1672
  const self = this;
1641
1673
  const api = this.api;
1642
1674
  const getRawValue = () => {
1643
1675
  if (_rawValue === undefined) {
1644
1676
  _rawValue = self.getRawValueFromRowNode(rowNode, columnId);
1677
+ if (_isPivotCell && _rawValue?.value != undefined) {
1678
+ // for pivot result columns, the raw value is an object with a value property
1679
+ // we want to return the value property as the raw value
1680
+ _rawValue = _rawValue.value;
1681
+ }
1645
1682
  }
1646
1683
  return _rawValue;
1647
1684
  };
@@ -1680,9 +1717,6 @@ You need to define at least one Layout!`);
1680
1717
  return _primaryKeyValue;
1681
1718
  },
1682
1719
  get isPivotCell() {
1683
- if (_isPivotCell === undefined) {
1684
- _isPivotCell = api.columnApi.isPivotResultColumn(columnId);
1685
- }
1686
1720
  return _isPivotCell;
1687
1721
  },
1688
1722
  get isRowGroupCell() {
@@ -1751,6 +1785,26 @@ You need to define at least one Layout!`);
1751
1785
  return formattedValue || '';
1752
1786
  }
1753
1787
  }
1788
+ else if (this.api.columnApi.isPivotResultColumn(columnId)) {
1789
+ const pivotResultColumn = this.agGridAdapter
1790
+ .getAgGridApi()
1791
+ .getPivotResultColumns()
1792
+ .find((col) => col.getColId() === columnId);
1793
+ const pivotResultColDef = pivotResultColumn?.getColDef();
1794
+ if (pivotResultColDef && typeof pivotResultColDef.valueFormatter === 'function') {
1795
+ const params = {
1796
+ value: rawValue,
1797
+ node: rowNode,
1798
+ data: rowNode.data,
1799
+ colDef: pivotResultColDef,
1800
+ column: pivotResultColumn,
1801
+ api: this.agGridAdapter.getAgGridApi(),
1802
+ context: this.agGridAdapter.getGridOption('context'),
1803
+ };
1804
+ const formattedValue = pivotResultColDef.valueFormatter(params);
1805
+ return formattedValue || '';
1806
+ }
1807
+ }
1754
1808
  return this.getCleanValue(rawValue);
1755
1809
  }
1756
1810
  getCleanValue(value) {
@@ -2272,8 +2326,9 @@ You need to define at least one Layout!`);
2272
2326
  }
2273
2327
  getDistinctGridCellsForColumn(column) {
2274
2328
  let gridCells = [];
2329
+ const isPivotResultColumn = column.isGeneratedPivotResultColumn;
2275
2330
  this.agGridAdapter.getAgGridApi().forEachNode((rowNode) => {
2276
- const gridCell = this.addDistinctColumnValue(rowNode, column.columnId);
2331
+ const gridCell = this.addDistinctColumnValue(rowNode, column.columnId, isPivotResultColumn);
2277
2332
  if (gridCell) {
2278
2333
  gridCells.push(gridCell);
2279
2334
  }
@@ -2298,17 +2353,36 @@ You need to define at least one Layout!`);
2298
2353
  return gridCells;
2299
2354
  }
2300
2355
  }
2301
- addDistinctColumnValue(rowNode, columnId) {
2302
- // we do not return the values of the aggregates when in grouping mode
2303
- // otherwise they would appear in the filter dropdown etc....
2304
- if (rowNode && !this.isGroupRowNode(rowNode)) {
2305
- const returnValue = this.getGridCellFromRowNode(rowNode, columnId);
2306
- if (Helper.objectExists(returnValue)) {
2307
- return returnValue;
2356
+ addDistinctColumnValue(rowNode, columnId, isPivotResultColumn) {
2357
+ if (!rowNode) {
2358
+ return;
2359
+ }
2360
+ if (!isPivotResultColumn && this.isGroupRowNode(rowNode)) {
2361
+ if (this.api.gridApi.isTreeDataGrid()) {
2362
+ if (rowNode.data == undefined) {
2363
+ // skip Tree Filler Groups
2364
+ // see https://www.ag-grid.com/javascript-data-grid/tree-data-paths/#filler-groups
2365
+ return;
2366
+ }
2367
+ }
2368
+ else {
2369
+ // for normal Table Columns we do NOT return the values of the aggregates
2370
+ return;
2308
2371
  }
2309
2372
  }
2310
- else {
2311
- return undefined;
2373
+ if (isPivotResultColumn) {
2374
+ // if it's a Pivot Result Column, we are interested only in the aggregated(pivoted) data
2375
+ if (!rowNode.aggData) {
2376
+ return;
2377
+ }
2378
+ if (!rowNode.leafGroup) {
2379
+ // if it's a Pivot Result Column, we are interested only in the leaf groups (pivot results, NOT group aggregates)
2380
+ return;
2381
+ }
2382
+ }
2383
+ const returnValue = this.getGridCellFromRowNode(rowNode, columnId);
2384
+ if (Helper.objectExists(returnValue)) {
2385
+ return returnValue;
2312
2386
  }
2313
2387
  }
2314
2388
  getUniqueGridCells(column, gridCells) {
@@ -2671,6 +2745,9 @@ You need to define at least one Layout!`);
2671
2745
  clearAgGridQuickSearch() {
2672
2746
  this.setAgGridQuickSearch('');
2673
2747
  }
2748
+ setAgGridFindSearchValue(searchText) {
2749
+ this.agGridAdapter.setGridOption('findSearchValue', searchText);
2750
+ }
2674
2751
  applyAdaptableTheme(theme) {
2675
2752
  const container = this.getAgGridContainerElement();
2676
2753
  if (container != null) {
@@ -2839,10 +2916,12 @@ You need to define at least one Layout!`);
2839
2916
  agGridApi.removeEventListener('columnPivotChanged', this.listenerPivotChanged);
2840
2917
  agGridApi.removeEventListener('cellEditingStarted', this.listenerCellEditingStarted);
2841
2918
  agGridApi.removeEventListener('cellSelectionChanged', this.listenerCellSelectionChanged);
2919
+ agGridApi.removeEventListener('columnGroupOpened', this.listenerColumnGroupOpened);
2842
2920
  agGridApi.removeEventListener('sortChanged', this.listenerSortChanged);
2843
2921
  agGridApi.removeGlobalListener(this.listenerGlobalSetRowSelection);
2844
2922
  this.listenerFirstDataRendered = null;
2845
2923
  this.listenerPivotChanged = null;
2924
+ this.listenerColumnGroupOpened = null;
2846
2925
  this.listenerCellEditingStarted = null;
2847
2926
  this.listenerCellSelectionChanged = null;
2848
2927
  this.listenerGlobalSetRowSelection = null;
@@ -9,6 +9,8 @@ export declare class AgGridAdapter {
9
9
  private DANGER_USE_GETTER_gridApi;
10
10
  private DANGER_gridApi_from_args;
11
11
  private DANGER_updateGridOptionsMonkeyPatcher;
12
+ private DANGER_doAggregateFiltersPassMonkeyPatcher;
13
+ private DANGER_isAggregateFilterPresentMonkeyPatcher;
12
14
  initialGridOptions: GridOptions;
13
15
  private _agGridId;
14
16
  constructor(_adaptableInstance: AdaptableAgGrid, config?: {
@@ -22,7 +24,8 @@ export declare class AgGridAdapter {
22
24
  setAgGridId(agGridId: string): void;
23
25
  setAgGridApi(gridApi: GridApi): void;
24
26
  getAgGridApi(skipLogging?: boolean): GridApi | undefined;
25
- monkeyPatchingGridOptionsUpdates(agGridApi: GridApi<any>): void;
27
+ monkeyPatchingGridOptionsUpdates(): void;
28
+ monkeyPatchingAggColumnFilters(): void;
26
29
  private DANGER_getPrivateAgGridBeans;
27
30
  DANGER_getLiveGridOptions(): GridOptions<any>;
28
31
  isAgGridModuleRegistered(moduleName: ModuleName): boolean;
@@ -1,6 +1,6 @@
1
1
  import { ColumnApiModule, } from 'ag-grid-enterprise';
2
2
  import { ACTION_COLUMN_TYPE, CALCULATED_COLUMN_TYPE, FDC3_COLUMN_TYPE, FREE_TEXT_COLUMN_TYPE, } from '../AdaptableState/Common/AdaptableColumn';
3
- import { ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME, AG_GRID_GROUPED_COLUMN, AG_GRID_SELECTION_COLUMN, } from '../Utilities/Constants/GeneralConstants';
3
+ import { ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME } from '../Utilities/Constants/GeneralConstants';
4
4
  import { createUuid } from '../AdaptableState/Uuid';
5
5
  import ArrayExtensions from '../Utilities/Extensions/ArrayExtensions';
6
6
  import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
@@ -16,6 +16,8 @@ export class AgGridAdapter {
16
16
  constructor(_adaptableInstance, config) {
17
17
  this._adaptableInstance = _adaptableInstance;
18
18
  const columnApiModuleReference = config?.getAgGridColumnApiModuleReference?.() ?? getColumnApiModule();
19
+ const beans = columnApiModuleReference?.beans;
20
+ console.log(beans?.length);
19
21
  const ColumnDefFactory_Prototype = columnApiModuleReference?.beans?.[0]?.prototype;
20
22
  if (!ColumnDefFactory_Prototype) {
21
23
  console.error(`CRITICAL: could not get hold of AG Grid beans, this should never happen!`);
@@ -38,6 +40,8 @@ export class AgGridAdapter {
38
40
  this.DANGER_gridApi_from_args = null;
39
41
  this.DANGER_USE_GETTER_gridApi = null;
40
42
  this.DANGER_updateGridOptionsMonkeyPatcher = null;
43
+ this.DANGER_doAggregateFiltersPassMonkeyPatcher = null;
44
+ this.DANGER_isAggregateFilterPresentMonkeyPatcher = null;
41
45
  this._adaptableInstance = null;
42
46
  }
43
47
  get adaptableOptions() {
@@ -71,7 +75,7 @@ export class AgGridAdapter {
71
75
  }
72
76
  // #gridOpts_monkey_patch
73
77
  // we need to intercept some of the GridOptions updates and refresh the Adaptable state
74
- monkeyPatchingGridOptionsUpdates(agGridApi) {
78
+ monkeyPatchingGridOptionsUpdates() {
75
79
  const agGridOptionsService = this.DANGER_getPrivateAgGridBeans()?.gos;
76
80
  if (!agGridOptionsService) {
77
81
  return;
@@ -107,6 +111,57 @@ export class AgGridAdapter {
107
111
  };
108
112
  agGridOptionsService.updateGridOptions = this.DANGER_updateGridOptionsMonkeyPatcher;
109
113
  }
114
+ monkeyPatchingAggColumnFilters() {
115
+ if (!this.adaptableApi.optionsApi.getFilterOptions().useAdaptableFiltering) {
116
+ // monkey patching is only needed if Adaptable is used for filtering
117
+ return;
118
+ }
119
+ const agGridColumnFilterService = this.DANGER_getPrivateAgGridBeans()?.colFilter;
120
+ if (!agGridColumnFilterService) {
121
+ this.logger.consoleError('Could not get hold of ColumnFilterService! This is a critical error and will prevent Adaptable from working correctly.');
122
+ return;
123
+ }
124
+ const self = this;
125
+ // https://github.com/ag-grid/ag-grid/blob/8409e99c8010473356a878e9bdfb836a5ea16718/packages/ag-grid-community/src/filter/columnFilterService.ts#L240
126
+ // monkey patch ColumnFilterService.doAggregateFiltersPass because currently Adaptable does NOT override the ColumnFilters
127
+ // (it uses the `doesExternalFilterPass` to evaluate the filters on the client side)
128
+ // #doAggregateFiltersPassMonkeyPatcher
129
+ this.DANGER_doAggregateFiltersPassMonkeyPatcher = function (rowNode, filterToSkip) {
130
+ if (!self.adaptableApi.layoutApi.isCurrentLayoutPivot()) {
131
+ // should NEVER happen
132
+ return true;
133
+ }
134
+ const pivotColumnFilters = self.adaptableApi.filterApi.columnFilterApi
135
+ .getActiveColumnFilters()
136
+ .filter((columnFilter) => self.adaptableApi.columnApi.isPivotResultColumn(columnFilter.ColumnId));
137
+ try {
138
+ if (pivotColumnFilters.length > 0) {
139
+ for (const columnFilter of pivotColumnFilters) {
140
+ const evaluateColumnFilterOnClient = self.adaptableApi.expressionApi.internalApi.shouldEvaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, columnFilter.Predicates);
141
+ if (evaluateColumnFilterOnClient) {
142
+ const columnFilterEvaluationResult = self.adaptableApi.filterApi.columnFilterApi.internalApi.evaluateColumnFilter(columnFilter, rowNode);
143
+ if (!columnFilterEvaluationResult) {
144
+ return false;
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ catch (ex) {
151
+ self.logger.error(ex);
152
+ return true;
153
+ }
154
+ return true;
155
+ };
156
+ agGridColumnFilterService.doAggregateFiltersPass =
157
+ this.DANGER_doAggregateFiltersPassMonkeyPatcher;
158
+ this.DANGER_isAggregateFilterPresentMonkeyPatcher = function () {
159
+ const columnFilters = self.adaptableApi.filterApi.columnFilterApi.getActiveColumnFilters();
160
+ return columnFilters.some((colFilter) => self.adaptableApi.columnApi.isPivotResultColumn(colFilter.ColumnId));
161
+ };
162
+ agGridColumnFilterService.isAggregateFilterPresent =
163
+ this.DANGER_isAggregateFilterPresentMonkeyPatcher;
164
+ }
110
165
  DANGER_getPrivateAgGridBeans() {
111
166
  const beans = DANGER_AG_GRID_BEANS_MAP[this._agGridId];
112
167
  if (!beans) {
@@ -159,12 +214,21 @@ export class AgGridAdapter {
159
214
  }
160
215
  }
161
216
  updateGridOptions(options) {
217
+ if (this.getAgGridApi()?.isDestroyed()) {
218
+ return;
219
+ }
162
220
  this.getAgGridApi()?.updateGridOptions(options);
163
221
  }
164
222
  getGridOption(key) {
223
+ if (this.getAgGridApi()?.isDestroyed()) {
224
+ return;
225
+ }
165
226
  return this.getAgGridApi()?.getGridOption(key);
166
227
  }
167
228
  setGridOption(key, value) {
229
+ if (this.getAgGridApi()?.isDestroyed()) {
230
+ return;
231
+ }
168
232
  this.getAgGridApi()?.setGridOption(key, value);
169
233
  }
170
234
  getUserGridOptionsProperty(propertyName) {
@@ -453,10 +517,21 @@ export class AgGridAdapter {
453
517
  this.logger.warn(`Column is undefined, returning 'text' for Type`);
454
518
  return 'text';
455
519
  }
456
- if (agColumn.getId() === AG_GRID_GROUPED_COLUMN ||
457
- agColumn.getId() === AG_GRID_SELECTION_COLUMN) {
520
+ if (this.adaptableApi.columnApi.isAutoRowGroupColumnForSingle(agColumn.getId()) ||
521
+ this.adaptableApi.columnApi.isSelectionColumn(agColumn.getId())) {
458
522
  return 'unknown';
459
523
  }
524
+ if (this.adaptableApi.columnApi.isAutoRowGroupColumnForMulti(agColumn.getId())) {
525
+ const rowGroupKey = agColumn.getColDef().showRowGroup;
526
+ if (typeof rowGroupKey !== 'string') {
527
+ return 'unknown';
528
+ }
529
+ const groupedColumn = this.adaptableApi.agGridApi.getColumn(rowGroupKey);
530
+ if (!groupedColumn) {
531
+ return 'unknown';
532
+ }
533
+ return this.deriveAdaptableColumnDataType(groupedColumn, logWarning);
534
+ }
460
535
  const colDefType = [].concat(agColumn.getColDef()?.type || []).filter(Boolean);
461
536
  const skippedSpecialCols = ['actionColumn', 'fdc3Column'];
462
537
  if (skippedSpecialCols.some((specialColType) => colDefType.includes(specialColType))) {
@@ -483,15 +558,17 @@ export class AgGridAdapter {
483
558
  this.logger.consoleError(`No data in grid, returning type "unknown" for Column: "${agColumn.getColId()}". This will impact several Adaptable features, such as Filters and ColumnFormats.`);
484
559
  return 'unknown';
485
560
  }
486
- // if it's a group we need the content of the group
487
- if (row.group) {
488
- const childNodes = row.childrenAfterGroup;
489
- if (ArrayExtensions.IsNullOrEmpty(childNodes)) {
490
- this.logger.consoleError(`No data in grid, returning type "unknown" for Column: "${agColumn.getColId()}". This will impact several Adaptable features, such as Filters and ColumnFormats.`);
491
- return 'unknown';
492
- }
493
- row = childNodes[0];
494
- }
561
+ // // if it's a group we need the content of the group
562
+ // if (row.group) {
563
+ // const childNodes = row.childrenAfterGroup;
564
+ // if (ArrayExtensions.IsNullOrEmpty(childNodes)) {
565
+ // this.logger.consoleError(
566
+ // `No data in grid, returning type "unknown" for Column: "${agColumn.getColId()}". This will impact several Adaptable features, such as Filters and ColumnFormats.`
567
+ // );
568
+ // return 'unknown';
569
+ // }
570
+ // row = childNodes[0];
571
+ // }
495
572
  const value = this._agGridApi_getValue(agColumn, row);
496
573
  switch (typeof value) {
497
574
  case 'string':
@@ -35,6 +35,8 @@ export declare class AgGridColumnAdapter {
35
35
  private setupColumnEditable;
36
36
  private setupColumnValueSetter;
37
37
  private setupColumnComparator;
38
+ private setupColumnGetFindText;
39
+ private isCellSearchable;
38
40
  private isQuickSearchActive;
39
41
  private getEditableCellClass;
40
42
  private getReadonlyCellClass;
@@ -45,6 +47,8 @@ export declare class AgGridColumnAdapter {
45
47
  private getCommentCellClassName;
46
48
  private getFormatColumnCellClass;
47
49
  private getQuickSearchCellStyle;
50
+ private getQuickSearchTextMatchStyle;
51
+ private getQuickSearchCurrentTextMatchStyle;
48
52
  private getReadOnlyCellStyle;
49
53
  private getEditableCellStyle;
50
54
  private getEditedCellStyle;