@adaptabletools/adaptable 18.0.0-canary.7 → 18.0.0-canary.9

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 (90) hide show
  1. package/base.css +7 -2
  2. package/base.css.map +1 -1
  3. package/index.css +9 -2
  4. package/index.css.map +1 -1
  5. package/package.json +2 -2
  6. package/src/AdaptableInterfaces/IAdaptable.d.ts +8 -1
  7. package/src/AdaptableOptions/AdaptableOptions.d.ts +1 -1
  8. package/src/Api/ConfigApi.d.ts +1 -1
  9. package/src/Api/GridApi.d.ts +4 -0
  10. package/src/Api/Implementation/CommentsApiImpl.d.ts +4 -0
  11. package/src/Api/Implementation/CommentsApiImpl.js +5 -0
  12. package/src/Api/Implementation/ConfigApiImpl.js +6 -3
  13. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  14. package/src/Api/Implementation/GridApiImpl.js +13 -0
  15. package/src/Api/Implementation/LayoutApiImpl.d.ts +2 -4
  16. package/src/Api/Implementation/LayoutApiImpl.js +15 -14
  17. package/src/Api/Implementation/NotesApiImpl.d.ts +4 -0
  18. package/src/Api/Implementation/NotesApiImpl.js +5 -0
  19. package/src/Api/Implementation/ScopeApiImpl.d.ts +2 -0
  20. package/src/Api/Implementation/ScopeApiImpl.js +20 -7
  21. package/src/Api/Internal/CalculatedColumnInternalApi.js +1 -1
  22. package/src/Api/Internal/CommentsInternalApi.d.ts +4 -0
  23. package/src/Api/Internal/CommentsInternalApi.js +13 -0
  24. package/src/Api/Internal/FormatColumnInternalApi.js +3 -2
  25. package/src/Api/Internal/FreeTextColumnInternalApi.js +1 -1
  26. package/src/Api/Internal/NotesInternalApi.d.ts +4 -0
  27. package/src/Api/Internal/NotesInternalApi.js +13 -0
  28. package/src/Api/LayoutApi.d.ts +11 -8
  29. package/src/Api/ScopeApi.d.ts +10 -0
  30. package/src/PredefinedConfig/Common/AdaptableColumn.d.ts +4 -0
  31. package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
  32. package/src/PredefinedConfig/Common/AdaptableScope.d.ts +4 -1
  33. package/src/PredefinedConfig/Common/RowSummary.d.ts +7 -0
  34. package/src/PredefinedConfig/Common/RowSummary.js +1 -0
  35. package/src/PredefinedConfig/LayoutState.d.ts +5 -0
  36. package/src/PredefinedConfig/SystemState.d.ts +7 -0
  37. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +9 -0
  38. package/src/Redux/ActionsReducers/LayoutRedux.js +20 -0
  39. package/src/Redux/ActionsReducers/SystemRedux.d.ts +5 -0
  40. package/src/Redux/ActionsReducers/SystemRedux.js +13 -1
  41. package/src/Redux/Store/AdaptableStore.js +11 -0
  42. package/src/Redux/Store/Interface/IAdaptableStore.d.ts +2 -2
  43. package/src/Strategy/CellSummaryModule.d.ts +1 -0
  44. package/src/Strategy/CellSummaryModule.js +50 -21
  45. package/src/Strategy/CommentsModule.js +3 -0
  46. package/src/Strategy/LayoutModule.d.ts +7 -0
  47. package/src/Strategy/LayoutModule.js +102 -3
  48. package/src/Strategy/NotesModule.js +3 -4
  49. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +2 -1
  50. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +294 -0
  51. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +1 -1
  52. package/src/Utilities/Extensions/ArrayExtensions.d.ts +2 -0
  53. package/src/Utilities/Extensions/ArrayExtensions.js +4 -0
  54. package/src/Utilities/ObjectFactory.js +6 -6
  55. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +3 -2
  56. package/src/Utilities/Services/AggregatedScalarLiveValue.js +11 -8
  57. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +1 -1
  58. package/src/Utilities/Services/LicenseService/index.js +10 -5
  59. package/src/Utilities/Services/QueryLanguageService.d.ts +1 -1
  60. package/src/Utilities/Services/QueryLanguageService.js +2 -1
  61. package/src/Utilities/Services/SummaryService.d.ts +19 -0
  62. package/src/Utilities/Services/SummaryService.js +29 -0
  63. package/src/View/AdaptableView.js +1 -1
  64. package/src/View/Components/AdaptableDateInput/index.d.ts +1 -1
  65. package/src/View/Components/NewScopeComponent.js +32 -1
  66. package/src/View/Components/Popups/AdaptableToaster.js +1 -1
  67. package/src/View/DataChangeHistory/DataChangeHistoryGrid.js +7 -7
  68. package/src/View/Layout/TransposedPopup.js +7 -6
  69. package/src/agGrid/ActionColumnRenderer.js +3 -2
  70. package/src/agGrid/AdaptableAgGrid.d.ts +16 -2
  71. package/src/agGrid/AdaptableAgGrid.js +201 -91
  72. package/src/agGrid/AgGridAdapter.d.ts +1 -0
  73. package/src/agGrid/AgGridAdapter.js +8 -0
  74. package/src/agGrid/AgGridColumnAdapter.js +14 -3
  75. package/src/components/ColorPicker/ColorPicker.d.ts +1 -1
  76. package/src/components/Datepicker/index.d.ts +1 -1
  77. package/src/components/Input/index.d.ts +1 -1
  78. package/src/components/List/ListGroupItem/index.d.ts +1 -1
  79. package/src/components/icons/index.js +2 -0
  80. package/src/components/icons/rows.d.ts +3 -0
  81. package/src/components/icons/rows.js +4 -0
  82. package/src/env.js +2 -2
  83. package/src/metamodel/adaptable.metamodel.d.ts +8 -0
  84. package/src/metamodel/adaptable.metamodel.js +18 -0
  85. package/src/parser/src/types.d.ts +5 -0
  86. package/tsconfig.esm.tsbuildinfo +1 -1
  87. package/src/View/Components/ScopeComponent.d.ts +0 -24
  88. package/src/View/Components/ScopeComponent.js +0 -133
  89. package/src/View/Export/Wizard/ReportScopeWizard.d.ts +0 -17
  90. package/src/View/Export/Wizard/ReportScopeWizard.js +0 -47
