@adaptabletools/adaptable 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 +19 -6
- 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 +7 -1
- package/src/Redux/ActionsReducers/CommentsRedux.d.ts +0 -4
- package/src/Redux/ActionsReducers/CommentsRedux.js +0 -34
- 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 +1 -0
- 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 +120 -0
- package/src/agGrid/defaultAdaptableOptions.js +0 -1
- package/src/agGrid/sortColumnStateForVisibleColumns.d.ts +12 -0
- package/src/agGrid/sortColumnStateForVisibleColumns.js +46 -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.esm.tsbuildinfo +1 -1
|
@@ -143,6 +143,19 @@ export const getFormatDisplayTypeForScope = (scope, api) => {
|
|
|
143
143
|
if ('DataTypes' in scope && scope.DataTypes.length == 1 && scope.DataTypes[0] == 'String') {
|
|
144
144
|
return 'String';
|
|
145
145
|
}
|
|
146
|
+
if ('ColumnTypes' in scope && scope.ColumnTypes.length) {
|
|
147
|
+
// need to check if all column with this column type has the same data type and return that particular one
|
|
148
|
+
const columns = scope.ColumnTypes.flatMap((columnType) => {
|
|
149
|
+
return api.columnApi.getColumnsByColumnType(columnType);
|
|
150
|
+
});
|
|
151
|
+
// check if all have the same type
|
|
152
|
+
if (columns.length &&
|
|
153
|
+
columns.every((column) => column.dataType === columns[0].dataType) &&
|
|
154
|
+
// supported data types
|
|
155
|
+
['Number', 'Date', 'String'].includes(columns[0].dataType)) {
|
|
156
|
+
return columns[0].dataType;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
146
159
|
return undefined;
|
|
147
160
|
};
|
|
148
161
|
const renderDateFormat = (data, _onChange, setFormatOption, scopedCustomFormatters) => {
|
|
@@ -189,7 +202,7 @@ const renderDateFormat = (data, _onChange, setFormatOption, scopedCustomFormatte
|
|
|
189
202
|
] })))))));
|
|
190
203
|
};
|
|
191
204
|
const renderNumberFormat = (data, onChange, setFormatOption, scopedCustomFormatters, formatColumnApi) => {
|
|
192
|
-
var _a, _b, _c;
|
|
205
|
+
var _a, _b, _c, _d, _e;
|
|
193
206
|
if (data.DisplayFormat.Formatter !== 'NumberFormatter') {
|
|
194
207
|
return null;
|
|
195
208
|
}
|
|
@@ -248,13 +261,13 @@ const renderNumberFormat = (data, onChange, setFormatOption, scopedCustomFormatt
|
|
|
248
261
|
React.createElement(Flex, { flexDirection: "row" },
|
|
249
262
|
React.createElement(FormLayout, { mr: 3 },
|
|
250
263
|
React.createElement(FormRow, { label: "Fraction Separator" },
|
|
251
|
-
React.createElement(Input, { "data-name": "fraction-separator", value: data.DisplayFormat.Options.FractionSeparator, onChange: (e) => setFormatOption('FractionSeparator', e.currentTarget.value) })),
|
|
264
|
+
React.createElement(Input, { "data-name": "fraction-separator", value: (_a = data.DisplayFormat.Options.FractionSeparator) !== null && _a !== void 0 ? _a : '', onChange: (e) => setFormatOption('FractionSeparator', e.currentTarget.value) })),
|
|
252
265
|
React.createElement(FormRow, { label: "Integer Separator" },
|
|
253
|
-
React.createElement(Input, { "data-name": "integer-separator", value: data.DisplayFormat.Options.IntegerSeparator, onChange: (e) => setFormatOption('IntegerSeparator', e.currentTarget.value) })),
|
|
266
|
+
React.createElement(Input, { "data-name": "integer-separator", value: (_b = data.DisplayFormat.Options.IntegerSeparator) !== null && _b !== void 0 ? _b : '', onChange: (e) => setFormatOption('IntegerSeparator', e.currentTarget.value) })),
|
|
254
267
|
React.createElement(FormRow, { label: "Prefix" },
|
|
255
|
-
React.createElement(Input, { "data-name": "prefix", value: (
|
|
268
|
+
React.createElement(Input, { "data-name": "prefix", value: (_c = data.DisplayFormat.Options.Prefix) !== null && _c !== void 0 ? _c : '', onChange: (e) => setFormatOption('Prefix', e.currentTarget.value) })),
|
|
256
269
|
React.createElement(FormRow, { label: "Suffix" },
|
|
257
|
-
React.createElement(Input, { "data-name": "suffix", value: (
|
|
270
|
+
React.createElement(Input, { "data-name": "suffix", value: (_d = data.DisplayFormat.Options.Suffix) !== null && _d !== void 0 ? _d : '', onChange: (e) => setFormatOption('Suffix', e.currentTarget.value) })),
|
|
258
271
|
React.createElement(FormRow, { label: "Truncate" },
|
|
259
272
|
React.createElement(CheckBox, { "data-name": "truncate-checkbox", checked: data.DisplayFormat.Options.Truncate, onChange: (checked) => setFormatOption('Truncate', checked) })),
|
|
260
273
|
React.createElement(FormRow, { label: "Ceiling" },
|
|
@@ -279,7 +292,7 @@ const renderNumberFormat = (data, onChange, setFormatOption, scopedCustomFormatt
|
|
|
279
292
|
React.createElement(Input, { "data-name": "multiplier", type: "number", value: data.DisplayFormat.Options.Multiplier, onChange: (e) => setFormatOption('Multiplier', Number(e.currentTarget.value)) })),
|
|
280
293
|
' ',
|
|
281
294
|
React.createElement(FormRow, { label: "Content" },
|
|
282
|
-
React.createElement(Input, { "data-name": "content", value: (
|
|
295
|
+
React.createElement(Input, { "data-name": "content", value: (_e = data.DisplayFormat.Options.Content) !== null && _e !== void 0 ? _e : '', onChange: (e) => setFormatOption('Content', e.currentTarget.value) })),
|
|
283
296
|
' ',
|
|
284
297
|
React.createElement(FormRow, { label: "Parentheses" },
|
|
285
298
|
React.createElement(CheckBox, { "data-name": "parentheses-checkbox", checked: data.DisplayFormat.Options.Parentheses, onChange: (checked) => setFormatOption('Parentheses', checked) })),
|
|
@@ -7,11 +7,6 @@ import { useOnePageAdaptableWizardContext } from '../../Wizard/OnePageAdaptableW
|
|
|
7
7
|
import { Tag } from '../../../components/Tag';
|
|
8
8
|
import { ToggleGroup } from '../../../components/Toggle/ToggleGroup';
|
|
9
9
|
import { Toggle } from '../../../components/Toggle/Toggle';
|
|
10
|
-
let alignmentOptions = [
|
|
11
|
-
{ value: 'Left', label: 'Left' },
|
|
12
|
-
{ value: 'Right', label: 'Right' },
|
|
13
|
-
{ value: 'Center', label: 'Center' },
|
|
14
|
-
];
|
|
15
10
|
export const renderFormatColumnSettingsSummary = (data) => {
|
|
16
11
|
var _a;
|
|
17
12
|
return (React.createElement(Box, { padding: 2 },
|
|
@@ -2,9 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import { DataSource, InfiniteTable } from '../../components/InfiniteTable';
|
|
4
4
|
import { GetAllNotesSelector } from '../../Redux/ActionsReducers/NoteRedux';
|
|
5
|
+
import dateFnsFormat from 'date-fns/format';
|
|
5
6
|
import { useAdaptable } from '../AdaptableContext';
|
|
6
7
|
import { AdaptableButtonComponent } from '../Components/AdaptableButton';
|
|
7
8
|
import { PopupPanel } from '../Components/Popups/AdaptablePopup/PopupPanel';
|
|
9
|
+
import { DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME } from '../../Utilities/Constants/GeneralConstants';
|
|
8
10
|
const tableDOMProps = {
|
|
9
11
|
style: {
|
|
10
12
|
height: '100%',
|
|
@@ -13,8 +15,10 @@ const tableDOMProps = {
|
|
|
13
15
|
},
|
|
14
16
|
};
|
|
15
17
|
export const NotePopup = (props) => {
|
|
18
|
+
var _a;
|
|
16
19
|
const adaptable = useAdaptable();
|
|
17
20
|
const primaryKeyHeader = adaptable.api.columnApi.getFriendlyNameForColumnId(adaptable.api.columnApi.getPrimaryKeyColumn().columnId);
|
|
21
|
+
const dateFormat = (_a = adaptable.api.optionsApi.getNoteOptions().dateFormat) !== null && _a !== void 0 ? _a : DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME;
|
|
18
22
|
const allNotes = useSelector((state) => GetAllNotesSelector(state.Note));
|
|
19
23
|
const isReadOnlyModule = adaptable.api.entitlementApi.getEntitlementAccessLevelForModule('Note') === 'ReadOnly';
|
|
20
24
|
const columnsMap = React.useMemo(() => {
|
|
@@ -39,8 +43,7 @@ export const NotePopup = (props) => {
|
|
|
39
43
|
timestamp: {
|
|
40
44
|
field: 'Timestamp',
|
|
41
45
|
valueGetter: (params) => {
|
|
42
|
-
|
|
43
|
-
return (_a = new Date(params.data.Timestamp)) === null || _a === void 0 ? void 0 : _a.toDateString();
|
|
46
|
+
return dateFnsFormat(params.data.Timestamp, dateFormat);
|
|
44
47
|
},
|
|
45
48
|
},
|
|
46
49
|
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;
|
|
@@ -96,6 +96,7 @@ import { ensurePortalElement } from '../components/Modal';
|
|
|
96
96
|
import { AdaptableLoadingScreen } from '../View/Components/Popups/AdaptableLoadingScreen';
|
|
97
97
|
import { createElement } from 'react';
|
|
98
98
|
import { removeUuidAndSource } from '../Utilities/Helpers/AdaptableHelper';
|
|
99
|
+
import { buildSortedColumnStateForLayout } from './buildSortedColumnStateForLayout';
|
|
99
100
|
const RowNodeProto = RowNode.prototype;
|
|
100
101
|
const RowNode_dispatchLocalEvent = RowNodeProto.dispatchLocalEvent;
|
|
101
102
|
/**
|
|
@@ -143,7 +144,7 @@ export class AdaptableAgGrid {
|
|
|
143
144
|
* once layouts are properly handled with the new aggrid methods & events
|
|
144
145
|
* we can remove this hack
|
|
145
146
|
*/
|
|
146
|
-
this.
|
|
147
|
+
this.previousAgGridLayoutState = '';
|
|
147
148
|
this.columnMinMaxValuesCache = {};
|
|
148
149
|
this.renderReactRoot = (node, container) => defaultRenderReactRoot(node, container);
|
|
149
150
|
/**
|
|
@@ -2203,53 +2204,20 @@ export class AdaptableAgGrid {
|
|
|
2203
2204
|
});
|
|
2204
2205
|
this.deriveAdaptableColumnStateFromAgGrid();
|
|
2205
2206
|
}
|
|
2206
|
-
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState,
|
|
2207
|
+
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState, layout) {
|
|
2208
|
+
layout = layout || this.api.layoutApi.getCurrentLayout();
|
|
2209
|
+
visibleColumnList = visibleColumnList || layout.Columns;
|
|
2207
2210
|
columnState = columnState || this.agGridAdapter.getAgGridApi().getColumnState();
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
acc[colId] = index;
|
|
2219
|
-
return acc;
|
|
2220
|
-
}, {});
|
|
2221
|
-
const result = [...columnState]
|
|
2222
|
-
.sort((colState1, colState2) => {
|
|
2223
|
-
const colId1 = colState1.colId;
|
|
2224
|
-
const colId2 = colState2.colId;
|
|
2225
|
-
const originalIndex1 = columnsStateIndexes[colId1];
|
|
2226
|
-
const originalIndex2 = columnsStateIndexes[colId2];
|
|
2227
|
-
if (pivotMode) {
|
|
2228
|
-
const isRowGroup1 = this.api.columnApi.isAutoRowGroupColumn(colId1);
|
|
2229
|
-
const isRowGroup2 = this.api.columnApi.isAutoRowGroupColumn(colId2);
|
|
2230
|
-
if (isRowGroup1 && isRowGroup2) {
|
|
2231
|
-
return 1;
|
|
2232
|
-
}
|
|
2233
|
-
if (isRowGroup1) {
|
|
2234
|
-
return -1;
|
|
2235
|
-
}
|
|
2236
|
-
if (isRowGroup2) {
|
|
2237
|
-
return 1;
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
if (newVisibleColumnsMap[colId1] != null && newVisibleColumnsMap[colId2] == null) {
|
|
2241
|
-
return -1;
|
|
2242
|
-
}
|
|
2243
|
-
if (newVisibleColumnsMap[colId1] == null && newVisibleColumnsMap[colId2] != null) {
|
|
2244
|
-
return 1;
|
|
2245
|
-
}
|
|
2246
|
-
if (newVisibleColumnsMap[colId1] == null && newVisibleColumnsMap[colId2] == null) {
|
|
2247
|
-
return originalIndex1 - originalIndex2;
|
|
2248
|
-
}
|
|
2249
|
-
return newVisibleColumnsMap[colState1.colId] - newVisibleColumnsMap[colState2.colId];
|
|
2250
|
-
})
|
|
2251
|
-
.map((colState) => (Object.assign(Object.assign({}, colState), { hide: NewVisibleColumnIdsMap[colState.colId] == null })));
|
|
2252
|
-
return result;
|
|
2211
|
+
return buildSortedColumnStateForLayout({
|
|
2212
|
+
columnState: columnState.map((colState) => {
|
|
2213
|
+
return {
|
|
2214
|
+
colId: colState.colId,
|
|
2215
|
+
hide: colState.hide,
|
|
2216
|
+
};
|
|
2217
|
+
}),
|
|
2218
|
+
layout: Object.assign(Object.assign({}, layout), { Columns: visibleColumnList }),
|
|
2219
|
+
gridOptions: this.agGridAdapter.getLiveGridOptions(),
|
|
2220
|
+
});
|
|
2253
2221
|
}
|
|
2254
2222
|
getDistinctValuesForColumn(column, distinctValuesParams) {
|
|
2255
2223
|
let gridCells = this.getGridCellsForPermittedValues(column, distinctValuesParams);
|
|
@@ -2957,7 +2925,7 @@ export class AdaptableAgGrid {
|
|
|
2957
2925
|
else {
|
|
2958
2926
|
(_b = this.agGridAdapter.getAgGridApi()) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
2959
2927
|
}
|
|
2960
|
-
this.
|
|
2928
|
+
this.previousAgGridLayoutState = '';
|
|
2961
2929
|
const gridContainerElement = this.getAgGridContainerElement();
|
|
2962
2930
|
if (gridContainerElement) {
|
|
2963
2931
|
gridContainerElement.removeEventListener('keydown', this.agGridListenerKeydown);
|
|
@@ -3190,10 +3158,6 @@ export class AdaptableAgGrid {
|
|
|
3190
3158
|
layout.PinnedColumnsMap = layout.PinnedColumnsMap || {};
|
|
3191
3159
|
layout.PinnedColumnsMap[actionRowColumn.colId] = actionRowColumn.pinned;
|
|
3192
3160
|
}
|
|
3193
|
-
const layoutColumnsMap = layout.Columns.reduce((acc, colId) => {
|
|
3194
|
-
acc[colId] = true;
|
|
3195
|
-
return acc;
|
|
3196
|
-
}, {});
|
|
3197
3161
|
const columnsState = this.agGridAdapter.getAgGridApi().getColumnState();
|
|
3198
3162
|
const columnsStateIndexes = {};
|
|
3199
3163
|
const columnsStateMap = columnsState.reduce((acc, colState, index) => {
|
|
@@ -3225,20 +3189,19 @@ export class AdaptableAgGrid {
|
|
|
3225
3189
|
.getPivotResultColumns()) === null || _b === void 0 ? void 0 : _b.map((column) => column.getColId())) || [];
|
|
3226
3190
|
let isChanged = false;
|
|
3227
3191
|
const colsToAutoSize = {};
|
|
3228
|
-
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState,
|
|
3192
|
+
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState, layout);
|
|
3229
3193
|
newColumnsState = newColumnsState
|
|
3230
3194
|
.map((colState) => {
|
|
3231
3195
|
var _a, _b, _c;
|
|
3232
3196
|
const { colId } = colState;
|
|
3233
3197
|
const oldColState = columnsStateMap[colId];
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
const newColState = Object.assign(Object.assign({}, oldColState), { hide });
|
|
3198
|
+
// it's important to have width here, so it's not inherited from the existing colState
|
|
3199
|
+
// which could be from a different layout
|
|
3200
|
+
const newColState = Object.assign(Object.assign(Object.assign({}, oldColState), { width: null }), colState);
|
|
3238
3201
|
if (layout.ColumnWidthMap && layout.ColumnWidthMap[colId] != null) {
|
|
3239
3202
|
newColState.width = layout.ColumnWidthMap[colId];
|
|
3240
3203
|
}
|
|
3241
|
-
else if (!hide) {
|
|
3204
|
+
else if (!colState.hide) {
|
|
3242
3205
|
// autosize only the columns which are part of the selected layout
|
|
3243
3206
|
colsToAutoSize[colId] = true;
|
|
3244
3207
|
}
|
|
@@ -3247,11 +3210,7 @@ export class AdaptableAgGrid {
|
|
|
3247
3210
|
}
|
|
3248
3211
|
newColState.rowGroupIndex =
|
|
3249
3212
|
groupedColumnsIndexesMap[colId] != null ? groupedColumnsIndexesMap[colId] : null;
|
|
3250
|
-
const previousRowGroup = newColState.rowGroup;
|
|
3251
3213
|
newColState.rowGroup = newColState.rowGroupIndex != null;
|
|
3252
|
-
if (!previousRowGroup && newColState.rowGroup) {
|
|
3253
|
-
this.agGridColumnAdapter.triggerSetupColumnKeyCreator(colId);
|
|
3254
|
-
}
|
|
3255
3214
|
const normalizePinned = (pinnedValue) => {
|
|
3256
3215
|
if (typeof pinnedValue === 'string') {
|
|
3257
3216
|
return pinnedValue;
|
|
@@ -3356,14 +3315,13 @@ export class AdaptableAgGrid {
|
|
|
3356
3315
|
// as otherwise column order is not preserved properly when
|
|
3357
3316
|
// going from pivoted to unpivoted layout
|
|
3358
3317
|
if (shouldUpdatePivoted) {
|
|
3359
|
-
this.agGridAdapter.
|
|
3318
|
+
this.agGridAdapter.setGridOption('pivotMode', pivoted);
|
|
3360
3319
|
}
|
|
3361
3320
|
const perfApplyColumnState = this.logger.beginPerf('applyColumnState (layout.isChanged)');
|
|
3362
3321
|
this.agGridAdapter.getAgGridApi().applyColumnState({
|
|
3363
3322
|
state: newColumnsState,
|
|
3364
3323
|
applyOrder: true,
|
|
3365
3324
|
});
|
|
3366
|
-
this.applyGroupColumnWidth(layout);
|
|
3367
3325
|
perfApplyColumnState.end();
|
|
3368
3326
|
this.api.gridApi.setColumnSorts(layout.ColumnSorts);
|
|
3369
3327
|
this.agGridAdapter.getAgGridApi().setPivotColumns(layout.PivotColumns || []);
|
|
@@ -3420,38 +3378,6 @@ export class AdaptableAgGrid {
|
|
|
3420
3378
|
}
|
|
3421
3379
|
return null;
|
|
3422
3380
|
}
|
|
3423
|
-
/**
|
|
3424
|
-
* Setting layout works by modifing the column state.
|
|
3425
|
-
* The column state is based on the current existing columns.
|
|
3426
|
-
* At this point the column groups do not exist, and the widths from layout are not applied.
|
|
3427
|
-
*
|
|
3428
|
-
* After the col sate is applied and the column groups are created we need
|
|
3429
|
-
* to apply the state again to update the widths of the group columns.
|
|
3430
|
-
*/
|
|
3431
|
-
applyGroupColumnWidth(layout) {
|
|
3432
|
-
if (!layout.RowGroupedColumns || !layout.RowGroupedColumns.length) {
|
|
3433
|
-
return;
|
|
3434
|
-
}
|
|
3435
|
-
const groupColumnWithDifferentWidths = this.agGridAdapter
|
|
3436
|
-
.getAgGridApi()
|
|
3437
|
-
.getColumnState()
|
|
3438
|
-
.reduce((acc, col) => {
|
|
3439
|
-
var _a;
|
|
3440
|
-
if (this.api.columnApi.isAutoRowGroupColumn(col.colId)) {
|
|
3441
|
-
const widthInLayout = (_a = layout.ColumnWidthMap) === null || _a === void 0 ? void 0 : _a[col.colId];
|
|
3442
|
-
if (widthInLayout && widthInLayout !== col.width) {
|
|
3443
|
-
acc.push(Object.assign(Object.assign({}, col), { width: widthInLayout }));
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
return acc;
|
|
3447
|
-
}, []);
|
|
3448
|
-
if (groupColumnWithDifferentWidths.length === 0) {
|
|
3449
|
-
return;
|
|
3450
|
-
}
|
|
3451
|
-
this.agGridAdapter.getAgGridApi().applyColumnState({
|
|
3452
|
-
state: groupColumnWithDifferentWidths,
|
|
3453
|
-
});
|
|
3454
|
-
}
|
|
3455
3381
|
onRowDataChanged({ rowNode, oldData, newData, }) {
|
|
3456
3382
|
if (oldData == null || oldData == undefined) {
|
|
3457
3383
|
return;
|
|
@@ -3748,15 +3674,18 @@ export class AdaptableAgGrid {
|
|
|
3748
3674
|
var _a, _b;
|
|
3749
3675
|
const agGridApi = this.agGridAdapter.getAgGridApi();
|
|
3750
3676
|
const columnState = agGridApi.getColumnState();
|
|
3677
|
+
const expandedState = agGridApi.getState().rowGroupExpansion || { expandedRowGroupIds: [] };
|
|
3678
|
+
const currentLayoutState = { columnState, expandedState };
|
|
3751
3679
|
try {
|
|
3752
|
-
|
|
3753
|
-
|
|
3680
|
+
// TODO
|
|
3681
|
+
const stringifiedLayoutState = JSON.stringify(currentLayoutState);
|
|
3682
|
+
if (stringifiedLayoutState === this.previousAgGridLayoutState) {
|
|
3754
3683
|
// same grid column state as a previous,
|
|
3755
3684
|
// so no need to update, as the layout has already been updated
|
|
3756
3685
|
// for this grid column state
|
|
3757
3686
|
return;
|
|
3758
3687
|
}
|
|
3759
|
-
this.
|
|
3688
|
+
this.previousAgGridLayoutState = stringifiedLayoutState;
|
|
3760
3689
|
}
|
|
3761
3690
|
catch (ex) {
|
|
3762
3691
|
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;
|
|
@@ -60,6 +60,10 @@ export class AgGridAdapter {
|
|
|
60
60
|
var _a;
|
|
61
61
|
(_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.updateGridOptions(options);
|
|
62
62
|
}
|
|
63
|
+
getGridOption(key) {
|
|
64
|
+
var _a;
|
|
65
|
+
return (_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.getGridOption(key);
|
|
66
|
+
}
|
|
63
67
|
setGridOption(key, value) {
|
|
64
68
|
var _a;
|
|
65
69
|
(_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;
|
|
@@ -102,24 +102,11 @@ export class AgGridColumnAdapter {
|
|
|
102
102
|
this.setupColumnHeader(colSetupInfo);
|
|
103
103
|
this.setupColumnQuickFilerText(colSetupInfo);
|
|
104
104
|
this.setupColumnAllowedAggFuncs(colSetupInfo);
|
|
105
|
-
this.setupColumnKeyCreator(colSetupInfo);
|
|
106
105
|
// this is just to make sure that AG Grid does NOT infer the cellDataType
|
|
107
106
|
// https://github.com/AdaptableTools/adaptable/issues/2230 should render it obsolete
|
|
108
107
|
this.setupColumnCellDataType(colSetupInfo);
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
|
-
triggerSetupColumnKeyCreator(colId) {
|
|
112
|
-
const col = this.agGridApi.getColumn(colId);
|
|
113
|
-
const colDef = col.getColDef();
|
|
114
|
-
const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
|
|
115
|
-
const colSetupInfo = {
|
|
116
|
-
col,
|
|
117
|
-
colDef,
|
|
118
|
-
colId,
|
|
119
|
-
abColumn,
|
|
120
|
-
};
|
|
121
|
-
this.setupColumnKeyCreator(colSetupInfo);
|
|
122
|
-
}
|
|
123
110
|
setupColumnValueGetter({ col }) {
|
|
124
111
|
// need this here if we want plugins to intercept
|
|
125
112
|
this.setColDefProperty(col, 'valueGetter', (userValue) => {
|
|
@@ -287,36 +274,6 @@ export class AgGridColumnAdapter {
|
|
|
287
274
|
return abColumn.availableAggregationFunctions;
|
|
288
275
|
});
|
|
289
276
|
}
|
|
290
|
-
setupColumnKeyCreator(columnSetupInfo) {
|
|
291
|
-
const { col, abColumn } = columnSetupInfo;
|
|
292
|
-
const adaptableOptions = this.adaptableOptions;
|
|
293
|
-
this.setColDefProperty(col, 'keyCreator', (userPropertyValue) => {
|
|
294
|
-
return (params) => {
|
|
295
|
-
var _a;
|
|
296
|
-
if (typeof userPropertyValue === 'function') {
|
|
297
|
-
return userPropertyValue(params);
|
|
298
|
-
}
|
|
299
|
-
const value = params.value;
|
|
300
|
-
if (this.adaptableInstance.agGridAdapter.getLiveGridOptions().groupAllowUnbalanced) {
|
|
301
|
-
return value;
|
|
302
|
-
}
|
|
303
|
-
const balancedGroupsKey = (_a = adaptableOptions.groupingOptions) === null || _a === void 0 ? void 0 : _a.balancedGroupsKey;
|
|
304
|
-
if (!balancedGroupsKey) {
|
|
305
|
-
return value;
|
|
306
|
-
}
|
|
307
|
-
let groupBalancedGroupsUnderKeyValue = typeof balancedGroupsKey === 'function'
|
|
308
|
-
? balancedGroupsKey({
|
|
309
|
-
adaptableApi: this.adaptableApi,
|
|
310
|
-
userName: this.adaptableOptions.userName,
|
|
311
|
-
adaptableId: this.adaptableOptions.adaptableId,
|
|
312
|
-
adaptableColumn: abColumn,
|
|
313
|
-
params,
|
|
314
|
-
})
|
|
315
|
-
: balancedGroupsKey;
|
|
316
|
-
return value === null || value === undefined ? groupBalancedGroupsUnderKeyValue : value;
|
|
317
|
-
};
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
277
|
setupColumnCellDataType(columnSetupInfo) {
|
|
321
278
|
const { col } = columnSetupInfo;
|
|
322
279
|
// 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,120 @@
|
|
|
1
|
+
import { AG_GRID_GROUPED_COLUMN } from '../Utilities/Constants/GeneralConstants';
|
|
2
|
+
import { getAutoRowGroupColumnIdFor } from '../Api/Internal/ColumnInternalApi';
|
|
3
|
+
import { isAutoRowGroupColumn } from '../Api/Implementation/ColumnApiImpl';
|
|
4
|
+
import { sortColumnStateForVisibleColumns } from './sortColumnStateForVisibleColumns';
|
|
5
|
+
export function buildSortedColumnStateForLayout(params) {
|
|
6
|
+
const { columnState, layout, gridOptions } = params;
|
|
7
|
+
let visibleColumnList = [...layout.Columns];
|
|
8
|
+
const multipleGroupColumns = gridOptions.groupDisplayType === 'multipleColumns';
|
|
9
|
+
const singleGroupColumn = !multipleGroupColumns;
|
|
10
|
+
const rowGroupedColumnsIndexes = {};
|
|
11
|
+
let generatedRowGroupColumnsIds = [];
|
|
12
|
+
// here we make sure the visibleColumnList includes all the generated group columns
|
|
13
|
+
if (layout.RowGroupedColumns) {
|
|
14
|
+
layout.RowGroupedColumns.forEach((colId, index) => {
|
|
15
|
+
rowGroupedColumnsIndexes[colId] = index;
|
|
16
|
+
rowGroupedColumnsIndexes[getAutoRowGroupColumnIdFor(colId)] = index;
|
|
17
|
+
});
|
|
18
|
+
// if the layout does not include the grouped columns,
|
|
19
|
+
// make sure we add the grouped columns to the visible column list
|
|
20
|
+
// at the start of the list
|
|
21
|
+
if (singleGroupColumn) {
|
|
22
|
+
if (!visibleColumnList.includes(AG_GRID_GROUPED_COLUMN)) {
|
|
23
|
+
visibleColumnList = [AG_GRID_GROUPED_COLUMN, ...visibleColumnList];
|
|
24
|
+
}
|
|
25
|
+
generatedRowGroupColumnsIds.push(AG_GRID_GROUPED_COLUMN);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
let missingGroupColumns = 0;
|
|
29
|
+
[...layout.RowGroupedColumns].reverse().forEach((colId) => {
|
|
30
|
+
const groupColId = getAutoRowGroupColumnIdFor(colId);
|
|
31
|
+
if (!visibleColumnList.includes(groupColId)) {
|
|
32
|
+
visibleColumnList = [groupColId, ...visibleColumnList];
|
|
33
|
+
missingGroupColumns++;
|
|
34
|
+
}
|
|
35
|
+
generatedRowGroupColumnsIds = [groupColId, ...generatedRowGroupColumnsIds];
|
|
36
|
+
});
|
|
37
|
+
// now we need to sort the visibleColumnList to contain the group columns
|
|
38
|
+
// in the correct order
|
|
39
|
+
// but we only need to do this if the layout.Columns list missed some of the
|
|
40
|
+
// group columns, but not all of them. if all were missing, we already
|
|
41
|
+
// inserted them at the start of the list
|
|
42
|
+
if (missingGroupColumns && missingGroupColumns < layout.RowGroupedColumns.length) {
|
|
43
|
+
visibleColumnList.sort((colId1, colId2) => {
|
|
44
|
+
const isRowGroup1 = isAutoRowGroupColumn(colId1);
|
|
45
|
+
const isRowGroup2 = isAutoRowGroupColumn(colId2);
|
|
46
|
+
if (isRowGroup1 && isRowGroup2) {
|
|
47
|
+
return rowGroupedColumnsIndexes[colId1] - rowGroupedColumnsIndexes[colId2];
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const visibleColumnsIndexes = visibleColumnList.reduce((acc, colId, index) => {
|
|
55
|
+
acc[colId] = index;
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
const pivotMode = layout.EnablePivot;
|
|
59
|
+
if (pivotMode) {
|
|
60
|
+
// in pivot mode, we sort the Visible columns of the layout
|
|
61
|
+
// to make sure the group cols are at the beginning
|
|
62
|
+
const groupCols = visibleColumnList.filter(isAutoRowGroupColumn);
|
|
63
|
+
visibleColumnList = visibleColumnList.filter((colId) => !isAutoRowGroupColumn(colId));
|
|
64
|
+
visibleColumnList = [...groupCols, ...visibleColumnList];
|
|
65
|
+
}
|
|
66
|
+
// we're now ready to go over the columnState
|
|
67
|
+
// we want as much as possible to keep the order of the columns
|
|
68
|
+
// as they are in the column state.
|
|
69
|
+
// if the order is different in the visibleColumns, we only move those columns around
|
|
70
|
+
// if some columns in the columnState are not in the visibleColumns, we need to return them as hide: true
|
|
71
|
+
// first step - keep the same order, but filter out old group columns
|
|
72
|
+
// VERY IMPORTANT to only filter out OLD group columns, that is,
|
|
73
|
+
// group columns that are not in the layout anymore
|
|
74
|
+
// since we might have different group columns in the layout
|
|
75
|
+
let newColumnState = [...columnState].filter((colState) => {
|
|
76
|
+
const { colId } = colState;
|
|
77
|
+
if (isAutoRowGroupColumn(colId) && rowGroupedColumnsIndexes[colId] == null) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
// second step - keep the same order
|
|
83
|
+
// but make sure the visibility is adjusted to reflect the
|
|
84
|
+
// visible columns in the layout
|
|
85
|
+
newColumnState = newColumnState.map((colState) => {
|
|
86
|
+
const { colId } = colState;
|
|
87
|
+
const visibleIndex = visibleColumnsIndexes[colId];
|
|
88
|
+
if (visibleIndex == null) {
|
|
89
|
+
return Object.assign(Object.assign({}, colState), { hide: true });
|
|
90
|
+
}
|
|
91
|
+
return Object.assign(Object.assign({}, colState), { hide: null });
|
|
92
|
+
});
|
|
93
|
+
// third step - correctly mark the columns that are grouped
|
|
94
|
+
newColumnState = newColumnState.map((colState) => {
|
|
95
|
+
const { colId } = colState;
|
|
96
|
+
const groupIndex = rowGroupedColumnsIndexes[colId];
|
|
97
|
+
if (groupIndex != null) {
|
|
98
|
+
return Object.assign(Object.assign({}, colState), { rowGroup: true, rowGroupIndex: groupIndex });
|
|
99
|
+
}
|
|
100
|
+
return Object.assign(Object.assign({}, colState), { rowGroup: false, rowGroupIndex: null });
|
|
101
|
+
});
|
|
102
|
+
// fourth step - add the new group columns, if they are missing
|
|
103
|
+
const columnStateIndexes = newColumnState.reduce((acc, colState, index) => {
|
|
104
|
+
acc[colState.colId] = index;
|
|
105
|
+
return acc;
|
|
106
|
+
}, {});
|
|
107
|
+
generatedRowGroupColumnsIds.reverse().forEach((rowGroupColId) => {
|
|
108
|
+
if (columnStateIndexes[rowGroupColId] == null) {
|
|
109
|
+
newColumnState = [
|
|
110
|
+
{
|
|
111
|
+
colId: rowGroupColId,
|
|
112
|
+
},
|
|
113
|
+
...newColumnState,
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
// fitfth step - sort the column state to respect the order of the visible columns
|
|
118
|
+
// we can't simply call sort in this case
|
|
119
|
+
return sortColumnStateForVisibleColumns(newColumnState, visibleColumnList);
|
|
120
|
+
}
|
|
@@ -143,7 +143,6 @@ const DefaultAdaptableOptions = {
|
|
|
143
143
|
customSortOptions: { customSortComparers: undefined },
|
|
144
144
|
dataSetOptions: { dataSets: EMPTY_ARRAY },
|
|
145
145
|
groupingOptions: {
|
|
146
|
-
balancedGroupsKey: undefined,
|
|
147
146
|
restoreUngroupedColumns: false,
|
|
148
147
|
autoOrderGroupedColumns: true,
|
|
149
148
|
},
|
|
@@ -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 {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset = 0, lastVisibleOffset = 0) {
|
|
2
|
+
const prevColState = result[result.length - 1 - offset];
|
|
3
|
+
if (!prevColState) {
|
|
4
|
+
result.splice(result.length - lastVisibleOffset, 0, colState);
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (prevColState.hide) {
|
|
8
|
+
insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset + 1,
|
|
9
|
+
/* do not advance this as, as we've encountered a hidden column*/ lastVisibleOffset);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const prevCol_visibilityIndex = visibleColumnsIndexes[prevColState.colId];
|
|
13
|
+
const currentCol_visibilityIndex = visibleColumnsIndexes[colState.colId];
|
|
14
|
+
if (currentCol_visibilityIndex < prevCol_visibilityIndex) {
|
|
15
|
+
insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset + 1,
|
|
16
|
+
/*make sure we sync with the normal offset, as we've hit a visible col*/ offset + 1);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
result.splice(result.length - lastVisibleOffset, 0, colState);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This method takes a column state and the list of visible columns
|
|
24
|
+
* and returns a new column state that respects the order of the visible columns
|
|
25
|
+
* while trying to keep the hidden columns in their original order.
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export function sortColumnStateForVisibleColumns(columnState, visibleColumns) {
|
|
29
|
+
const visibleColumnsIndexes = visibleColumns.reduce((acc, colId, index) => {
|
|
30
|
+
acc[colId] = index;
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
const result = [];
|
|
34
|
+
for (let i = 0, len = columnState.length; i < len; i++) {
|
|
35
|
+
const colState = columnState[i];
|
|
36
|
+
const colVisible = visibleColumnsIndexes[colState.colId] != null;
|
|
37
|
+
if (!colVisible) {
|
|
38
|
+
// for cols not present in this layout, we keep them
|
|
39
|
+
// where they are
|
|
40
|
+
result.push(colState);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
insertAtCorrectIndex(result, colState, visibleColumnsIndexes);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
package/src/env.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
|
|
3
|
-
PUBLISH_TIMESTAMP:
|
|
4
|
-
VERSION: "18.0.0-canary.
|
|
3
|
+
PUBLISH_TIMESTAMP: 1712304058670 || Date.now(),
|
|
4
|
+
VERSION: "18.0.0-canary.23" || '--current-version--',
|
|
5
5
|
};
|