@adaptabletools/adaptable-cjs 21.1.3 → 21.2.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 (37) hide show
  1. package/base.css +1 -0
  2. package/base.css.map +1 -1
  3. package/index.css +1 -0
  4. package/index.css.map +1 -1
  5. package/package.json +1 -1
  6. package/src/AdaptableOptions/PredicateOptions.d.ts +5 -5
  7. package/src/AdaptableState/Common/AdaptablePredicate.d.ts +8 -1
  8. package/src/Api/ColumnApi.d.ts +6 -0
  9. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  10. package/src/Api/Implementation/ColumnApiImpl.js +11 -0
  11. package/src/Api/Implementation/CommentsApiImpl.d.ts +1 -1
  12. package/src/Api/Implementation/CommentsApiImpl.js +6 -6
  13. package/src/Api/Implementation/NoteApiImpl.d.ts +1 -1
  14. package/src/Api/Implementation/NoteApiImpl.js +2 -2
  15. package/src/Api/Internal/AlertInternalApi.js +2 -2
  16. package/src/Api/Internal/ColumnFilterInternalApi.js +3 -2
  17. package/src/Api/Internal/FormatColumnInternalApi.js +1 -0
  18. package/src/Api/NoteApi.d.ts +2 -2
  19. package/src/Redux/ActionsReducers/CommentsRedux.d.ts +34 -31
  20. package/src/Redux/ActionsReducers/CommentsRedux.js +39 -36
  21. package/src/Redux/Store/AdaptableStore.js +6 -6
  22. package/src/Strategy/FlashingCellModule.js +3 -3
  23. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +32 -4
  24. package/src/Utilities/Services/ValidationService.js +1 -0
  25. package/src/Utilities/weightedAverage.d.ts +3 -3
  26. package/src/Utilities/weightedAverage.js +27 -14
  27. package/src/View/Alert/Wizard/AlertButtonsEditor.js +32 -15
  28. package/src/View/FormatColumn/Wizard/FormatColumnSettingsWizardSection.js +5 -5
  29. package/src/View/StateManagement/components/ExportDropdown.js +2 -2
  30. package/src/View/StateManagement/handleExportState.d.ts +2 -1
  31. package/src/View/StateManagement/handleExportState.js +2 -2
  32. package/src/agGrid/AdaptableAgGrid.js +2 -1
  33. package/src/agGrid/AgGridAdapter.js +4 -2
  34. package/src/agGrid/cellRenderers/BadgeRenderer.js +2 -0
  35. package/src/env.js +2 -2
  36. package/src/metamodel/adaptable.metamodel.js +1 -1
  37. package/tsconfig.cjs.tsbuildinfo +1 -1
@@ -2,74 +2,77 @@ import * as Redux from 'redux';
2
2
  import { CommentThread, AdaptableComment, CommentState } from '../../AdaptableState/CommentState';
3
3
  import { CellAddress } from '../../types';
4
4
  /**
5
- * @ReduxAction A Comments has been added
5
+ * @ReduxAction A Comment has been added
6
6
  */
7
- export declare const COMMENTS_ADD = "COMMENTS_ADD";
7
+ export declare const COMMENT_ADD = "COMMENT_ADD";
8
8
  /**
9
- * @ReduxAction Cell Comments has been added
9
+ * @ReduxAction A Comment Thread has been added
10
10
  */
11
- export declare const COMMENTS_CELL_ADD = "COMMENTS_CELL_ADD";
11
+ export declare const COMMENT_THREAD_ADD = "COMMENT_THREAD_ADD";
12
12
  /**
13
- * @ReduxAction Cell comments have been removed
13
+ * @ReduxAction A Comment Thread has been removed
14
14
  */
15
- export declare const COMMENTS_CELL_DELETE = "COMMENTS_CELL_DELETE";
15
+ export declare const COMMENT_THREAD_DELETE = "COMMENT_THREAD_DELETE";
16
16
  /**
17
- * @ReduxAction A Comments has been edited
17
+ * @ReduxAction A Comment has been edited
18
18
  */
19
- export declare const COMMENTS_EDIT = "COMMENTS_EDIT";
19
+ export declare const COMMENT_EDIT = "COMMENT_EDIT";
20
20
  /**
21
- * @ReduxAction A Comments has been deleted
21
+ * @ReduxAction A Comment has been deleted
22
22
  */
23
- export declare const COMMENTS_DELETE = "COMMENTS_DELETE";
23
+ export declare const COMMENT_DELETE = "COMMENT_DELETE";
24
24
  /**
25
25
  * @ReduxAction Comments Module is ready
26
26
  */
27
27
  export declare const COMMENTS_READY = "COMMENTS_READY";
