@adaptabletools/adaptable-cjs 18.0.0-canary.28 → 18.0.0-canary.29

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 (54) hide show
  1. package/base.css +3 -13
  2. package/base.css.map +1 -1
  3. package/index.css +3 -13
  4. package/index.css.map +1 -1
  5. package/package.json +1 -1
  6. package/src/AdaptableOptions/AdaptableFrameworkComponent.d.ts +3 -0
  7. package/src/AdaptableOptions/MenuOptions.d.ts +1 -1
  8. package/src/Api/GridApi.d.ts +4 -1
  9. package/src/Api/Implementation/ConfigApiImpl.js +0 -1
  10. package/src/Api/Implementation/GridApiImpl.d.ts +1 -1
  11. package/src/Api/Implementation/GridApiImpl.js +6 -1
  12. package/src/Api/Implementation/UserInterfaceApiImpl.d.ts +14 -5
  13. package/src/Api/Implementation/UserInterfaceApiImpl.js +26 -4
  14. package/src/Api/Internal/AdaptableInternalApi.d.ts +0 -1
  15. package/src/Api/Internal/AdaptableInternalApi.js +2 -6
  16. package/src/Api/Internal/FormatColumnInternalApi.js +6 -2
  17. package/src/Api/Internal/LayoutInternalApi.js +1 -1
  18. package/src/Api/UserInterfaceApi.d.ts +15 -2
  19. package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
  20. package/src/PredefinedConfig/Common/Menu.d.ts +1 -1
  21. package/src/PredefinedConfig/Common/Menu.js +22 -12
  22. package/src/PredefinedConfig/FormatColumnState.d.ts +4 -0
  23. package/src/PredefinedConfig/PopupState.d.ts +1 -2
  24. package/src/PredefinedConfig/StyledColumnState.d.ts +5 -0
  25. package/src/PredefinedConfig/SystemState.d.ts +4 -2
  26. package/src/Redux/ActionsReducers/PopupRedux.d.ts +5 -13
  27. package/src/Redux/ActionsReducers/PopupRedux.js +1 -22
  28. package/src/Redux/ActionsReducers/SystemRedux.d.ts +9 -3
  29. package/src/Redux/ActionsReducers/SystemRedux.js +8 -5
  30. package/src/Strategy/ExportModule.d.ts +0 -1
  31. package/src/Strategy/ExportModule.js +37 -26
  32. package/src/Strategy/LayoutModule.d.ts +1 -8
  33. package/src/Strategy/LayoutModule.js +3 -113
  34. package/src/Strategy/StyledColumnModule.js +5 -2
  35. package/src/Strategy/Utilities/FormatColumn/getFormatColumnSettingsViewItems.js +1 -0
  36. package/src/Utilities/Interface/MessagePopups.d.ts +0 -3
  37. package/src/Utilities/Services/RowSummaryService.d.ts +22 -0
  38. package/src/Utilities/Services/RowSummaryService.js +146 -0
  39. package/src/View/FormatColumn/Wizard/FormatColumnSettingsWizardSection.js +11 -2
  40. package/src/View/StyledColumn/Wizard/StyledColumnWizard.js +1 -1
  41. package/src/View/StyledColumn/Wizard/StyledColumnWizardSettingsSection.js +14 -10
  42. package/src/agGrid/AgGridColumnAdapter.js +19 -13
  43. package/src/agGrid/AgGridMenuAdapter.d.ts +5 -0
  44. package/src/agGrid/AgGridMenuAdapter.js +111 -57
  45. package/src/agGrid/BadgeRenderer.js +7 -1
  46. package/src/agGrid/PercentBarRenderer.js +3 -1
  47. package/src/components/ProgressIndicator/ProgressIndicator.js +15 -6
  48. package/src/components/icons/copy.d.ts +3 -0
  49. package/src/components/icons/copy.js +7 -0
  50. package/src/components/icons/index.js +2 -0
  51. package/src/env.js +2 -2
  52. package/src/metamodel/adaptable.metamodel.js +1 -1
  53. package/src/types.d.ts +1 -1
  54. package/tsconfig.cjs.tsbuildinfo +1 -1
@@ -50,58 +50,69 @@ class ExportModule extends AdaptableModuleBase_1.AdaptableModuleBase {
50
50
  return;
51
51
  }
52
52
  let returnMenuItems = [];
53
- const canExportCells = menuContext.selectedCellInfo &&
53
+ const availableSystemReports = this.api.exportApi.getAvailableSystemReports();
54
+ if (availableSystemReports.includes(GeneralConstants_1.VISUAL_DATA_REPORT)) {
55
+ returnMenuItems.push(this.createMenuItemClickFunction('export-visual-data-excel', 'Excel', this.moduleInfo.Glyph, () => this.export(this.api.exportApi.getReportByName(GeneralConstants_1.VISUAL_DATA_REPORT), Enums_1.ExportDestination.Excel)));
56
+ }
57
+ if (availableSystemReports.includes(GeneralConstants_1.ALL_DATA_REPORT)) {
58
+ const allDataReport = this.api.exportApi.getReportByName(GeneralConstants_1.ALL_DATA_REPORT);
59
+ returnMenuItems.push(...this.buildReportMenuItems(allDataReport));
60
+ }
61
+ if (availableSystemReports.includes(GeneralConstants_1.CURRENT_DATA_REPORT)) {
62
+ const currentDataReport = this.api.exportApi.getReportByName(GeneralConstants_1.CURRENT_DATA_REPORT);
63
+ returnMenuItems.push(...this.buildReportMenuItems(currentDataReport));
64
+ }
65
+ const canExportCells = availableSystemReports.includes(GeneralConstants_1.SELECTED_CELLS_REPORT) &&
66
+ menuContext.selectedCellInfo &&
54
67
  ArrayExtensions_1.default.IsNotNullOrEmpty(menuContext.selectedCellInfo.columns) &&
