@adaptabletools/adaptable-cjs 20.1.9 → 20.2.0-canary.1

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/FilterOptions.d.ts +4 -0
  10. package/src/AdaptableOptions/QuickSearchOptions.d.ts +2 -4
  11. package/src/AdaptableState/FormatColumnState.d.ts +8 -0
  12. package/src/AdaptableState/LayoutState.d.ts +15 -2
  13. package/src/AdaptableState/QuickSearchState.d.ts +8 -0
  14. package/src/AdaptableState/Selection/GridCell.d.ts +1 -0
  15. package/src/Api/ColumnApi.d.ts +5 -0
  16. package/src/Api/ExportApi.d.ts +23 -7
  17. package/src/Api/Implementation/ColumnApiImpl.d.ts +2 -2
  18. package/src/Api/Implementation/ColumnApiImpl.js +15 -31
  19. package/src/Api/Implementation/ExportApiImpl.d.ts +11 -4
  20. package/src/Api/Implementation/ExportApiImpl.js +50 -8
  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/QuickSearchApi.d.ts +16 -0
  32. package/src/Redux/Store/AdaptableStore.js +3 -2
  33. package/src/Utilities/Constants/GeneralConstants.js +2 -1
  34. package/src/View/Components/Forms/AdaptableFormControlTextClear.d.ts +1 -0
  35. package/src/View/Components/Forms/AdaptableFormControlTextClear.js +1 -0
  36. package/src/View/Components/NewScopeComponent.js +4 -4
  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 +24 -20
  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 +132 -38
  47. package/src/agGrid/AgGridAdapter.d.ts +4 -1
  48. package/src/agGrid/AgGridAdapter.js +89 -12
  49. package/src/agGrid/AgGridColumnAdapter.d.ts +4 -0
  50. package/src/agGrid/AgGridColumnAdapter.js +142 -35
  51. package/src/agGrid/AgGridExportAdapter.d.ts +6 -1
  52. package/src/agGrid/AgGridExportAdapter.js +103 -14
  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 +133 -18
  58. package/src/layout-manager/src/normalizeLayoutModel.d.ts +2 -4
  59. package/src/layout-manager/src/normalizeLayoutModel.js +13 -18
  60. package/src/layout-manager/src/simplifyLayoutModel.js +14 -2
  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.cjs.tsbuildinfo +1 -1
  65. package/src/Utilities/buildSortedColumnStateForLayout.d.ts +0 -7
  66. package/src/Utilities/buildSortedColumnStateForLayout.js +0 -135
