@adaptabletools/adaptable-cjs 18.0.0-canary.21 → 18.0.0-canary.23
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/base.css +2 -0
- package/base.css.map +1 -1
- package/index.css +4 -0
- package/index.css.map +1 -1
- package/package.json +1 -1
- package/src/AdaptableOptions/CommentOptions.d.ts +9 -3
- package/src/AdaptableOptions/DataImportOptions.d.ts +2 -2
- package/src/AdaptableOptions/GroupingOptions.d.ts +0 -19
- package/src/AdaptableOptions/NoteOptions.d.ts +8 -2
- package/src/Api/ColumnApi.d.ts +5 -0
- package/src/Api/CommentApi.d.ts +12 -13
- package/src/Api/Implementation/ColumnApiImpl.d.ts +3 -0
- package/src/Api/Implementation/ColumnApiImpl.js +22 -7
- package/src/Api/Implementation/CommentsApiImpl.d.ts +3 -3
- package/src/Api/Implementation/CommentsApiImpl.js +5 -5
- package/src/Api/Implementation/ScopeApiImpl.js +34 -1
- package/src/Api/Internal/ColumnInternalApi.d.ts +2 -0
- package/src/Api/Internal/ColumnInternalApi.js +8 -1
- package/src/Redux/ActionsReducers/CommentsRedux.d.ts +0 -4
- package/src/Redux/ActionsReducers/CommentsRedux.js +1 -39
- package/src/Redux/Store/AdaptableStore.js +4 -4
- package/src/Strategy/CommentModule.d.ts +0 -1
- package/src/Strategy/CommentModule.js +7 -7
- package/src/Utilities/Constants/GeneralConstants.d.ts +1 -0
- package/src/Utilities/Constants/GeneralConstants.js +3 -2
- package/src/View/Comments/CommentsEditor.js +4 -6
- package/src/View/Comments/CommentsPopup.js +5 -2
- package/src/View/Components/CellPopup/index.js +1 -1
- package/src/View/Components/Popups/AdaptablePopup/useMenuItems.js +9 -1
- package/src/View/DataImport/DataImportWizard/DataImportWizard.js +1 -1
- package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +19 -6
- package/src/View/FormatColumn/Wizard/FormatColumnSettingsWizardSection.js +0 -5
- package/src/View/Note/NotePopup.js +5 -2
- package/src/agGrid/AdaptableAgGrid.d.ts +1 -10
- package/src/agGrid/AdaptableAgGrid.js +28 -99
- package/src/agGrid/AgGridAdapter.d.ts +1 -0
- package/src/agGrid/AgGridAdapter.js +4 -0
- package/src/agGrid/AgGridColumnAdapter.d.ts +0 -2
- package/src/agGrid/AgGridColumnAdapter.js +0 -43
- package/src/agGrid/buildSortedColumnStateForLayout.d.ts +7 -0
- package/src/agGrid/buildSortedColumnStateForLayout.js +124 -0
- package/src/agGrid/defaultAdaptableOptions.js +0 -1
- package/src/agGrid/sortColumnStateForVisibleColumns.d.ts +12 -0
- package/src/agGrid/sortColumnStateForVisibleColumns.js +50 -0
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.d.ts +18 -22
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/types.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -136,7 +136,7 @@ const DataImportWizard = (props) => {
|
|
|
136
136
|
return [...userDefinedHandlers, ...systemFileHandlers_1.systemFileHandlers];
|
|
137
137
|
}, []);
|
|
138
138
|
const supportedFileFormats = React.useMemo(() => {
|
|
139
|
-
return fileHandlers.map((h) => h.fileExtension).join(', ');
|
|
139
|
+
return [...new Set(fileHandlers.map((h) => h.fileExtension)).values()].join(', ');
|
|
140
140
|
}, [fileHandlers]);
|
|
141
141
|
const readFile = React.useCallback(async (file) => {
|
|
142
142
|
var _a, _b;
|
|
@@ -149,6 +149,19 @@ const getFormatDisplayTypeForScope = (scope, api) => {
|
|
|
149
149
|
if ('DataTypes' in scope && scope.DataTypes.length == 1 && scope.DataTypes[0] == 'String') {
|
|
150
150
|
return 'String';
|
|
151
151
|
}
|
|
152
|
+
if ('ColumnTypes' in scope && scope.ColumnTypes.length) {
|
|
153
|
+
// need to check if all column with this column type has the same data type and return that particular one
|
|
154
|
+
const columns = scope.ColumnTypes.flatMap((columnType) => {
|
|
155
|
+
return api.columnApi.getColumnsByColumnType(columnType);
|
|
156
|
+
});
|
|
157
|
+
// check if all have the same type
|
|
158
|
+
if (columns.length &&
|
|
159
|
+
columns.every((column) => column.dataType === columns[0].dataType) &&
|
|
160
|
+
// supported data types
|
|
161
|
+
['Number', 'Date', 'String'].includes(columns[0].dataType)) {
|
|
162
|
+
return columns[0].dataType;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
152
165
|
return undefined;
|
|
153
166
|
};
|
|
154
167
|
exports.getFormatDisplayTypeForScope = getFormatDisplayTypeForScope;
|
|
@@ -196,7 +209,7 @@ const renderDateFormat = (data, _onChange, setFormatOption, scopedCustomFormatte
|
|
|
196
209
|
] })))))));
|
|
197
210
|
};
|
|
198
211
|
const renderNumberFormat = (data, onChange, setFormatOption, scopedCustomFormatters, formatColumnApi) => {
|
|
199
|
-
var _a, _b, _c;
|
|
212
|
+
var _a, _b, _c, _d, _e;
|
|
200
213
|
if (data.DisplayFormat.Formatter !== 'NumberFormatter') {
|
|
201
214
|
return null;
|
|
202
215
|
}
|
|
@@ -255,13 +268,13 @@ const renderNumberFormat = (data, onChange, setFormatOption, scopedCustomFormatt
|
|
|
255
268
|
React.createElement(rebass_1.Flex, { flexDirection: "row" },
|
|
256
269
|
React.createElement(FormLayout_1.default, { mr: 3 },
|
|
257
270
|
React.createElement(FormLayout_1.FormRow, { label: "Fraction Separator" },
|
|
258
|
-
React.createElement(Input_1.default, { "data-name": "fraction-separator", value: data.DisplayFormat.Options.FractionSeparator, onChange: (e) => setFormatOption('FractionSeparator', e.currentTarget.value) })),
|
|
271
|
+
React.createElement(Input_1.default, { "data-name": "fraction-separator", value: (_a = data.DisplayFormat.Options.FractionSeparator) !== null && _a !== void 0 ? _a : '', onChange: (e) => setFormatOption('FractionSeparator', e.currentTarget.value) })),
|
|
259
272
|
React.createElement(FormLayout_1.FormRow, { label: "Integer Separator" },
|
|
260
|
-
React.createElement(Input_1.default, { "data-name": "integer-separator", value: data.DisplayFormat.Options.IntegerSeparator, onChange: (e) => setFormatOption('IntegerSeparator', e.currentTarget.value) })),
|
|
273
|
+
React.createElement(Input_1.default, { "data-name": "integer-separator", value: (_b = data.DisplayFormat.Options.IntegerSeparator) !== null && _b !== void 0 ? _b : '', onChange: (e) => setFormatOption('IntegerSeparator', e.currentTarget.value) })),
|
|
261
274
|
React.createElement(FormLayout_1.FormRow, { label: "Prefix" },
|
|
262
|
-
React.createElement(Input_1.default, { "data-name": "prefix", value: (
|
|
275
|
+
React.createElement(Input_1.default, { "data-name": "prefix", value: (_c = data.DisplayFormat.Options.Prefix) !== null && _c !== void 0 ? _c : '', onChange: (e) => setFormatOption('Prefix', e.currentTarget.value) })),
|
|
263
276
|
React.createElement(FormLayout_1.FormRow, { label: "Suffix" },
|
|
264
|
-
React.createElement(Input_1.default, { "data-name": "suffix", value: (
|
|
277
|
+
React.createElement(Input_1.default, { "data-name": "suffix", value: (_d = data.DisplayFormat.Options.Suffix) !== null && _d !== void 0 ? _d : '', onChange: (e) => setFormatOption('Suffix', e.currentTarget.value) })),
|
|
265
278
|
React.createElement(FormLayout_1.FormRow, { label: "Truncate" },
|
|
266
279
|
React.createElement(CheckBox_1.CheckBox, { "data-name": "truncate-checkbox", checked: data.DisplayFormat.Options.Truncate, onChange: (checked) => setFormatOption('Truncate', checked) })),
|
|
267
280
|
React.createElement(FormLayout_1.FormRow, { label: "Ceiling" },
|
|
@@ -286,7 +299,7 @@ const renderNumberFormat = (data, onChange, setFormatOption, scopedCustomFormatt
|
|
|
286
299
|
React.createElement(Input_1.default, { "data-name": "multiplier", type: "number", value: data.DisplayFormat.Options.Multiplier, onChange: (e) => setFormatOption('Multiplier', Number(e.currentTarget.value)) })),
|
|
287
300
|
' ',
|
|
288
301
|
React.createElement(FormLayout_1.FormRow, { label: "Content" },
|
|
289
|
-
React.createElement(Input_1.default, { "data-name": "content", value: (
|
|
302
|
+
React.createElement(Input_1.default, { "data-name": "content", value: (_e = data.DisplayFormat.Options.Content) !== null && _e !== void 0 ? _e : '', onChange: (e) => setFormatOption('Content', e.currentTarget.value) })),
|
|
290
303
|
' ',
|
|
291
304
|
React.createElement(FormLayout_1.FormRow, { label: "Parentheses" },
|
|
292
305
|
React.createElement(CheckBox_1.CheckBox, { "data-name": "parentheses-checkbox", checked: data.DisplayFormat.Options.Parentheses, onChange: (checked) => setFormatOption('Parentheses', checked) })),
|
|
@@ -11,11 +11,6 @@ const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
|
|
|
11
11
|
const Tag_1 = require("../../../components/Tag");
|
|
12
12
|
const ToggleGroup_1 = require("../../../components/Toggle/ToggleGroup");
|
|
13
13
|
const Toggle_1 = require("../../../components/Toggle/Toggle");
|
|
14
|
-
let alignmentOptions = [
|
|
15
|
-
{ value: 'Left', label: 'Left' },
|
|
16
|
-
{ value: 'Right', label: 'Right' },
|
|
17
|
-
{ value: 'Center', label: 'Center' },
|
|
18
|
-
];
|
|
19
14
|
const renderFormatColumnSettingsSummary = (data) => {
|
|
20
15
|
var _a;
|
|
21
16
|
return (React.createElement(rebass_1.Box, { padding: 2 },
|
|
@@ -6,9 +6,11 @@ const React = tslib_1.__importStar(require("react"));
|
|
|
6
6
|
const react_redux_1 = require("react-redux");
|
|
7
7
|
const InfiniteTable_1 = require("../../components/InfiniteTable");
|
|
8
8
|
const NoteRedux_1 = require("../../Redux/ActionsReducers/NoteRedux");
|
|
9
|
+
const format_1 = tslib_1.__importDefault(require("date-fns/format"));
|
|
9
10
|
const AdaptableContext_1 = require("../AdaptableContext");
|
|
10
11
|
const AdaptableButton_1 = require("../Components/AdaptableButton");
|
|
11
12
|
const PopupPanel_1 = require("../Components/Popups/AdaptablePopup/PopupPanel");
|
|
13
|
+
const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
|
|
12
14
|
const tableDOMProps = {
|
|
13
15
|
style: {
|
|
14
16
|
height: '100%',
|
|
@@ -17,8 +19,10 @@ const tableDOMProps = {
|
|
|
17
19
|
},
|
|
18
20
|
};
|
|
19
21
|
const NotePopup = (props) => {
|
|
22
|
+
var _a;
|
|
20
23
|
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
21
24
|
const primaryKeyHeader = adaptable.api.columnApi.getFriendlyNameForColumnId(adaptable.api.columnApi.getPrimaryKeyColumn().columnId);
|
|
25
|
+
const dateFormat = (_a = adaptable.api.optionsApi.getNoteOptions().dateFormat) !== null && _a !== void 0 ? _a : GeneralConstants_1.DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME;
|
|
22
26
|
const allNotes = (0, react_redux_1.useSelector)((state) => (0, NoteRedux_1.GetAllNotesSelector)(state.Note));
|
|
23
27
|
const isReadOnlyModule = adaptable.api.entitlementApi.getEntitlementAccessLevelForModule('Note') === 'ReadOnly';
|
|
24
28
|
const columnsMap = React.useMemo(() => {
|
|
@@ -43,8 +47,7 @@ const NotePopup = (props) => {
|
|
|
43
47
|
timestamp: {
|
|
44
48
|
field: 'Timestamp',
|
|
45
49
|
valueGetter: (params) => {
|
|
46
|
-
|
|
47
|
-
return (_a = new Date(params.data.Timestamp)) === null || _a === void 0 ? void 0 : _a.toDateString();
|
|
50
|
+
return (0, format_1.default)(params.data.Timestamp, dateFormat);
|
|
48
51
|
},
|
|
49
52
|
},
|
|
50
53
|
delete: {
|
|
@@ -58,7 +58,7 @@ export declare class AdaptableAgGrid implements IAdaptable {
|
|
|
58
58
|
* once layouts are properly handled with the new aggrid methods & events
|
|
59
59
|
* we can remove this hack
|
|
60
60
|
*/
|
|
61
|
-
private
|
|
61
|
+
private previousAgGridLayoutState;
|
|
62
62
|
_rawAdaptableOptions: AdaptableOptions;
|
|
63
63
|
adaptableOptions: AdaptableOptions;
|
|
64
64
|
_isDetailGrid: boolean;
|
|
@@ -310,15 +310,6 @@ export declare class AdaptableAgGrid implements IAdaptable {
|
|
|
310
310
|
getChartRef(chartId: string): ChartRef;
|
|
311
311
|
setLayout(layout?: Layout): void;
|
|
312
312
|
private getActiveAdaptableAggFuncForCol;
|
|
313
|
-
/**
|
|
314
|
-
* Setting layout works by modifing the column state.
|
|
315
|
-
* The column state is based on the current existing columns.
|
|
316
|
-
* At this point the column groups do not exist, and the widths from layout are not applied.
|
|
317
|
-
*
|
|
318
|
-
* After the col sate is applied and the column groups are created we need
|
|
319
|
-
* to apply the state again to update the widths of the group columns.
|
|
320
|
-
*/
|
|
321
|
-
private applyGroupColumnWidth;
|
|
322
313
|
private onRowDataChanged;
|
|
323
314
|
private onCellDataChanged;
|
|
324
315
|
private isUndoChange;
|
|
@@ -100,6 +100,7 @@ const Modal_1 = require("../components/Modal");
|
|
|
100
100
|
const AdaptableLoadingScreen_1 = require("../View/Components/Popups/AdaptableLoadingScreen");
|
|
101
101
|
const react_1 = require("react");
|
|
102
102
|
const AdaptableHelper_1 = require("../Utilities/Helpers/AdaptableHelper");
|
|
103
|
+
const buildSortedColumnStateForLayout_1 = require("./buildSortedColumnStateForLayout");
|
|
103
104
|
const RowNodeProto = core_1.RowNode.prototype;
|
|
104
105
|
const RowNode_dispatchLocalEvent = RowNodeProto.dispatchLocalEvent;
|
|
105
106
|
/**
|
|
@@ -147,7 +148,7 @@ class AdaptableAgGrid {
|
|
|
147
148
|
* once layouts are properly handled with the new aggrid methods & events
|
|
148
149
|
* we can remove this hack
|
|
149
150
|
*/
|
|
150
|
-
this.
|
|
151
|
+
this.previousAgGridLayoutState = '';
|
|
151
152
|
this.columnMinMaxValuesCache = {};
|
|
152
153
|
this.renderReactRoot = (node, container) => (0, renderReactRoot_1.renderReactRoot)(node, container);
|
|
153
154
|
/**
|
|
@@ -2207,53 +2208,20 @@ class AdaptableAgGrid {
|
|
|
2207
2208
|
});
|
|
2208
2209
|
this.deriveAdaptableColumnStateFromAgGrid();
|
|
2209
2210
|
}
|
|
2210
|
-
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState,
|
|
2211
|
+
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState, layout) {
|
|
2212
|
+
layout = layout || this.api.layoutApi.getCurrentLayout();
|
|
2213
|
+
visibleColumnList = visibleColumnList || layout.Columns;
|
|
2211
2214
|
columnState = columnState || this.agGridAdapter.getAgGridApi().getColumnState();
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
acc[colId] = index;
|
|
2223
|
-
return acc;
|
|
2224
|
-
}, {});
|
|
2225
|
-
const result = [...columnState]
|
|
2226
|
-
.sort((colState1, colState2) => {
|
|
2227
|
-
const colId1 = colState1.colId;
|
|
2228
|
-
const colId2 = colState2.colId;
|
|
2229
|
-
const originalIndex1 = columnsStateIndexes[colId1];
|
|
2230
|
-
const originalIndex2 = columnsStateIndexes[colId2];
|
|
2231
|
-
if (pivotMode) {
|
|
2232
|
-
const isRowGroup1 = this.api.columnApi.isAutoRowGroupColumn(colId1);
|
|
2233
|
-
const isRowGroup2 = this.api.columnApi.isAutoRowGroupColumn(colId2);
|
|
2234
|
-
if (isRowGroup1 && isRowGroup2) {
|
|
2235
|
-
return 1;
|
|
2236
|
-
}
|
|
2237
|
-
if (isRowGroup1) {
|
|
2238
|
-
return -1;
|
|
2239
|
-
}
|
|
2240
|
-
if (isRowGroup2) {
|
|
2241
|
-
return 1;
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
if (newVisibleColumnsMap[colId1] != null && newVisibleColumnsMap[colId2] == null) {
|
|
2245
|
-
return -1;
|
|
2246
|
-
}
|
|
2247
|
-
if (newVisibleColumnsMap[colId1] == null && newVisibleColumnsMap[colId2] != null) {
|
|
2248
|
-
return 1;
|
|
2249
|
-
}
|
|
2250
|
-
if (newVisibleColumnsMap[colId1] == null && newVisibleColumnsMap[colId2] == null) {
|
|
2251
|
-
return originalIndex1 - originalIndex2;
|
|
2252
|
-
}
|
|
2253
|
-
return newVisibleColumnsMap[colState1.colId] - newVisibleColumnsMap[colState2.colId];
|
|
2254
|
-
})
|
|
2255
|
-
.map((colState) => (Object.assign(Object.assign({}, colState), { hide: NewVisibleColumnIdsMap[colState.colId] == null })));
|
|
2256
|
-
return result;
|
|
2215
|
+
return (0, buildSortedColumnStateForLayout_1.buildSortedColumnStateForLayout)({
|
|
2216
|
+
columnState: columnState.map((colState) => {
|
|
2217
|
+
return {
|
|
2218
|
+
colId: colState.colId,
|
|
2219
|
+
hide: colState.hide,
|
|
2220
|
+
};
|
|
2221
|
+
}),
|
|
2222
|
+
layout: Object.assign(Object.assign({}, layout), { Columns: visibleColumnList }),
|
|
2223
|
+
gridOptions: this.agGridAdapter.getLiveGridOptions(),
|
|
2224
|
+
});
|
|
2257
2225
|
}
|
|
2258
2226
|
getDistinctValuesForColumn(column, distinctValuesParams) {
|
|
2259
2227
|
let gridCells = this.getGridCellsForPermittedValues(column, distinctValuesParams);
|
|
@@ -2961,7 +2929,7 @@ class AdaptableAgGrid {
|
|
|
2961
2929
|
else {
|
|
2962
2930
|
(_b = this.agGridAdapter.getAgGridApi()) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
2963
2931
|
}
|
|
2964
|
-
this.
|
|
2932
|
+
this.previousAgGridLayoutState = '';
|
|
2965
2933
|
const gridContainerElement = this.getAgGridContainerElement();
|
|
2966
2934
|
if (gridContainerElement) {
|
|
2967
2935
|
gridContainerElement.removeEventListener('keydown', this.agGridListenerKeydown);
|
|
@@ -3194,10 +3162,6 @@ class AdaptableAgGrid {
|
|
|
3194
3162
|
layout.PinnedColumnsMap = layout.PinnedColumnsMap || {};
|
|
3195
3163
|
layout.PinnedColumnsMap[actionRowColumn.colId] = actionRowColumn.pinned;
|
|
3196
3164
|
}
|
|
3197
|
-
const layoutColumnsMap = layout.Columns.reduce((acc, colId) => {
|
|
3198
|
-
acc[colId] = true;
|
|
3199
|
-
return acc;
|
|
3200
|
-
}, {});
|
|
3201
3165
|
const columnsState = this.agGridAdapter.getAgGridApi().getColumnState();
|
|
3202
3166
|
const columnsStateIndexes = {};
|
|
3203
3167
|
const columnsStateMap = columnsState.reduce((acc, colState, index) => {
|
|
@@ -3229,20 +3193,19 @@ class AdaptableAgGrid {
|
|
|
3229
3193
|
.getPivotResultColumns()) === null || _b === void 0 ? void 0 : _b.map((column) => column.getColId())) || [];
|
|
3230
3194
|
let isChanged = false;
|
|
3231
3195
|
const colsToAutoSize = {};
|
|
3232
|
-
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState,
|
|
3196
|
+
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState, layout);
|
|
3233
3197
|
newColumnsState = newColumnsState
|
|
3234
3198
|
.map((colState) => {
|
|
3235
3199
|
var _a, _b, _c;
|
|
3236
3200
|
const { colId } = colState;
|
|
3237
3201
|
const oldColState = columnsStateMap[colId];
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
const newColState = Object.assign(Object.assign({}, oldColState), { hide });
|
|
3202
|
+
// it's important to have width here, so it's not inherited from the existing colState
|
|
3203
|
+
// which could be from a different layout
|
|
3204
|
+
const newColState = Object.assign(Object.assign(Object.assign({}, oldColState), { width: null }), colState);
|
|
3242
3205
|
if (layout.ColumnWidthMap && layout.ColumnWidthMap[colId] != null) {
|
|
3243
3206
|
newColState.width = layout.ColumnWidthMap[colId];
|
|
3244
3207
|
}
|
|
3245
|
-
else if (!hide) {
|
|
3208
|
+
else if (!colState.hide) {
|
|
3246
3209
|
// autosize only the columns which are part of the selected layout
|
|
3247
3210
|
colsToAutoSize[colId] = true;
|
|
3248
3211
|
}
|
|
@@ -3251,11 +3214,7 @@ class AdaptableAgGrid {
|
|
|
3251
3214
|
}
|
|
3252
3215
|
newColState.rowGroupIndex =
|
|
3253
3216
|
groupedColumnsIndexesMap[colId] != null ? groupedColumnsIndexesMap[colId] : null;
|
|
3254
|
-
const previousRowGroup = newColState.rowGroup;
|
|
3255
3217
|
newColState.rowGroup = newColState.rowGroupIndex != null;
|
|
3256
|
-
if (!previousRowGroup && newColState.rowGroup) {
|
|
3257
|
-
this.agGridColumnAdapter.triggerSetupColumnKeyCreator(colId);
|
|
3258
|
-
}
|
|
3259
3218
|
const normalizePinned = (pinnedValue) => {
|
|
3260
3219
|
if (typeof pinnedValue === 'string') {
|
|
3261
3220
|
return pinnedValue;
|
|
@@ -3360,14 +3319,13 @@ class AdaptableAgGrid {
|
|
|
3360
3319
|
// as otherwise column order is not preserved properly when
|
|
3361
3320
|
// going from pivoted to unpivoted layout
|
|
3362
3321
|
if (shouldUpdatePivoted) {
|
|
3363
|
-
this.agGridAdapter.
|
|
3322
|
+
this.agGridAdapter.setGridOption('pivotMode', pivoted);
|
|
3364
3323
|
}
|
|
3365
3324
|
const perfApplyColumnState = this.logger.beginPerf('applyColumnState (layout.isChanged)');
|
|
3366
3325
|
this.agGridAdapter.getAgGridApi().applyColumnState({
|
|
3367
3326
|
state: newColumnsState,
|
|
3368
3327
|
applyOrder: true,
|
|
3369
3328
|
});
|
|
3370
|
-
this.applyGroupColumnWidth(layout);
|
|
3371
3329
|
perfApplyColumnState.end();
|
|
3372
3330
|
this.api.gridApi.setColumnSorts(layout.ColumnSorts);
|
|
3373
3331
|
this.agGridAdapter.getAgGridApi().setPivotColumns(layout.PivotColumns || []);
|
|
@@ -3424,38 +3382,6 @@ class AdaptableAgGrid {
|
|
|
3424
3382
|
}
|
|
3425
3383
|
return null;
|
|
3426
3384
|
}
|
|
3427
|
-
/**
|
|
3428
|
-
* Setting layout works by modifing the column state.
|
|
3429
|
-
* The column state is based on the current existing columns.
|
|
3430
|
-
* At this point the column groups do not exist, and the widths from layout are not applied.
|
|
3431
|
-
*
|
|
3432
|
-
* After the col sate is applied and the column groups are created we need
|
|
3433
|
-
* to apply the state again to update the widths of the group columns.
|
|
3434
|
-
*/
|
|
3435
|
-
applyGroupColumnWidth(layout) {
|
|
3436
|
-
if (!layout.RowGroupedColumns || !layout.RowGroupedColumns.length) {
|
|
3437
|
-
return;
|
|
3438
|
-
}
|
|
3439
|
-
const groupColumnWithDifferentWidths = this.agGridAdapter
|
|
3440
|
-
.getAgGridApi()
|
|
3441
|
-
.getColumnState()
|
|
3442
|
-
.reduce((acc, col) => {
|
|
3443
|
-
var _a;
|
|
3444
|
-
if (this.api.columnApi.isAutoRowGroupColumn(col.colId)) {
|
|
3445
|
-
const widthInLayout = (_a = layout.ColumnWidthMap) === null || _a === void 0 ? void 0 : _a[col.colId];
|
|
3446
|
-
if (widthInLayout && widthInLayout !== col.width) {
|
|
3447
|
-
acc.push(Object.assign(Object.assign({}, col), { width: widthInLayout }));
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
return acc;
|
|
3451
|
-
}, []);
|
|
3452
|
-
if (groupColumnWithDifferentWidths.length === 0) {
|
|
3453
|
-
return;
|
|
3454
|
-
}
|
|
3455
|
-
this.agGridAdapter.getAgGridApi().applyColumnState({
|
|
3456
|
-
state: groupColumnWithDifferentWidths,
|
|
3457
|
-
});
|
|
3458
|
-
}
|
|
3459
3385
|
onRowDataChanged({ rowNode, oldData, newData, }) {
|
|
3460
3386
|
if (oldData == null || oldData == undefined) {
|
|
3461
3387
|
return;
|
|
@@ -3752,15 +3678,18 @@ class AdaptableAgGrid {
|
|
|
3752
3678
|
var _a, _b;
|
|
3753
3679
|
const agGridApi = this.agGridAdapter.getAgGridApi();
|
|
3754
3680
|
const columnState = agGridApi.getColumnState();
|
|
3681
|
+
const expandedState = agGridApi.getState().rowGroupExpansion || { expandedRowGroupIds: [] };
|
|
3682
|
+
const currentLayoutState = { columnState, expandedState };
|
|
3755
3683
|
try {
|
|
3756
|
-
|
|
3757
|
-
|
|
3684
|
+
// TODO
|
|
3685
|
+
const stringifiedLayoutState = JSON.stringify(currentLayoutState);
|
|
3686
|
+
if (stringifiedLayoutState === this.previousAgGridLayoutState) {
|
|
3758
3687
|
// same grid column state as a previous,
|
|
3759
3688
|
// so no need to update, as the layout has already been updated
|
|
3760
3689
|
// for this grid column state
|
|
3761
3690
|
return;
|
|
3762
3691
|
}
|
|
3763
|
-
this.
|
|
3692
|
+
this.previousAgGridLayoutState = stringifiedLayoutState;
|
|
3764
3693
|
}
|
|
3765
3694
|
catch (ex) {
|
|
3766
3695
|
this.logger.consoleError('Error stringifying column state', ex);
|
|
@@ -24,6 +24,7 @@ export declare class AgGridAdapter {
|
|
|
24
24
|
grabAgGridApiOnTheFly(args: unknown): void;
|
|
25
25
|
getLiveGridOptions(): GridOptions | undefined;
|
|
26
26
|
updateGridOptions(options: ManagedGridOptions): void;
|
|
27
|
+
getGridOption<Key extends keyof GridOptions>(key: Key): GridOptions[Key];
|
|
27
28
|
setGridOption<Key extends ManagedGridOptionKey>(key: Key, value: GridOptions[Key]): void;
|
|
28
29
|
getUserGridOptionsProperty<T extends keyof GridOptions>(propertyName: T): GridOptions[T];
|
|
29
30
|
updateColumnFilterActiveState(): void;
|
|
@@ -64,6 +64,10 @@ class AgGridAdapter {
|
|
|
64
64
|
var _a;
|
|
65
65
|
(_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.updateGridOptions(options);
|
|
66
66
|
}
|
|
67
|
+
getGridOption(key) {
|
|
68
|
+
var _a;
|
|
69
|
+
return (_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.getGridOption(key);
|
|
70
|
+
}
|
|
67
71
|
setGridOption(key, value) {
|
|
68
72
|
var _a;
|
|
69
73
|
(_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.setGridOption(key, value);
|
|
@@ -12,7 +12,6 @@ export declare class AgGridColumnAdapter {
|
|
|
12
12
|
setColDefProperty<T extends keyof ColDef>(col: Column, propertyName: T, propertyGetter: (userPropertyValue: ColDef[T]) => ColDef[T] | undefined): void;
|
|
13
13
|
getUserColDefProperty<T extends keyof ColDef>(columnId: string, propertyName: T): ColDef[T] | undefined;
|
|
14
14
|
setupColumns(): void;
|
|
15
|
-
triggerSetupColumnKeyCreator(colId: string): void;
|
|
16
15
|
private setupColumnValueGetter;
|
|
17
16
|
private setupColumnCellClass;
|
|
18
17
|
private setupColumnCellStyle;
|
|
@@ -21,7 +20,6 @@ export declare class AgGridColumnAdapter {
|
|
|
21
20
|
private setupColumnTooltipValueGetter;
|
|
22
21
|
private setupColumnQuickFilerText;
|
|
23
22
|
private setupColumnAllowedAggFuncs;
|
|
24
|
-
private setupColumnKeyCreator;
|
|
25
23
|
private setupColumnCellDataType;
|
|
26
24
|
setupColumnHeader({ col, abColumn }: ColumnSetupInfo): boolean;
|
|
27
25
|
private setupColumnFilter;
|
|
@@ -106,24 +106,11 @@ class AgGridColumnAdapter {
|
|
|
106
106
|
this.setupColumnHeader(colSetupInfo);
|
|
107
107
|
this.setupColumnQuickFilerText(colSetupInfo);
|
|
108
108
|
this.setupColumnAllowedAggFuncs(colSetupInfo);
|
|
109
|
-
this.setupColumnKeyCreator(colSetupInfo);
|
|
110
109
|
// this is just to make sure that AG Grid does NOT infer the cellDataType
|
|
111
110
|
// https://github.com/AdaptableTools/adaptable/issues/2230 should render it obsolete
|
|
112
111
|
this.setupColumnCellDataType(colSetupInfo);
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
|
-
triggerSetupColumnKeyCreator(colId) {
|
|
116
|
-
const col = this.agGridApi.getColumn(colId);
|
|
117
|
-
const colDef = col.getColDef();
|
|
118
|
-
const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
|
|
119
|
-
const colSetupInfo = {
|
|
120
|
-
col,
|
|
121
|
-
colDef,
|
|
122
|
-
colId,
|
|
123
|
-
abColumn,
|
|
124
|
-
};
|
|
125
|
-
this.setupColumnKeyCreator(colSetupInfo);
|
|
126
|
-
}
|
|
127
114
|
setupColumnValueGetter({ col }) {
|
|
128
115
|
// need this here if we want plugins to intercept
|
|
129
116
|
this.setColDefProperty(col, 'valueGetter', (userValue) => {
|
|
@@ -291,36 +278,6 @@ class AgGridColumnAdapter {
|
|
|
291
278
|
return abColumn.availableAggregationFunctions;
|
|
292
279
|
});
|
|
293
280
|
}
|
|
294
|
-
setupColumnKeyCreator(columnSetupInfo) {
|
|
295
|
-
const { col, abColumn } = columnSetupInfo;
|
|
296
|
-
const adaptableOptions = this.adaptableOptions;
|
|
297
|
-
this.setColDefProperty(col, 'keyCreator', (userPropertyValue) => {
|
|
298
|
-
return (params) => {
|
|
299
|
-
var _a;
|
|
300
|
-
if (typeof userPropertyValue === 'function') {
|
|
301
|
-
return userPropertyValue(params);
|
|
302
|
-
}
|
|
303
|
-
const value = params.value;
|
|
304
|
-
if (this.adaptableInstance.agGridAdapter.getLiveGridOptions().groupAllowUnbalanced) {
|
|
305
|
-
return value;
|
|
306
|
-
}
|
|
307
|
-
const balancedGroupsKey = (_a = adaptableOptions.groupingOptions) === null || _a === void 0 ? void 0 : _a.balancedGroupsKey;
|
|
308
|
-
if (!balancedGroupsKey) {
|
|
309
|
-
return value;
|
|
310
|
-
}
|
|
311
|
-
let groupBalancedGroupsUnderKeyValue = typeof balancedGroupsKey === 'function'
|
|
312
|
-
? balancedGroupsKey({
|
|
313
|
-
adaptableApi: this.adaptableApi,
|
|
314
|
-
userName: this.adaptableOptions.userName,
|
|
315
|
-
adaptableId: this.adaptableOptions.adaptableId,
|
|
316
|
-
adaptableColumn: abColumn,
|
|
317
|
-
params,
|
|
318
|
-
})
|
|
319
|
-
: balancedGroupsKey;
|
|
320
|
-
return value === null || value === undefined ? groupBalancedGroupsUnderKeyValue : value;
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
281
|
setupColumnCellDataType(columnSetupInfo) {
|
|
325
282
|
const { col } = columnSetupInfo;
|
|
326
283
|
// AG Grid introduced since v30.x an inferred cellDataType
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColumnState, GridOptions } from '@ag-grid-community/core';
|
|
2
|
+
import { Layout } from '../types';
|
|
3
|
+
export declare function buildSortedColumnStateForLayout(params: {
|
|
4
|
+
columnState: ColumnState[];
|
|
5
|
+
layout: Layout;
|
|
6
|
+
gridOptions: GridOptions;
|
|
7
|
+
}): ColumnState[];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSortedColumnStateForLayout = void 0;
|
|
4
|
+
const GeneralConstants_1 = require("../Utilities/Constants/GeneralConstants");
|
|
5
|
+
const ColumnInternalApi_1 = require("../Api/Internal/ColumnInternalApi");
|
|
6
|
+
const ColumnApiImpl_1 = require("../Api/Implementation/ColumnApiImpl");
|
|
7
|
+
const sortColumnStateForVisibleColumns_1 = require("./sortColumnStateForVisibleColumns");
|
|
8
|
+
function buildSortedColumnStateForLayout(params) {
|
|
9
|
+
const { columnState, layout, gridOptions } = params;
|
|
10
|
+
let visibleColumnList = [...layout.Columns];
|
|
11
|
+
const multipleGroupColumns = gridOptions.groupDisplayType === 'multipleColumns';
|
|
12
|
+
const singleGroupColumn = !multipleGroupColumns;
|
|
13
|
+
const rowGroupedColumnsIndexes = {};
|
|
14
|
+
let generatedRowGroupColumnsIds = [];
|
|
15
|
+
// here we make sure the visibleColumnList includes all the generated group columns
|
|
16
|
+
if (layout.RowGroupedColumns) {
|
|
17
|
+
layout.RowGroupedColumns.forEach((colId, index) => {
|
|
18
|
+
rowGroupedColumnsIndexes[colId] = index;
|
|
19
|
+
rowGroupedColumnsIndexes[(0, ColumnInternalApi_1.getAutoRowGroupColumnIdFor)(colId)] = index;
|
|
20
|
+
});
|
|
21
|
+
// if the layout does not include the grouped columns,
|
|
22
|
+
// make sure we add the grouped columns to the visible column list
|
|
23
|
+
// at the start of the list
|
|
24
|
+
if (singleGroupColumn) {
|
|
25
|
+
if (!visibleColumnList.includes(GeneralConstants_1.AG_GRID_GROUPED_COLUMN)) {
|
|
26
|
+
visibleColumnList = [GeneralConstants_1.AG_GRID_GROUPED_COLUMN, ...visibleColumnList];
|
|
27
|
+
}
|
|
28
|
+
generatedRowGroupColumnsIds.push(GeneralConstants_1.AG_GRID_GROUPED_COLUMN);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
let missingGroupColumns = 0;
|
|
32
|
+
[...layout.RowGroupedColumns].reverse().forEach((colId) => {
|
|
33
|
+
const groupColId = (0, ColumnInternalApi_1.getAutoRowGroupColumnIdFor)(colId);
|
|
34
|
+
if (!visibleColumnList.includes(groupColId)) {
|
|
35
|
+
visibleColumnList = [groupColId, ...visibleColumnList];
|
|
36
|
+
missingGroupColumns++;
|
|
37
|
+
}
|
|
38
|
+
generatedRowGroupColumnsIds = [groupColId, ...generatedRowGroupColumnsIds];
|
|
39
|
+
});
|
|
40
|
+
// now we need to sort the visibleColumnList to contain the group columns
|
|
41
|
+
// in the correct order
|
|
42
|
+
// but we only need to do this if the layout.Columns list missed some of the
|
|
43
|
+
// group columns, but not all of them. if all were missing, we already
|
|
44
|
+
// inserted them at the start of the list
|
|
45
|
+
if (missingGroupColumns && missingGroupColumns < layout.RowGroupedColumns.length) {
|
|
46
|
+
visibleColumnList.sort((colId1, colId2) => {
|
|
47
|
+
const isRowGroup1 = (0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId1);
|
|
48
|
+
const isRowGroup2 = (0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId2);
|
|
49
|
+
if (isRowGroup1 && isRowGroup2) {
|
|
50
|
+
return rowGroupedColumnsIndexes[colId1] - rowGroupedColumnsIndexes[colId2];
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const visibleColumnsIndexes = visibleColumnList.reduce((acc, colId, index) => {
|
|
58
|
+
acc[colId] = index;
|
|
59
|
+
return acc;
|
|
60
|
+
}, {});
|
|
61
|
+
const pivotMode = layout.EnablePivot;
|
|
62
|
+
if (pivotMode) {
|
|
63
|
+
// in pivot mode, we sort the Visible columns of the layout
|
|
64
|
+
// to make sure the group cols are at the beginning
|
|
65
|
+
const groupCols = visibleColumnList.filter(ColumnApiImpl_1.isAutoRowGroupColumn);
|
|
66
|
+
visibleColumnList = visibleColumnList.filter((colId) => !(0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId));
|
|
67
|
+
visibleColumnList = [...groupCols, ...visibleColumnList];
|
|
68
|
+
}
|
|
69
|
+
// we're now ready to go over the columnState
|
|
70
|
+
// we want as much as possible to keep the order of the columns
|
|
71
|
+
// as they are in the column state.
|
|
72
|
+
// if the order is different in the visibleColumns, we only move those columns around
|
|
73
|
+
// if some columns in the columnState are not in the visibleColumns, we need to return them as hide: true
|
|
74
|
+
// first step - keep the same order, but filter out old group columns
|
|
75
|
+
// VERY IMPORTANT to only filter out OLD group columns, that is,
|
|
76
|
+
// group columns that are not in the layout anymore
|
|
77
|
+
// since we might have different group columns in the layout
|
|
78
|
+
let newColumnState = [...columnState].filter((colState) => {
|
|
79
|
+
const { colId } = colState;
|
|
80
|
+
if ((0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId) && rowGroupedColumnsIndexes[colId] == null) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
});
|
|
85
|
+
// second step - keep the same order
|
|
86
|
+
// but make sure the visibility is adjusted to reflect the
|
|
87
|
+
// visible columns in the layout
|
|
88
|
+
newColumnState = newColumnState.map((colState) => {
|
|
89
|
+
const { colId } = colState;
|
|
90
|
+
const visibleIndex = visibleColumnsIndexes[colId];
|
|
91
|
+
if (visibleIndex == null) {
|
|
92
|
+
return Object.assign(Object.assign({}, colState), { hide: true });
|
|
93
|
+
}
|
|
94
|
+
return Object.assign(Object.assign({}, colState), { hide: null });
|
|
95
|
+
});
|
|
96
|
+
// third step - correctly mark the columns that are grouped
|
|
97
|
+
newColumnState = newColumnState.map((colState) => {
|
|
98
|
+
const { colId } = colState;
|
|
99
|
+
const groupIndex = rowGroupedColumnsIndexes[colId];
|
|
100
|
+
if (groupIndex != null) {
|
|
101
|
+
return Object.assign(Object.assign({}, colState), { rowGroup: true, rowGroupIndex: groupIndex });
|
|
102
|
+
}
|
|
103
|
+
return Object.assign(Object.assign({}, colState), { rowGroup: false, rowGroupIndex: null });
|
|
104
|
+
});
|
|
105
|
+
// fourth step - add the new group columns, if they are missing
|
|
106
|
+
const columnStateIndexes = newColumnState.reduce((acc, colState, index) => {
|
|
107
|
+
acc[colState.colId] = index;
|
|
108
|
+
return acc;
|
|
109
|
+
}, {});
|
|
110
|
+
generatedRowGroupColumnsIds.reverse().forEach((rowGroupColId) => {
|
|
111
|
+
if (columnStateIndexes[rowGroupColId] == null) {
|
|
112
|
+
newColumnState = [
|
|
113
|
+
{
|
|
114
|
+
colId: rowGroupColId,
|
|
115
|
+
},
|
|
116
|
+
...newColumnState,
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
// fitfth step - sort the column state to respect the order of the visible columns
|
|
121
|
+
// we can't simply call sort in this case
|
|
122
|
+
return (0, sortColumnStateForVisibleColumns_1.sortColumnStateForVisibleColumns)(newColumnState, visibleColumnList);
|
|
123
|
+
}
|
|
124
|
+
exports.buildSortedColumnStateForLayout = buildSortedColumnStateForLayout;
|
|
@@ -147,7 +147,6 @@ const DefaultAdaptableOptions = {
|
|
|
147
147
|
customSortOptions: { customSortComparers: undefined },
|
|
148
148
|
dataSetOptions: { dataSets: GeneralConstants_1.EMPTY_ARRAY },
|
|
149
149
|
groupingOptions: {
|
|
150
|
-
balancedGroupsKey: undefined,
|
|
151
150
|
restoreUngroupedColumns: false,
|
|
152
151
|
autoOrderGroupedColumns: true,
|
|
153
152
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ColState = {
|
|
2
|
+
colId: string;
|
|
3
|
+
hide?: boolean | null;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* This method takes a column state and the list of visible columns
|
|
7
|
+
* and returns a new column state that respects the order of the visible columns
|
|
8
|
+
* while trying to keep the hidden columns in their original order.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function sortColumnStateForVisibleColumns<T extends ColState>(columnState: T[], visibleColumns: string[]): T[];
|
|
12
|
+
export {};
|