55
68
  ArrayExtensions_1.default.IsNotNullOrEmpty(menuContext.selectedCellInfo.gridCells);
56
- const canExportRows = menuContext.selectedRowInfo &&
69
+ if (canExportCells) {
70
+ const selectedCellReport = this.api.exportApi.getReportByName(GeneralConstants_1.SELECTED_CELLS_REPORT);
71
+ returnMenuItems.push(...this.buildReportMenuItems(selectedCellReport));
72
+ }
73
+ const canExportRows = availableSystemReports.includes(GeneralConstants_1.SELECTED_ROWS_REPORT) &&
74
+ menuContext.selectedRowInfo &&
57
75
  ArrayExtensions_1.default.IsNotNullOrEmpty(menuContext.selectedRowInfo.gridRows) &&
58
76
  menuContext.gridCell &&
59
77
  menuContext.gridCell.primaryKeyValue &&
60
78
  menuContext.isSelectedRow;
61
- if (canExportCells) {
62
- const selectedCellReport = this.api.exportApi.getReportByName(GeneralConstants_1.SELECTED_CELLS_REPORT);
63
- returnMenuItems.push(...this.buildReportMenuItems(selectedCellReport, 'cells'));
64
- }
65
79
  if (canExportRows) {
66
80
  const selectedRowReport = this.api.exportApi.getReportByName(GeneralConstants_1.SELECTED_ROWS_REPORT);
67
- returnMenuItems.push(...this.buildReportMenuItems(selectedRowReport, 'rows'));
81
+ returnMenuItems.push(...this.buildReportMenuItems(selectedRowReport));
68
82
  }
69
83
  return returnMenuItems;
70
84
  }
71
- buildReportMenuItems(report, selectionType) {
85
+ buildReportMenuItems(report) {
86
+ // a bit convoluted, but ce la vie, that's what happens when you use enums instead of union types
87
+ // convert to lowercase and replace empty spaces with hyphens
88
+ const adjustName = (name = '') => {
89
+ const result = name.replace(/ /g, '-');
90
+ return result.toLowerCase();
91
+ };
92
+ const getMenuItemName = (reportName, destination) => {
93
+ return `export-${adjustName(reportName)}-${adjustName(destination)}`;
94
+ };
72
95
  const menuItems = [];
73
96
  for (const destination of this.api.exportApi.getAvailableExportDestinations()) {
74
- menuItems.push(this.createMenuItemClickFunction(this.getMenuName(destination, selectionType), destination, this.moduleInfo.Glyph, () => this.export(report, destination)));
97
+ menuItems.push(this.createMenuItemClickFunction(getMenuItemName(report.Name, destination), destination, this.moduleInfo.Glyph, () => this.export(report, destination)));
75
98
  }
76
99
  for (const customDestination of this.api.exportApi.getCustomDestinations()) {
77
- menuItems.push(this.createMenuItemClickFunction(`export-${selectionType}-custom-destination`, customDestination.name, this.moduleInfo.Glyph, () => this.export(report, customDestination.name)));
100
+ menuItems.push(this.createMenuItemClickFunction(getMenuItemName(report.Name, customDestination.name), customDestination.name, this.moduleInfo.Glyph, () => this.export(report, customDestination.name)));
78
101
  }
79
102
  return menuItems;
80
103
  }
81
- getMenuName(exportDestination, selectionType) {
82
- switch (exportDestination) {
83
- case Enums_1.ExportDestination.CSV:
84
- return `export-${selectionType}-csv`;
85
- case Enums_1.ExportDestination.Clipboard:
86
- return `export-${selectionType}-clipboard`;
87
- case Enums_1.ExportDestination.Excel:
88
- return `export-${selectionType}-excel`;
89
- case Enums_1.ExportDestination.JSON:
90
- return `export-${selectionType}-json`;
91
- case Enums_1.ExportDestination.Table:
92
- return `export-${selectionType}-table`;
93
- }
94
- }
95
104
  async export(report, exportDestination) {
96
105
  var _a;
97
106
  const cleanupExportProcess = () => {
98
107
  this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemVisualExportEnd)());
99
- this.api.internalApi.hideProgressIndicator();
108
+ this.api.userInterfaceApi.hideProgressIndicator();
100
109
  };
101
110
  if (report.Name === GeneralConstants_1.VISUAL_DATA_REPORT) {
102
111
  this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemVisualExportBegin)());