@@ -407,7 +407,8 @@ class AdaptableAgGrid {
407
407
  perfInitAgGrid.end();
408
408
  // we need to intercept several AG Grid Api methods and trigger Adaptable state changes
409
409
  this.agGridAdapter.setAgGridApi(agGridApi);
410
- this.agGridAdapter.monkeyPatchingGridOptionsUpdates(agGridApi);
410
+ this.agGridAdapter.monkeyPatchingGridOptionsUpdates();
411
+ this.agGridAdapter.monkeyPatchingAggColumnFilters();
411
412
  this.lifecycleState = 'agGridReady';
412
413
  this.logger.info(`Registered AG Grid modules: `, this.agGridAdapter.getAgGridRegisteredModuleNames().sort());
413
414
  /**
@@ -422,12 +423,22 @@ class AdaptableAgGrid {
422
423
  // TODO AFL MIG: we could just patch the defautl Layout on init? instead
423
424
  this.checkShouldClearExistingFiltersOrSearches();
424
425
  this.applyFiltering();
426
+ // apply quick search if there is one
427
+ // yes, we could have put this on the gridOptions.findSearchValue
428
+ // but we need to wait for setupColumns to run first so as to correctly
429
+ // determine on which columns the quick search should be applied or not
430
+ // and also to setup the quick search style
431
+ const quickSearchState = this.api.stateApi.getQuickSearchState();
432
+ if (quickSearchState.QuickSearchText) {
433
+ this.setAgGridFindSearchValue(quickSearchState.QuickSearchText);
434
+ }
425
435
  this.addGridEventListeners();
426
436
  this.temporaryAdaptableStateUpdates();
427
437
  this.redrawBody();
428
438
  this.refreshHeader();
429
439
  const currentLayout = this.api.layoutApi.getCurrentLayout();
430
440
  (0, LayoutHelpers_1.checkForDuplicateColumns)(currentLayout);
441
+ this.__prevLayoutForRefresh = currentLayout;
431
442
  if ((0, LayoutHelpers_1.isPivotLayout)(currentLayout)) {
432
443
  // this is very very strange!
433
444
  // for some projects, if the initial layout is pivot, the columnDefs of the pivot resutl columns are NOT derived correctly from the main colDefs
@@ -441,7 +452,9 @@ class AdaptableAgGrid {
441
452
  // see test /tests/pages/quick-search/pivot-search.spec.ts
442
453
  this.updateColumnModelAndRefreshGrid();
443
454
  }
444
- this.layoutManager.applyRowGroupValues((0, LayoutHelpers_1.layoutStateToLayoutModel)(currentLayout).RowGroupValues);
455
+ const layoutModelForApply = (0, LayoutHelpers_1.layoutStateToLayoutModel)(currentLayout);
456
+ this.layoutManager.applyRowGroupValues(layoutModelForApply.RowGroupValues);
457
+ this.layoutManager.applyColumnGroupCollapseExpandState(layoutModelForApply);
445
458
  this.autoSizeLayoutIfNeeded();
446
459
  this.ModuleService.createModuleUIItems();
447
460
  const adaptableContainerElem = this.getAdaptableContainerElement();
@@ -765,10 +778,14 @@ You need to define at least one Layout!`);
765
778
  if (!this.isAvailable) {
766
779
  return true;
767
780
  }
768
- const isColumnFiltersActive = ArrayExtensions_1.default.IsNotNullOrEmpty(this.api.filterApi.columnFilterApi.getActiveColumnFilters());
769
781
  const isGridFilterActive = StringExtensions_1.default.IsNotNullOrEmpty(this.api.filterApi.gridFilterApi.getCurrentGridFilterExpression());
770
- return (isColumnFiltersActive ||
771
- isGridFilterActive ||
782
+ const isTableColumnFiltersActive = ArrayExtensions_1.default.IsNotNullOrEmpty(this.api.filterApi.columnFilterApi
783
+ .getActiveColumnFilters()
784
+ .filter((columnFilter) => !this.api.columnApi.isPivotResultColumn(columnFilter.ColumnId)));
785
+ return (isGridFilterActive ||
786
+ // only Table ColumnFilters are handled here
787
+ // see #doAggregateFiltersPassMonkeyPatcher for filtering Pivot Columns
788
+ isTableColumnFiltersActive ||
772
789
  // it means that userPropertyValue will be called so we re-init that collection
773
790
  (original_isExternalFilterPresent ? original_isExternalFilterPresent(params) : false));
774
791
  };
@@ -781,10 +798,20 @@ You need to define at least one Layout!`);
781
798
  if (!this.isAvailable) {
782
799
  return true;
783
800
  }
784
- // Note: not sure we need this check as doubtful AG Grid ever passes in a Group Row node to filter...
785
- // But if it does, then we might change this IF we allow Column filtering (but not Grid Filters) for Group nodes
786
801
  if (this.isGroupRowNode(node)) {
787
- return true;
802
+ if (this.api.gridApi.isTreeDataGrid()) {
803
+ if (node.data == undefined) {
804
+ // Filler Groups are not filterable
805
+ // see https://www.ag-grid.com/javascript-data-grid/tree-data-paths/#filler-groups
806
+ return false;
807
+ }
808
+ }
809
+ else {
810
+ // for non-Tree Data Grids, we don't filter Group Rows
811
+ // not sure if that's 100% correct, but we did it like this in the past
812
+ // so we keep it like this for now until bugs are reported
813
+ return true;
814
+ }
788
815
  }
789
816
  // first assess if the Row i s filterable - if not, then return true so it appears in Grid
790
817
  const isRowFilterable = this.api.optionsApi.getFilterOptions().isRowFilterable;
@@ -820,11 +847,15 @@ You need to define at least one Layout!`);
820
847
  }
821
848
  }
822
849
  // finally we evaluate column filters
823
- const columnFilters = this.api.filterApi.columnFilterApi.getActiveColumnFilters();
850
+ const tableColumnFilters = this.api.filterApi.columnFilterApi
851
+ .getActiveColumnFilters()
852
+ .filter((columnFilter) => !this.api.columnApi.isPivotResultColumn(columnFilter.ColumnId));
824
853
  try {
825
- if (columnFilters.length > 0) {
826
- for (const columnFilter of columnFilters) {
827
- const evaluateColumnFilterOnClient = this.api.expressionApi.internalApi.evaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, columnFilter.Predicates);
854
+ // only Table ColumnFilters are handled here
855
+ // see #doAggregateFiltersPassMonkeyPatcher for filtering Pivot Columns
856
+ if (tableColumnFilters.length > 0) {
857
+ for (const columnFilter of tableColumnFilters) {
858
+ const evaluateColumnFilterOnClient = this.api.expressionApi.internalApi.shouldEvaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, columnFilter.Predicates);
828
859
  if (evaluateColumnFilterOnClient) {
829
860
  const columnFilterEvaluationResult = this.api.filterApi.columnFilterApi.internalApi.evaluateColumnFilter(columnFilter, node);
830
861
  if (!columnFilterEvaluationResult) {
@@ -1047,18 +1078,6 @@ You need to define at least one Layout!`);
1047
1078
  // this array reference will be used for the entire AG Grid session
1048
1079
  return this.agGridExportAdapter.DANGER_excelStyles;
1049
1080
  });
1050
- /**
1051
- * `processPivotResultColDef`
1052
- */
1053
- this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'processPivotResultColDef', (original_processPivotResultColDef) => {
1054
- return (colDef) => {
1055
- if (this.adaptableOptions.filterOptions.useAdaptableFiltering) {
1056
- colDef.floatingFilter = false;
1057
- colDef.filter = false;
1058
- }
1059
- original_processPivotResultColDef?.(colDef);
1060
- };
1061
- });
1062
1081
  /**
1063
1082
  * `maintainColumnOrder`
1064
1083
  */
