@adaptabletools/adaptable 18.0.0-canary.4 → 18.0.0-canary.6
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.
- package/agGrid.d.ts +4 -21
- package/agGrid.js +9 -26
- package/base.css +1 -1
- package/base.css.map +1 -1
- package/index.css +74 -68
- package/index.css.map +1 -1
- package/package.json +3 -4
- package/src/AdaptableInterfaces/IAdaptable.d.ts +55 -109
- package/src/AdaptableOptions/AdaptableOptions.d.ts +6 -0
- package/src/AdaptableOptions/UserInterfaceOptions.d.ts +17 -0
- package/src/Api/AdaptableApi.d.ts +5 -0
- package/src/Api/ColumnFilterApi.d.ts +0 -5
- package/src/Api/Events/AdaptableReady.d.ts +3 -3
- package/src/Api/Events/GridDataChanged.d.ts +4 -4
- package/src/Api/GridApi.d.ts +14 -13
- package/src/Api/Implementation/ActionColumnApiImpl.d.ts +2 -0
- package/src/Api/Implementation/ActionColumnApiImpl.js +33 -0
- package/src/Api/Implementation/AdaptableApiImpl.d.ts +1 -0
- package/src/Api/Implementation/AdaptableApiImpl.js +3 -0
- package/src/Api/Implementation/ApiBase.d.ts +2 -1
- package/src/Api/Implementation/ApiBase.js +3 -0
- package/src/Api/Implementation/ColumnFilterApiImpl.d.ts +0 -1
- package/src/Api/Implementation/ColumnFilterApiImpl.js +0 -10
- package/src/Api/Implementation/CommentsApiImpl.js +2 -1
- package/src/Api/Implementation/ConfigApiImpl.js +8 -3
- package/src/Api/Implementation/GridApiImpl.d.ts +3 -3
- package/src/Api/Implementation/GridApiImpl.js +20 -14
- package/src/Api/Implementation/StatusBarApiImpl.d.ts +0 -1
- package/src/Api/Implementation/StatusBarApiImpl.js +0 -3
- package/src/Api/Implementation/ToolPanelApiImpl.js +6 -6
- package/src/Api/Internal/ActionRowInternalApi.d.ts +5 -1
- package/src/Api/Internal/ActionRowInternalApi.js +106 -0
- package/src/Api/Internal/AdaptableInternalApi.d.ts +3 -4
- package/src/Api/Internal/AdaptableInternalApi.js +10 -8
- package/src/Api/Internal/CalculatedColumnInternalApi.d.ts +2 -0
- package/src/Api/Internal/CalculatedColumnInternalApi.js +70 -0
- package/src/Api/Internal/ColumnFilterInternalApi.d.ts +1 -0
- package/src/Api/Internal/ColumnFilterInternalApi.js +11 -1
- package/src/Api/Internal/ColumnInternalApi.d.ts +4 -1
- package/src/Api/Internal/ColumnInternalApi.js +12 -0
- package/src/Api/Internal/CustomSortInternalApi.d.ts +3 -2
- package/src/Api/Internal/CustomSortInternalApi.js +32 -1
- package/src/Api/Internal/DataSetInternalApi.js +1 -1
- package/src/Api/Internal/FreeTextColumnInternalApi.d.ts +2 -0
- package/src/Api/Internal/FreeTextColumnInternalApi.js +59 -0
- package/src/Api/Internal/GridFilterInternalApi.js +1 -1
- package/src/Api/Internal/GridInternalApi.d.ts +21 -3
- package/src/Api/Internal/GridInternalApi.js +126 -7
- package/src/Api/Internal/TeamSharingInternalApi.js +1 -1
- package/src/EnvVars.d.ts +3 -0
- package/src/EnvVars.js +4 -0
- package/src/PredefinedConfig/Common/AggregationColumns.d.ts +1 -0
- package/src/PredefinedConfig/Common/AggregationColumns.js +3 -0
- package/src/PredefinedConfig/Common/DataUpdateConfig.d.ts +8 -0
- package/src/Redux/Store/AdaptableStore.d.ts +4 -6
- package/src/Redux/Store/AdaptableStore.js +22 -50
- package/src/Redux/Store/Interface/IAdaptableStore.d.ts +7 -1
- package/src/Strategy/AdaptableModuleBase.d.ts +2 -3
- package/src/Strategy/AdaptableModuleBase.js +4 -7
- package/src/Strategy/AlertModule.d.ts +1 -2
- package/src/Strategy/AlertModule.js +2 -55
- package/src/Strategy/CalculatedColumnModule.d.ts +2 -3
- package/src/Strategy/CalculatedColumnModule.js +5 -25
- package/src/Strategy/ChartingModule.d.ts +0 -1
- package/src/Strategy/ChartingModule.js +0 -21
- package/src/Strategy/ColumnFilterModule.d.ts +1 -2
- package/src/Strategy/ColumnFilterModule.js +1 -64
- package/src/Strategy/CommentsModule.d.ts +1 -0
- package/src/Strategy/CommentsModule.js +2 -1
- package/src/Strategy/CustomSortModule.js +1 -1
- package/src/Strategy/DashboardModule.d.ts +1 -2
- package/src/Strategy/DashboardModule.js +1 -8
- package/src/Strategy/DataChangeHistoryModule.d.ts +1 -0
- package/src/Strategy/DataChangeHistoryModule.js +3 -1
- package/src/Strategy/DataSetModule.d.ts +1 -1
- package/src/Strategy/DataSetModule.js +1 -1
- package/src/Strategy/FlashingCellModule.d.ts +1 -2
- package/src/Strategy/FlashingCellModule.js +2 -15
- package/src/Strategy/FormatColumnModule.d.ts +0 -2
- package/src/Strategy/FormatColumnModule.js +0 -47
- package/src/Strategy/FreeTextColumnModule.d.ts +0 -1
- package/src/Strategy/FreeTextColumnModule.js +0 -30
- package/src/Strategy/GridFilterModule.d.ts +0 -1
- package/src/Strategy/GridFilterModule.js +0 -37
- package/src/Strategy/Interface/IModule.d.ts +0 -1
- package/src/Strategy/LayoutModule.d.ts +1 -3
- package/src/Strategy/LayoutModule.js +6 -50
- package/src/Strategy/NamedQueryModule.d.ts +0 -1
- package/src/Strategy/NamedQueryModule.js +0 -19
- package/src/Strategy/PlusMinusModule.d.ts +1 -1
- package/src/Strategy/PlusMinusModule.js +1 -1
- package/src/Strategy/ScheduleModule.d.ts +1 -1
- package/src/Strategy/ScheduleModule.js +1 -1
- package/src/Strategy/ShortcutModule.d.ts +1 -1
- package/src/Strategy/ShortcutModule.js +1 -1
- package/src/Strategy/StyledColumnModule.d.ts +0 -1
- package/src/Strategy/StyledColumnModule.js +0 -21
- package/src/Strategy/TeamSharingModule.d.ts +1 -0
- package/src/Strategy/TeamSharingModule.js +5 -5
- package/src/Strategy/ToolPanelModule.d.ts +0 -1
- package/src/Strategy/ToolPanelModule.js +0 -23
- package/src/Utilities/Constants/GeneralConstants.d.ts +1 -0
- package/src/Utilities/Constants/GeneralConstants.js +1 -0
- package/src/Utilities/Helpers/AdaptableHelper.d.ts +0 -3
- package/src/Utilities/Helpers/AdaptableHelper.js +0 -58
- package/src/Utilities/Services/CellPopupService.js +0 -1
- package/src/Utilities/Services/LicenseService/index.d.ts +3 -0
- package/src/Utilities/Services/LicenseService/index.js +10 -3
- package/src/Utilities/Services/MetamodelService.d.ts +1 -1
- package/src/Utilities/Services/MetamodelService.js +6 -3
- package/src/Utilities/Services/RowEditService.d.ts +3 -2
- package/src/Utilities/Services/RowEditService.js +3 -1
- package/src/View/AdaptableView.js +0 -2
- package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizard.js +2 -2
- package/src/View/CalculatedColumn/utils.d.ts +1 -1
- package/src/View/CellSummary/CellSummaryPopup.js +1 -1
- package/src/View/Components/Popups/AdaptableLoadingScreen.d.ts +6 -5
- package/src/View/Components/Popups/AdaptableLoadingScreen.js +19 -9
- package/src/View/CustomSort/CustomSortSummary.js +1 -1
- package/src/View/DataChangeHistory/DataChangeHistoryGrid.js +1 -1
- package/src/View/GridFilter/GridFilterViewPanel.js +6 -2
- package/src/View/GridInfo/GridInfoPopup/GridInfoPopup.js +2 -3
- package/src/View/Layout/Wizard/LayoutWizard.js +1 -1
- package/src/agGrid/ActionColumnRenderer.js +4 -4
- package/src/agGrid/Adaptable.d.ts +3 -455
- package/src/agGrid/Adaptable.js +8 -5292
- package/src/agGrid/AdaptableAgGrid.d.ts +336 -0
- package/src/agGrid/AdaptableAgGrid.js +3810 -0
- package/src/agGrid/AdaptableLogger.js +77 -11
- package/src/agGrid/AgGridAdapter.d.ts +54 -0
- package/src/agGrid/AgGridAdapter.js +549 -0
- package/src/agGrid/AgGridColumnAdapter.d.ts +56 -0
- package/src/agGrid/AgGridColumnAdapter.js +813 -0
- package/src/agGrid/AgGridMenuAdapter.d.ts +28 -0
- package/src/agGrid/AgGridMenuAdapter.js +271 -0
- package/src/agGrid/AgGridOptionsService.d.ts +11 -0
- package/src/agGrid/AgGridOptionsService.js +50 -0
- package/src/agGrid/BadgeRenderer.js +1 -1
- package/src/agGrid/CheckboxRenderer.js +1 -1
- package/src/agGrid/FilterWrapper.d.ts +2 -2
- package/src/agGrid/FilterWrapper.js +1 -1
- package/src/agGrid/attachAddaptableColumnTypes.d.ts +12 -12
- package/src/agGrid/defaultAdaptableOptions.d.ts +3 -0
- package/src/{Utilities/Defaults/DefaultAdaptableOptions.js → agGrid/defaultAdaptableOptions.js} +69 -8
- package/src/agGrid/editors/AdaptableDateEditor/index.js +2 -2
- package/src/agGrid/editors/AdaptableNumberEditor/index.js +2 -2
- package/src/components/Datepicker/index.d.ts +1 -1
- package/src/components/InfiniteTable/index.js +2 -2
- package/src/components/Modal/index.d.ts +1 -0
- package/src/components/Modal/index.js +4 -3
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.d.ts +9 -9
- package/src/metamodel/adaptable.metamodel.js +7 -0
- package/src/migration/AdaptableUpgradeHelper.d.ts +38 -0
- package/src/migration/AdaptableUpgradeHelper.js +48 -0
- package/src/migration/VersionUpgrade.d.ts +8 -0
- package/src/migration/VersionUpgrade.js +11 -0
- package/src/migration/VersionUpgrade17.d.ts +18 -0
- package/src/migration/VersionUpgrade17.js +342 -0
- package/src/migration/VersionUpgrade18.d.ts +5 -0
- package/src/migration/VersionUpgrade18.js +6 -0
- package/src/types.d.ts +5 -4
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/src/Utilities/Defaults/DefaultAdaptableOptions.d.ts +0 -2
- package/src/Utilities/Services/Interface/IRowEditService.d.ts +0 -3
- package/src/Utilities/Services/Interface/IRowEditService.js +0 -1
- package/src/agGrid/agGridHelper.d.ts +0 -57
- package/src/agGrid/agGridHelper.js +0 -686
- package/src/agGrid/agGridMenuHelper.d.ts +0 -46
- package/src/agGrid/agGridMenuHelper.js +0 -668
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
import { ModuleRegistry, } from '@ag-grid-community/core';
|
|
2
|
+
import { ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME, ADAPTABLE_ROW_ACTION_BUTTONS, ADAPTABLE_ROW_ACTION_BUTTONS_FRIENDLY_NAME, } from '../Utilities/Constants/GeneralConstants';
|
|
3
|
+
import { createUuid } from '../PredefinedConfig/Uuid';
|
|
4
|
+
import ArrayExtensions from '../Utilities/Extensions/ArrayExtensions';
|
|
5
|
+
import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
|
|
6
|
+
export class AgGridAdapter {
|
|
7
|
+
constructor(adaptableInstance) {
|
|
8
|
+
this.adaptableInstance = adaptableInstance;
|
|
9
|
+
}
|
|
10
|
+
get adaptableOptions() {
|
|
11
|
+
return this.adaptableInstance.adaptableOptions;
|
|
12
|
+
}
|
|
13
|
+
get adaptableApi() {
|
|
14
|
+
return this.adaptableInstance.api;
|
|
15
|
+
}
|
|
16
|
+
get logger() {
|
|
17
|
+
return this.adaptableInstance.logger;
|
|
18
|
+
}
|
|
19
|
+
destroy() {
|
|
20
|
+
this.adaptableInstance = null;
|
|
21
|
+
}
|
|
22
|
+
setAgGridApi(gridApi) {
|
|
23
|
+
this.DANGER_USE_GETTER_gridApi = gridApi;
|
|
24
|
+
}
|
|
25
|
+
getAgGridApi(skipLogging) {
|
|
26
|
+
if (this.DANGER_USE_GETTER_gridApi) {
|
|
27
|
+
return this.DANGER_USE_GETTER_gridApi;
|
|
28
|
+
}
|
|
29
|
+
if (!skipLogging) {
|
|
30
|
+
console.error('AgGridApi is not available yet');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// do NOT ever mutate the returned object!!
|
|
34
|
+
getLiveGridOptions() {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
return (_b = (_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.gos) === null || _b === void 0 ? void 0 : _b.gridOptions;
|
|
38
|
+
}
|
|
39
|
+
updateGridOptions(options) {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.updateGridOptions(options);
|
|
42
|
+
}
|
|
43
|
+
setGridOption(key, value) {
|
|
44
|
+
var _a;
|
|
45
|
+
(_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.setGridOption(key, value);
|
|
46
|
+
}
|
|
47
|
+
updateColumnFilterActiveState() {
|
|
48
|
+
var _a;
|
|
49
|
+
const columnFilters = this.adaptableApi.columnFilterApi.getActiveColumnFilters();
|
|
50
|
+
const activeFilters = (_a = columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.filter) === null || _a === void 0 ? void 0 : _a.call(columnFilters, (columnFilter) => this.adaptableApi.columnFilterApi.isColumnFilterActive(columnFilter));
|
|
51
|
+
const isFilterActive = ArrayExtensions.IsNotNullOrEmpty(activeFilters);
|
|
52
|
+
const columnsWithActiveFilters = {};
|
|
53
|
+
if (isFilterActive) {
|
|
54
|
+
// used in particular at init time to show the filter icon correctly
|
|
55
|
+
for (const colFilter of activeFilters) {
|
|
56
|
+
const agGridCol = this.getAgGridApi().getColumn(colFilter.ColumnId);
|
|
57
|
+
if (agGridCol) {
|
|
58
|
+
columnsWithActiveFilters[agGridCol.getColId()] = true;
|
|
59
|
+
if (!agGridCol.isFilterActive()) {
|
|
60
|
+
// TODO AFL MIG: added source, not sure it's OK
|
|
61
|
+
agGridCol.setFilterActive(true, 'filterChanged');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const agFilterModel = this.getAgGridApi().getFilterModel();
|
|
67
|
+
(this.getAgGridApi().getColumns() || []).forEach((col) => {
|
|
68
|
+
/**
|
|
69
|
+
* When AG Grid filters are used active state should not be removed for all columns.
|
|
70
|
+
* Need to check if the column has a filter model.
|
|
71
|
+
*/
|
|
72
|
+
const isColumnInFilterModel = agFilterModel && agFilterModel[col.getColId()];
|
|
73
|
+
if (!isColumnInFilterModel &&
|
|
74
|
+
!columnsWithActiveFilters[col.getColId()] &&
|
|
75
|
+
col.isFilterActive()) {
|
|
76
|
+
// TODO AFL MIG: added source, not sure it's OK
|
|
77
|
+
col.setFilterActive(false, 'filterChanged');
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
deriveSelectedCellInfoFromAgGrid() {
|
|
82
|
+
const selected = this.getAgGridApi().getCellRanges();
|
|
83
|
+
const columns = [];
|
|
84
|
+
const gridCells = [];
|
|
85
|
+
if (!(selected === null || selected === void 0 ? void 0 : selected.length) || this.adaptableApi.internalApi.isGridInPivotMode()) {
|
|
86
|
+
return { columns: [], gridCells: [] };
|
|
87
|
+
}
|
|
88
|
+
// we iterate for each ranges
|
|
89
|
+
selected.forEach((rangeSelection) => {
|
|
90
|
+
let shouldIncludeRange = true;
|
|
91
|
+
if (rangeSelection.startRow && rangeSelection.endRow) {
|
|
92
|
+
let isStartRowPin = rangeSelection.startRow.rowPinned != null;
|
|
93
|
+
let isEndRowPin = rangeSelection.endRow.rowPinned != null;
|
|
94
|
+
// Warn user if trying to select pinned rows
|
|
95
|
+
// If only selecting pinned rows then stop
|
|
96
|
+
if (isStartRowPin) {
|
|
97
|
+
if (isEndRowPin) {
|
|
98
|
+
shouldIncludeRange = false;
|
|
99
|
+
}
|
|
100
|
+
this.adaptableInstance.logger.consoleWarn('Cannot select pinned rows in AG Grid.');
|
|
101
|
+
}
|
|
102
|
+
if (shouldIncludeRange) {
|
|
103
|
+
const y1 = Math.min(rangeSelection.startRow.rowIndex, rangeSelection.endRow.rowIndex);
|
|
104
|
+
const y2 = Math.max(rangeSelection.startRow.rowIndex, rangeSelection.endRow.rowIndex);
|
|
105
|
+
for (const column of rangeSelection.columns) {
|
|
106
|
+
if (column != null) {
|
|
107
|
+
const colId = column.getColId();
|
|
108
|
+
const selectedColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
|
|
109
|
+
if (selectedColumn &&
|
|
110
|
+
columns.find((c) => c.columnId == selectedColumn.columnId) == null) {
|
|
111
|
+
columns.push(selectedColumn);
|
|
112
|
+
}
|
|
113
|
+
for (let rowIndex = y1; rowIndex <= y2; rowIndex++) {
|
|
114
|
+
const rowNode = this.getAgGridApi().getDisplayedRowAtIndex(rowIndex);
|
|
115
|
+
// we used NOT to return grouped rows but I think that was wrong - if someone wants to return them then that is up to them...
|
|
116
|
+
// we definitely dont return pinned rows as they cannot be selected
|
|
117
|
+
if (rowNode && !this.isPinnedRowNode(rowNode)) {
|
|
118
|
+
const selectedCell = this.adaptableInstance.getGridCellFromRowNode(rowNode, colId);
|
|
119
|
+
gridCells.push(selectedCell);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
columns,
|
|
129
|
+
gridCells,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
deriveSelectedRowInfoFromAgGrid() {
|
|
133
|
+
const nodes = this.getAgGridApi().getSelectedNodes();
|
|
134
|
+
const selectedRows = [];
|
|
135
|
+
if (this.getAgGridApi().isPivotMode()) {
|
|
136
|
+
// dont perform row selection in pivot mode
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
if (ArrayExtensions.IsNotNullOrEmpty(nodes)) {
|
|
140
|
+
nodes.forEach((node) => {
|
|
141
|
+
const rowInfo = {
|
|
142
|
+
isMaster: !!(node.master != null && node.master == true),
|
|
143
|
+
isExpanded: !!(node.expanded != null && node.expanded == true),
|
|
144
|
+
isGroup: !!(node.group != null && node.group == true),
|
|
145
|
+
isSelected: true,
|
|
146
|
+
isDisplayed: node.displayed == true,
|
|
147
|
+
rowGroupLevel: node.level,
|
|
148
|
+
};
|
|
149
|
+
const gridRow = {
|
|
150
|
+
primaryKeyValue: this.adaptableInstance.getPrimaryKeyValueFromRowNode(node),
|
|
151
|
+
rowData: node.data,
|
|
152
|
+
rowNode: node,
|
|
153
|
+
rowInfo,
|
|
154
|
+
};
|
|
155
|
+
selectedRows.push(gridRow);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return { gridRows: selectedRows };
|
|
159
|
+
}
|
|
160
|
+
isModulePresent(moduleName) {
|
|
161
|
+
const standardAgGridRegistrationCheck = ModuleRegistry.__isRegistered(moduleName, this.getAgGridApi().getGridId());
|
|
162
|
+
if (standardAgGridRegistrationCheck) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
return this.getRegisteredModuleNames().some((name) => name === moduleName);
|
|
166
|
+
}
|
|
167
|
+
getRegisteredModuleNames() {
|
|
168
|
+
return this.getRegisteredModules().map((module) => module.moduleName);
|
|
169
|
+
}
|
|
170
|
+
getRegisteredModules() {
|
|
171
|
+
const gridId = this.getAgGridApi().getGridId();
|
|
172
|
+
return ModuleRegistry.__getRegisteredModules(gridId);
|
|
173
|
+
}
|
|
174
|
+
isPinnedRowNode(rowNode) {
|
|
175
|
+
if (!rowNode) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (rowNode.isRowPinned()) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
// TODO AFL MIG rename to getFirstGroupedColumnId()
|
|
184
|
+
getFirstGroupedColumn() {
|
|
185
|
+
var _a, _b, _c, _d;
|
|
186
|
+
return (_d = (_c = (_b = (_a = this.getAgGridApi) === null || _a === void 0 ? void 0 : _a.call(this)) === null || _b === void 0 ? void 0 : _b.getRowGroupColumns()) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.getColId();
|
|
187
|
+
}
|
|
188
|
+
createAdaptableColumnFromAgGridColumn(agGridColumn, colsToGroups) {
|
|
189
|
+
const colId = agGridColumn.getColId();
|
|
190
|
+
const colDef = agGridColumn.getColDef();
|
|
191
|
+
const ColumnId = colId;
|
|
192
|
+
const pkColumn = this.adaptableInstance.adaptableOptions.primaryKey;
|
|
193
|
+
const ColumnGroup = colsToGroups === null || colsToGroups === void 0 ? void 0 : colsToGroups[ColumnId];
|
|
194
|
+
const isRealColumnGroup = ColumnGroup
|
|
195
|
+
? ColumnGroup.columnGroupId !== ColumnGroup.friendlyName
|
|
196
|
+
: false;
|
|
197
|
+
const isActionRowButtonColumn = this.adaptableInstance.api.columnApi.internalApi.isActionRowButtonColumn(colId);
|
|
198
|
+
const isFdc3MainActionColumn = this.adaptableInstance.api.fdc3Api.internalApi.isFdc3MainActionColumn(colId);
|
|
199
|
+
let friendlyName;
|
|
200
|
+
const colExists = this.adaptableInstance.api.columnApi.doesColumnExist(ColumnId);
|
|
201
|
+
if (colExists) {
|
|
202
|
+
friendlyName = this.adaptableInstance.api.columnApi.getFriendlyNameForColumnId(ColumnId);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const displayName = this.getAgGridApi().getDisplayNameForColumn(agGridColumn, 'header');
|
|
206
|
+
const columnFriendlyName = this.adaptableInstance.adaptableOptions.columnOptions.columnFriendlyName;
|
|
207
|
+
const customFriendlyName = typeof columnFriendlyName === 'function'
|
|
208
|
+
? columnFriendlyName({
|
|
209
|
+
colId: colId,
|
|
210
|
+
agColumn: agGridColumn,
|
|
211
|
+
columnGroup: isRealColumnGroup ? ColumnGroup : undefined,
|
|
212
|
+
displayName: displayName,
|
|
213
|
+
})
|
|
214
|
+
: null;
|
|
215
|
+
friendlyName =
|
|
216
|
+
customFriendlyName !== null && customFriendlyName !== void 0 ? customFriendlyName : (isActionRowButtonColumn
|
|
217
|
+
? ADAPTABLE_ROW_ACTION_BUTTONS_FRIENDLY_NAME
|
|
218
|
+
: isFdc3MainActionColumn
|
|
219
|
+
? ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME
|
|
220
|
+
: displayName);
|
|
221
|
+
// Add Column Group;s friendlyname to the Column Friendly Name if its in a legitimate Column Group
|
|
222
|
+
if (this.adaptableInstance.adaptableOptions.columnOptions.addColumnGroupToColumnFriendlyName &&
|
|
223
|
+
colDef.columnGroupShow &&
|
|
224
|
+
ColumnGroup &&
|
|
225
|
+
ColumnGroup.columnGroupId !== ColumnGroup.friendlyName) {
|
|
226
|
+
friendlyName += ' [' + ColumnGroup.friendlyName + ']';
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const dataType = this.getColumnDataType(agGridColumn, false);
|
|
230
|
+
const abColumn = {
|
|
231
|
+
Uuid: createUuid(),
|
|
232
|
+
columnId: ColumnId,
|
|
233
|
+
field: colDef.field,
|
|
234
|
+
friendlyName: friendlyName,
|
|
235
|
+
isPrimaryKey: ColumnId === pkColumn,
|
|
236
|
+
dataType: dataType,
|
|
237
|
+
visible: agGridColumn.isVisible(),
|
|
238
|
+
readOnly: this.isColumnReadonly(colDef),
|
|
239
|
+
columnGroup: ColumnGroup,
|
|
240
|
+
fieldOnly: this.isColumnFieldonly(colDef),
|
|
241
|
+
sortable: this.isColumnSortable(colDef),
|
|
242
|
+
filterable: this.isColumnFilterable(colDef),
|
|
243
|
+
groupable: this.isColumnRowGroupable(colDef),
|
|
244
|
+
pivotable: this.isColumnPivotable(colDef),
|
|
245
|
+
aggregatable: this.isColumnAggregetable(colDef),
|
|
246
|
+
availableAggregationFunctions: null,
|
|
247
|
+
aggregationFunction: null,
|
|
248
|
+
moveable: this.isColumnMoveable(colDef),
|
|
249
|
+
hideable: this.isColumnHideable(colDef),
|
|
250
|
+
queryable: this.isColumnQueryable(colDef, ColumnId, friendlyName, dataType),
|
|
251
|
+
exportable: this.isColumnExportable(colDef, ColumnId, friendlyName, dataType),
|
|
252
|
+
isGrouped: this.isColumnRowGrouped(colDef),
|
|
253
|
+
isFixed: this.isColumnFixed(colDef),
|
|
254
|
+
pinned: this.getColumnPinnedPosition(colDef),
|
|
255
|
+
isExcludedFromQuickSearch: false,
|
|
256
|
+
isSparkline: this.isColumnSparkline(colDef),
|
|
257
|
+
};
|
|
258
|
+
if (abColumn.aggregatable) {
|
|
259
|
+
abColumn.availableAggregationFunctions = this.getColumnAggregationFunctions(colDef);
|
|
260
|
+
if (typeof colDef.aggFunc === 'string') {
|
|
261
|
+
abColumn.aggregationFunction = colDef.aggFunc;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// lets set this here one as the function cannot change the result so dont need to run it each time
|
|
265
|
+
let excludeColumnFromQuickSearch = this.adaptableInstance.adaptableOptions.quickSearchOptions.excludeColumnFromQuickSearch;
|
|
266
|
+
if (excludeColumnFromQuickSearch) {
|
|
267
|
+
if (excludeColumnFromQuickSearch(abColumn)) {
|
|
268
|
+
abColumn.isExcludedFromQuickSearch = true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return abColumn;
|
|
272
|
+
}
|
|
273
|
+
getColumnDataType(column, logWarning = true) {
|
|
274
|
+
// Some columns can have no ID or Title. we return string as a consequence but it needs testing
|
|
275
|
+
if (!column) {
|
|
276
|
+
this.adaptableInstance.logger.warn('column is undefined returning String for Type');
|
|
277
|
+
return 'String';
|
|
278
|
+
}
|
|
279
|
+
let dataType = 'Unknown';
|
|
280
|
+
// get the column type if already in store (and not unknown)
|
|
281
|
+
const existingColumn = this.adaptableInstance.api.columnApi.getColumnWithColumnId(column.getId(), logWarning);
|
|
282
|
+
if (existingColumn && existingColumn.dataType !== 'Unknown') {
|
|
283
|
+
return existingColumn.dataType;
|
|
284
|
+
}
|
|
285
|
+
// check for column type
|
|
286
|
+
const colType = column.getColDef().type;
|
|
287
|
+
if (colType) {
|
|
288
|
+
if (Array.isArray(colType)) {
|
|
289
|
+
colType.forEach((c) => {
|
|
290
|
+
if (dataType == 'Unknown') {
|
|
291
|
+
dataType = this.getAbColDefValue(c);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
dataType = this.getAbColDefValue(colType);
|
|
297
|
+
}
|
|
298
|
+
if (dataType != 'Unknown') {
|
|
299
|
+
return dataType;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
let row = this.getAgGridApi().getDisplayedRowAtIndex(0);
|
|
303
|
+
if (row == null) {
|
|
304
|
+
// possible that there will be no data.
|
|
305
|
+
this.adaptableInstance.logger.warn(`No data in grid so returning type "Unknown" for Column: "${column.getColId()}"`);
|
|
306
|
+
return 'Unknown';
|
|
307
|
+
}
|
|
308
|
+
// if it's a group we need the content of the group
|
|
309
|
+
if (row.group) {
|
|
310
|
+
const childNodes = row.childrenAfterGroup;
|
|
311
|
+
if (ArrayExtensions.IsNullOrEmpty(childNodes)) {
|
|
312
|
+
this.adaptableInstance.logger.warn(`No data in grid so returning type "Unknown" for Column: "${column.getColId()}"`);
|
|
313
|
+
return 'Unknown';
|
|
314
|
+
}
|
|
315
|
+
row = childNodes[0];
|
|
316
|
+
}
|
|
317
|
+
const value = this.getAgGridApi().getValue(column, row);
|
|
318
|
+
if (value instanceof Date) {
|
|
319
|
+
dataType = 'Date';
|
|
320
|
+
}
|
|
321
|
+
else if (Array.isArray(value) && value.length && typeof value[0] === 'number') {
|
|
322
|
+
dataType = 'Unknown';
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
switch (typeof value) {
|
|
326
|
+
case 'string':
|
|
327
|
+
dataType = 'String';
|
|
328
|
+
break;
|
|
329
|
+
case 'number':
|
|
330
|
+
dataType = 'Number';
|
|
331
|
+
break;
|
|
332
|
+
case 'boolean':
|
|
333
|
+
dataType = 'Boolean';
|
|
334
|
+
break;
|
|
335
|
+
case 'object':
|
|
336
|
+
dataType = 'Object';
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
this.adaptableInstance.logger.warn(`No defined type for column '${column.getColId()}'. Defaulting to type of first value: ${dataType}`);
|
|
343
|
+
return dataType;
|
|
344
|
+
}
|
|
345
|
+
getAbColDefValue(colType) {
|
|
346
|
+
if (colType == 'numericColumn') {
|
|
347
|
+
return 'Number';
|
|
348
|
+
}
|
|
349
|
+
if (colType.startsWith('abColDef')) {
|
|
350
|
+
const abColType = colType;
|
|
351
|
+
switch (abColType) {
|
|
352
|
+
case 'abColDefNumber':
|
|
353
|
+
return 'Number';
|
|
354
|
+
case 'abColDefString':
|
|
355
|
+
return 'String';
|
|
356
|
+
case 'abColDefBoolean':
|
|
357
|
+
return 'Boolean';
|
|
358
|
+
case 'abColDefDate':
|
|
359
|
+
return 'Date';
|
|
360
|
+
case 'abColDefObject':
|
|
361
|
+
return 'Object';
|
|
362
|
+
case 'abColDefStringArray':
|
|
363
|
+
return 'StringArray';
|
|
364
|
+
case 'abColDefNumberArray':
|
|
365
|
+
return 'NumberArray';
|
|
366
|
+
case 'abColDefTupleNumberArray':
|
|
367
|
+
return 'TupleNumberArray';
|
|
368
|
+
case 'abColDefObjectNumberArray':
|
|
369
|
+
return 'ObjectNumberArray';
|
|
370
|
+
default:
|
|
371
|
+
return 'Unknown';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return 'Unknown';
|
|
375
|
+
}
|
|
376
|
+
isColumnReadonly(colDef) {
|
|
377
|
+
// if the column has conditional/dynamic editability, we assume some rows may be editable
|
|
378
|
+
if (colDef && typeof colDef.editable === 'function') {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
// otherwise we evaluate the colDef.editable property (columns are NOT editable by default)
|
|
382
|
+
return !colDef.editable;
|
|
383
|
+
}
|
|
384
|
+
isColumnFieldonly(colDef) {
|
|
385
|
+
if (colDef.hide == true && colDef.initialHide == true && colDef.lockVisible == true) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
isColumnSortable(colDef) {
|
|
391
|
+
if (colDef && colDef.sortable != null) {
|
|
392
|
+
return colDef.sortable;
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
isColumnRowGroupable(colDef) {
|
|
397
|
+
if (colDef && colDef.enableRowGroup != null) {
|
|
398
|
+
return colDef.enableRowGroup;
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
isColumnPivotable(colDef) {
|
|
403
|
+
if (colDef && colDef.enablePivot != null) {
|
|
404
|
+
return colDef.enablePivot;
|
|
405
|
+
}
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
isColumnAggregetable(colDef) {
|
|
409
|
+
if (colDef && colDef.enableValue != null) {
|
|
410
|
+
return colDef.enableValue;
|
|
411
|
+
}
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
getColumnAggregationFunctions(colDef) {
|
|
415
|
+
return colDef.allowedAggFuncs || ['sum', 'min', 'max', 'count', 'avg', 'first', 'last']; // those are the default fns aggrid supports out-of-the-box
|
|
416
|
+
}
|
|
417
|
+
isColumnMoveable(colDef) {
|
|
418
|
+
if (!colDef) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
if (colDef.suppressMovable != null && colDef.suppressMovable == true) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
if (this.isColumnFixed(colDef)) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
isColumnQueryable(colDef, columnId, friendlyName, datatype) {
|
|
430
|
+
if (!colDef) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
if (colDef.colId === ADAPTABLE_ROW_ACTION_BUTTONS) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
const abColumnBase = {
|
|
437
|
+
columnId: columnId,
|
|
438
|
+
friendlyName: friendlyName,
|
|
439
|
+
dataType: datatype,
|
|
440
|
+
};
|
|
441
|
+
return this.adaptableInstance.api.expressionApi.isColumnQueryable(abColumnBase);
|
|
442
|
+
}
|
|
443
|
+
isColumnExportable(colDef, columnId, friendlyName, datatype) {
|
|
444
|
+
if (!colDef) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
if (colDef.colId === ADAPTABLE_ROW_ACTION_BUTTONS) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
const abColumnBase = {
|
|
451
|
+
columnId,
|
|
452
|
+
friendlyName,
|
|
453
|
+
dataType: datatype,
|
|
454
|
+
};
|
|
455
|
+
return this.adaptableInstance.api.exportApi.isColumnExportable(abColumnBase);
|
|
456
|
+
}
|
|
457
|
+
isColumnHideable(colDef) {
|
|
458
|
+
if (!colDef) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
if (colDef.lockVisible != null && colDef.lockVisible == true) {
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
isColumnFilterable(colDef) {
|
|
467
|
+
// follow agGrid logic which is that ONLY filterable if explicitly set
|
|
468
|
+
if (this.adaptableInstance.EntitlementService.getEntitlementAccessLevelForModule(ModuleConstants.ColumnFilterModuleId) == 'Hidden') {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
return colDef != null && colDef.filter != null && colDef.filter != false;
|
|
472
|
+
}
|
|
473
|
+
getColumnPinnedPosition(colDef) {
|
|
474
|
+
return colDef.pinned
|
|
475
|
+
? colDef.pinned === 'left' || colDef.pinned === true
|
|
476
|
+
? 'left'
|
|
477
|
+
: 'right'
|
|
478
|
+
: false;
|
|
479
|
+
}
|
|
480
|
+
// used for AG Grid when the column is FixedPinned, meaning it should never be unpinned
|
|
481
|
+
isColumnFixed(colDef) {
|
|
482
|
+
if (!colDef) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
if (colDef.lockPosition != null && colDef.lockPosition == true) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
if (colDef.lockPinned != null && colDef.lockPinned == true) {
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
isColumnRowGrouped(colDef) {
|
|
494
|
+
if (!colDef) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
if (colDef.rowGroup != null && colDef.rowGroup == true) {
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
if (colDef.rowGroupIndex != null) {
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
isColumnSparkline(colDef) {
|
|
506
|
+
// see https://www.ag-grid.com/javascript-data-grid/sparklines-overview/#enabling-sparklines
|
|
507
|
+
return (colDef === null || colDef === void 0 ? void 0 : colDef.cellRenderer) === 'agSparklineCellRenderer';
|
|
508
|
+
}
|
|
509
|
+
isVisibleNode(rowNode) {
|
|
510
|
+
var _a;
|
|
511
|
+
const foundNode = (_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.getRenderedNodes().find((n) => n.id == rowNode.id);
|
|
512
|
+
return foundNode != null;
|
|
513
|
+
}
|
|
514
|
+
getFlattenedColDefs(colDefs = []) {
|
|
515
|
+
const flattenedColDefs = [];
|
|
516
|
+
colDefs.forEach((colDef) => {
|
|
517
|
+
if (colDef.children) {
|
|
518
|
+
flattenedColDefs.push(...this.getFlattenedColDefs(colDef.children));
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
flattenedColDefs.push(colDef);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
this.assignColumnIdsToColDefs(flattenedColDefs);
|
|
525
|
+
return flattenedColDefs;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Mutates the colDefs to ensure that each column has a colId
|
|
529
|
+
*/
|
|
530
|
+
assignColumnIdsToColDefs(colDefs = []) {
|
|
531
|
+
const assignColId = (colDef) => {
|
|
532
|
+
if (!colDef) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (colDef.field && !colDef.colId) {
|
|
536
|
+
colDef.colId = colDef.field;
|
|
537
|
+
}
|
|
538
|
+
if (colDef.children) {
|
|
539
|
+
colDef.children.forEach((colDef) => assignColId(colDef));
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
if (!colDef.colId) {
|
|
543
|
+
this.logger.warn('A column is missing the colId - please check ', colDef, 'Either pass a "field" property or a "colId" property.');
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
colDefs.forEach((colDef) => assignColId(colDef));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AdaptableAgGrid } from './AdaptableAgGrid';
|
|
2
|
+
import { ColumnSetupInfo } from './ColumnSetupInfo';
|
|
3
|
+
import { ColDef, Column } from '@ag-grid-community/core';
|
|
4
|
+
export declare class AgGridColumnAdapter {
|
|
5
|
+
private adaptableInstance;
|
|
6
|
+
private colDefPropertyCache;
|
|
7
|
+
constructor(adaptableInstance: AdaptableAgGrid);
|
|
8
|
+
destroy(): void;
|
|
9
|
+
private get adaptableApi();
|
|
10
|
+
private get adaptableOptions();
|
|
11
|
+
private get agGridApi();
|
|
12
|
+
setColDefProperty<T extends keyof ColDef>(col: Column, propertyName: T, propertyGetter: (userPropertyValue: ColDef[T]) => ColDef[T] | undefined): void;
|
|
13
|
+
getUserColDefProperty<T extends keyof ColDef>(columnId: string, propertyName: T): ColDef[T] | undefined;
|
|
14
|
+
setupColumns(): void;
|
|
15
|
+
triggerSetupColumnKeyCreator(colId: string): void;
|
|
16
|
+
private setupColumnValueGetter;
|
|
17
|
+
private setupColumnCellClass;
|
|
18
|
+
private setupColumnCellStyle;
|
|
19
|
+
private setupColumnCellEditor;
|
|
20
|
+
private setupColumnCellRenderer;
|
|
21
|
+
private setupColumnTooltipValueGetter;
|
|
22
|
+
private setupColumnQuickFilerText;
|
|
23
|
+
private setupColumnAllowedAggFuncs;
|
|
24
|
+
private setupColumnKeyCreator;
|
|
25
|
+
private setupColumnCellDataType;
|
|
26
|
+
setupColumnHeader({ col, abColumn }: ColumnSetupInfo): boolean;
|
|
27
|
+
private setupColumnFilter;
|
|
28
|
+
private setupColumnFloatingFilter;
|
|
29
|
+
private setupColumnValueFormatter;
|
|
30
|
+
private setupColumnEditable;
|
|
31
|
+
private setupColumnValueSetter;
|
|
32
|
+
private setupColumnComparator;
|
|
33
|
+
private getExcelClassNameForCell;
|
|
34
|
+
private isQuickSearchActive;
|
|
35
|
+
private getEditableCellClass;
|
|
36
|
+
private getReadonlyCellClass;
|
|
37
|
+
private getAlertCellClass;
|
|
38
|
+
private getFlashingCellClass;
|
|
39
|
+
private getNoteCellClassName;
|
|
40
|
+
private getCommentCellClassName;
|
|
41
|
+
private getFormatColumnCellClass;
|
|
42
|
+
private getQuickSearchCellStyle;
|
|
43
|
+
private getReadOnlyCellStyle;
|
|
44
|
+
private getEditableCellStyle;
|
|
45
|
+
/**
|
|
46
|
+
* The combination of styled column and format cells
|
|
47
|
+
* This functiond decides when the two can be merged.
|
|
48
|
+
*/
|
|
49
|
+
private getFormatColumnAndStyledColumnCellStyle;
|
|
50
|
+
private getStyledColumnStyle;
|
|
51
|
+
private getFormatColumnCellStyle;
|
|
52
|
+
private getFormatColumnAdaptableStyle;
|
|
53
|
+
private getAlertCellStyle;
|
|
54
|
+
private getFlashingCellStyle;
|
|
55
|
+
private getCellHighlightStyle;
|
|
56
|
+
}
|