103
112
  }
104
- this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemProgressIndicatorShow)(`${report.Name} Export in progress...`));
113
+ this.api.userInterfaceApi.showProgressIndicator({
114
+ text: `${report.Name} Export in progress...`,
115
+ });
105
116
  try {
106
117
  // waitForTimeout required to give the ProgressIndicator rendering a head-start (see rAF in ProgressIndicator implementation)
107
118
  await (0, waitForTimeout_1.waitForTimeout)(16);
@@ -7,13 +7,11 @@ import { AdaptableColumn } from '../PredefinedConfig/Common/AdaptableColumn';
7
7
  import { AdaptableApi } from '../Api/AdaptableApi';
8
8
  import { AdaptableModuleView, IModule, TeamSharingReferences } from './Interface/IModule';
9
9
  import { AdaptableObject } from '../PredefinedConfig/Common/AdaptableObject';
10
- import { AggregatedScalarLiveValue } from '../Utilities/Services/AggregatedScalarLiveValue';
11
10
  export declare class LayoutModule extends AdaptableModuleBase implements IModule {
12
- cachedCellSummary: Map<string, AggregatedScalarLiveValue>;
13
11
  protected LayoutState: LayoutState;
12
+ private rowSummaryService;
14
13
  constructor(api: AdaptableApi);
15
14
  onAdaptableReady(): void;
16
- rowSummariesSubscriptions(): void;
17
15
  getModuleAdaptableObjects(): AdaptableObject[];
18
16
  getExplicitlyReferencedColumnIds(layout: Layout): string[];
19
17
  getTeamSharingReferences(adaptableObject: AdaptableObject): TeamSharingReferences;
@@ -45,9 +43,4 @@ export declare class LayoutModule extends AdaptableModuleBase implements IModule
45
43
  getViewProperties(): AdaptableModuleView;
46
44
  handleLayoutChange(): void;
47
45
  getReferencedNamedQueryNames(layout: Layout): string[];
48
- /**
49
- *
50
- * @param colId optional to evaluate only one column
51
- */
52
- private evaluateRowSummary;
53
46
  }
@@ -19,16 +19,14 @@ const windowFactory_1 = require("../View/Components/Popups/WindowPopups/windowFa
19
19
  const flattenDeep_1 = tslib_1.__importDefault(require("lodash/flattenDeep"));
20
20
  const StringExtensions_1 = tslib_1.__importDefault(require("../Utilities/Extensions/StringExtensions"));
21
21
  const getGridFilterPreview_1 = require("../View/Layout/Wizard/getGridFilterPreview");
22
- const AggregatedScalarLiveValue_1 = require("../Utilities/Services/AggregatedScalarLiveValue");
23
- const SystemRedux_1 = require("../Redux/ActionsReducers/SystemRedux");
24
- const RowSummary_1 = require("../PredefinedConfig/Common/RowSummary");
25
- const Helper_1 = tslib_1.__importDefault(require("../Utilities/Helpers/Helper"));
22
+ const RowSummaryService_1 = require("../Utilities/Services/RowSummaryService");
26
23
  class LayoutModule extends AdaptableModuleBase_1.AdaptableModuleBase {
27
24
  constructor(api) {
28
25
  super(ModuleConstants.LayoutModuleId, ModuleConstants.LayoutFriendlyName, 'grid', 'LayoutPopup', 'Named sets of column visibility, order, groupings, aggregation, pivots etc.', api);
29
- this.cachedCellSummary = new Map();
26
+ this.rowSummaryService = new RowSummaryService_1.RowSummaryService(this.api);
30
27
  }
31
28
  onAdaptableReady() {
29
+ this.rowSummaryService.onAdapterReady();
32
30
  this.api.eventApi.on('LayoutChanged', (layoutChangedInfo) => {
33
31
  var _a;
34
32
  if (layoutChangedInfo.newLayoutState.CurrentLayout !==
@@ -40,49 +38,6 @@ class LayoutModule extends AdaptableModuleBase_1.AdaptableModuleBase {
40
38
  requestAnimationFrame(() => {
41
39
  this.api.layoutApi.internalApi.fireLayoutChangedEvent('ADAPTABLE_READY', null, this.api.layoutApi.getLayoutState());
42
40
  });
43
- this.rowSummariesSubscriptions();
44
- }
45
- rowSummariesSubscriptions() {
46
- if (this.api.isDestroyed()) {
47
- return;
48
- }
49
- // Currently not available for serverside model
50
- if (!this.api.layoutApi.internalApi.getLayoutSupportedFeatures().RowSummaries) {
51
- return;
52
- }
53
- // ROW SUMMARY
54
- this.evaluateRowSummary();
55
- this.api.eventApi.on('AdaptableStateReloaded', () => {
56
- this.evaluateRowSummary();
57
- });
58
- this.api.eventApi.on('GridDataChanged', (event) => {
59
- this.evaluateRowSummary();
60
- });
61
- this.api.eventApi.on('CellChanged', (event) => {
62
- const columnId = event.cellChange.column.columnId;
63
- this.evaluateRowSummary({
64
- columnId,
65
- });
66
- });
67
- this.api.eventApi.on('LayoutChanged', (event) => {
68
- // exclude filter events, those are handled in another event
69
- if (event.actionName.includes('FILTER')) {
70
- return;
71
- }
72
- setTimeout(() => {
73
- // the timeout is added so the grid has time to repond to the layout changed
74
- this.evaluateRowSummary();
75
- }, 16);
76
- });
77
- const adaptable = this.api.internalApi.getAdaptableInstance();
78
- adaptable._on('AdapTableFiltersApplied', () => {
79
- // we need to use this instead of layout changed
80
- // so the rows have time to update
81
- this.evaluateRowSummary();
82
- });
83
- adaptable._on('FirstDataRendered', () => {
84
- this.evaluateRowSummary();
85
- });
86
41
  }
87
42
  getModuleAdaptableObjects() {
88
43
  return this.api.layoutApi.getLayouts();
@@ -448,70 +403,5 @@ class LayoutModule extends AdaptableModuleBase_1.AdaptableModuleBase {
448
403
  }
449
404
  return this.api.namedQueryApi.internalApi.getReferencedNamedQueryNames(layout.GridFilter.Expression);
450
405
  }
451
- /**
452
- *
453
- * @param colId optional to evaluate only one column
454
- */
455
- evaluateRowSummary(reason) {
456
- var _a;
457
- if (this.api.isDestroyed()) {
458
- return;
459
- }
460
- const currentLayout = this.api.layoutApi.getCurrentLayout();
461
- const rowSummaries = (_a = this.api.layoutApi.getCurrentLayout().RowSummaries) !== null && _a !== void 0 ? _a : [];
462
- const rowSummariesResults = rowSummaries.map(({ ColumnsMap, Position }) => {
463
- return {
464
- Position,
465
- RowData: Object.entries(ColumnsMap !== null && ColumnsMap !== void 0 ? ColumnsMap : {}).reduce((acc, [columnId, expression]) => {
466
- const key = `${columnId}-${expression}`;
467
- let expressionLiveValue = this.cachedCellSummary.get(key);
468
- if (expressionLiveValue) {
469
- if (!reason) {
470
- // refresh all of them
471
- expressionLiveValue.refresh();
472
- }
473
- else if ('columnId' in reason && reason.columnId === columnId) {
474
- expressionLiveValue.refresh();
475
- }
476
- }
477
- if (!expressionLiveValue) {
478
- try {
479
- let aggregatedScalarExpression = `${expression}([${columnId}])`;
480
- if (aggregatedScalarExpression.includes(RowSummary_1.WEIGHTED_AVERAGE_AGGREATED_FUNCTION) &&
481
- currentLayout.AggregationColumns[columnId] &&
482
- typeof currentLayout.AggregationColumns[columnId] === 'object') {
483
- const weight = currentLayout.AggregationColumns[columnId]
484
- .weightedColumnId;
485
- if (weight) {
486
- aggregatedScalarExpression = `AVG([${columnId}], WEIGHT([${weight}]))`;
487
- }
488
- }
489
- expressionLiveValue = new AggregatedScalarLiveValue_1.AggregatedScalarLiveValue({
490
- aggregatedScalarExpression,
491
- }, ModuleConstants.LayoutModuleId, this.api, () => {
492
- return this.api.gridApi.getVisibleRowNodes();
493
- });
494
- }
495
- catch (e) {
496
- this.api.logError('Error evaluating row summary', e);
497
- }
498
- this.cachedCellSummary.set(key, expressionLiveValue);
499
- }
500
- let value = null;
501
- if (expressionLiveValue) {
502
- value = expressionLiveValue.getGlobalAggregatedValue();
503
- if (typeof value === 'number' && !isNaN(value)) {
504
- value = Helper_1.default.roundNumber(value, 2);
505
- }
506
- }
507
- acc[columnId] = value;
508
- return acc;
509
- }, {
510
- [RowSummary_1.ROW_SUMMARY_ROW_ID]: true,
511
- }),
512
- };
513
- });
514
- this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemRowSummarySet)(rowSummariesResults));
515
- }
516
406
  }
517
407
  exports.LayoutModule = LayoutModule;
@@ -175,10 +175,13 @@ class StyledColumnModule extends AdaptableModuleBase_1.AdaptableModuleBase {
175
175
  },
176
176
  });
177
177
  }
178
- if (!styledColumn.BadgeStyle) {
178
+ if (styledColumn.BadgeStyle) {
179
179
  specificTypeItems.push({
180
180
  name: 'Settings',
181
- values: [`Include grouped rows: ${styledColumn.IncludeGroupedRows ? 'Yes' : 'No'}`],
181
+ values: [
182
+ `Include grouped rows: ${styledColumn.IncludeGroupedRows ? 'Yes' : 'No'}`,
183
+ `Include row summaries: ${styledColumn.IncludeRowSummaries ? 'Yes' : 'No'}`,
184
+ ],
182
185
  });
183
186
  }
184
187
  if (styledColumn.BadgeStyle) {
@@ -6,6 +6,7 @@ const getFormatColumnSettingsViewItems = (formatColumn) => {
6
6
  const values = [
7
7
  `Cell alignment: ${(_a = formatColumn.CellAlignment) !== null && _a !== void 0 ? _a : 'default'}`,
8
8
  `Include grouped rows: ${formatColumn.IncludeGroupedRows ? 'Yes' : 'No'}`,
9
+ `Include row summaries: ${formatColumn.IncludeRowSummaries ? 'Yes' : 'No'}`,
9
10
  ].filter(Boolean);
10
11
  return {
11
12
  name: 'Settings',
@@ -32,9 +32,6 @@ export interface ScreenPopup {
32
32
  [key: string]: any;
33
33
  };
34
34
  }
35
- export interface LoadingPopup {
36
- ShowLoadingPopup: boolean;
37
- }
38
35
  export interface ConfirmationPopup {
39
36
  ShowConfirmationPopup: boolean;
40
37
  Header: string;
@@ -0,0 +1,22 @@
1
+ import { AdaptableApi, Layout } from '../../types';
2
+ import { AggregatedScalarLiveValue } from './AggregatedScalarLiveValue';
3
+ /**
4
+ * The logic is extracted here to make it easier to follow
5
+ */
6
+ export declare class RowSummaryService {
7
+ private api;
8
+ cachedCellSummary: Map<string, AggregatedScalarLiveValue>;
9
+ previousRowSummaries: any;
10
+ previousLayout: Layout | null;
11
+ debouncedEvaluateRowSummary: import("lodash").DebouncedFunc<(reason?: {
12
+ columnId: string;
13
+ }) => void>;
14
+ constructor(api: AdaptableApi);
15
+ onAdapterReady(): void;
16
+ rowSummariesSubscriptions(): void;
17
+ /**
18
+ *
19
+ * @param colId optional to evaluate only one column
20
+ */
21
+ private evaluateRowSummary;
22
+ }
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RowSummaryService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const lodash_1 = require("lodash");
6
+ const RowSummary_1 = require("../../PredefinedConfig/Common/RowSummary");
7
+ const SystemRedux_1 = require("../../Redux/ActionsReducers/SystemRedux");
8
+ const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
9
+ const Helper_1 = tslib_1.__importDefault(require("../Helpers/Helper"));
10
+ const AggregatedScalarLiveValue_1 = require("./AggregatedScalarLiveValue");
11
+ const ObjectExtensions_1 = require("../Extensions/ObjectExtensions");
12
+ const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
13
+ /**
14
+ * The logic is extracted here to make it easier to follow
15
+ */
16
+ class RowSummaryService {
17
+ constructor(api) {
18
+ this.api = api;
19
+ this.cachedCellSummary = new Map();
20
+ this.debouncedEvaluateRowSummary = (0, debounce_1.default)(this.evaluateRowSummary, 300);
21
+ }
22
+ onAdapterReady() {
23
+ this.rowSummariesSubscriptions();
24
+ }
25
+ rowSummariesSubscriptions() {
26
+ // return;
27
+ if (this.api.isDestroyed()) {
28
+ return;
29
+ }
30
+ // Currently not available for serverside model
31
+ if (!this.api.layoutApi.internalApi.getLayoutSupportedFeatures().RowSummaries) {
32
+ return;
33
+ }
34
+ this.debouncedEvaluateRowSummary();
35
+ this.api.eventApi.on('AdaptableStateReloaded', () => {
36
+ this.debouncedEvaluateRowSummary();
37
+ });
38
+ this.api.eventApi.on('GridDataChanged', (event) => {
39
+ this.debouncedEvaluateRowSummary();
40
+ });
41
+ this.api.eventApi.on('CellChanged', (event) => {
42
+ const columnId = event.cellChange.column.columnId;
43
+ this.debouncedEvaluateRowSummary({
44
+ columnId,
45
+ });
46
+ });
47
+ this.api.eventApi.on('LayoutChanged', (event) => {
48
+ // exclude filter events, those are handled in another event
49
+ if (event.actionName.includes('FILTER')) {
50
+ return;
51
+ }
52
+ setTimeout(() => {
53
+ // the timeout is added so the grid has time to repond to the layout changed
54
+ this.debouncedEvaluateRowSummary();
55
+ }, 16);
56
+ });
57
+ const adaptable = this.api.internalApi.getAdaptableInstance();
58
+ adaptable._on('AdapTableFiltersApplied', () => {
59
+ // we need to use this instead of layout changed
60
+ // so the rows have time to update
61
+ this.debouncedEvaluateRowSummary();
62
+ });
63
+ adaptable._on('FirstDataRendered', () => {
64
+ this.debouncedEvaluateRowSummary();
65
+ });
66
+ }
67
+ /**
68
+ *
69
+ * @param colId optional to evaluate only one column
70
+ */
71
+ evaluateRowSummary(reason) {
72
+ var _a;
73
+ if (this.api.isDestroyed()) {
74
+ return;
75
+ }
76
+ const currentLayout = this.api.layoutApi.getCurrentLayout();
77
+ let previousLayout = this.previousLayout;
78
+ // it is added here to be sure it is saved
79
+ this.previousLayout = currentLayout;
80
+ /**
81
+ * If the previous & current layout does not have row summaries, it is safe to exit
82
+ */
83
+ if ((0, ObjectExtensions_1.isObjectEmpty)(currentLayout === null || currentLayout === void 0 ? void 0 : currentLayout.RowSummaries) && (0, ObjectExtensions_1.isObjectEmpty)(previousLayout === null || previousLayout === void 0 ? void 0 : previousLayout.RowSummaries)) {
84
+ return;
85
+ }
86
+ const rowSummaries = (_a = this.api.layoutApi.getCurrentLayout().RowSummaries) !== null && _a !== void 0 ? _a : [];
87
+ const rowSummariesResults = rowSummaries.map(({ ColumnsMap, Position }) => {
88
+ return {
89
+ Position,
90
+ RowData: Object.entries(ColumnsMap !== null && ColumnsMap !== void 0 ? ColumnsMap : {}).reduce((acc, [columnId, expression]) => {
91
+ const key = `${columnId}-${expression}`;
92
+ let expressionLiveValue = this.cachedCellSummary.get(key);
93
+ if (expressionLiveValue) {
94
+ if (!reason) {
95
+ // refresh all of them
96
+ expressionLiveValue.refresh();
97
+ }
98
+ else if ('columnId' in reason && reason.columnId === columnId) {
99
+ expressionLiveValue.refresh();
100
+ }
101
+ }
102
+ if (!expressionLiveValue) {
103
+ try {
104
+ let aggregatedScalarExpression = `${expression}([${columnId}])`;
105
+ if (aggregatedScalarExpression.includes(RowSummary_1.WEIGHTED_AVERAGE_AGGREATED_FUNCTION) &&
106
+ currentLayout.AggregationColumns[columnId] &&
107
+ typeof currentLayout.AggregationColumns[columnId] === 'object') {
108
+ const weight = currentLayout.AggregationColumns[columnId]
109
+ .weightedColumnId;
110
+ if (weight) {
111
+ aggregatedScalarExpression = `AVG([${columnId}], WEIGHT([${weight}]))`;
112
+ }
113
+ }
114
+ expressionLiveValue = new AggregatedScalarLiveValue_1.AggregatedScalarLiveValue({
115
+ aggregatedScalarExpression,
116
+ }, ModuleConstants.LayoutModuleId, this.api, () => {
117
+ return this.api.gridApi.getVisibleRowNodes();
118
+ });
119
+ }
120
+ catch (e) {
121
+ this.api.logError('Error evaluating row summary', e);
122
+ }
123
+ this.cachedCellSummary.set(key, expressionLiveValue);
124
+ }
125
+ let value = null;
126
+ if (expressionLiveValue) {
127
+ value = expressionLiveValue.getGlobalAggregatedValue();
128
+ if (typeof value === 'number' && !isNaN(value)) {
129
+ value = Helper_1.default.roundNumber(value, 2);
130
+ }
131
+ }
132
+ acc[columnId] = value;
133
+ return acc;
134
+ }, {
135
+ [RowSummary_1.ROW_SUMMARY_ROW_ID]: true,
136
+ }),
137
+ };
138
+ });
139
+ if (this.previousRowSummaries && (0, lodash_1.isEqual)(rowSummariesResults, this.previousRowSummaries)) {
140
+ return;
141
+ }
142
+ this.api.internalApi.dispatchReduxAction((0, SystemRedux_1.SystemRowSummarySet)(rowSummariesResults));
143
+ this.previousRowSummaries = rowSummariesResults;
144
+ }
145
+ }
146
+ exports.RowSummaryService = RowSummaryService;
@@ -19,7 +19,10 @@ const renderFormatColumnSettingsSummary = (data) => {
19
19
  React.createElement(Tag_1.Tag, null, (_a = data.CellAlignment) !== null && _a !== void 0 ? _a : 'default')),
20
20
  React.createElement(rebass_1.Text, { mt: 3 },
21
21
  "Include grouped rows ",
22
- React.createElement(Tag_1.Tag, null, data.IncludeGroupedRows ? 'yes' : 'no'))));
22
+ React.createElement(Tag_1.Tag, null, data.IncludeGroupedRows ? 'yes' : 'no')),
23
+ React.createElement(rebass_1.Text, { mt: 3 },
24
+ "Include row summaries ",
25
+ React.createElement(Tag_1.Tag, null, data.IncludeRowSummaries ? 'yes' : 'no'))));
23
26
  };
