@adaptabletools/adaptable 21.1.3-canary.0 → 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 (44) 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 +33 -30
  21. package/src/Redux/Store/AdaptableStore.js +6 -6
  22. package/src/Strategy/CommentModule.js +3 -1
  23. package/src/Strategy/FlashingCellModule.js +3 -3
  24. package/src/Strategy/LayoutModule.js +2 -1
  25. package/src/Strategy/NoteModule.js +3 -1
  26. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +32 -4
  27. package/src/Utilities/Services/ValidationService.js +1 -0
  28. package/src/Utilities/weightedAverage.d.ts +3 -3
  29. package/src/Utilities/weightedAverage.js +27 -14
  30. package/src/View/Alert/Wizard/AlertButtonsEditor.js +32 -15
  31. package/src/View/FormatColumn/Wizard/FormatColumnSettingsWizardSection.js +5 -5
  32. package/src/View/Layout/Wizard/sections/ColumnsSection.js +2 -1
  33. package/src/View/StateManagement/components/ExportDropdown.js +2 -2
  34. package/src/View/StateManagement/handleExportState.d.ts +2 -1
  35. package/src/View/StateManagement/handleExportState.js +2 -2
  36. package/src/agGrid/AdaptableAgGrid.js +2 -1
  37. package/src/agGrid/AgGridAdapter.js +4 -2
  38. package/src/agGrid/AgGridColumnAdapter.js +22 -1
  39. package/src/agGrid/AgGridExportAdapter.d.ts +3 -2
  40. package/src/agGrid/AgGridExportAdapter.js +80 -14
  41. package/src/agGrid/cellRenderers/BadgeRenderer.js +2 -0
  42. package/src/env.js +2 -2
  43. package/src/metamodel/adaptable.metamodel.js +1 -1
  44. package/tsconfig.esm.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>;
@@ -2,54 +2,57 @@ import { EMPTY_ARRAY } from '../../Utilities/Constants/GeneralConstants';
2
2
  import ObjectFactory from '../../Utilities/ObjectFactory';
3
3
  import { AnnotationsService } from '../../Utilities/Services/AnnotationsService';
4
4
  /**
5
- * @ReduxAction A Comments has been added
5
+ * @ReduxAction A Comment has been added
6
6
  */
7
- export const COMMENTS_ADD = 'COMMENTS_ADD';
7
+ export 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 const COMMENTS_CELL_ADD = 'COMMENTS_CELL_ADD';
11
+ export 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 const COMMENTS_CELL_DELETE = 'COMMENTS_CELL_DELETE';
15
+ export 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 const COMMENTS_EDIT = 'COMMENTS_EDIT';
19
+ export 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 const COMMENTS_DELETE = 'COMMENTS_DELETE';
23
+ export const COMMENT_DELETE = 'COMMENT_DELETE';
24
24
  /**
25
25
  * @ReduxAction Comments Module is ready
26
26
  */
27
27
  export const COMMENTS_READY = 'COMMENTS_READY';