@@ -28,6 +28,10 @@ export const LAYOUT_SELECT = 'LAYOUT_SELECT';
28
28
  * @ReduxAction A Layout has been (auto)saved
29
29
  */
30
30
  export const LAYOUT_SAVE = 'LAYOUT_SAVE';
31
+ /**
32
+ * @ReduxAction A Column has been added
33
+ */
34
+ export const LAYOUT_ADD_COLUMN = 'LAYOUT_ADD_COLUMN';
31
35
  /**
32
36
  * @ReduxAction A Column has been removed
33
37
  */
@@ -149,6 +153,11 @@ export const LayoutSetColumnCaption = (layoutName, columnId, caption) => ({
149
153
  columnId,
150
154
  caption,
151
155
  });
156
+ export const LayoutAddColumn = (layoutName, columnId) => ({
157
+ type: LAYOUT_ADD_COLUMN,
158
+ layoutName,
159
+ columnId,
160
+ });
152
161
  export const LayoutRemoveColumn = (layoutName, columnId) => ({
153
162
  type: LAYOUT_REMOVE_COLUMN,
154
163
  layoutName,
@@ -218,6 +227,17 @@ export const LayoutReducer = (state = initialState, action) => {
218
227
  }
219
228
  return state;
220
229
  }
230
+ case LAYOUT_ADD_COLUMN: {
231
+ const addColumnAction = action;
232
+ const layoutname = addColumnAction.layoutName;
233
+ const colToAdd = addColumnAction.columnId;
234
+ let layoutToUpdate = state.Layouts.find((l) => l.Name === layoutname);
235
+ if (layoutToUpdate) {
236
+ layoutToUpdate.Columns.push(colToAdd);
237
+ return Object.assign(Object.assign({}, state), { Layouts: state.Layouts.map((abObject) => abObject.Uuid === layoutToUpdate.Uuid ? layoutToUpdate : abObject) });
238
+ }
239
+ return state;
240
+ }
221
241
  case LAYOUT_REMOVE_COLUMN: {
222
242
  const removeColumnAction = action;
223
243
  const layoutname = removeColumnAction.layoutName;
@@ -77,6 +77,7 @@ export declare const SYSTEM_VISUAL_EXPORT_END = "SYSTEM_VISUAL_EXPORT_END";
77
77
  export declare const SYSTEM_CELL_POPUP_SHOW = "SYSTEM_CELL_POPUP_SHOW";
78
78
  export declare const SYSTEM_CELL_POPUP_HIDE = "SYSTEM_CELL_POPUP_HIDE";
79
79
  export declare const SYSTEM_CELL_POPUP_EDIT_FOCUSED_ENTITY = "SYSTEM_CELL_POPUP_EDIT_FOCUSED_ENTITY";
80
+ export declare const SYSTEM_SUMMARY_ROW_SET = "SYSTEM_SUMMARY_ROW_SET";
80
81
  export declare const DATA_IMPORT_COMPLETED = "DATA_IMPORT_COMPLETED";
81
82
  export interface DataImportCompletedAction extends Redux.Action {
82
83
  dataImportedInfo: DataImportedInfo;
@@ -328,6 +329,10 @@ export declare const SystemVisualExportEnd: () => SystemVisualExportEndAction;
328
329
  export declare const SystemQuickSearchFloatingVisibility: (visible: boolean) => SystemQuickSearchFloatingVisibilityAction;
329
330
  export declare const SystemCellPopupShow: (cellPosition: CellAddress, editMode?: boolean) => SystemCellPopupShowAction;
330
331
  export declare const SystemCellPopupEditFocusedEntity: (focusedEntity: 'Note' | 'Comment') => SystemCellPopupEditFocusedEntityAction;
332
+ export declare const SystemRowSummartSet: (systemRowSummaries: SystemState['RowSummary']['rowSummaries']) => {
333
+ readonly type: "SYSTEM_SUMMARY_ROW_SET";
334
+ readonly rowSummaries: import("../../PredefinedConfig/SystemState").SystemRowSummary[];
335
+ };
331
336
  export declare const SystemCellPopupHide: () => SystemCellPopupHideAction;
332
337
  export declare const SystemDisableDeleteConfirmationSelector: (state: SystemState) => boolean;
333
338
  export declare const SystemPreviousGroupedColumnsSelector: (state: SystemState) => Record<string, Record<string, number>>;
@@ -87,10 +87,12 @@ export const SYSTEM_SET_QUICK_SEARCH_FLOATING_VISIBILITY = 'SYSTEM_SET_QUICK_SEA
87
87
  // Data Export (Report)
88
88
  export const SYSTEM_VISUAL_EXPORT_BEGIN = 'SYSTEM_VISUAL_EXPORT_BEGIN';
89
89
  export const SYSTEM_VISUAL_EXPORT_END = 'SYSTEM_VISUAL_EXPORT_END';
90
- // Notes
90
+ // Notes and Comments
91
91
  export const SYSTEM_CELL_POPUP_SHOW = 'SYSTEM_CELL_POPUP_SHOW';
92
92
  export const SYSTEM_CELL_POPUP_HIDE = 'SYSTEM_CELL_POPUP_HIDE';
93
93
  export const SYSTEM_CELL_POPUP_EDIT_FOCUSED_ENTITY = 'SYSTEM_CELL_POPUP_EDIT_FOCUSED_ENTITY';
94
+ // Row Summaries
95
+ export const SYSTEM_SUMMARY_ROW_SET = 'SYSTEM_SUMMARY_ROW_SET';
94
96
  // Data Import
95
97
  export const DATA_IMPORT_COMPLETED = 'DATA_IMPORT_COMPLETED';
96
98
  export const SystemHighlightCellAdd = (cellHighlightInfo) => ({
@@ -316,6 +318,10 @@ export const SystemCellPopupEditFocusedEntity = (focusedEntity) => ({
316
318
  type: SYSTEM_CELL_POPUP_EDIT_FOCUSED_ENTITY,
317
319
  focusedEntity,
318
320
  });
321
+ export const SystemRowSummartSet = (systemRowSummaries) => ({
322
+ type: SYSTEM_SUMMARY_ROW_SET,
323
+ rowSummaries: systemRowSummaries,
324
+ });
319
325
  export const SystemCellPopupHide = () => ({
320
326
  type: SYSTEM_CELL_POPUP_HIDE,
321
327
  });
@@ -758,6 +764,12 @@ export const SystemReducer = (state = initialState, action) => {
758
764
  popupPosition: null,
759
765
  } });
760
766
  }
767
+ case SYSTEM_SUMMARY_ROW_SET: {
768
+ const typedAction = action;
769
+ return Object.assign(Object.assign({}, state), { RowSummary: {
770
+ rowSummaries: typedAction.rowSummaries,
771
+ } });
772
+ }
761
773
  default:
762
774
  return state;
763
775
  }
@@ -310,6 +310,16 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
310
310
  const ret = next(action);
311
311
  return ret;
312
312
  }