24
27
  exports.renderFormatColumnSettingsSummary = renderFormatColumnSettingsSummary;
25
28
  const FormatColumnSettingsWizardSection = (props) => {
@@ -34,6 +37,9 @@ const FormatColumnSettingsWizardSection = (props) => {
34
37
  const onIncludeGroupedRowsChanged = (IncludeGroupedRows) => {
35
38
  props.onChange(Object.assign(Object.assign({}, data), { IncludeGroupedRows }));
36
39
  };
40
+ const onIncludeRowSummariesChanged = (IncludeRowSummaries) => {
41
+ props.onChange(Object.assign(Object.assign({}, data), { IncludeRowSummaries }));
42
+ };
37
43
  return (React.createElement(Tabs_1.Tabs, null,
38
44
  React.createElement(Tabs_1.Tabs.Tab, null, "Settings"),
39
45
  React.createElement(Tabs_1.Tabs.Content, null,
@@ -52,6 +58,9 @@ const FormatColumnSettingsWizardSection = (props) => {
52
58
  : onCellAlignmentSelectChanged(null) }))),
53
59
  React.createElement(FormLayout_1.FormRow, { label: "Include Grouped Rows:" },
54
60
  React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
55
- React.createElement(CheckBox_1.CheckBox, { "data-name": "include-grouped-rows-checkbox", checked: data.IncludeGroupedRows, onChange: onIncludeGroupedRowsChanged, mr: 2 }))))))));
61
+ React.createElement(CheckBox_1.CheckBox, { "data-name": "include-grouped-rows-checkbox", checked: data.IncludeGroupedRows, onChange: onIncludeGroupedRowsChanged, mr: 2 }))),
62
+ React.createElement(FormLayout_1.FormRow, { label: "Include Row Summaries:" },
63
+ React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
64
+ React.createElement(CheckBox_1.CheckBox, { "data-name": "include-grouped-rows-checkbox", checked: data.IncludeRowSummaries, onChange: onIncludeRowSummariesChanged, mr: 2 }))))))));
56
65
  };