@@ -1099,6 +1118,12 @@ You need to define at least one Layout!`);
1099
1118
  const revertedDateTypeDefinitions = agGridDataTypeDefinitions_1.agGridDataTypeDefinitions;
1100
1119
  return revertedDateTypeDefinitions;
1101
1120
  });
1121
+ this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'findOptions', (original_findOptions) => {
1122
+ return {
1123
+ ...original_findOptions,
1124
+ caseSensitive: !!this.adaptableOptions.quickSearchOptions.isQuickSearchCaseSensitive,
1125
+ };
1126
+ });
1102
1127
  }
1103
1128
  /**
1104
1129
  * Either initializes the AG Grid instance or delegates it to the framework wrappers (React/Anglar)
@@ -1300,6 +1325,17 @@ You need to define at least one Layout!`);
1300
1325
  }
1301
1326
  this.autoSizeLayoutIfNeeded();
1302
1327
  }));
1328
+ /**
1329
+ * Use Case: A format column that has ColumnGroupState needs to be re-evaluated
1330
+ * whenever a column group is expanded or collapsed
1331
+ */
1332
+ this.agGridAdapter.getAgGridApi().addEventListener('columnGroupOpened', (this.listenerColumnGroupOpened = () => {
1333
+ if (this.api.formatColumnApi.getActiveFormatColumns().some((fc) => {
1334
+ return fc.ColumnGroupState != null;
1335
+ })) {
1336
+ this.updateColumnModelAndRefreshGrid();
1337
+ }
1338
+ }));
1303
1339
  /**
1304
1340
  * Use Case: A pivot column has changed
1305
1341
  * Action: Autosize pivot columns (if autosize pivot in Layout is true)
@@ -1635,13 +1671,18 @@ You need to define at least one Layout!`);
1635
1671
  let _rawValue;
1636
1672
  let _displayValue;
1637
1673
  let _normalisedValue;
1638
- let _isPivotCell;
1639
1674
  let _isRowGroupCell;
1675
+ const _isPivotCell = this.api.columnApi.isPivotResultColumn(columnId);
1640
1676
  const self = this;
1641
1677
  const api = this.api;
1642
1678
  const getRawValue = () => {
1643
1679
  if (_rawValue === undefined) {
1644
1680
  _rawValue = self.getRawValueFromRowNode(rowNode, columnId);
1681
+ if (_isPivotCell && _rawValue?.value != undefined) {
1682
+ // for pivot result columns, the raw value is an object with a value property
1683
+ // we want to return the value property as the raw value
1684
+ _rawValue = _rawValue.value;
1685
+ }
1645
1686
  }
1646
1687
  return _rawValue;
1647
1688
  };
@@ -1680,9 +1721,6 @@ You need to define at least one Layout!`);
1680
1721
  return _primaryKeyValue;
1681
1722
  },
1682
1723
  get isPivotCell() {
1683
- if (_isPivotCell === undefined) {
1684
- _isPivotCell = api.columnApi.isPivotResultColumn(columnId);
1685
- }
1686
1724
  return _isPivotCell;
1687
1725
  },
1688
1726
  get isRowGroupCell() {
@@ -1751,6 +1789,26 @@ You need to define at least one Layout!`);
1751
1789
  return formattedValue || '';
1752
1790
  }
1753
1791
  }
1792
+ else if (this.api.columnApi.isPivotResultColumn(columnId)) {
1793
+ const pivotResultColumn = this.agGridAdapter
1794
+ .getAgGridApi()
1795
+ .getPivotResultColumns()
1796
+ .find((col) => col.getColId() === columnId);
1797
+ const pivotResultColDef = pivotResultColumn?.getColDef();
1798
+ if (pivotResultColDef && typeof pivotResultColDef.valueFormatter === 'function') {
1799
+ const params = {
1800
+ value: rawValue,
1801
+ node: rowNode,
1802
+ data: rowNode.data,
1803
+ colDef: pivotResultColDef,
1804
+ column: pivotResultColumn,
1805
+ api: this.agGridAdapter.getAgGridApi(),
1806
+ context: this.agGridAdapter.getGridOption('context'),
1807
+ };
1808
+ const formattedValue = pivotResultColDef.valueFormatter(params);
1809
+ return formattedValue || '';
1810
+ }
1811
+ }
1754
1812
  return this.getCleanValue(rawValue);
1755
1813
  }
1756
1814
  getCleanValue(value) {
@@ -2194,6 +2252,9 @@ You need to define at least one Layout!`);
2194
2252
  get visible() {
2195
2253
  return gridCell.visible;
2196
2254
  },
2255
+ get visibleCount() {
2256
+ return gridCell.visibleCount;
2257
+ },
2197
2258
  };
2198
2259
  });
2199
2260
  return result;
@@ -2208,6 +2269,9 @@ You need to define at least one Layout!`);
2208
2269
  get visible() {
2209
2270
  return gridCell.visible;
2210
2271
  },
2272
+ get visibleCount() {
2273
+ return gridCell.visibleCount;
2274
+ },
2211
2275
  };
2212
2276
  });
2213
2277
  return result;
@@ -2272,8 +2336,9 @@ You need to define at least one Layout!`);
2272
2336
  }
2273
2337
  getDistinctGridCellsForColumn(column) {
2274
2338
  let gridCells = [];
2339
+ const isPivotResultColumn = column.isGeneratedPivotResultColumn;
2275
2340
  this.agGridAdapter.getAgGridApi().forEachNode((rowNode) => {
2276
- const gridCell = this.addDistinctColumnValue(rowNode, column.columnId);
2341
+ const gridCell = this.addDistinctColumnValue(rowNode, column.columnId, isPivotResultColumn);
2277
2342
  if (gridCell) {
2278
2343
  gridCells.push(gridCell);
2279
2344
  }
@@ -2298,17 +2363,36 @@ You need to define at least one Layout!`);
2298
2363
  return gridCells;
2299
2364
  }
2300
2365
  }
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_1.Helper.objectExists(returnValue)) {
2307
- return returnValue;
2366
+ addDistinctColumnValue(rowNode, columnId, isPivotResultColumn) {
2367
+ if (!rowNode) {
2368
+ return;
2369
+ }
2370
+ if (!isPivotResultColumn && this.isGroupRowNode(rowNode)) {
2371
+ if (this.api.gridApi.isTreeDataGrid()) {
2372
+ if (rowNode.data == undefined) {
2373
+ // skip Tree Filler Groups
2374
+ // see https://www.ag-grid.com/javascript-data-grid/tree-data-paths/#filler-groups
2375
+ return;
2376
+ }
2377
+ }
2378
+ else {
2379
+ // for normal Table Columns we do NOT return the values of the aggregates
2380
+ return;
2308
2381
  }
2309
2382
  }
2310
- else {
2311
- return undefined;
2383
+ if (isPivotResultColumn) {
2384
+ // if it's a Pivot Result Column, we are interested only in the aggregated(pivoted) data
2385
+ if (!rowNode.aggData) {
2386
+ return;
2387
+ }
2388
+ if (!rowNode.leafGroup) {
2389
+ // if it's a Pivot Result Column, we are interested only in the leaf groups (pivot results, NOT group aggregates)
2390
+ return;
2391
+ }
2392
+ }
2393
+ const returnValue = this.getGridCellFromRowNode(rowNode, columnId);
2394
+ if (Helper_1.Helper.objectExists(returnValue)) {
2395
+ return returnValue;
2312
2396
  }
2313
2397
  }
2314
2398
  getUniqueGridCells(column, gridCells) {
@@ -2356,6 +2440,11 @@ You need to define at least one Layout!`);
2356
2440
  return (rowNodesWithSameCellValue.findIndex((pk) => self.isRowNodeAvailableAfterFiltering(pk) === true) !== -1);
2357
2441
  },
2358
2442
  });
2443
+ Object.defineProperty(cellWithCount, 'visibleCount', {
2444
+ get: () => {
2445
+ return rowNodesWithSameCellValue.filter((pk) => self.isRowNodeAvailableAfterFiltering(pk) === true).length;
2446
+ },
2447
+ });
2359
2448
  result.push(cellWithCount);
2360
2449
  });
2361
2450
  return result;
@@ -2671,6 +2760,9 @@ You need to define at least one Layout!`);
2671
2760
  clearAgGridQuickSearch() {
2672
2761
  this.setAgGridQuickSearch('');
2673
2762
  }
2763
+ setAgGridFindSearchValue(searchText) {
2764
+ this.agGridAdapter.setGridOption('findSearchValue', searchText);
2765
+ }
2674
2766
  applyAdaptableTheme(theme) {
2675
2767
  const container = this.getAgGridContainerElement();
2676
2768
  if (container != null) {
@@ -2839,10 +2931,12 @@ You need to define at least one Layout!`);
2839
2931
  agGridApi.removeEventListener('columnPivotChanged', this.listenerPivotChanged);
2840
2932
  agGridApi.removeEventListener('cellEditingStarted', this.listenerCellEditingStarted);
2841
2933
  agGridApi.removeEventListener('cellSelectionChanged', this.listenerCellSelectionChanged);
2934
+ agGridApi.removeEventListener('columnGroupOpened', this.listenerColumnGroupOpened);
2842
2935
  agGridApi.removeEventListener('sortChanged', this.listenerSortChanged);
2843
2936
  agGridApi.removeGlobalListener(this.listenerGlobalSetRowSelection);
2844
2937
  this.listenerFirstDataRendered = null;
2845
2938
  this.listenerPivotChanged = null;
2939
+ this.listenerColumnGroupOpened = null;
2846
2940
  this.listenerCellEditingStarted = null;
2847
2941
  this.listenerCellSelectionChanged = null;
2848
2942
  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;
@@ -20,6 +20,8 @@ class AgGridAdapter {
20
20
  constructor(_adaptableInstance, config) {
21
21
  this._adaptableInstance = _adaptableInstance;
22
22
  const columnApiModuleReference = config?.getAgGridColumnApiModuleReference?.() ?? getColumnApiModule();
23
+ const beans = columnApiModuleReference?.beans;
24
+ console.log(beans?.length);
23
25
  const ColumnDefFactory_Prototype = columnApiModuleReference?.beans?.[0]?.prototype;
24
26
  if (!ColumnDefFactory_Prototype) {
25
27
  console.error(`CRITICAL: could not get hold of AG Grid beans, this should never happen!`);
@@ -42,6 +44,8 @@ class AgGridAdapter {
42
44
  this.DANGER_gridApi_from_args = null;
43
45
  this.DANGER_USE_GETTER_gridApi = null;
44
46
  this.DANGER_updateGridOptionsMonkeyPatcher = null;
47
+ this.DANGER_doAggregateFiltersPassMonkeyPatcher = null;
48
+ this.DANGER_isAggregateFilterPresentMonkeyPatcher = null;
45
49
  this._adaptableInstance = null;
46
50
  }
47
51
  get adaptableOptions() {
@@ -75,7 +79,7 @@ class AgGridAdapter {
75
79
  }
76
80
  // #gridOpts_monkey_patch
77
81
  // we need to intercept some of the GridOptions updates and refresh the Adaptable state
78
- monkeyPatchingGridOptionsUpdates(agGridApi) {
82
+ monkeyPatchingGridOptionsUpdates() {
79
83
  const agGridOptionsService = this.DANGER_getPrivateAgGridBeans()?.gos;
80
84
  if (!agGridOptionsService) {
81
85
  return;
@@ -111,6 +115,57 @@ class AgGridAdapter {
111
115
  };
112
116
  agGridOptionsService.updateGridOptions = this.DANGER_updateGridOptionsMonkeyPatcher;
113
117
  }
118
+ monkeyPatchingAggColumnFilters() {
119
+ if (!this.adaptableApi.optionsApi.getFilterOptions().useAdaptableFiltering) {
120
+ // monkey patching is only needed if Adaptable is used for filtering
121
+ return;
122
+ }
123
+ const agGridColumnFilterService = this.DANGER_getPrivateAgGridBeans()?.colFilter;
124
+ if (!agGridColumnFilterService) {
125
+ this.logger.consoleError('Could not get hold of ColumnFilterService! This is a critical error and will prevent Adaptable from working correctly.');
126
+ return;
127
+ }
128
+ const self = this;
129
+ // https://github.com/ag-grid/ag-grid/blob/8409e99c8010473356a878e9bdfb836a5ea16718/packages/ag-grid-community/src/filter/columnFilterService.ts#L240
130
+ // monkey patch ColumnFilterService.doAggregateFiltersPass because currently Adaptable does NOT override the ColumnFilters
131
+ // (it uses the `doesExternalFilterPass` to evaluate the filters on the client side)
132
+ // #doAggregateFiltersPassMonkeyPatcher
133
+ this.DANGER_doAggregateFiltersPassMonkeyPatcher = function (rowNode, filterToSkip) {
134
+ if (!self.adaptableApi.layoutApi.isCurrentLayoutPivot()) {
135
+ // should NEVER happen
136
+ return true;
137
+ }
138
+ const pivotColumnFilters = self.adaptableApi.filterApi.columnFilterApi
139
+ .getActiveColumnFilters()
140
+ .filter((columnFilter) => self.adaptableApi.columnApi.isPivotResultColumn(columnFilter.ColumnId));
141
+ try {
142
+ if (pivotColumnFilters.length > 0) {
143
+ for (const columnFilter of pivotColumnFilters) {
144
+ const evaluateColumnFilterOnClient = self.adaptableApi.expressionApi.internalApi.shouldEvaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, columnFilter.Predicates);
145
+ if (evaluateColumnFilterOnClient) {
146
+ const columnFilterEvaluationResult = self.adaptableApi.filterApi.columnFilterApi.internalApi.evaluateColumnFilter(columnFilter, rowNode);
147
+ if (!columnFilterEvaluationResult) {
148
+ return false;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ catch (ex) {
155
+ self.logger.error(ex);
156
+ return true;
157
+ }
158
+ return true;
159
+ };
160
+ agGridColumnFilterService.doAggregateFiltersPass =
161
+ this.DANGER_doAggregateFiltersPassMonkeyPatcher;
162
+ this.DANGER_isAggregateFilterPresentMonkeyPatcher = function () {
163
+ const columnFilters = self.adaptableApi.filterApi.columnFilterApi.getActiveColumnFilters();
164
+ return columnFilters.some((colFilter) => self.adaptableApi.columnApi.isPivotResultColumn(colFilter.ColumnId));
165
+ };
166
+ agGridColumnFilterService.isAggregateFilterPresent =
167
+ this.DANGER_isAggregateFilterPresentMonkeyPatcher;
168
+ }
114
169
  DANGER_getPrivateAgGridBeans() {
115
170
  const beans = DANGER_AG_GRID_BEANS_MAP[this._agGridId];
116
171
  if (!beans) {
@@ -163,12 +218,21 @@ class AgGridAdapter {
163
218
  }
164
219
  }
165
220
  updateGridOptions(options) {
221
+ if (this.getAgGridApi()?.isDestroyed()) {
222
+ return;
223
+ }
166
224
  this.getAgGridApi()?.updateGridOptions(options);
167
225
  }
168
226
  getGridOption(key) {
227
+ if (this.getAgGridApi()?.isDestroyed()) {
228
+ return;
229
+ }
169
230
  return this.getAgGridApi()?.getGridOption(key);
170
231
  }
171
232
  setGridOption(key, value) {
233
+ if (this.getAgGridApi()?.isDestroyed()) {
234
+ return;
235
+ }
172
236
  this.getAgGridApi()?.setGridOption(key, value);
173
237
  }
174
238
  getUserGridOptionsProperty(propertyName) {
@@ -457,10 +521,21 @@ class AgGridAdapter {
457
521
  this.logger.warn(`Column is undefined, returning 'text' for Type`);
458
522
  return 'text';
459
523
  }
460
- if (agColumn.getId() === GeneralConstants_1.AG_GRID_GROUPED_COLUMN ||
461
- agColumn.getId() === GeneralConstants_1.AG_GRID_SELECTION_COLUMN) {
524
+ if (this.adaptableApi.columnApi.isAutoRowGroupColumnForSingle(agColumn.getId()) ||
525
+ this.adaptableApi.columnApi.isSelectionColumn(agColumn.getId())) {
462
526
  return 'unknown';
463
527
  }
528
+ if (this.adaptableApi.columnApi.isAutoRowGroupColumnForMulti(agColumn.getId())) {
529
+ const rowGroupKey = agColumn.getColDef().showRowGroup;
530
+ if (typeof rowGroupKey !== 'string') {
531
+ return 'unknown';
532
+ }
533
+ const groupedColumn = this.adaptableApi.agGridApi.getColumn(rowGroupKey);
534
+ if (!groupedColumn) {
535
+ return 'unknown';
536
+ }
537
+ return this.deriveAdaptableColumnDataType(groupedColumn, logWarning);
538
+ }
464
539
  const colDefType = [].concat(agColumn.getColDef()?.type || []).filter(Boolean);
465
540
  const skippedSpecialCols = ['actionColumn', 'fdc3Column'];
466
541
  if (skippedSpecialCols.some((specialColType) => colDefType.includes(specialColType))) {
@@ -487,15 +562,17 @@ class AgGridAdapter {
487
562
  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.`);
488
563
  return 'unknown';
489
564
  }
490
- // if it's a group we need the content of the group
491
- if (row.group) {
492
- const childNodes = row.childrenAfterGroup;
493
- if (ArrayExtensions_1.default.IsNullOrEmpty(childNodes)) {
494
- 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.`);
495
- return 'unknown';
496
- }
497
- row = childNodes[0];
498
- }
565
+ // // if it's a group we need the content of the group
566
+ // if (row.group) {
567
+ // const childNodes = row.childrenAfterGroup;
568
+ // if (ArrayExtensions.IsNullOrEmpty(childNodes)) {
569
+ // this.logger.consoleError(
570
+ // `No data in grid, returning type "unknown" for Column: "${agColumn.getColId()}". This will impact several Adaptable features, such as Filters and ColumnFormats.`
571
+ // );
572
+ // return 'unknown';
573
+ // }
574
+ // row = childNodes[0];
575
+ // }
499
576
  const value = this._agGridApi_getValue(agColumn, row);
500
577
  switch (typeof value) {
501
578
  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;