@adaptabletools/adaptable 18.1.7 → 18.1.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 (33) hide show
  1. package/package.json +1 -1
  2. package/src/AdaptableInterfaces/IAdaptable.d.ts +2 -1
  3. package/src/AdaptableOptions/DataChangeHistoryOptions.d.ts +4 -0
  4. package/src/Api/DataChangeHistoryApi.d.ts +6 -0
  5. package/src/Api/Implementation/DataChangeHistoryApiImpl.d.ts +2 -0
  6. package/src/Api/Implementation/DataChangeHistoryApiImpl.js +24 -3
  7. package/src/Api/Internal/AlertInternalApi.d.ts +0 -3
  8. package/src/Api/Internal/AlertInternalApi.js +12 -39
  9. package/src/Api/Internal/FormatColumnInternalApi.d.ts +2 -2
  10. package/src/Api/Internal/FormatColumnInternalApi.js +6 -6
  11. package/src/Api/Internal/GridInternalApi.js +13 -7
  12. package/src/PredefinedConfig/Common/AdaptableFormat.d.ts +9 -9
  13. package/src/Redux/ActionsReducers/SystemRedux.d.ts +9 -8
  14. package/src/Redux/ActionsReducers/SystemRedux.js +11 -11
  15. package/src/Strategy/DataChangeHistoryModule.js +1 -2
  16. package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +1 -0
  17. package/src/Utilities/Constants/DocumentationLinkConstants.js +1 -0
  18. package/src/Utilities/Helpers/FormatContentHelper.d.ts +22 -0
  19. package/src/Utilities/Helpers/FormatContentHelper.js +34 -0
  20. package/src/Utilities/Helpers/FormatHelper.d.ts +5 -4
  21. package/src/Utilities/Helpers/FormatHelper.js +40 -13
  22. package/src/Utilities/Helpers/Helper.d.ts +6 -0
  23. package/src/Utilities/Helpers/Helper.js +31 -0
  24. package/src/View/Alert/Wizard/AlertMessageWizardSection.js +4 -3
  25. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +33 -10
  26. package/src/agGrid/AdaptableAgGrid.d.ts +2 -1
  27. package/src/agGrid/AdaptableAgGrid.js +29 -8
  28. package/src/agGrid/AgGridMenuAdapter.js +15 -1
  29. package/src/agGrid/defaultAdaptableOptions.js +1 -0
  30. package/src/env.js +2 -2
  31. package/src/metamodel/adaptable.metamodel.d.ts +8 -0
  32. package/src/metamodel/adaptable.metamodel.js +1 -1
  33. package/tsconfig.esm.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "18.1.7",