57
66
  exports.FormatColumnSettingsWizardSection = FormatColumnSettingsWizardSection;
@@ -81,7 +81,7 @@ const StyledColumnWizard = (props) => {
81
81
  React.createElement(StyledColumnWizardStyleSection_1.StyledColumnWizardStyleSection, { onChange: setStyledColumn })));
82
82
  },
83
83
  title: 'Style',
84
- }, AdditionalSettingSection);
84
+ });
85
85
  }
86
86
  else if (styledColumn.BadgeStyle) {
87
87
  specificSteps.push({
@@ -4,28 +4,29 @@ exports.StyledColumnWizardSettingsSection = exports.renderStyledColumnWizardSett
4
4
  const tslib_1 = require("tslib");
5
5
  const React = tslib_1.__importStar(require("react"));
6
6
  const rebass_1 = require("rebass");
7
- const FormLayout_1 = tslib_1.__importStar(require("../../../components/FormLayout"));
8
7
  const CheckBox_1 = require("../../../components/CheckBox");
8
+ const FormLayout_1 = tslib_1.__importStar(require("../../../components/FormLayout"));
9
9
  const Tabs_1 = require("../../../components/Tabs");
10
- const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
11
10
  const Tag_1 = require("../../../components/Tag");
12
- let alignmentOptions = [
13
- { value: 'Left', label: 'Left' },
14
- { value: 'Right', label: 'Right' },
15
- { value: 'Center', label: 'Center' },
16
- ];
11
+ const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
17
12
  const renderStyledColumnWizardSettingsSummary = (data) => {
18
13
  return (React.createElement(rebass_1.Box, { padding: 2 },
19
14
  React.createElement(rebass_1.Text, { mt: 3 },
20
15
  "Include grouped rows ",
21
- React.createElement(Tag_1.Tag, null, data.IncludeGroupedRows ? 'yes' : 'no'))));
16
+ React.createElement(Tag_1.Tag, null, data.IncludeGroupedRows ? 'yes' : 'no')),
17
+ React.createElement(rebass_1.Text, { mt: 3 },
18
+ "Include row summaries ",
19
+ React.createElement(Tag_1.Tag, null, data.IncludeRowSummaries ? 'yes' : 'no'))));
22
20
  };