28
- export declare const COMMENTS_LOAD = "COMMENTS_LOAD";
28
+ /**
29
+ * @ReduxAction Comments have been loaded
30
+ */
31
+ export declare const COMMENTS_THREADS_LOAD = "COMMENTS_THREADS_LOAD";
29
32
  export interface AdaptableCommentAction extends Redux.Action {
30
33
  comment: AdaptableComment;
31
34
  cellAddress: CellAddress;
32
35
  }
33
- export interface AdaptableCommentsAddAction extends AdaptableCommentAction {
36
+ export interface AdaptableCommentAddAction extends AdaptableCommentAction {
34
37
  }
35
- export interface AdaptableCommentsCellAddAction extends Redux.Action {
38
+ export interface AdaptableCommentThreadAddAction extends Redux.Action {
36
39
  commentThread: CommentThread;
37
40
  }
38
- export interface AdaptableCommentsSetAction extends Redux.Action {
39
- commentThread: CommentThread[];
41
+ export interface AdaptableCommentThreadsLoadAction extends Redux.Action {
42
+ commentThreads: CommentThread[];
40
43
  }
41
- export interface AdaptableCommentsCellDeleteAction extends Redux.Action {
44
+ export interface AdaptableCommentThreadDeleteAction extends Redux.Action {
42
45
  cellAddress: CellAddress;
43
46
  }
44
- export interface AdaptableCommentsEditAction extends AdaptableCommentAction {
47
+ export interface AdaptableCommentEditAction extends AdaptableCommentAction {
45
48
  }
46
- export interface AdaptableCommentsDeleteAction extends Redux.Action {
49
+ export interface AdaptableCommentDeleteAction extends Redux.Action {
47
50
  commentUuid: AdaptableComment['Uuid'];
48
51
  cellAddress: CellAddress;
49
52
  }
50
- export interface NoteReadyAction extends Redux.Action {
53
+ export interface CommentReadyAction extends Redux.Action {
51
54
  commentState: CommentState;
52
55
  }
53
- export declare const CommentsSet: ({ commentThread, }: {
54
- commentThread: CommentThread[];
55
- }) => AdaptableCommentsSetAction;
56
- export declare const CommentsAdd: ({ comment, cellAddress, }: {
56
+ export declare const CommentThreadsLoad: ({ commentThreads, }: {
57
+ commentThreads: CommentThread[];
58
+ }) => AdaptableCommentThreadsLoadAction;
59
+ export declare const CommentAdd: ({ comment, cellAddress, }: {
57
60
  comment: AdaptableComment;
58
61
  cellAddress: CellAddress;
59
- }) => AdaptableCommentsAddAction;
60
- export declare const CommentsCellAdd: ({ commentThread, }: {
62
+ }) => AdaptableCommentAddAction;
63
+ export declare const CommentThreadAdd: ({ commentThread, }: {
61
64
  commentThread: CommentThread;
62
- }) => AdaptableCommentsCellAddAction;
63
- export declare const CommentsCellDelete: ({ cellAddress: cellAddress, }: {
65
+ }) => AdaptableCommentThreadAddAction;
66
+ export declare const CommentThreadDelete: ({ cellAddress: cellAddress, }: {
64
67
  cellAddress: CellAddress;
65
- }) => AdaptableCommentsCellDeleteAction;
66
- export declare const CommentsEdit: ({ comment, cellAddress, }: {
68
+ }) => AdaptableCommentThreadDeleteAction;
69
+ export declare const CommentEdit: ({ comment, cellAddress, }: {
67
70
  comment: AdaptableComment;
68
71
  cellAddress: CellAddress;
69
- }) => AdaptableCommentsEditAction;
72
+ }) => AdaptableCommentEditAction;
70
73
  export declare const CommentsDelete: ({ commentUuid, cellAddress, }: {
71
74
  commentUuid: AdaptableComment['Uuid'];
72
75
  cellAddress: CellAddress;
73
- }) => AdaptableCommentsDeleteAction;
76
+ }) => AdaptableCommentDeleteAction;
74
77
  export declare const GetCellCommentSelector: (state: CommentState, address: CellAddress) => CommentThread | undefined;
75
78
  export declare const CommentsReducer: Redux.Reducer<CommentState>;
@@ -1,64 +1,67 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommentsReducer = exports.GetCellCommentSelector = exports.CommentsDelete = exports.CommentsEdit = exports.CommentsCellDelete = exports.CommentsCellAdd = exports.CommentsAdd = exports.CommentsSet = exports.COMMENTS_LOAD = exports.COMMENTS_READY = exports.COMMENTS_DELETE = exports.COMMENTS_EDIT = exports.COMMENTS_CELL_DELETE = exports.COMMENTS_CELL_ADD = exports.COMMENTS_ADD = void 0;
3
+ exports.CommentsReducer = exports.GetCellCommentSelector = exports.CommentsDelete = exports.CommentEdit = exports.CommentThreadDelete = exports.CommentThreadAdd = exports.CommentAdd = exports.CommentThreadsLoad = exports.COMMENTS_THREADS_LOAD = exports.COMMENTS_READY = exports.COMMENT_DELETE = exports.COMMENT_EDIT = exports.COMMENT_THREAD_DELETE = exports.COMMENT_THREAD_ADD = exports.COMMENT_ADD = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
6
6
  const ObjectFactory_1 = tslib_1.__importDefault(require("../../Utilities/ObjectFactory"));
7
7
  const AnnotationsService_1 = require("../../Utilities/Services/AnnotationsService");
8
8
  /**
9
- * @ReduxAction A Comments has been added
9
+ * @ReduxAction A Comment has been added
10
10
  */
11
- exports.COMMENTS_ADD = 'COMMENTS_ADD';
11
+ exports.COMMENT_ADD = 'COMMENT_ADD';
12
12
  /**
13
- * @ReduxAction Cell Comments has been added
13
+ * @ReduxAction A Comment Thread has been added
14
14
  */
15
- exports.COMMENTS_CELL_ADD = 'COMMENTS_CELL_ADD';
15
+ exports.COMMENT_THREAD_ADD = 'COMMENT_THREAD_ADD';
16
16
  /**
17
- * @ReduxAction Cell comments have been removed
17
+ * @ReduxAction A Comment Thread has been removed
18
18
  */
19
- exports.COMMENTS_CELL_DELETE = 'COMMENTS_CELL_DELETE';
19
+ exports.COMMENT_THREAD_DELETE = 'COMMENT_THREAD_DELETE';
20
20
  /**
21
- * @ReduxAction A Comments has been edited
21
+ * @ReduxAction A Comment has been edited
22
22
  */
23
- exports.COMMENTS_EDIT = 'COMMENTS_EDIT';
23
+ exports.COMMENT_EDIT = 'COMMENT_EDIT';
24
24
  /**
25
- * @ReduxAction A Comments has been deleted
25
+ * @ReduxAction A Comment has been deleted
26
26
  */
27
- exports.COMMENTS_DELETE = 'COMMENTS_DELETE';
27
+ exports.COMMENT_DELETE = 'COMMENT_DELETE';
28
28
  /**
29
29
  * @ReduxAction Comments Module is ready
30
30
  */
31
31
  exports.COMMENTS_READY = 'COMMENTS_READY';
32
- exports.COMMENTS_LOAD = 'COMMENTS_LOAD';
33
- const CommentsSet = ({ commentThread, }) => ({
34
- type: exports.COMMENTS_LOAD,
35
- commentThread,
32
+ /**
33
+ * @ReduxAction Comments have been loaded
34
+ */
35
+ exports.COMMENTS_THREADS_LOAD = 'COMMENTS_THREADS_LOAD';
36
+ const CommentThreadsLoad = ({ commentThreads, }) => ({
37
+ type: exports.COMMENTS_THREADS_LOAD,
38
+ commentThreads,
36
39
  });
37
- exports.CommentsSet = CommentsSet;
38
- const CommentsAdd = ({ comment, cellAddress, }) => ({
39
- type: exports.COMMENTS_ADD,
40
+ exports.CommentThreadsLoad = CommentThreadsLoad;
41
+ const CommentAdd = ({ comment, cellAddress, }) => ({
42
+ type: exports.COMMENT_ADD,
40
43
  comment,
41
44
  cellAddress,
42
45
  });
43
- exports.CommentsAdd = CommentsAdd;
44
- const CommentsCellAdd = ({ commentThread, }) => ({
45
- type: exports.COMMENTS_CELL_ADD,
46
+ exports.CommentAdd = CommentAdd;
47
+ const CommentThreadAdd = ({ commentThread, }) => ({
48
+ type: exports.COMMENT_THREAD_ADD,
46
49
  commentThread,
47
50
  });
48
- exports.CommentsCellAdd = CommentsCellAdd;
49
- const CommentsCellDelete = ({ cellAddress: cellAddress, }) => ({
50
- type: exports.COMMENTS_CELL_DELETE,
51
+ exports.CommentThreadAdd = CommentThreadAdd;
52
+ const CommentThreadDelete = ({ cellAddress: cellAddress, }) => ({
53
+ type: exports.COMMENT_THREAD_DELETE,
51
54
  cellAddress: cellAddress,
52
55
  });
53
- exports.CommentsCellDelete = CommentsCellDelete;
54
- const CommentsEdit = ({ comment, cellAddress, }) => ({
55
- type: exports.COMMENTS_EDIT,
56
+ exports.CommentThreadDelete = CommentThreadDelete;
57
+ const CommentEdit = ({ comment, cellAddress, }) => ({
58
+ type: exports.COMMENT_EDIT,
56
59
  comment,
57
60
  cellAddress,
58
61
  });
59
- exports.CommentsEdit = CommentsEdit;
62
+ exports.CommentEdit = CommentEdit;
60
63
  const CommentsDelete = ({ commentUuid, cellAddress, }) => ({
61
- type: exports.COMMENTS_DELETE,
64
+ type: exports.COMMENT_DELETE,
62
65
  cellAddress,
63
66
  commentUuid,
64
67
  });
@@ -77,7 +80,7 @@ const initialState = {
77
80
  };
78
81
  const CommentsReducer = (state = initialState, action) => {
79
82
  switch (action.type) {
80
- case exports.COMMENTS_ADD: {
83
+ case exports.COMMENT_ADD: {
81
84
  const addAction = action;
82
85
  const commentThread = state.CommentThreads ?? [];
83
86
  const cellCommentIndex = commentThread.findIndex((cellComments) => {
@@ -100,7 +103,7 @@ const CommentsReducer = (state = initialState, action) => {
100
103
  }
101
104
  return { ...state, CommentThreads: comments };
102
105
  }
103
- case exports.COMMENTS_CELL_ADD: {
106
+ case exports.COMMENT_THREAD_ADD: {
104
107
  return {
105
108
  ...state,
106
109
  CommentThreads: [
@@ -109,14 +112,14 @@ const CommentsReducer = (state = initialState, action) => {
109
112
  ],
110
113
  };
111
114
  }
112
- case exports.COMMENTS_CELL_DELETE: {
115
+ case exports.COMMENT_THREAD_DELETE: {
113
116
  const deleteAction = action;
114
117
  return {
115
118
  ...state,
116
119
  CommentThreads: (state.CommentThreads ?? []).filter((cellComments) => !AnnotationsService_1.AnnotationsService.isSameAddress(cellComments, deleteAction.cellAddress)),
117
120
  };
118
121
  }
119
- case exports.COMMENTS_EDIT: {
122
+ case exports.COMMENT_EDIT: {
120
123
  const editAction = action;
121
124
  let edited = false;
122
125
  const adaptableCellComments = (state.CommentThreads ?? []).map((cellComments) => {
@@ -139,7 +142,7 @@ const CommentsReducer = (state = initialState, action) => {
139
142
  CommentThreads: adaptableCellComments,
140
143
  };
141
144
  }
142
- case exports.COMMENTS_DELETE: {
145
+ case exports.COMMENT_DELETE: {
143
146
  const deleteAction = action;
144
147
  const adaptableCellComments = (state.CommentThreads ?? [])
145
148
  .map((cellComments) => {
@@ -163,10 +166,10 @@ const CommentsReducer = (state = initialState, action) => {
163
166
  CommentThreads: adaptableCellComments,
164
167
  };
165
168
  }
166
- case exports.COMMENTS_LOAD: {
169
+ case exports.COMMENTS_THREADS_LOAD: {
167
170
  return {
168
171
  ...state,
169
- CommentThreads: action.commentThread,
172
+ CommentThreads: action.commentThreads,
170
173
  };
171
174
  }
172
175
  default:
@@ -871,11 +871,11 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
871
871
  * Use Case: Comments has been edited/deleted/added
872
872
  * Action: Triangle can be removed/added
873
873
  */
874
- case CommentsRedux.COMMENTS_ADD:
875
- case CommentsRedux.COMMENTS_EDIT:
876
- case CommentsRedux.COMMENTS_DELETE:
877
- case CommentsRedux.COMMENTS_CELL_DELETE:
878
- case CommentsRedux.COMMENTS_CELL_ADD: {
874
+ case CommentsRedux.COMMENT_ADD:
875
+ case CommentsRedux.COMMENT_EDIT:
876
+ case CommentsRedux.COMMENT_DELETE:
877
+ case CommentsRedux.COMMENT_THREAD_DELETE:
878
+ case CommentsRedux.COMMENT_THREAD_ADD: {
879
879
  let returnAction = next(action);
880
880
  adaptable.AnnotationsService.checkListenToEvents();
881
881
  let rowNode = null;
@@ -900,7 +900,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
900
900
  }
901
901
  return returnAction;
902
902
  }
903
- case CommentsRedux.COMMENTS_LOAD: {
903
+ case CommentsRedux.COMMENTS_THREADS_LOAD: {
904
904
  const previousCommentThreads = adaptable.api.commentApi.getAllComments();
905
905
  let returnAction = next(action);
906
906
  const newCommentThreads = adaptable.api.commentApi.getAllComments() ?? [];
@@ -189,7 +189,7 @@ class FlashingCellModule extends AdaptableModuleBase_1.AdaptableModuleBase {
189
189
  ColumnIds: [column.columnId],
190
190
  },
191
191
  Rule: {
192
- Predicates: [{ PredicateId: 'AnyChange' }],
192
+ BooleanExpression: 'ANY_CHANGE([' + column.columnId + '])',
193
193
  },
194
194
  })),
195
195
  ];
@@ -232,8 +232,8 @@ class FlashingCellModule extends AdaptableModuleBase_1.AdaptableModuleBase {
232
232
  const predicateDefHandlerContext = {
233
233
  value: dataChangedEvent.newValue,
234
234
  oldValue: dataChangedEvent.oldValue,
235
- // TODO send real display value
236
- displayValue: null,
235
+ rawValue: dataChangedEvent.newValue,
236
+ displayValue: dataChangedEvent.newValue,
237
237
  node: dataChangedEvent.rowNode,
238
238
  column: dataChangedEvent.column,
239
239
  ...this.api.internalApi.buildBaseContext(),
@@ -646,7 +646,7 @@ exports.scalarExpressionFunctions = {
646
646
  description: "Returns the percentage difference between a cell's current value and its previous value.",
647
647
  signatures: [
648
648
  'PERCENT_CHANGE( [colName], <INCREASE|DECREASE> )',
649
- 'PERCENT_CHANGE( COL(name: string), <INCREASE|DECREASE>)',
649
+ 'PERCENT_CHANGE( COL(name: string), <INCREASE|DECREASE> )',
650
650
  ],
651
651
  examples: [
652
652
  'PERCENT_CHANGE([col1])',
@@ -666,11 +666,39 @@ exports.scalarExpressionFunctions = {
666
666
  throw new ExpressionEvaluationError_1.ExpressionEvaluationError('ABSOLUTE_CHANGE', 'First argument should be numeric');
667
667
  }
668
668
  const previousValue = context.dataChangedEvent.oldValue;
669
- return currentValue - previousValue;
669
+ const increaseDecrease = args[1];
670
+ let result;
671
+ if (!increaseDecrease) {
672
+ result = sanitizeNumericResult(Math.abs(previousValue - currentValue));
673
+ }
674
+ else if (increaseDecrease === 'INCREASE') {
675
+ result =
676
+ currentValue - previousValue > 0
677
+ ? sanitizeNumericResult(currentValue - previousValue)
678
+ : undefined;
679
+ }
680
+ else if (increaseDecrease === 'DECREASE') {
681
+ result =
682
+ currentValue - previousValue < 0
683
+ ? sanitizeNumericResult(previousValue - currentValue)
684
+ : undefined;
685
+ }
686
+ else {
687
+ throw new ExpressionEvaluationError_1.ExpressionEvaluationError('ABSOLUTE_CHANGE', 'Optional second argument must be "INCREASE" or "DECREASE"');
688
+ }
689
+ return result;
670
690
  },
671
691
  description: "Returns the absolute difference between a cell's current value and its previous value.",
672
- signatures: ['ABSOLUTE_CHANGE( [colName] )', 'ABSOLUTE_CHANGE( COL(name: string) )'],
673
- examples: ['ABSOLUTE_CHANGE([col1])'],
692
+ signatures: [
693
+ 'ABSOLUTE_CHANGE( [colName] )',
694
+ 'ABSOLUTE_CHANGE( COL(name: string) )',
695
+ 'ABSOLUTE_CHANGE( COL(name: string), <INCREASE|DECREASE> )',
696
+ ],
697
+ examples: [
698
+ 'ABSOLUTE_CHANGE([col1])',
699
+ 'ABSOLUTE_CHANGE([col1], "INCREASE")',
700
+ 'ABSOLUTE_CHANGE([col1], "DECREASE")',
701
+ ],
674
702
  category: 'changes',
675
703
  returnType: 'number',
676
704
  },
@@ -85,6 +85,7 @@ class ValidationService {
85
85
  const predicateDefHandlerContext = {
86
86
  value: dataChangedEvent.newValue,
87
87
  oldValue: dataChangedEvent.oldValue,
88
+ rawValue: dataChangedEvent.newValue,
88
89
  displayValue,
89
90
  node: dataChangedEvent.rowNode,
90
91
  column: dataChangedEvent.column,
@@ -1,7 +1,7 @@
1
1
  import { IAggFuncParams } from 'ag-grid-enterprise';
2
2
  export declare const getNumericValue: (input: unknown) => number | null;
3
3
  export declare const weightedAverage: (params: IAggFuncParams, columnId: string, weightColumnId: string) => {
4
- [x: string]: number | (() => number | "");
5
- toString: () => number | "";
6
- valueOf: () => number;
4
+ [x: string]: number | (() => string) | (() => number);
5
+ toString: () => string;
6
+ toNumber: () => number;
7
7
  };
@@ -11,12 +11,27 @@ const getNumericValue = (input) => {
11
11
  return isNaN(numericValue) ? null : numericValue;
12
12
  };
13
13
  exports.getNumericValue = getNumericValue;
14
+ function getWeightedAverageLeafNodes(gridApi, groupRowNode, filteredOnly) {
15
+ const nodeList = (filteredOnly ? groupRowNode.childrenAfterFilter : groupRowNode.childrenAfterGroup) ?? [];
16
+ let leafNodes = [];
17
+ nodeList.forEach((rowNode) => {
18
+ if (rowNode.group === true) {
19
+ // Recursively extract leaf nodes from group
20
+ leafNodes = leafNodes.concat(getWeightedAverageLeafNodes(gridApi, rowNode, filteredOnly));
21
+ }
22
+ else {
23
+ leafNodes.push(rowNode);
24
+ }
25
+ });
26
+ return leafNodes;
27
+ }
14
28
  const weightedAverage = (params, columnId, weightColumnId) => {
15
29
  const { api: gridApi, rowNode: groupRowNode } = params;
16
30
  let weightedColumnValueSum = 0;
17
31
  let columnValueSum = 0;
18
- // TODO AFL: improve performance by using the intermediary aggregated values (for nested groups)
19
- groupRowNode.allLeafChildren.forEach((rowNode) => {
32
+ const filteredOnly = !gridApi.getGridOption('suppressAggFilteredOnly');
33
+ const leafNodes = getWeightedAverageLeafNodes(gridApi, groupRowNode, filteredOnly);
34
+ leafNodes.forEach((rowNode) => {
20
35
  // when editing values might be converted to strings
21
36
  const rawColumnValue = gridApi.getCellValue({ colKey: columnId, rowNode });
22
37
  const columnValue = (0, exports.getNumericValue)(rawColumnValue);
@@ -29,21 +44,19 @@ const weightedAverage = (params, columnId, weightColumnId) => {
29
44
  columnValueSum += columnValue * weightedColumnValue;
30
45
  }
31
46
  });
47
+ let result = columnValueSum / weightedColumnValueSum;
48
+ // 0 / 0 = NaN
49
+ if (isNaN(result)) {
50
+ result = 0;
51
+ }
32
52
  return {
53
+ // the grid by default uses toString to render values for an object, so this
54
+ // is a trick to get the default cellRenderer to display the avg value
33
55
  toString: () => {
34
- const result = columnValueSum / weightedColumnValueSum;
35
- // 0 / 0 = NaN
36
- if (isNaN(result)) {
37
- return '';
38
- }
39
- return result;
56
+ return String(result);
40
57
  },
41
- valueOf: () => {
42
- const result = columnValueSum / weightedColumnValueSum;
43
- // 0 / 0 = NaN
44
- if (isNaN(result)) {
45
- return 0;
46
- }
58
+ // used for sorting
59
+ toNumber: function () {
47
60
  return result;
48
61
  },
49
62
  [columnId]: columnValueSum,
@@ -4,7 +4,6 @@ exports.AlertButtonsEditor = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const rebass_1 = require("rebass");
6
6
  const React = tslib_1.__importStar(require("react"));
7
- const sentence_case_1 = require("sentence-case");
8
7
  const SimpleButton_1 = tslib_1.__importDefault(require("../../../components/SimpleButton"));
9
8
  const Input_1 = tslib_1.__importDefault(require("../../../components/Input"));
10
9
  const FormLayout_1 = tslib_1.__importStar(require("../../../components/FormLayout"));
@@ -13,6 +12,26 @@ const Helper_1 = require("../../../Utilities/Helpers/Helper");
13
12
  const StringExtensions_1 = tslib_1.__importDefault(require("../../../Utilities/Extensions/StringExtensions"));
14
13
  const AdaptableIconSelector_1 = require("../../Components/AdaptableIconSelector");
15
14
  const Select_1 = require("../../../components/Select");
15
+ function renderCommand(command) {
16
+ switch (command) {
17
+ case 'highlight-cell':
18
+ return 'Highlight Cell';
19
+ case 'highlight-row':
20
+ return 'Highlight Row';
21
+ case 'jump-to-cell':
22
+ return 'Jump to Cell';
23
+ case 'jump-to-column':
24
+ return 'Jump to Column';
25
+ case 'jump-to-row':
26
+ return 'Jump to Row';
27
+ case 'suspend':
28
+ return 'Suspend';
29
+ case 'undo':
30
+ return 'Undo';
31
+ default:
32
+ return command;
33
+ }
34
+ }
16
35
  const TONE_OPTIONS = [
17
36
  {
18
37
  label: 'Tone: Use Alert Tone',
@@ -77,6 +96,12 @@ const AlertButtonsEditor = (props) => {
77
96
  if (hasSuspend) {
78
97
  buttonCommands.push('suspend');
79
98
  }
99
+ const commandHandlers = api.optionsApi.getAlertOptions().commandHandlers;
100
+ if (commandHandlers) {
101
+ commandHandlers.forEach((ch) => {
102
+ buttonCommands.push(ch.name);
103
+ });
104
+ }
80
105
  return (React.createElement(React.Fragment, null,
81
106
  React.createElement(rebass_1.Flex, { flexDirection: "row", alignItems: "center", justifyContent: "space-between" },
82
107
  React.createElement(rebass_1.Text, { fontSize: 2, mt: 3, mb: 2 }, "Add Buttons to the Alert Notification, and set Actions to perform when the Button is clicked"),
@@ -102,7 +127,7 @@ const AlertButtonsEditor = (props) => {
102
127
  btnCommands = button.Command;
103
128
  }
104
129
  // filter out the adaptable standard commands
105
- const btnUserFunctions = btnCommands.filter((command) => !buttonCommands.includes(command));
130
+ // const btnUserFunctions = btnCommands.filter((command) => !buttonCommands.includes(command));
106
131
  const setVariant = (variant) => {
107
132
  onChange(AlertButtons.map((btn, i) => {
108
133
  if (i === index) {
@@ -201,19 +226,11 @@ const AlertButtonsEditor = (props) => {
201
226
  React.createElement(SimpleButton_1.default, { icon: "close", tone: "error", disabled: AlertButtons.length <= 1, marginLeft: 1, variant: "text", tooltip: AlertButtons.length <= 1 ? 'Cannot remove last button' : 'Remove button', onClick: () => {
202
227
  onChange(AlertButtons.filter((btn) => btn !== button));
203
228
  } }))),
204
- React.createElement(FormLayout_1.FormRow, { label: React.createElement(rebass_1.Text, { fontSize: 2 }, "Actions") },
205
- buttonCommands.map((commandName) => {
206
- return (React.createElement(CheckBox_1.CheckBox, { key: commandName, marginRight: 3, onChange: (checked) => handleCommandChange(checked, commandName), checked: button.Command === commandName ||
207
- (Array.isArray(button.Command) && button.Command.includes(commandName)) },
208
- React.createElement(rebass_1.Text, { fontSize: 2 }, (0, sentence_case_1.sentenceCase)(commandName))));
209
- }),
210
- btnUserFunctions.length ? (React.createElement(CheckBox_1.CheckBox, { checked: true, disabled: true },
211
- React.createElement(rebass_1.Text, { fontSize: 2 },
212
- "User function",
213
- btnUserFunctions.length > 1 ? 's' : '',
214
- ":",
215
- ' ',
216
- btnUserFunctions.join(', ')))) : null),
229
+ React.createElement(FormLayout_1.FormRow, { label: React.createElement(rebass_1.Text, { fontSize: 2 }, "Actions") }, buttonCommands.map((commandName) => {
230
+ return (React.createElement(CheckBox_1.CheckBox, { key: commandName, marginRight: 3, onChange: (checked) => handleCommandChange(checked, commandName), checked: button.Command === commandName ||
231
+ (Array.isArray(button.Command) && button.Command.includes(commandName)) },
232
+ React.createElement(rebass_1.Text, { fontSize: 2 }, renderCommand(commandName))));
233
+ })),
217
234
  iconSelector && (React.createElement(FormLayout_1.FormRow, { label: React.createElement(rebass_1.Text, { fontSize: 2 }, "Icon") },
218
235
  React.createElement(rebass_1.Box, null, iconSelector))))));
219
236
  })));
@@ -16,20 +16,20 @@ const renderFormatColumnSettingsSummary = (data) => {
16
16
  return (React.createElement(rebass_1.Box, { padding: 2 },
17
17
  React.createElement(rebass_1.Text, null,
18
18
  "Cell alignment ",
19
- React.createElement(Tag_1.Tag, null, data.CellAlignment ?? 'default')),
19
+ React.createElement(Tag_1.Tag, null, data.CellAlignment ?? 'Default')),
20
20
  React.createElement(rebass_1.Text, { mt: 3 },
21
21
  "Data Rows ",
22
- React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeDataRows ? 'no' : 'yes')),
22
+ React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeDataRows ? 'No' : 'Yes')),
23
23
  ' ',
24
24
  React.createElement(rebass_1.Text, { mt: 3 },
25
25
  "Group Rows ",
26
- React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeGroupRows ? 'no' : 'yes')),
26
+ React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeGroupRows ? 'No' : 'Yes')),
27
27
  React.createElement(rebass_1.Text, { mt: 3 },
28
28
  "Summary Rows ",
29
- React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeSummaryRows ? 'no' : 'yes')),
29
+ React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeSummaryRows ? 'No' : 'Yes')),
30
30
  React.createElement(rebass_1.Text, { mt: 3 },
31
31
  "Total Rows ",
32
- React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeTotalRows ? 'no' : 'yes')),
32
+ React.createElement(Tag_1.Tag, null, data.RowScope?.ExcludeTotalRows ? 'No' : 'Yes')),
33
33
  React.createElement(rebass_1.Text, { mt: 3 },
34
34
  "Apply on Column Groups:",
35
35
  ' ',
@@ -10,11 +10,11 @@ const ExportDropdown = (props) => {
10
10
  switch (props.type) {
11
11
  case 'adaptableState':
12
12
  const adaptableState = props.api.stateApi.getPersistentState();
13
- (0, handleExportState_1.handleExportState)(destination, 'adaptableState', adaptableState);
13
+ (0, handleExportState_1.handleExportState)(destination, 'adaptableState', adaptableState, props.api);
14
14
  break;
15
15
  case 'initialState':
16
16
  const initialState = props.api.stateApi.getInitialState();
17
- (0, handleExportState_1.handleExportState)(destination, 'initialState', initialState);
17
+ (0, handleExportState_1.handleExportState)(destination, 'initialState', initialState, props.api);
18
18
  break;
19
19
  }
20
20
  };
@@ -1 +1,2 @@
1
- export declare const handleExportState: (type: 'Clipboard' | 'Console' | 'JSON', name: 'adaptableState' | 'initialState', state: any) => void;
1
+ import { AdaptableApi } from '../../types';
2
+ export declare const handleExportState: (type: 'Clipboard' | 'Console' | 'JSON', name: 'adaptableState' | 'initialState', state: any, api: AdaptableApi) => void;
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleExportState = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Helper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/Helper"));
6
- const handleExportState = (type, name, state) => {
6
+ const handleExportState = (type, name, state, api) => {
7
7
  switch (type) {
8
8
  case 'Clipboard':
9
9
  let stringifiedState = JSON.stringify(state);
10
10
  Helper_1.default.copyToClipboard(stringifiedState);
11
11
  break;
12
12
  case 'Console':
13
- console.log('Adaptable State: ', state);
13
+ api.consoleLog('Adaptable State: ', state);
14
14
  break;
15
15
  case 'JSON':
16
16
  const jsonFileName = name + '.json';
@@ -1768,7 +1768,8 @@ You need to define at least one Layout!`);
1768
1768
  let _displayValue = defaults ? defaults.displayValue : undefined;
1769
1769
  let _normalisedValue = defaults ? defaults.normalisedValue : undefined;
1770
1770
  let _isRowGroupCell;
1771
- const _isPivotCell = this.api.columnApi.isPivotResultColumn(columnId);
1771
+ const _isPivotCell = this.api.columnApi.isPivotResultColumn(columnId) ||
1772
+ this.api.columnApi.isPivotAggColumnWithNoPivotColumns(columnId);
1772
1773
  const self = this;
1773
1774
  const api = this.api;
1774
1775
  const getRawValue = () => {
@@ -158,7 +158,8 @@ class AgGridAdapter {
158
158
  const pivotColumnFilters = self.adaptableApi.filterApi.columnFilterApi
159
159
  .getActiveColumnFilters()
160
160
  .filter((columnFilter) => self.adaptableApi.columnApi.isPivotResultColumn(columnFilter.ColumnId) ||
161
- self.adaptableApi.columnApi.isAutoRowGroupColumnForSingle(columnFilter.ColumnId));
161
+ self.adaptableApi.columnApi.isAutoRowGroupColumnForSingle(columnFilter.ColumnId) ||
162
+ self.adaptableApi.columnApi.isPivotAggColumnWithNoPivotColumns(columnFilter.ColumnId));
162
163
  try {
163
164
  if (pivotColumnFilters.length > 0) {
164
165
  for (const columnFilter of pivotColumnFilters) {
@@ -182,7 +183,8 @@ class AgGridAdapter {
182
183
  this.DANGER_isAggFilterPresentMonkeyPatcher = function () {
183
184
  const columnFilters = self.adaptableApi.filterApi.columnFilterApi.getActiveColumnFilters();
184
185
  return columnFilters.some((colFilter) => self.adaptableApi.columnApi.isPivotResultColumn(colFilter.ColumnId) ||
185
- self.adaptableApi.columnApi.isAutoRowGroupColumnForSingle(colFilter.ColumnId));
186
+ self.adaptableApi.columnApi.isAutoRowGroupColumnForSingle(colFilter.ColumnId) ||
187
+ self.adaptableApi.columnApi.isPivotAggColumnWithNoPivotColumns(colFilter.ColumnId));
186
188
  };
187
189
  agGridColumnFilterService.isAggFilterPresent = this.DANGER_isAggFilterPresentMonkeyPatcher;
188
190
  }
@@ -63,6 +63,7 @@ const getBadgeRendererForColumn = (badgeStyle, abColumn, api) => {
63
63
  for (const value of params.value) {
64
64
  const predicateDefHandlerContext = {
65
65
  value: value,
66
+ rawValue: value,
66
67
  oldValue: null,
67
68
  displayValue: params.formatValue,
68
69
  node: params.node,
@@ -86,6 +87,7 @@ const getBadgeRendererForColumn = (badgeStyle, abColumn, api) => {
86
87
  let formattedValue = params.formatValue?.(params.value) ?? params.value ?? '';
87
88
  const predicateDefHandlerContext = {
88
89
  value: params.value,
90
+ rawValue: params.value,
89
91
  oldValue: null,
90
92
  displayValue: params.formatValue,
91
93
  node: params.node,