313
+ /*******************
314
+ * System Row Summary ACTIONS
315
+ *******************/
316
+ case SystemRedux.SYSTEM_SUMMARY_ROW_SET: {
317
+ let nextAction = next(action);
318
+ setTimeout(() => {
319
+ adaptable.setupRowSummaries();
320
+ }, 0);
321
+ return nextAction;
322
+ }
313
323
  /*******************
314
324
  * FLASHING CELL ACTIONS
315
325
  *******************/
@@ -1045,6 +1055,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
1045
1055
  adaptable.setLayout(savingLayout);
1046
1056
  }
1047
1057
  }
1058
+ adaptable.refreshQuickFilter();
1048
1059
  return returnAction;
1049
1060
  }
1050
1061
  /*******************
@@ -10,8 +10,8 @@ export interface LoadStoreConfig {
10
10
  }
11
11
  export interface IAdaptableStore {
12
12
  TheStore: Redux.Store<AdaptableState>;
13
- Load: PromiseLike<any>;
14
- loadStore: (config: LoadStoreConfig) => PromiseLike<any>;
13
+ Load: Promise<any>;
14
+ loadStore: (config: LoadStoreConfig) => Promise<any>;
15
15
  getCurrentStorageState: () => AdaptableState | void;
16
16
  saveStateNow: (adaptable: IAdaptable) => Promise<any>;
17
17
  on: (eventName: string, callback: (data?: any) => any) => () => void;
@@ -8,6 +8,7 @@ import { AccessLevel } from '../PredefinedConfig/Common/Entitlement';
8
8
  import { CellSummmary } from '../PredefinedConfig/Common/CellSummary';
9
9
  import { AdaptableColumn } from '../PredefinedConfig/Common/AdaptableColumn';
10
10
  export declare class CellSummaryModule extends AdaptableModuleBase implements ICellSummaryModule {
11
+ cachedCellSummary: WeakMap<SelectedCellInfo<any>, CellSummmary>;
11
12
  constructor(api: AdaptableApi);
12
13
  getViewAccessLevel(): AccessLevel;
13
14
  addColumnMenuItems(column: AdaptableColumn): AdaptableMenuItem[] | undefined;
@@ -6,6 +6,7 @@ import { CellSummaryStatusPanel } from '../View/CellSummary/CellSummaryStatusPan
6
6
  export class CellSummaryModule extends AdaptableModuleBase {
7
7
  constructor(api) {
8
8
  super(ModuleConstants.CellSummaryModuleId, ModuleConstants.CellSummaryFriendlyName, 'cells', 'CellSummaryPopup', 'See summary information on a group of cells using multiple summary operations', api);
9
+ this.cachedCellSummary = new WeakMap();
9
10
  }
10
11
  getViewAccessLevel() {
11
12
  return 'Full';
@@ -42,6 +43,9 @@ export class CellSummaryModule extends AdaptableModuleBase {
42
43
  });
43
44
  }
44
45
  createCellSummary(selectedCellInfo) {
46
+ if (this.cachedCellSummary.has(selectedCellInfo)) {
47
+ return this.cachedCellSummary.get(selectedCellInfo);
48
+ }
45
49
  let selectedCellSummary;
46
50
  if (selectedCellInfo && ArrayExtensions.IsNotNullOrEmpty(selectedCellInfo.columns)) {
47
51
  let numericValues = [];
@@ -70,28 +74,52 @@ export class CellSummaryModule extends AdaptableModuleBase {
70
74
  // copying so that we keep the order - needed for others
71
75
  const newNumericValues = [...numericValues];
72
76
  let hasNumericColumns = numericValues.length > 0;
73
- let distinctCount = ArrayExtensions.RetrieveDistinct(allValues).length;
77
+ if (selectedCellInfo.columns.length > 1) {
78
+ return {
79
+ Sum: null,
80
+ Average: null,
81
+ Median: null,
82
+ Mode: null,
83
+ Distinct: null,
84
+ Max: null,
85
+ Min: null,
86
+ Count: null,
87
+ Std_Deviation: null,
88
+ Only: '',
89
+ };
90
+ }
91
+ const handleExpression = (functionName) => {
92
+ const columnId = selectedCellInfo.columns[0].columnId;
93
+ const rowNodes = selectedCellInfo.gridCells.map((gc) => gc.rowNode);
94
+ return this.api.internalApi.getAdaptableInstance().SummaryService.evaluateExpressionValue({
95
+ expression: {
96
+ function: functionName,
97
+ },
98
+ columnId: columnId,
99
+ getRowNodes: () => rowNodes,
100
+ }, ModuleConstants.CellSummaryModuleId);
101
+ };
102
+ const sumValue = hasNumericColumns ? handleExpression('SUM') : null;
103
+ const avgValue = hasNumericColumns ? Helper.roundNumber(handleExpression('AVG'), 2) : null;
104
+ const modeValue = hasNumericColumns ? handleExpression('MODE') : null;
105
+ const medianValue = hasNumericColumns ? handleExpression('MEDIAN') : null;
106
+ const distinctValue = handleExpression('DISTINCT');
107
+ const maxValue = hasNumericColumns ? handleExpression('MAX') : null;
108
+ const minValue = hasNumericColumns ? handleExpression('MIN') : null;
109
+ const stdDeviation = hasNumericColumns
110
+ ? Helper.roundNumberTo4dp(handleExpression('STD_DEVIATION'))
111
+ : null;
74
112
  selectedCellSummary = {
75
- Sum: hasNumericColumns
76
- ? Helper.roundNumberTo4dp(Helper.sumNumberArray(numericValues))
77
- : undefined,
78
- Average: hasNumericColumns
79
- ? Helper.roundNumberTo4dp(Helper.meanNumberArray(numericValues))
80
- : undefined,
81
- Median: hasNumericColumns
82
- ? Helper.roundNumberTo4dp(Helper.medianNumberArray(numericValues))
83
- : undefined,
84
- Mode: hasNumericColumns
85
- ? Helper.roundNumberTo4dp(Helper.modeNumberArray(numericValues))
86
- : undefined,
87
- Distinct: distinctCount,
88
- Max: hasNumericColumns ? Helper.roundNumberTo4dp(Math.max(...numericValues)) : undefined,
89
- Min: hasNumericColumns ? Helper.roundNumberTo4dp(Math.min(...numericValues)) : undefined,
113
+ Sum: sumValue,
114
+ Average: avgValue,
115
+ Median: medianValue,
116
+ Mode: modeValue,
117
+ Distinct: distinctValue,
118
+ Max: maxValue,
119
+ Min: minValue,
90
120
  Count: allValues.length,
91
- Std_Deviation: hasNumericColumns
92
- ? Helper.roundNumberTo4dp(Helper.standardDeviationNumberArray(numericValues))
93
- : undefined,
94
- Only: distinctCount == 1 ? JSON.stringify(allValues[0]) : '',
121
+ Std_Deviation: stdDeviation,
122
+ Only: distinctValue == 1 ? JSON.stringify(allValues[0]) : '',
95
123
  };
96
124
  numericValues = [...newNumericValues];
97
125
  const operationDefinitions = this.api.cellSummaryApi.getCellSummaryOperationDefinitions();
@@ -100,7 +128,7 @@ export class CellSummaryModule extends AdaptableModuleBase {
100
128
  if (operation.operationFunction) {
101
129
  const cellSummaryOperationContext = {
102
130
  selectedCellInfo,
103
- distinctCount,
131
+ distinctCount: distinctValue,
104
132
  allValues,
105
133
  numericValues,
106
134
  numericColumns,
@@ -112,6 +140,7 @@ export class CellSummaryModule extends AdaptableModuleBase {
112
140
  }
113
141
  });
114
142
  }
143
+ this.cachedCellSummary.set(selectedCellInfo, selectedCellSummary);
115
144
  return selectedCellSummary;
116
145
  }
117
146
  getViewProperties() {
@@ -55,6 +55,9 @@ export class CommentsModule extends AdaptableModuleBase {
55
55
  ColumnId: menuContext.adaptableColumn.columnId,
56
56
  };
57
57
  const comments = this.adaptable.api.commentApi.getComments(cellAddress);
58
+ if (!this.api.commentApi.internalApi.areCommentsAvailable()) {
59
+ return items;
60
+ }
58
61
  if (comments) {
59
62
  items.push(this.createColumnMenuItemClickFunction('Remove Comments', this.moduleInfo.Glyph, () => {
60
63
  this.api.commentApi.deleteCommentThread(cellAddress);
@@ -7,7 +7,9 @@ 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';
10
11
  export declare class LayoutModule extends AdaptableModuleBase implements IModule {
12
+ cachedCellSummary: Map<string, AggregatedScalarLiveValue>;
11
13
  protected LayoutState: LayoutState;
12
14
  constructor(api: AdaptableApi);
13
15
  onAdaptableReady(): void;
@@ -42,4 +44,9 @@ export declare class LayoutModule extends AdaptableModuleBase implements IModule
42
44
  getViewProperties(): AdaptableModuleView;
43
45
  handleLayoutChange(): void;
44
46
  getReferencedNamedQueryNames(layout: Layout): string[];
47
+ /**
48
+ *
49
+ * @param colId optional to evaluate only one column
50
+ */
51
+ private evaluateRowSummary;
45
52
  }