23
21
  exports.renderStyledColumnWizardSettingsSummary = renderStyledColumnWizardSettingsSummary;
24
22
  const StyledColumnWizardSettingsSection = (props) => {
25
- const { data, api } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
23
+ const { data } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
26
24
  const onIncludeGroupedRowsChanged = (IncludeGroupedRows) => {
27
25
  props.onChange(Object.assign(Object.assign({}, data), { IncludeGroupedRows }));
28
26
  };
27
+ const onIncludeRowSummariesChanged = (IncludeRowSummaries) => {
28
+ props.onChange(Object.assign(Object.assign({}, data), { IncludeRowSummaries }));
29
+ };
29
30
  return (React.createElement(Tabs_1.Tabs, null,
30
31
  React.createElement(Tabs_1.Tabs.Tab, null, "Settings"),
31
32
  React.createElement(Tabs_1.Tabs.Content, null,
@@ -33,6 +34,9 @@ const StyledColumnWizardSettingsSection = (props) => {
33
34
  React.createElement(FormLayout_1.default, null,
34
35
  React.createElement(FormLayout_1.FormRow, { label: "Include Grouped Rows:" },
35
36
  React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
36
- React.createElement(CheckBox_1.CheckBox, { "data-name": "include-grouped-rows-checkbox", checked: data.IncludeGroupedRows, onChange: onIncludeGroupedRowsChanged, mr: 2 }))))))));
37
+ React.createElement(CheckBox_1.CheckBox, { "data-name": "include-grouped-rows-checkbox", checked: data.IncludeGroupedRows, onChange: onIncludeGroupedRowsChanged, mr: 2 }))),
38
+ React.createElement(FormLayout_1.FormRow, { label: "Include Row Summaries:" },
39
+ React.createElement(rebass_1.Flex, { alignItems: "center", marginLeft: 2 },
40
+ React.createElement(CheckBox_1.CheckBox, { "data-name": "include-grouped-rows-checkbox", checked: data.IncludeRowSummaries, onChange: onIncludeRowSummariesChanged, mr: 2 }))))))));
37
41
  };