3
+ "version": "18.1.9",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -177,7 +177,8 @@ export interface IAdaptable {
177
177
  getDisplayValueFromRowNode(rowNode: IRowNode, columnId: string): string | undefined;
178
178
  getDisplayValueFromRawValue(rowNode: IRowNode, columnId: string, rawValue: any): string | undefined;
179
179
  getNormalisedValueFromRawValue(rawValue: any, column: AdaptableColumn): string | number | boolean | Date | unknown;
180
- getGridCellsForColumn(columnId: string, includeBlanks?: boolean, onlyVisibleRows?: boolean): GridCell[] | undefined;
180
+ getGridCellsForColumn(columnId: string, onlyVisibleRows?: boolean): GridCell[] | undefined;
181
+ getGridCellsForColumnTemp(columnId: string, onlyVisibleRows?: boolean): GridCell[] | undefined;
181
182
  getRowNodesForPrimaryKeys(primaryKeyValues: any[]): IRowNode[];
182
183
  getRowNodeForPrimaryKey(primaryKeyValue: any): IRowNode;
183
184
  getRowNodeByIndex(index: number): IRowNode;
@@ -25,6 +25,10 @@ export interface DataChangeHistoryOptions<TData = any> {
25
25
  * @defaultValue undefined
26
26
  */
27
27
  changeHistoryButton?: DataChangeHistoryButton<TData> | DataChangeHistoryButton<TData>[];
28
+ /**
29
+ * Whether to show all changes for each cell or just the last one
30
+ */
31
+ showLastDataChangeOnly?: boolean;
28
32
  }
29
33
  /**
30
34
  * Built in `undo` or `clear` data change action
@@ -25,6 +25,12 @@ export interface DataChangeHistoryApi {
25
25
  * Retrieves all data changes which are currently available
26
26
  */
27
27
  getDataChangeHistoryLog(): CellDataChangedInfo[];
28
+ /**
29
+ * Adds item to Data Change History log
30
+ *
31
+ * @param dataChangeInfo the change to log
32
+ */
33
+ addDataChangeHistoryEntry(dataChangeInfo: CellDataChangedInfo): void;
28
34
  /**
29
35
  * Reverts the provided data change to its previous value
30
36
  *
@@ -7,7 +7,9 @@ export declare class DataChangeHistoryApiImpl extends ApiBase implements DataCha
7
7
  deactivateDataChangeHistory(): void;
8
8
  suspendDataChangeHistory(): void;
9
9
  getDataChangeHistoryLog(): CellDataChangedInfo[];
10
+ addDataChangeHistoryEntry(dataChangeInfo: CellDataChangedInfo): void;
10
11
  undoDataChangeHistoryEntry(dataChangeInfo: CellDataChangedInfo): void;
11
12
  clearDataChangeHistoryEntry(dataChangeInfo: CellDataChangedInfo): void;
12
13
  openDataChangeHistorySettingsPanel(): void;
14
+ private getDataChangeHistoryKey;
13
15
  }
@@ -1,7 +1,22 @@
1
1
  import { ApiBase } from './ApiBase';
2
- import { SystemDataChangeHistoryClearRow, SystemDataChangeHistoryDisable, SystemDataChangeHistoryEnable, SystemDataChangeHistoryResume, SystemDataChangeHistorySuspend, SystemDataChangeHistoryUndo, } from '../../Redux/ActionsReducers/SystemRedux';
2
+ import { SystemDataChangeHistoryClearRow, SystemDataChangeHistoryDisable, SystemDataChangeHistoryEnable, SystemDataChangeHistoryResume, SystemDataChangeHistorySuspend, SystemDataChangeHistoryUndo, SystemDataChangeHistoryAdd, } from '../../Redux/ActionsReducers/SystemRedux';
3
3
  import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants';
4
4
  export class DataChangeHistoryApiImpl extends ApiBase {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.getDataChangeHistoryKey = (dataChangeInfo) => {
8
+ const columnId = dataChangeInfo.column.columnId;
9
+ const primaryKeyValue = dataChangeInfo.primaryKeyValue;
10
+ const changedAt = dataChangeInfo.changedAt;
11
+ const showLastDataChangeOnly = this.getAdaptableApi().optionsApi.getDataChangeHistoryOptions().showLastDataChangeOnly;
12
+ if (showLastDataChangeOnly) {
13
+ return JSON.stringify({ columnId, primaryKeyValue });
14
+ }
15
+ else {
16
+ return JSON.stringify({ columnId, primaryKeyValue, changedAt });
17
+ }
18
+ };
19
+ }
5
20
  getDataChangeHistoryMode() {
6
21
  return this.getAdaptableState().System.DataChangeHistory.currentMode;
7
22
  }
@@ -33,11 +48,17 @@ export class DataChangeHistoryApiImpl extends ApiBase {
33
48
  const changeLog = (_a = this.getAdaptableState().System.DataChangeHistory.logs) !== null && _a !== void 0 ? _a : {};
34
49
  return Object.values(changeLog);
35
50
  }
51
+ addDataChangeHistoryEntry(dataChangeInfo) {
52
+ const uniqueKey = this.getDataChangeHistoryKey(dataChangeInfo);
53
+ this.dispatchAction(SystemDataChangeHistoryAdd(dataChangeInfo, uniqueKey));
54
+ }
36
55
  undoDataChangeHistoryEntry(dataChangeInfo) {
37
- this.dispatchAction(SystemDataChangeHistoryUndo(dataChangeInfo));
56
+ const uniqueKey = this.getDataChangeHistoryKey(dataChangeInfo);
57
+ this.dispatchAction(SystemDataChangeHistoryUndo(dataChangeInfo, uniqueKey));
38
58
  }
39
59
  clearDataChangeHistoryEntry(dataChangeInfo) {
40
- this.dispatchAction(SystemDataChangeHistoryClearRow(dataChangeInfo));
60
+ const uniqueKey = this.getDataChangeHistoryKey(dataChangeInfo);
61
+ this.dispatchAction(SystemDataChangeHistoryClearRow(dataChangeInfo, uniqueKey));
41
62
  }
42
63
  openDataChangeHistorySettingsPanel() {
43
64
  this.showModulePopup(ModuleConstants.DataChangeHistoryModuleId);
@@ -156,7 +156,4 @@ export declare class AlertInternalApi extends ApiBase {
156
156
  * - trigger -> [trigger]
157
157
  */
158
158
  private annotateAlertText;
159
- private replaceAll;
160
- private extractColsFromText;
161
- private extractContextKeysFromText;
162
159
  }
@@ -5,6 +5,7 @@ import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
5
5
  import { AlertModuleId } from '../../Utilities/Constants/ModuleConstants';
6
6
  import { isCellDataChangedInfo } from '../../Utilities/Services/Interface/IAlertService';
7
7
  import ObjectFactory from '../../Utilities/ObjectFactory';