28
- export const COMMENTS_LOAD = 'COMMENTS_LOAD';
29
- export const CommentsSet = ({ commentThread, }) => ({
30
- type: COMMENTS_LOAD,
31
- commentThread,
28
+ /**
29
+ * @ReduxAction Comments have been loaded
30
+ */
31
+ export const COMMENTS_THREADS_LOAD = 'COMMENTS_THREADS_LOAD';
32
+ export const CommentThreadsLoad = ({ commentThreads, }) => ({
33
+ type: COMMENTS_THREADS_LOAD,
34
+ commentThreads,
32
35
  });
33
- export const CommentsAdd = ({ comment, cellAddress, }) => ({
34
- type: COMMENTS_ADD,
36
+ export const CommentAdd = ({ comment, cellAddress, }) => ({
37
+ type: COMMENT_ADD,
35
38
  comment,
36
39
  cellAddress,
37
40
  });
38
- export const CommentsCellAdd = ({ commentThread, }) => ({
39
- type: COMMENTS_CELL_ADD,
41
+ export const CommentThreadAdd = ({ commentThread, }) => ({
42
+ type: COMMENT_THREAD_ADD,
40
43
  commentThread,
41
44
  });
42
- export const CommentsCellDelete = ({ cellAddress: cellAddress, }) => ({
43
- type: COMMENTS_CELL_DELETE,
45
+ export const CommentThreadDelete = ({ cellAddress: cellAddress, }) => ({
46
+ type: COMMENT_THREAD_DELETE,
44
47
  cellAddress: cellAddress,
45
48
  });
46
- export const CommentsEdit = ({ comment, cellAddress, }) => ({
47
- type: COMMENTS_EDIT,
49
+ export const CommentEdit = ({ comment, cellAddress, }) => ({
50
+ type: COMMENT_EDIT,
48
51
  comment,
49
52
  cellAddress,
50
53
  });
51
54
  export const CommentsDelete = ({ commentUuid, cellAddress, }) => ({
52
- type: COMMENTS_DELETE,
55
+ type: COMMENT_DELETE,
53
56
  cellAddress,
54
57
  commentUuid,
55
58
  });
@@ -66,7 +69,7 @@ const initialState = {
66
69
  };
67
70
  export const CommentsReducer = (state = initialState, action) => {
68
71
  switch (action.type) {
69
- case COMMENTS_ADD: {
72
+ case COMMENT_ADD: {
70
73
  const addAction = action;
71
74
  const commentThread = state.CommentThreads ?? [];
72
75
  const cellCommentIndex = commentThread.findIndex((cellComments) => {
@@ -89,7 +92,7 @@ export const CommentsReducer = (state = initialState, action) => {
89
92
  }
90
93
  return { ...state, CommentThreads: comments };
91
94
  }
92
- case COMMENTS_CELL_ADD: {
95
+ case COMMENT_THREAD_ADD: {
93
96
  return {
94
97
  ...state,
95
98
  CommentThreads: [
@@ -98,14 +101,14 @@ export const CommentsReducer = (state = initialState, action) => {
98
101
  ],
99
102
  };
100
103
  }
101
- case COMMENTS_CELL_DELETE: {
104
+ case COMMENT_THREAD_DELETE: {
102
105
  const deleteAction = action;
103
106
  return {
104
107
  ...state,
105
108
  CommentThreads: (state.CommentThreads ?? []).filter((cellComments) => !AnnotationsService.isSameAddress(cellComments, deleteAction.cellAddress)),
106
109
  };
107
110
  }
108
- case COMMENTS_EDIT: {
111
+ case COMMENT_EDIT: {
109
112
  const editAction = action;
110
113
  let edited = false;
111
114
  const adaptableCellComments = (state.CommentThreads ?? []).map((cellComments) => {
@@ -128,7 +131,7 @@ export const CommentsReducer = (state = initialState, action) => {
128
131
  CommentThreads: adaptableCellComments,
129
132
  };
130
133
  }
131
- case COMMENTS_DELETE: {
134
+ case COMMENT_DELETE: {
132
135
  const deleteAction = action;
133
136
  const adaptableCellComments = (state.CommentThreads ?? [])
134
137
  .map((cellComments) => {
@@ -152,10 +155,10 @@ export const CommentsReducer = (state = initialState, action) => {
152
155
  CommentThreads: adaptableCellComments,
153
156
  };
154
157
  }
155
- case COMMENTS_LOAD: {
158
+ case COMMENTS_THREADS_LOAD: {
156
159
  return {
157
160
  ...state,
158
- CommentThreads: action.commentThread,
161
+ CommentThreads: action.commentThreads,
159
162
  };
160
163
  }
161
164
  default:
@@ -864,11 +864,11 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
864
864
  * Use Case: Comments has been edited/deleted/added
865
865
  * Action: Triangle can be removed/added
866
866
  */
867
- case CommentsRedux.COMMENTS_ADD:
868
- case CommentsRedux.COMMENTS_EDIT:
869
- case CommentsRedux.COMMENTS_DELETE:
870
- case CommentsRedux.COMMENTS_CELL_DELETE:
871
- case CommentsRedux.COMMENTS_CELL_ADD: {
867
+ case CommentsRedux.COMMENT_ADD:
868
+ case CommentsRedux.COMMENT_EDIT:
869
+ case CommentsRedux.COMMENT_DELETE:
870
+ case CommentsRedux.COMMENT_THREAD_DELETE:
871
+ case CommentsRedux.COMMENT_THREAD_ADD: {
872
872
  let returnAction = next(action);
873
873
  adaptable.AnnotationsService.checkListenToEvents();
874
874
  let rowNode = null;
@@ -893,7 +893,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
893
893
  }
894
894
  return returnAction;
895
895
  }
896
- case CommentsRedux.COMMENTS_LOAD: {
896
+ case CommentsRedux.COMMENTS_THREADS_LOAD: {
897
897
  const previousCommentThreads = adaptable.api.commentApi.getAllComments();
898
898
  let returnAction = next(action);
899
899
  const newCommentThreads = adaptable.api.commentApi.getAllComments() ?? [];
@@ -30,7 +30,9 @@ export class CommentModule extends AdaptableModuleBase {
30
30
  if (!this.api.commentApi.internalApi.areCommentsSupportedInLayout()) {
31
31
  return;
32
32
  }
33
- if (menuContext.isRowGroupColumn || menuContext.isGroupedNode) {
33
+ if (menuContext.isRowGroupColumn ||
34
+ menuContext.isGroupedNode ||
35
+ !menuContext.isSingleSelectedCell) {
34
36
  return;
35
37
  }
36
38
  const items = [];
@@ -185,7 +185,7 @@ export class FlashingCellModule extends AdaptableModuleBase {
185
185
  ColumnIds: [column.columnId],
186
186
  },
187
187
  Rule: {
188
- Predicates: [{ PredicateId: 'AnyChange' }],
188
+ BooleanExpression: 'ANY_CHANGE([' + column.columnId + '])',
189
189
  },
190
190
  })),
191
191
  ];
@@ -228,8 +228,8 @@ export class FlashingCellModule extends AdaptableModuleBase {
228
228
  const predicateDefHandlerContext = {
229
229
  value: dataChangedEvent.newValue,
230
230
  oldValue: dataChangedEvent.oldValue,
231
- // TODO send real display value
232
- displayValue: null,
231
+ rawValue: dataChangedEvent.newValue,
232
+ displayValue: dataChangedEvent.newValue,
233
233
  node: dataChangedEvent.rowNode,
234
234
  column: dataChangedEvent.column,
235
235
  ...this.api.internalApi.buildBaseContext(),
@@ -283,7 +283,8 @@ export class LayoutModule extends AdaptableModuleBase {
283
283
  };
284
284
  let columns = (layout.TableColumns || [])
285
285
  .filter((c) => !this.api.columnApi.isAutoRowGroupColumn(c))
286
- .filter((c) => !this.api.columnApi.isPivotResultColumn(c));
286
+ .filter((c) => !this.api.columnApi.isPivotResultColumn(c))
287
+ .filter((c) => !this.api.columnApi.isSelectionColumn(c));
287
288
  if (columns.length >
288
289
  maxColumnsToDisplay + 1 /* +1 is to show tag only beginning with 2, 'other 2' */) {
289
290
  const extraColumns = columns.length - maxColumnsToDisplay;
@@ -18,7 +18,9 @@ export class NoteModule extends AdaptableModuleBase {
18
18
  if (!this.api.noteApi.internalApi.areNotesSupported()) {
19
19
  return;
20
20
  }
21
- if (menuContext.isRowGroupColumn || menuContext.isGroupedNode) {
21
+ if (menuContext.isRowGroupColumn ||
22
+ menuContext.isGroupedNode ||
23
+ !menuContext.isSingleSelectedCell) {
22
24
  return;
23
25
  }
24
26
  const isReadOnly = this.api.entitlementApi.getEntitlementAccessLevelForModule(this.moduleInfo.ModuleName) ===
@@ -642,7 +642,7 @@ export const scalarExpressionFunctions = {
642
642
  description: "Returns the percentage difference between a cell's current value and its previous value.",
643
643
  signatures: [
644
644
  'PERCENT_CHANGE( [colName], <INCREASE|DECREASE> )',
645
- 'PERCENT_CHANGE( COL(name: string), <INCREASE|DECREASE>)',
645
+ 'PERCENT_CHANGE( COL(name: string), <INCREASE|DECREASE> )',
646
646
  ],
647
647
  examples: [
648
648
  'PERCENT_CHANGE([col1])',
@@ -662,11 +662,39 @@ export const scalarExpressionFunctions = {
662
662
  throw new ExpressionEvaluationError('ABSOLUTE_CHANGE', 'First argument should be numeric');
663
663
  }
664
664
  const previousValue = context.dataChangedEvent.oldValue;
665
- return currentValue - previousValue;
665
+ const increaseDecrease = args[1];
666
+ let result;
667
+ if (!increaseDecrease) {
668
+ result = sanitizeNumericResult(Math.abs(previousValue - currentValue));
669
+ }
670
+ else if (increaseDecrease === 'INCREASE') {
671
+ result =
672
+ currentValue - previousValue > 0
673
+ ? sanitizeNumericResult(currentValue - previousValue)
674
+ : undefined;
675
+ }
676
+ else if (increaseDecrease === 'DECREASE') {
677
+ result =
678
+ currentValue - previousValue < 0
679
+ ? sanitizeNumericResult(previousValue - currentValue)
680
+ : undefined;
681
+ }
682
+ else {
683
+ throw new ExpressionEvaluationError('ABSOLUTE_CHANGE', 'Optional second argument must be "INCREASE" or "DECREASE"');
684
+ }
685
+ return result;
666
686
  },
667
687
  description: "Returns the absolute difference between a cell's current value and its previous value.",
668
- signatures: ['ABSOLUTE_CHANGE( [colName] )', 'ABSOLUTE_CHANGE( COL(name: string) )'],
669
- examples: ['ABSOLUTE_CHANGE([col1])'],
688
+ signatures: [
689
+ 'ABSOLUTE_CHANGE( [colName] )',
690
+ 'ABSOLUTE_CHANGE( COL(name: string) )',
691
+ 'ABSOLUTE_CHANGE( COL(name: string), <INCREASE|DECREASE> )',
692
+ ],
693
+ examples: [
694
+ 'ABSOLUTE_CHANGE([col1])',
695
+ 'ABSOLUTE_CHANGE([col1], "INCREASE")',
696
+ 'ABSOLUTE_CHANGE([col1], "DECREASE")',
697
+ ],
670
698
  category: 'changes',
671
699
  returnType: 'number',
672
700
  },
@@ -81,6 +81,7 @@ export class ValidationService {
81
81
  const predicateDefHandlerContext = {
82
82
  value: dataChangedEvent.newValue,
83
83
  oldValue: dataChangedEvent.oldValue,
84
+ rawValue: dataChangedEvent.newValue,
84
85
  displayValue,
85
86
  node: dataChangedEvent.rowNode,
86
87
  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
  };
@@ -6,12 +6,27 @@ export const getNumericValue = (input) => {
6
6
  const numericValue = toNumber(input);
7
7
  return isNaN(numericValue) ? null : numericValue;
8
8
  };
9
+ function getWeightedAverageLeafNodes(gridApi, groupRowNode, filteredOnly) {
10
+ const nodeList = (filteredOnly ? groupRowNode.childrenAfterFilter : groupRowNode.childrenAfterGroup) ?? [];
11
+ let leafNodes = [];
12
+ nodeList.forEach((rowNode) => {
13
+ if (rowNode.group === true) {
14
+ // Recursively extract leaf nodes from group
15
+ leafNodes = leafNodes.concat(getWeightedAverageLeafNodes(gridApi, rowNode, filteredOnly));
16
+ }
17
+ else {
18
+ leafNodes.push(rowNode);
19
+ }
20
+ });
21
+ return leafNodes;
22
+ }
9
23
  export const weightedAverage = (params, columnId, weightColumnId) => {
10
24
  const { api: gridApi, rowNode: groupRowNode } = params;
11
25
  let weightedColumnValueSum = 0;
12
26
  let columnValueSum = 0;
13
- // TODO AFL: improve performance by using the intermediary aggregated values (for nested groups)
14
- groupRowNode.allLeafChildren.forEach((rowNode) => {
27
+ const filteredOnly = !gridApi.getGridOption('suppressAggFilteredOnly');
28
+ const leafNodes = getWeightedAverageLeafNodes(gridApi, groupRowNode, filteredOnly);
29
+ leafNodes.forEach((rowNode) => {
15
30
  // when editing values might be converted to strings
16
31
  const rawColumnValue = gridApi.getCellValue({ colKey: columnId, rowNode });
17
32
  const columnValue = getNumericValue(rawColumnValue);
@@ -24,21 +39,19 @@ export const weightedAverage = (params, columnId, weightColumnId) => {
24
39
  columnValueSum += columnValue * weightedColumnValue;
25
40
  }
26
41
  });
42
+ let result = columnValueSum / weightedColumnValueSum;
43
+ // 0 / 0 = NaN
44
+ if (isNaN(result)) {
45
+ result = 0;
46
+ }
27
47
  return {
48
+ // the grid by default uses toString to render values for an object, so this
49
+ // is a trick to get the default cellRenderer to display the avg value
28
50
  toString: () => {
29
- const result = columnValueSum / weightedColumnValueSum;
30
- // 0 / 0 = NaN
31
- if (isNaN(result)) {
32
- return '';
33
- }
34
- return result;
51
+ return String(result);
35
52
  },
36
- valueOf: () => {
37
- const result = columnValueSum / weightedColumnValueSum;
38
- // 0 / 0 = NaN
39
- if (isNaN(result)) {
40
- return 0;
41
- }
53
+ // used for sorting
54
+ toNumber: function () {
42
55
  return result;
43
56
  },
44
57
  [columnId]: columnValueSum,
@@ -1,6 +1,5 @@
1
1
  import { Flex, Box, Text } from 'rebass';
2
2
  import * as React from 'react';
3
- import { sentenceCase } from 'sentence-case';
4
3
  import SimpleButton from '../../../components/SimpleButton';
5
4
  import Input from '../../../components/Input';
6
5
  import FormLayout, { FormRow } from '../../../components/FormLayout';
@@ -9,6 +8,26 @@ import { cloneObject } from '../../../Utilities/Helpers/Helper';
9
8
  import StringExtensions from '../../../Utilities/Extensions/StringExtensions';
10
9
  import { AdaptableIconSelector } from '../../Components/AdaptableIconSelector';
11
10
  import { Select } from '../../../components/Select';
11
+ function renderCommand(command) {
12
+ switch (command) {
13
+ case 'highlight-cell':
14
+ return 'Highlight Cell';
15
+ case 'highlight-row':
16
+ return 'Highlight Row';
17
+ case 'jump-to-cell':
18
+ return 'Jump to Cell';
19
+ case 'jump-to-column':
20
+ return 'Jump to Column';
21
+ case 'jump-to-row':
22
+ return 'Jump to Row';
23
+ case 'suspend':
24
+ return 'Suspend';
25
+ case 'undo':
26
+ return 'Undo';
27
+ default:
28
+ return command;
29
+ }
30
+ }
12
31
  const TONE_OPTIONS = [
13
32
  {
14
33
  label: 'Tone: Use Alert Tone',
@@ -73,6 +92,12 @@ export const AlertButtonsEditor = (props) => {
73
92
  if (hasSuspend) {
74
93
  buttonCommands.push('suspend');
75
94
  }
95
+ const commandHandlers = api.optionsApi.getAlertOptions().commandHandlers;
96
+ if (commandHandlers) {
97
+ commandHandlers.forEach((ch) => {
98
+ buttonCommands.push(ch.name);
99
+ });
100
+ }
76
101
  return (React.createElement(React.Fragment, null,
77
102
  React.createElement(Flex, { flexDirection: "row", alignItems: "center", justifyContent: "space-between" },
78
103
  React.createElement(Text, { fontSize: 2, mt: 3, mb: 2 }, "Add Buttons to the Alert Notification, and set Actions to perform when the Button is clicked"),
@@ -98,7 +123,7 @@ export const AlertButtonsEditor = (props) => {
98
123
  btnCommands = button.Command;
99
124
  }
100
125
  // filter out the adaptable standard commands
101
- const btnUserFunctions = btnCommands.filter((command) => !buttonCommands.includes(command));
126
+ // const btnUserFunctions = btnCommands.filter((command) => !buttonCommands.includes(command));
102
127
  const setVariant = (variant) => {
103
128
  onChange(AlertButtons.map((btn, i) => {
104
129
  if (i === index) {
@@ -197,19 +222,11 @@ export const AlertButtonsEditor = (props) => {
197
222
  React.createElement(SimpleButton, { icon: "close", tone: "error", disabled: AlertButtons.length <= 1, marginLeft: 1, variant: "text", tooltip: AlertButtons.length <= 1 ? 'Cannot remove last button' : 'Remove button', onClick: () => {
198
223
  onChange(AlertButtons.filter((btn) => btn !== button));
199
224
  } }))),
200
- React.createElement(FormRow, { label: React.createElement(Text, { fontSize: 2 }, "Actions") },
201
- buttonCommands.map((commandName) => {
202
- return (React.createElement(CheckBox, { key: commandName, marginRight: 3, onChange: (checked) => handleCommandChange(checked, commandName), checked: button.Command === commandName ||
203
- (Array.isArray(button.Command) && button.Command.includes(commandName)) },
204
- React.createElement(Text, { fontSize: 2 }, sentenceCase(commandName))));
205
- }),
206
- btnUserFunctions.length ? (React.createElement(CheckBox, { checked: true, disabled: true },
207
- React.createElement(Text, { fontSize: 2 },
208
- "User function",
209
- btnUserFunctions.length > 1 ? 's' : '',
210
- ":",
211
- ' ',
212
- btnUserFunctions.join(', ')))) : null),
225
+ React.createElement(FormRow, { label: React.createElement(Text, { fontSize: 2 }, "Actions") }, buttonCommands.map((commandName) => {
226
+ return (React.createElement(CheckBox, { key: commandName, marginRight: 3, onChange: (checked) => handleCommandChange(checked, commandName), checked: button.Command === commandName ||
227
+ (Array.isArray(button.Command) && button.Command.includes(commandName)) },
228
+ React.createElement(Text, { fontSize: 2 }, renderCommand(commandName))));
229
+ })),
213
230
  iconSelector && (React.createElement(FormRow, { label: React.createElement(Text, { fontSize: 2 }, "Icon") },
214
231
  React.createElement(Box, null, iconSelector))))));
215
232
  })));
@@ -12,20 +12,20 @@ export const renderFormatColumnSettingsSummary = (data) => {
12
12
  return (React.createElement(Box, { padding: 2 },
13
13
  React.createElement(Text, null,
14
14
  "Cell alignment ",
15
- React.createElement(Tag, null, data.CellAlignment ?? 'default')),
15
+ React.createElement(Tag, null, data.CellAlignment ?? 'Default')),
16
16
  React.createElement(Text, { mt: 3 },
17
17
  "Data Rows ",
18
- React.createElement(Tag, null, data.RowScope?.ExcludeDataRows ? 'no' : 'yes')),
18
+ React.createElement(Tag, null, data.RowScope?.ExcludeDataRows ? 'No' : 'Yes')),
19
19
  ' ',
20
20
  React.createElement(Text, { mt: 3 },
21
21
  "Group Rows ",
22
- React.createElement(Tag, null, data.RowScope?.ExcludeGroupRows ? 'no' : 'yes')),
22
+ React.createElement(Tag, null, data.RowScope?.ExcludeGroupRows ? 'No' : 'Yes')),
23
23
  React.createElement(Text, { mt: 3 },
24
24
  "Summary Rows ",
25
- React.createElement(Tag, null, data.RowScope?.ExcludeSummaryRows ? 'no' : 'yes')),
25
+ React.createElement(Tag, null, data.RowScope?.ExcludeSummaryRows ? 'No' : 'Yes')),
26
26
  React.createElement(Text, { mt: 3 },
27
27
  "Total Rows ",
28
- React.createElement(Tag, null, data.RowScope?.ExcludeTotalRows ? 'no' : 'yes')),
28
+ React.createElement(Tag, null, data.RowScope?.ExcludeTotalRows ? 'No' : 'Yes')),
29
29
  React.createElement(Text, { mt: 3 },
30
30
  "Apply on Column Groups:",
31
31
  ' ',
@@ -40,7 +40,8 @@ export const ColumnsSectionSummary = () => {
40
40
  const data = React.useMemo(() => {
41
41
  return ColumnIds.map((columnId) => {
42
42
  if (adaptable.api.columnApi.isPivotResultColumn(columnId) ||
43
- adaptable.api.columnApi.isAutoRowGroupColumn(columnId)) {
43
+ adaptable.api.columnApi.isAutoRowGroupColumn(columnId) ||
44
+ adaptable.api.columnApi.isSelectionColumn(columnId)) {
44
45
  return null;
45
46
  }
46
47
  const friendlyName = adaptable.api.columnApi.getFriendlyNameForColumnId(columnId, layout);
@@ -6,11 +6,11 @@ export const ExportDropdown = (props) => {
6
6
  switch (props.type) {
7
7
  case 'adaptableState':
8
8
  const adaptableState = props.api.stateApi.getPersistentState();
9
- handleExportState(destination, 'adaptableState', adaptableState);
9
+ handleExportState(destination, 'adaptableState', adaptableState, props.api);
10
10
  break;
11
11
  case 'initialState':
12
12
  const initialState = props.api.stateApi.getInitialState();
13
- handleExportState(destination, 'initialState', initialState);
13
+ handleExportState(destination, 'initialState', initialState, props.api);
14
14
  break;
15
15
  }
16
16
  };
@@ -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;
@@ -1,12 +1,12 @@
1
1
  import Helper from '../../Utilities/Helpers/Helper';
2
- export const handleExportState = (type, name, state) => {
2
+ export const handleExportState = (type, name, state, api) => {
3
3
  switch (type) {
4
4
  case 'Clipboard':
5
5
  let stringifiedState = JSON.stringify(state);
6
6
  Helper.copyToClipboard(stringifiedState);
7
7
  break;
8
8
  case 'Console':
9
- console.log('Adaptable State: ', state);
9
+ api.consoleLog('Adaptable State: ', state);
10
10
  break;
11
11
  case 'JSON':
12
12
  const jsonFileName = name + '.json';
@@ -1764,7 +1764,8 @@ You need to define at least one Layout!`);
1764
1764
  let _displayValue = defaults ? defaults.displayValue : undefined;
1765
1765
  let _normalisedValue = defaults ? defaults.normalisedValue : undefined;
1766
1766
  let _isRowGroupCell;
1767
- const _isPivotCell = this.api.columnApi.isPivotResultColumn(columnId);
1767
+ const _isPivotCell = this.api.columnApi.isPivotResultColumn(columnId) ||
1768
+ this.api.columnApi.isPivotAggColumnWithNoPivotColumns(columnId);
1768
1769
  const self = this;
1769
1770
  const api = this.api;
1770
1771
  const getRawValue = () => {