38
42
  exports.StyledColumnWizardSettingsSection = StyledColumnWizardSettingsSection;
@@ -9,7 +9,6 @@ const FloatingFilterWrapper_1 = require("./FloatingFilterWrapper");
9
9
  const StyleHelper_1 = require("../Utilities/Helpers/StyleHelper");
10
10
  const StringExtensions_1 = tslib_1.__importDefault(require("../Utilities/Extensions/StringExtensions"));
11
11
  const ObjectFactory_1 = require("../Utilities/ObjectFactory");
12
- const clamp_1 = tslib_1.__importDefault(require("lodash/clamp"));
13
12
  const tinycolor2_1 = tslib_1.__importDefault(require("tinycolor2"));
14
13
  const UIHelper_1 = tslib_1.__importDefault(require("../View/UIHelper"));
15
14
  const PercentBarRenderer_1 = require("./PercentBarRenderer");
@@ -669,6 +668,7 @@ class AgGridColumnAdapter {
669
668
  return Object.assign(Object.assign({}, this.getFormatColumnCellStyle(gridCell.column, activeFormatColumnsWithStyle, params)), styledColumnStyle);
670
669
  }
671
670
  getStyledColumnStyle(styledColumn, abColumn, params) {
671
+ var _a, _b;
672
672
  let style = {};
673
673
  const gradientStyle = styledColumn === null || styledColumn === void 0 ? void 0 : styledColumn.GradientStyle;
674
674
  if (params.value === undefined) {
@@ -676,18 +676,24 @@ class AgGridColumnAdapter {
676
676
  }
677
677
  let colValue = params.value;
678
678
  if (this.adaptableApi.gridApi.isGroupRowNode(params.node)) {
679
- if (styledColumn.IncludeGroupedRows) {
680
- const minColumnValue = this.adaptableApi.styledColumnApi.internalApi.getMinValueForNumericColumn(abColumn);
681
- const maxColumnValue = this.adaptableApi.styledColumnApi.internalApi.getMaxValueForNumericColumn(abColumn);
682
- /**
683
- * Color should always be in bounds, it should not overflow.
684
- * If the value is out of range, it shoul set the maximum/minimum color.
685
- */
686
- colValue = (0, clamp_1.default)(params.value, minColumnValue, maxColumnValue);
687
- }
688
- else {
689
- return style;
690
- }
679
+ // We no longer support Grouped Rows
680
+ return style;
681
+ // if (styledColumn.IncludeGroupedRows) {
682
+ // const minColumnValue =
683
+ // this.adaptableApi.styledColumnApi.internalApi.getMinValueForNumericColumn(abColumn);
684
+ // const maxColumnValue =
685
+ // this.adaptableApi.styledColumnApi.internalApi.getMaxValueForNumericColumn(abColumn);
686
+ // /**
687
+ // * Color should always be in bounds, it should not overflow.
688
+ // * If the value is out of range, it shoul set the maximum/minimum color.
689
+ // */
690
+ // colValue = clamp(params.value, minColumnValue, maxColumnValue);
691
+ // } else {
692
+ // return style;
693
+ // }
694
+ }
695
+ if (((_b = (_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[RowSummary_1.ROW_SUMMARY_ROW_ID]) && !styledColumn.IncludeRowSummaries) {
696
+ return style;
691
697
  }
692
698
  if (gradientStyle) {
693
699
  const min = this.adaptableApi.styledColumnApi.internalApi.getNumericStyleMinValue(styledColumn, abColumn, params.node, colValue);
@@ -10,6 +10,7 @@ export declare class AgGridMenuAdapter {
10
10
  destroy(): void;
11
11
  buildColumnMenu(params: GetMainMenuItemsParams, originalGetMainMenuItems: GetMainMenuItems): (string | MenuItemDef)[];
12
12
  buildContextMenu(params: GetContextMenuItemsParams, originalGetContextMenuItems: GetContextMenuItems): (string | MenuItemDef)[];
13
+ private removeConsecutiveSeparators;
13
14
  private createColumnMenuContextObject;
14
15
  private createAdaptableContextMenuItems;
15
16
  private createContextMenuContextObject;
@@ -17,6 +18,10 @@ export declare class AgGridMenuAdapter {
17
18
  private mapCustomMenuItemToAgGridMenuDefinition;
18
19
  private mapUserMenuItemToAgGridMenuDefinition;
19
20
  private buildContextMenuDefaultStructure;
21
+ /**
22
+ * Hide menu group with no subitems or elevate single subitem to parent level
23
+ */
24
+ private normalizeMenuGroup;
20
25
  /**
21
26
  * Default strategy for menu items: return as is if there is only one item, otherwise group them under a parent item
22
27
  */