8
+ import Helper from '../../Utilities/Helpers/Helper';
8
9
  export class AlertInternalApi extends ApiBase {
9
10
  getExpressionForAlertRule(alertRule) {
10
11
  var expression;
@@ -631,19 +632,19 @@ export class AlertInternalApi extends ApiBase {
631
632
  return text;
632
633
  }
633
634
  if (context === null || context === void 0 ? void 0 : context.newValue) {
634
- text = this.replaceAll(text, '[newValue]', context.newValue);
635
+ text = Helper.replaceAll(text, '[newValue]', context.newValue);
635
636
  }
636
637
  if (context === null || context === void 0 ? void 0 : context.oldValue) {
637
- text = this.replaceAll(text, '[oldValue]', context.oldValue);
638
+ text = Helper.replaceAll(text, '[oldValue]', context.oldValue);
638
639
  }
639
640
  if (context === null || context === void 0 ? void 0 : context.primaryKeyValue) {
640
- text = this.replaceAll(text, '[primaryKeyValue]', context.primaryKeyValue);
641
+ text = Helper.replaceAll(text, '[primaryKeyValue]', context.primaryKeyValue);
641
642
  }
642
643
  if (context === null || context === void 0 ? void 0 : context.timestamp) {
643
- text = this.replaceAll(text, '[timestamp]', context.timestamp + '');
644
+ text = Helper.replaceAll(text, '[timestamp]', context.timestamp + '');
644
645
  }
645
646
  if (context === null || context === void 0 ? void 0 : context.numberOfRows) {
646
- text = this.replaceAll(text, '[numberOfRows]', context.numberOfRows + '');
647
+ text = Helper.replaceAll(text, '[numberOfRows]', context.numberOfRows + '');
647
648
  }
648
649
  if (context === null || context === void 0 ? void 0 : context.trigger) {
649
650
  const dataChangeTriggerMap = {
@@ -661,56 +662,28 @@ export class AlertInternalApi extends ApiBase {
661
662
  const mappedTrigger =
662
663
  // @ts-ignore
663
664
  (_a = (dataChangeTriggerMap[context.trigger] || rowChangeTriggerMap[context.trigger])) !== null && _a !== void 0 ? _a : context.trigger;
664
- text = this.replaceAll(text, '[trigger]', mappedTrigger);
665
+ text = Helper.replaceAll(text, '[trigger]', mappedTrigger);
665
666
  }
666
667
  if (context === null || context === void 0 ? void 0 : context.column) {
667
- text = this.replaceAll(text, '[column]', this.getColumnApi().getFriendlyNameForColumnId(context.column.columnId));
668
+ text = Helper.replaceAll(text, '[column]', this.getColumnApi().getFriendlyNameForColumnId(context.column.columnId));
668
669
  }
669
670
  if (context === null || context === void 0 ? void 0 : context.rowNode) {
670
- const columns = this.extractColsFromText(text);
671
+ const columns = Helper.extractColsFromText(text);
671
672
  for (const column of columns) {
672
673
  if (this.getColumnApi().getColumnWithColumnId(column)) {
673
- text = this.replaceAll(text, `[rowData.${column}]`, this.getGridApi().getRawValueFromRowNode(context.rowNode, column));
674
+ text = Helper.replaceAll(text, `[rowData.${column}]`, this.getGridApi().getRawValueFromRowNode(context.rowNode, column));
674
675
  }
675
676
  }
676
677
  }
677
678
  if (text.indexOf('[context') !== -1) {
678
679
  const agGridContext = (_c = (_b = this.adaptable.agGridAdapter).getGridOption) === null || _c === void 0 ? void 0 : _c.call(_b, 'context');
679
- const agGridContextKeys = this.extractContextKeysFromText(text);
680
+ const agGridContextKeys = Helper.extractContextKeysFromText(text);
680
681
  for (const key of agGridContextKeys) {
681
682
  if (agGridContext[key]) {
682
- text = this.replaceAll(text, `[context.${key}]`, agGridContext[key]);
683
+ text = Helper.replaceAll(text, `[context.${key}]`, agGridContext[key]);
683
684
  }
684
685
  }
685
686
  }
686
687
  return text;
687
688
  }
688
- replaceAll(text, toReplace, replaceWith) {
689
- if (!text) {
690
- return text;
691
- }
692
- // fails for []
693
- toReplace = toReplace.replace('[', '\\[').replace(']', '\\]');
694
- return text.replace(new RegExp(toReplace, 'g'), replaceWith);
695
- }
696
- extractColsFromText(text) {
697
- // rowData.columnName => columnName
698
- const regex = /\[rowData\.(.*?)\]/g;
699
- let m;
700
- const cols = [];
701
- while ((m = regex.exec(text)) !== null) {
702
- cols.push(m[1]);
703
- }
704
- return cols;
705
- }
706
- extractContextKeysFromText(text) {
707
- // context.columnName => columnName
708
- const regex = /\[context\.(.*?)\]/g;
709
- let m;
710
- const contextKeys = [];
711
- while ((m = regex.exec(text)) !== null) {
712
- contextKeys.push(m[1]);
713
- }
714
- return contextKeys;
715
- }
716
689
  }
@@ -56,14 +56,14 @@ export declare class FormatColumnInternalApi extends ApiBase {
56
56
  * @param customDisplayFormatterContext context that includes value to format
57
57
  * @param options formatter options
58
58
  */
59
- getNumberFormattedValue(value: any, node: IRowNode, abColumn: AdaptableColumn, options: AdaptableFormat['Options']): any;
59
+ getNumberFormattedValue(value: any, node: IRowNode, column: AdaptableColumn, options: AdaptableFormat['Options']): any;
60
60
  /**
61
61
  * Format value according to format options.
62
62
  *
63
63
  * @param value context that includes value to format
64
64
  * @param options formatter options
65
65
  */
66
- getStringFormattedValue(value: any, node: IRowNode, abColumn: AdaptableColumn, options: StringFormatterOptions): string;
66
+ getStringFormattedValue(value: any, node: IRowNode, column: AdaptableColumn, options: StringFormatterOptions): string;
67
67
  /**
68
68
  * Format value according to format options.
69
69
  *
@@ -91,9 +91,9 @@ export class FormatColumnInternalApi extends ApiBase {
91
91
  * @param customDisplayFormatterContext context that includes value to format
92
92
  * @param options formatter options
93
93
  */
94
- getNumberFormattedValue(value, node, abColumn, options) {
95
- const preparedValue = this.applyCustomFormatters(value, node, abColumn, options);
96
- return FormatHelper.NumberFormatter(preparedValue, options);
94
+ getNumberFormattedValue(value, node, column, options) {
95
+ const preparedValue = this.applyCustomFormatters(value, node, column, options);
96
+ return FormatHelper.NumberFormatter(preparedValue, options, node, column, this.getAdaptableApi());
97
97
  }
98
98
  /**
99
99
  * Format value according to format options.
@@ -101,9 +101,9 @@ export class FormatColumnInternalApi extends ApiBase {
101
101
  * @param value context that includes value to format
102
102
  * @param options formatter options
103
103
  */
104
- getStringFormattedValue(value, node, abColumn, options) {
105
- const preparedValue = this.applyCustomFormatters(value, node, abColumn, options);
106
- return FormatHelper.StringFormatter(preparedValue, options);
104
+ getStringFormattedValue(value, node, column, options) {
105
+ const preparedValue = this.applyCustomFormatters(value, node, column, options);
106
+ return FormatHelper.StringFormatter(preparedValue, options, node, column, this.getAdaptableApi());
107
107
  }
108
108
  /**
109
109
  * Format value according to format options.
@@ -84,7 +84,7 @@ export class GridInternalApi extends ApiBase {
84
84
  const shouldShowValuesCount = this.shouldShowValuesCount(abColumn);
85
85
  let valueOptions = [];
86
86
  if (shouldShowValuesCount) {
87
- const allGridCells = this.adaptable.getGridCellsForColumn(columnId, false, this.getColumnFilterOptions().valuesFilterOptions.showCurrentlyFilteredValuesCount);
87
+ const allGridCells = this.adaptable.getGridCellsForColumn(columnId, this.getColumnFilterOptions().valuesFilterOptions.showCurrentlyFilteredValuesCount);
88
88
  const allGridValues = allGridCells.map((gc) => gc.displayValue);
89
89
  const newsortedDistinctValues = sortedDistinctValues.filter((gc) => gc.displayValue != undefined && gc.displayValue != '' && gc.displayValue != null);
90
90
  valueOptions = newsortedDistinctValues.map((cv) => {
@@ -111,17 +111,17 @@ export class GridInternalApi extends ApiBase {
111
111
  }
112
112
  shouldShowValuesCount(column) {
113
113
  const showValuesCount = this.getColumnFilterOptions().valuesFilterOptions.showValuesCount;
114
- let shouldShowValuesCount = false;
114
+ let returnValue = false;
115
115
  if (showValuesCount) {
116
116
  if (typeof showValuesCount === 'function') {
117
117
  const columnFilterContext = Object.assign({ column }, this.getAdaptableApi().internalApi.buildBaseContext());
118
- shouldShowValuesCount = showValuesCount(columnFilterContext);
118
+ returnValue = showValuesCount(columnFilterContext);
119
119
  }
120
120
  else {
121
- shouldShowValuesCount = showValuesCount;
121
+ returnValue = showValuesCount;
122
122
  }
123
123
  }
124
- return shouldShowValuesCount;
124
+ return returnValue;
125
125
  }
126
126
  async getDistinctFilterDisplayValuesForColumnForFiltersUI(columnId, filter, showFilteredRowsOnly) {
127
127
  const abColumn = this.getColumnApi().getColumnWithColumnId(columnId);
@@ -144,7 +144,13 @@ export class GridInternalApi extends ApiBase {
144
144
  addPredicateValues(params) {
145
145
  var _a, _b, _c, _d;
146
146
  const { valueOptions, column, shouldShowValuesCount, visibleRowsOnly } = params;
147
- const allGridCells = this.adaptable.getGridCellsForColumn(column.columnId, true, visibleRowsOnly);
147
+ const visibleGridCells = this.adaptable.getGridCellsForColumnTemp(column.columnId, visibleRowsOnly);
148
+ let allGridCells;
149
+ if (shouldShowValuesCount) {
150
+ allGridCells = visibleRowsOnly
151
+ ? visibleGridCells
152
+ : this.adaptable.getGridCellsForColumnTemp(column.columnId, this.getColumnFilterOptions().valuesFilterOptions.showCurrentlyFilteredValuesCount);
153
+ }
148
154
  const adaptableApi = this.getAdaptableApi();
149
155
  const predicateIds = adaptableApi.columnFilterApi.internalApi.getValuesFitlerPredicateIds(column);
150
156
  if (ArrayExtensions.IsNullOrEmpty(predicateIds)) {
@@ -157,7 +163,7 @@ export class GridInternalApi extends ApiBase {
157
163
  if (!visibleRowsOnly) {
158
164
  return true;
159
165
  }
160
- return this.isPredicateInVisibleCellValues(predicateId, allGridCells);
166
+ return this.isPredicateInVisibleCellValues(predicateId, visibleGridCells);
161
167
  })
162
168
  .map((predicateId) => {
163
169
  var _a;
@@ -35,19 +35,19 @@ export interface NumberFormatterOptions extends BaseFormatterOptions {
35
35
  */
36
36
  IntegerSeparator?: string;
37
37
  /**
38
- * Prefix to use before the number
38
+ * Prefix to use before cell value
39
39
  */
40
40
  Prefix?: string;
41
41
  /**
42
- * Suffix to use after the number
42
+ * Suffix to use after cell value
43
43
  */
44
44
  Suffix?: string;
45
45
  /**
46
- * Replaces cell value with supplied value
46
+ * Replaces cell value with supplied value (that can contain placeholders)
47
47
  */
48
48
  Content?: string | number;
49
49
  /**
50
- * Multiplier to use on the number
50
+ * Multiplier to use on cell value
51
51
  */
52
52
  Multiplier?: number;
53
53
  /**
@@ -55,23 +55,23 @@ export interface NumberFormatterOptions extends BaseFormatterOptions {
55
55
  */
56
56
  Parentheses?: boolean;
57
57
  /**
58
- * Truncates a number
58
+ * Truncates cell value
59
59
  */
60
60
  Truncate?: boolean;
61
61
  /**
62
- * Returns absolute value of a number
62
+ * Returns absolute value of cell value
63
63
  */
64
64
  Abs?: boolean;
65
65
  /**
66
- * Returns smallest integer > number
66
+ * Returns smallest integer greater than cell value
67
67
  */
68
68
  Ceiling?: boolean;
69
69
  /**
70
- * Returns largest intger < number
70
+ * Returns largest integer cell value
71
71
  */
72
72
  Floor?: boolean;
73
73
  /**
74
- * Rounds a Number
74
+ * Rounds cell value
75
75
  */
76
76
  Round?: boolean;
77
77
  }
@@ -210,14 +210,15 @@ export interface SystemLicenseShowWatermarkAction extends Redux.Action {
210
210
  }
211
211
  export interface SystemLicenseDisablePersistenceAction extends Redux.Action {
212
212
  }
213
- export interface SystemDataChangeHistoryAddAction extends Redux.Action {
213
+ export interface SystemDataChangeHistoryAction extends Redux.Action {
214
214
  changeInfo: CellDataChangedInfo;
215
+ uniqueKey: string;
215
216
  }
216
- export interface SystemDataChangeHistoryUndoAction extends Redux.Action {
217
- changeInfo: CellDataChangedInfo;
217
+ export interface SystemDataChangeHistoryAddAction extends SystemDataChangeHistoryAction {
218
218
  }
219
- export interface SystemDataChangeHistoryClearRowAction extends Redux.Action {
220
- changeInfo: CellDataChangedInfo;
219
+ export interface SystemDataChangeHistoryUndoAction extends SystemDataChangeHistoryAction {
220
+ }
221
+ export interface SystemDataChangeHistoryClearRowAction extends SystemDataChangeHistoryAction {
221
222
  }
222
223
  export interface SystemDataChangeHistoryEnableAction extends Redux.Action {
223
224
  }
@@ -307,9 +308,9 @@ export declare const SystemProgressIndicatorShow: (progressIndicatorConfig: Prog
307
308
  export declare const SystemProgressIndicatorHide: () => SystemProgressIndicatorHideAction;
308
309
  export declare const SystemLicenseShowWatermark: (text: string) => SystemLicenseShowWatermarkAction;
309
310
  export declare const SystemLicenseDisablePersistence: () => SystemLicenseDisablePersistenceAction;
310
- export declare const SystemDataChangeHistoryAdd: (changeInfo: CellDataChangedInfo) => SystemDataChangeHistoryAddAction;
311
- export declare const SystemDataChangeHistoryUndo: (changeInfo: CellDataChangedInfo) => SystemDataChangeHistoryUndoAction;
312
- export declare const SystemDataChangeHistoryClearRow: (changeInfo: CellDataChangedInfo) => SystemDataChangeHistoryClearRowAction;
311
+ export declare const SystemDataChangeHistoryAdd: (changeInfo: CellDataChangedInfo, uniqueKey: string) => SystemDataChangeHistoryAddAction;
312
+ export declare const SystemDataChangeHistoryUndo: (changeInfo: CellDataChangedInfo, uniqueKey: string) => SystemDataChangeHistoryUndoAction;
313
+ export declare const SystemDataChangeHistoryClearRow: (changeInfo: CellDataChangedInfo, uniqueKey: string) => SystemDataChangeHistoryClearRowAction;
313
314
  export declare const SystemDataChangeHistoryEnable: () => SystemDataChangeHistoryEnableAction;
314
315
  export declare const SystemDataChangeHistoryDisable: () => SystemDataChangeHistoryDisableAction;
315
316
  export declare const SystemDataChangeHistorySuspend: () => SystemDataChangeHistorySuspendAction;
@@ -234,17 +234,20 @@ export const SystemLicenseShowWatermark = (text) => ({
234
234
  export const SystemLicenseDisablePersistence = () => ({
235
235
  type: SYSTEM_LICENSE_DISABLE_PERSISTENCE,
236
236
  });
237
- export const SystemDataChangeHistoryAdd = (changeInfo) => ({
237
+ export const SystemDataChangeHistoryAdd = (changeInfo, uniqueKey) => ({
238
238
  type: SYSTEM_DATA_CHANGE_HISTORY_ADD,
239
239
  changeInfo,
240
+ uniqueKey,
240
241
  });
241
- export const SystemDataChangeHistoryUndo = (changeInfo) => ({
242
+ export const SystemDataChangeHistoryUndo = (changeInfo, uniqueKey) => ({
242
243
  type: SYSTEM_DATA_CHANGE_HISTORY_UNDO,
243
244
  changeInfo,
245
+ uniqueKey,
244
246
  });
245
- export const SystemDataChangeHistoryClearRow = (changeInfo) => ({
247
+ export const SystemDataChangeHistoryClearRow = (changeInfo, uniqueKey) => ({
246
248
  type: SYSTEM_DATA_CHANGE_HISTORY_CLEAR_ROW,
247
249
  changeInfo,
250
+ uniqueKey,
248
251
  });
249
252
  export const SystemDataChangeHistoryEnable = () => ({
250
253
  type: SYSTEM_DATA_CHANGE_HISTORY_ENABLE,
@@ -654,7 +657,7 @@ export const SystemReducer = (state = initialState, action) => {
654
657
  case SYSTEM_DATA_CHANGE_HISTORY_ADD: {
655
658
  const actionTypedAdd = action;
656
659
  const cellDataChangedInfo = actionTypedAdd.changeInfo;
657
- const uniqueKey = getDataChangeHistoryKey(cellDataChangedInfo);
660
+ const uniqueKey = actionTypedAdd.uniqueKey;
658
661
  const updatedDataChangeHistoryLogs = Object.assign({}, state.DataChangeHistory.logs);
659
662
  updatedDataChangeHistoryLogs[uniqueKey] = cellDataChangedInfo;
660
663
  return Object.assign(Object.assign({}, state), { DataChangeHistory: Object.assign(Object.assign({}, state.DataChangeHistory), { logs: updatedDataChangeHistoryLogs }) });
@@ -662,15 +665,15 @@ export const SystemReducer = (state = initialState, action) => {
662
665
  case SYSTEM_DATA_CHANGE_HISTORY_UNDO: {
663
666
  const actionTypedUndo = action;
664
667
  const cellDataChangedInfo = actionTypedUndo.changeInfo;
665
- const uniqueKey = getDataChangeHistoryKey(cellDataChangedInfo);
668
+ const uniqueKey = actionTypedUndo.uniqueKey;
666
669
  const updatedDataChangeHistoryLogs = Object.assign({}, state.DataChangeHistory.logs);
667
670
  delete updatedDataChangeHistoryLogs[uniqueKey];
668
671
  return Object.assign(Object.assign({}, state), { DataChangeHistory: Object.assign(Object.assign({}, state.DataChangeHistory), { logs: updatedDataChangeHistoryLogs }) });
669
672
  }
670
673
  case SYSTEM_DATA_CHANGE_HISTORY_CLEAR_ROW: {
671
- const actionTypedUndo = action;
672
- const cellDataChangedInfo = actionTypedUndo.changeInfo;
673
- const uniqueKey = getDataChangeHistoryKey(cellDataChangedInfo);
674
+ const actionTypedClearRow = action;
675
+ const cellDataChangedInfo = actionTypedClearRow.changeInfo;
676
+ const uniqueKey = actionTypedClearRow.uniqueKey;
674
677
  const updatedDataChangeHistoryLogs = Object.assign({}, state.DataChangeHistory.logs);
675
678
  delete updatedDataChangeHistoryLogs[uniqueKey];
676
679
  return Object.assign(Object.assign({}, state), { DataChangeHistory: Object.assign(Object.assign({}, state.DataChangeHistory), { logs: updatedDataChangeHistoryLogs }) });
@@ -775,6 +778,3 @@ export const SystemReducer = (state = initialState, action) => {
775
778
  return state;
776
779
  }
777
780
  };
778
- const getDataChangeHistoryKey = ({ column: columnId, primaryKeyValue, }) => {
779
- return JSON.stringify({ columnId, primaryKeyValue });
780
- };
@@ -1,6 +1,5 @@
1
1
  import { AdaptableModuleBase } from './AdaptableModuleBase';
2
2
  import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
3
- import { SystemDataChangeHistoryAdd } from '../Redux/ActionsReducers/SystemRedux';
4
3
  import { DataChangeHistoryStatusBarContent } from '../View/DataChangeHistory/DataChangeHistoryStatusBarContent';
5
4
  import { ModuleNames } from '@ag-grid-community/core';
6
5
  export class DataChangeHistoryModule extends AdaptableModuleBase {
@@ -13,7 +12,7 @@ export class DataChangeHistoryModule extends AdaptableModuleBase {
13
12
  .on('CellDataChanged', (cellDataChangedInfo) => {
14
13
  if (cellDataChangedInfo.trigger !== 'undo' && cellDataChangedInfo.trigger !== 'aggChange') {
15
14
  if (this.shouldLogDataChange(cellDataChangedInfo)) {
16
- this.api.internalApi.dispatchReduxAction(SystemDataChangeHistoryAdd(cellDataChangedInfo));
15
+ this.api.dataChangeHistoryApi.addDataChangeHistoryEntry(cellDataChangedInfo);
17
16
  }
18
17
  }
19
18
  });
@@ -13,3 +13,4 @@ export declare const LicenseDocsLink: string;
13
13
  export declare const AdaptableOptionsDocsLink: string;
14
14
  export declare const AgGridModulesDocsLink: string;
15
15
  export declare const AlertMessageDocsLink: string;
16
+ export declare const FormatColumnPlaceholderDocsLink: string;
@@ -14,3 +14,4 @@ export const LicenseDocsLink = `${HOST_URL_DOCS}/guide/licensing`;
14
14
  export const AdaptableOptionsDocsLink = `${HOST_URL_DOCS}/guide/reference-options-overview`;
15
15
  export const AgGridModulesDocsLink = `${HOST_URL_DOCS}/guide/dev-guide-aggrid-modules-overview`;
16
16
  export const AlertMessageDocsLink = `${HOST_URL_DOCS}/guide/handbook-alerting-message`;
17
+ export const FormatColumnPlaceholderDocsLink = `${HOST_URL_DOCS}/guide/handbook-column-formatting-display-format-placeholder`;
@@ -0,0 +1,22 @@
1
+ import { IRowNode } from '@ag-grid-community/core';
2
+ import { AdaptableApi, AdaptableColumn } from '../../types';
3
+ /**
4
+ * Context used for Placeholders in Display Format
5
+ */
6
+ export interface DisplayFormatPlaceholderContext {
7
+ column: AdaptableColumn;
8
+ rowNode: IRowNode;
9
+ input: any;
10
+ api: AdaptableApi;
11
+ }
12
+ /**
13
+ * Supported tokens:
14
+ * - column -> [column]
15
+ * - input -> [value]
16
+ * - rowData.colId -> [rowData.colId]
17
+ */
18
+ export declare function resolvePlaceholders(text: string, context: DisplayFormatPlaceholderContext): string;
19
+ export declare const FormatContentHelper: {
20
+ resolvePlaceholders: typeof resolvePlaceholders;
21
+ };
22
+ export default FormatContentHelper;
@@ -0,0 +1,34 @@
1
+ import Helper from '../../Utilities/Helpers/Helper';
2
+ /**
3
+ * Supported tokens:
4
+ * - column -> [column]
5
+ * - input -> [value]
6
+ * - rowData.colId -> [rowData.colId]
7
+ */
8
+ export function resolvePlaceholders(text, context) {
9
+ if (!text) {
10
+ return text;
11
+ }
12
+ if (!context) {
13
+ return text;
14
+ }
15
+ if (context === null || context === void 0 ? void 0 : context.input) {
16
+ text = Helper.replaceAll(text, '[value]', context.input);
17
+ }
18
+ if (context === null || context === void 0 ? void 0 : context.column) {
19
+ text = Helper.replaceAll(text, '[column]', context.api.columnApi.getFriendlyNameForColumnId(context.column.columnId));
20
+ }
21
+ if (context === null || context === void 0 ? void 0 : context.rowNode) {
22
+ const columns = Helper.extractColsFromText(text);
23
+ for (const column of columns) {
24
+ if (context.api.columnApi.getColumnWithColumnId(column)) {
25
+ text = Helper.replaceAll(text, `[rowData.${column}]`, context.api.gridApi.getRawValueFromRowNode(context.rowNode, column));
26
+ }
27
+ }
28
+ }
29
+ return text;
30
+ }
31
+ export const FormatContentHelper = {
32
+ resolvePlaceholders,
33
+ };
34
+ export default FormatContentHelper;
@@ -1,8 +1,9 @@
1
- import { NumberFormatterOptions, DateFormatterOptions, AdaptableFormat, StringFormatterOptions } from '../../PredefinedConfig/Common/AdaptableFormat';
2
- export declare function Format(input: any, format: AdaptableFormat): string;
3
- export declare function NumberFormatter(input: number | string, options?: NumberFormatterOptions): string;
1
+ import { NumberFormatterOptions, DateFormatterOptions, StringFormatterOptions } from '../../PredefinedConfig/Common/AdaptableFormat';
2
+ import { IRowNode } from '@ag-grid-community/core';
3
+ import { AdaptableApi, AdaptableColumn } from '../../types';
4
+ export declare function NumberFormatter(input: number, options?: NumberFormatterOptions, rowNode?: IRowNode, column?: AdaptableColumn, api?: AdaptableApi): string;
4
5
  export declare function DateFormatter(input: number | Date | string, options: DateFormatterOptions, strictFormatting?: boolean): string | undefined;
5
- export declare function StringFormatter(input: string, options?: StringFormatterOptions): string;
6
+ export declare function StringFormatter(input: string, options?: StringFormatterOptions, rowNode?: IRowNode, column?: AdaptableColumn, api?: AdaptableApi): string;
6
7
  declare const _default: {
7
8
  NumberFormatter: typeof NumberFormatter;
8
9
  DateFormatter: typeof DateFormatter;
@@ -3,18 +3,33 @@
3
3
  import dateFnsFormat from 'date-fns/format';
4
4
  import { sentenceCase } from 'sentence-case';
5
5
  import { DEFAULT_DATE_FORMAT_PATTERN } from '../Constants/GeneralConstants';
6
- export function Format(input, format) {
7
- if (format.Formatter === 'NumberFormatter') {
8
- return NumberFormatter(input, format.Options);
6
+ import FormatContentHelper from './FormatContentHelper';
7
+ /*
8
+ export function Format(input: any, format: AdaptableFormat) {
9
+ if (format.Formatter === 'NumberFormatter') {
10
+ return NumberFormatter(input, format.Options);
11
+ }
12
+ if (format.Formatter === 'DateFormatter') {
13
+ return DateFormatter(input, format.Options);
14
+ }
15
+ throw new Error('Unknown formatter');
16
+ }
17
+ */
18
+ export function NumberFormatter(input, options = {}, rowNode, column, api) {
19
+ var _a;
20
+ let preparedInput;
21
+ if (options.Content) {
22
+ const context = {
23
+ column,
24
+ rowNode,
25
+ input,
26
+ api,
27
+ };
28
+ preparedInput = FormatContentHelper.resolvePlaceholders(options.Content.toString(), context);
9
29
  }
10
- if (format.Formatter === 'DateFormatter') {
11
- return DateFormatter(input, format.Options);
30
+ else {
31
+ preparedInput = input;
12
32
  }
13
- throw new Error('Unknown formatter');
14
- }
15
- export function NumberFormatter(input, options = {}) {
16
- var _a, _b;
17
- let preparedInput = (_a = options.Content) !== null && _a !== void 0 ? _a : input;
18
33
  if (preparedInput == null || preparedInput == undefined) {
19
34
  return undefined;
20
35
  }
@@ -66,7 +81,7 @@ export function NumberFormatter(input, options = {}) {
66
81
  digitsToUse = options.FractionDigits;
67
82
  }
68
83
  else {
69
- let decimalCount = Math.floor(n) === n ? 0 : ((_b = n.toString().split(fractionsSepatator)[1]) === null || _b === void 0 ? void 0 : _b.length) || 0;
84
+ let decimalCount = Math.floor(n) === n ? 0 : ((_a = n.toString().split(fractionsSepatator)[1]) === null || _a === void 0 ? void 0 : _a.length) || 0;
70
85
  digitsToUse = decimalCount;
71
86
  }
72
87
  s = n.toLocaleString('en-US', {
@@ -107,8 +122,20 @@ export function DateFormatter(input, options, strictFormatting = false) {
107
122
  return input;
108
123
  }
109
124
  }
110
- export function StringFormatter(input, options = {}) {
111
- let preparedInput = options.Content ? options.Content : input;
125
+ export function StringFormatter(input, options = {}, rowNode, column, api) {
126
+ let preparedInput;
127
+ if (options.Content) {
128
+ const context = {
129
+ column,
130
+ rowNode,
131
+ input,
132
+ api,
133
+ };
134
+ preparedInput = FormatContentHelper.resolvePlaceholders(options.Content, context);
135
+ }
136
+ else {
137
+ preparedInput = input;
138
+ }
112
139
  if (preparedInput == null || preparedInput == undefined) {
113
140
  return undefined;
114
141
  }