@@ -15,9 +15,13 @@ import { SHOW_PIVOT_COLUMN_DETAILS } from '../View/Components/Popups/WindowPopup
15
15
  import flattenDeep from 'lodash/flattenDeep';
16
16
  import StringExtensions from '../Utilities/Extensions/StringExtensions';
17
17
  import { getGridFilterViewItems } from '../View/Layout/Wizard/getGridFilterPreview';
18
+ import { SystemRowSummartSet } from '../Redux/ActionsReducers/SystemRedux';
19
+ import { ROW_SUMMARY_ROW_ID } from '../PredefinedConfig/Common/RowSummary';
20
+ import Helper from '../Utilities/Helpers/Helper';
18
21
  export class LayoutModule extends AdaptableModuleBase {
19
22
  constructor(api) {
20
23
  super(ModuleConstants.LayoutModuleId, ModuleConstants.LayoutFriendlyName, 'grid', 'LayoutPopup', 'Named sets of column visibility, order, groupings, aggregation, pivots etc.', api);
24
+ this.cachedCellSummary = new Map();
21
25
  }
22
26
  onAdaptableReady() {
23
27
  this.api.eventApi.on('LayoutChanged', (layoutChangedInfo) => {
@@ -31,6 +35,26 @@ export class LayoutModule extends AdaptableModuleBase {
31
35
  requestAnimationFrame(() => {
32
36
  this.api.layoutApi.internalApi.fireLayoutChangedEvent('ADAPTABLE_READY', null, this.api.layoutApi.getLayoutState());
33
37
  });
38
+ this.evaluateRowSummary();
39
+ this.api.eventApi.on('AdaptableStateReloaded', () => {
40
+ this.evaluateRowSummary();
41
+ });
42
+ this.api.eventApi.on('GridDataChanged', (event) => {
43
+ this.evaluateRowSummary();
44
+ });
45
+ this.api.eventApi.on('CellChanged', (event) => {
46
+ const columnId = event.cellChange.column.columnId;
47
+ this.evaluateRowSummary({
48
+ columnId,
49
+ });
50
+ });
51
+ this.api.eventApi.on('LayoutChanged', (event) => {
52
+ this.evaluateRowSummary();
53
+ });
54
+ const adaptable = this.api.internalApi.getAdaptableInstance();
55
+ adaptable._on('FirstDataRendered', () => {
56
+ this.evaluateRowSummary();
57
+ });
34
58
  }
35
59
  getModuleAdaptableObjects() {
36
60
  return this.api.layoutApi.getLayouts();
@@ -195,7 +219,7 @@ export class LayoutModule extends AdaptableModuleBase {
195
219
  }
196
220
  createViewPivotItemsMenuItem(menuContext) {
197
221
  // current group => menuContext.rowNode.field;
198
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
222
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
199
223
  const selectedCellInfo = (_a = menuContext.selectedCellInfo) !== null && _a !== void 0 ? _a : this.api.gridApi.getSelectedCellInfo();
200
224
  if (((_b = selectedCellInfo === null || selectedCellInfo === void 0 ? void 0 : selectedCellInfo.gridCells) === null || _b === void 0 ? void 0 : _b.length) !== 1) {
201
225
  return;
@@ -236,7 +260,9 @@ export class LayoutModule extends AdaptableModuleBase {
236
260
  }
237
261
  const data = flattenDeep(getData(menuContext.rowNode.childrenAfterFilter));
238
262
  const rowGroups = currentLayout.RowGroupedColumns;
239
- const cellValue = isPivotColumn ? menuContext.rowNode.aggData[columnId] : gridCell.displayValue;
263
+ const cellValue = isPivotColumn
264
+ ? (_o = (_m = menuContext.rowNode) === null || _m === void 0 ? void 0 : _m.aggData) === null || _o === void 0 ? void 0 : _o[columnId]
265
+ : gridCell.displayValue;
240
266
  const popupProps = {
241
267
  hasPivotValue: isPivotColumn,
242
268
  columnId,
@@ -277,7 +303,7 @@ export class LayoutModule extends AdaptableModuleBase {
277
303
  return this.getModuleAdaptableObjects().map((layout) => this.toView(layout));
278
304
  }
279
305
  toView(layout) {
280
- var _a, _b, _c, _d, _e, _f;
306
+ var _a, _b, _c, _d, _e, _f, _g;
281
307
  const maxColumnsToDisplay = (_b = (_a = this.api.optionsApi.getLayoutOptions().layoutViewOptions) === null || _a === void 0 ? void 0 : _a.maxColumnsToDisplay) !== null && _b !== void 0 ? _b : 10;
282
308
  const columnIdToFriendlyName = (columnId) => {
283
309
  return this.api.columnApi.getFriendlyNameForColumnId(columnId);
@@ -346,6 +372,22 @@ export class LayoutModule extends AdaptableModuleBase {
346
372
  (layout === null || layout === void 0 ? void 0 : layout.GridFilter) &&
347
373
  StringExtensions.IsNotNullOrEmpty(layout.GridFilter.Expression) &&
348
374
  getGridFilterViewItems(layout),
375
+ ((_g = layout === null || layout === void 0 ? void 0 : layout.RowSummaries) === null || _g === void 0 ? void 0 : _g.length) && {
376
+ name: 'Row Summaries',
377
+ values: layout === null || layout === void 0 ? void 0 : layout.RowSummaries.map((rowSummary) => {
378
+ var _a;
379
+ const columns = Object.entries((_a = rowSummary.ColumnsMap) !== null && _a !== void 0 ? _a : {})
380
+ .map(([columnId, expression]) => {
381
+ if (columnId === 'Source' || columnId === 'Uuid') {
382
+ return '';
383
+ }
384
+ return `${expression}(${columnIdToFriendlyName(columnId)})`;
385
+ })
386
+ .filter(Boolean)
387
+ .join(', ');
388
+ return `${rowSummary.Position}: ${columns}`;
389
+ }),
390
+ },
349
391
  ].filter(Boolean),
350
392
  abObject: layout,
351
393
  };
@@ -400,4 +442,61 @@ export class LayoutModule extends AdaptableModuleBase {
400
442
  }
401
443
  return this.api.namedQueryApi.internalApi.getReferencedNamedQueryNames(layout.GridFilter.Expression);
402
444
  }
445
+ /**
446
+ *
447
+ * @param colId optional to evaluate only one column
448
+ */
449
+ evaluateRowSummary(reason) {
450
+ var _a;
451
+ const rowSummaries = (_a = this.api.layoutApi.getCurrentLayout().RowSummaries) !== null && _a !== void 0 ? _a : [];
452
+ const rowSummariesResults = rowSummaries.map(({ ColumnsMap, Position }) => {
453
+ return {
454
+ Position,
455
+ RowData: Object.entries(ColumnsMap !== null && ColumnsMap !== void 0 ? ColumnsMap : {}).reduce((acc, [columnId, expression]) => {
456
+ const key = `${columnId}-${expression}`;
457
+ let expressionLiveValue = this.cachedCellSummary.get(key);
458
+ if (expressionLiveValue) {
459
+ if (!reason) {
460
+ // refresh all of them
461
+ expressionLiveValue.refresh();
462
+ }
463
+ else if ('columnId' in reason && reason.columnId === columnId) {
464
+ expressionLiveValue.refresh();
465
+ }
466
+ }
467
+ if (!expressionLiveValue) {
468
+ try {
469
+ expressionLiveValue = this.api.internalApi
470
+ .getAdaptableInstance()
471
+ .SummaryService.evaluateScalarLiveValue({
472
+ expression: {
473
+ function: expression,
474
+ },
475
+ columnId: columnId,
476
+ getRowNodes: () => {
477
+ return this.api.gridApi.getVisibleRowNodes();
478
+ },
479
+ }, ModuleConstants.LayoutModuleId);
480
+ }
481
+ catch (e) {
482
+ this.api.logError('Error evaluating row summary', e);
483
+ }
484
+ this.cachedCellSummary.set(key, expressionLiveValue);
485
+ }
486
+ let value = null;
487
+ if (expressionLiveValue) {
488
+ value = expressionLiveValue.getGlobalAggregatedValue();
489
+ if (typeof value === 'number' && !isNaN(value)) {
490
+ value = Helper.roundNumber(value, 2);
491
+ }
492
+ }
493
+ acc[columnId] = value;
494
+ return acc;
495
+ }, {
496
+ [ROW_SUMMARY_ROW_ID]: true,
497
+ }),
498
+ };
499
+ });
500
+ this.api.internalApi.dispatchReduxAction(SystemRowSummartSet(rowSummariesResults));
501
+ }
403
502
  }
@@ -5,10 +5,6 @@ export class NotesModule extends AdaptableModuleBase {
5
5
  super(ModuleConstants.NotesModuleId, ModuleConstants.NotesFriendlyName, 'note', 'NotesPopup', 'Notes', api);
6
6
  this.adaptable = api.internalApi.getAdaptableInstance();
7
7
  }
8
- // isModuleAvailable(): boolean {
9
- // // FIXME remove this once Notes feature is public
10
- // return true;
11
- // }
12
8
  addContextMenuItems(menuContext) {
13
9
  var _a, _b;
14
10
  if (!this.isModuleAvailable()) {
@@ -32,6 +28,9 @@ export class NotesModule extends AdaptableModuleBase {
32
28
  getAddRemoveNoteMenuItems(menuContext) {
33
29
  var _a;
34
30
  const items = [];
31
+ if (!this.api.notesApi.internalApi.areNotesAvailable()) {
32
+ return items;
33
+ }
35
34
  // does not have note
36
35
  const [note] = (_a = this.adaptable.api.notesApi.getCellNotes({
37
36
  PrimaryKeyValue: menuContext.primaryKeyValue,
@@ -6,7 +6,7 @@ import { AggregateParams } from './scalarAggregationHelper';
6
6
  * List of all the AggregatedScalar Functions available in AdaptableQL
7
7
  */
8
8
  export type AggregatedScalarFunctionName = ScalarAggregationFunction | OperandFunction;
9
- export type ScalarAggregationFunction = 'SUM' | 'PERCENTAGE' | 'QUANT' | 'QUARTILE' | 'PERCENTILE' | 'AVG' | 'MIN' | 'MAX' | 'COUNT' | 'CUMUL';
9
+ export type ScalarAggregationFunction = 'SUM' | 'PERCENTAGE' | 'QUANT' | 'QUARTILE' | 'PERCENTILE' | 'AVG' | 'MIN' | 'MAX' | 'COUNT' | 'CUMUL' | 'MEDIAN' | 'MODE' | 'DISTINCT' | 'ONLY' | 'STD_DEVIATION';
10
10
  type OperandFunction = 'COL' | 'OVER' | 'GROUP_BY' | 'WEIGHT';
11
11
  export interface ScalarAggregationParameter extends BaseParameter<'aggregationScalar', ScalarAggregationFunction> {
12
12
  value: AggregatedScalarExpressionEvaluation;
@@ -28,6 +28,7 @@ export interface AggregatedScalarExpressionEvaluation {
28
28
  };
29
29
  sortByColumn?: string;
30
30
  rowFilterFn?: (rowNode: IRowNode) => boolean;
31
+ getRowNodes?: () => IRowNode[];
31
32
  }
32
33
  export interface CumulatedAggregationValue {
33
34
  currentValue: number;