@adaptabletools/adaptable-cjs 18.0.0-canary.20 → 18.0.0-canary.22
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/package.json +1 -1
- package/src/AdaptableInterfaces/IAdaptable.d.ts +2 -1
- package/src/AdaptableOptions/AdaptableOptions.d.ts +0 -6
- package/src/AdaptableOptions/CommentOptions.d.ts +7 -1
- package/src/AdaptableOptions/GroupingOptions.d.ts +0 -4
- package/src/AdaptableOptions/NoteOptions.d.ts +8 -2
- package/src/AdaptableOptions/StateOptions.d.ts +6 -0
- package/src/Api/ColumnApi.d.ts +5 -0
- package/src/Api/CommentApi.d.ts +2 -2
- package/src/Api/Implementation/ColumnApiImpl.d.ts +3 -0
- package/src/Api/Implementation/ColumnApiImpl.js +22 -7
- package/src/Api/Implementation/ConfigApiImpl.js +3 -0
- package/src/Api/Implementation/GridApiImpl.js +3 -1
- package/src/Api/Implementation/ScopeApiImpl.js +34 -1
- package/src/Api/Internal/ActionRowInternalApi.d.ts +1 -0
- package/src/Api/Internal/ActionRowInternalApi.js +12 -1
- package/src/Api/Internal/ColumnInternalApi.d.ts +2 -0
- package/src/Api/Internal/ColumnInternalApi.js +8 -1
- package/src/PredefinedConfig/Common/TransposeConfig.d.ts +5 -0
- package/src/Strategy/LayoutModule.js +6 -0
- package/src/Utilities/Constants/GeneralConstants.d.ts +1 -0
- package/src/Utilities/Constants/GeneralConstants.js +3 -2
- package/src/View/Comments/CommentsPopup.js +5 -2
- package/src/View/Components/CellPopup/index.js +1 -1
- package/src/View/Components/FilterForm/QuickFilterValues.js +39 -23
- 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/Layout/TransposedPopup.js +2 -2
- package/src/View/Note/NotePopup.js +5 -2
- package/src/agGrid/AdaptableAgGrid.d.ts +2 -0
- package/src/agGrid/AdaptableAgGrid.js +29 -66
- 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 +1 -2
- 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 +29 -23
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -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 },
|
|
@@ -11,7 +11,7 @@ const ColumnSelector_1 = require("../Components/Selectors/ColumnSelector");
|
|
|
11
11
|
const AdaptableAgGrid_1 = require("../../agGrid/AdaptableAgGrid");
|
|
12
12
|
const TransposedPopup = (props) => {
|
|
13
13
|
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
14
|
-
const { transposedColumnId, hideTransposedColumn, visibleColumns, visibleRows } = props.popupProps;
|
|
14
|
+
const { transposedColumnId, hideTransposedColumn, visibleColumns, visibleRows, autosize } = props.popupProps;
|
|
15
15
|
const rowNodes = React.useMemo(() => {
|
|
16
16
|
return props.popupProps.visibleRows
|
|
17
17
|
? adaptable.api.gridApi.getVisibleRowNodes()
|
|
@@ -100,7 +100,7 @@ const TransposedPopup = (props) => {
|
|
|
100
100
|
},
|
|
101
101
|
layoutOptions: {
|
|
102
102
|
createDefaultLayout: false,
|
|
103
|
-
autoSizeColumnsInLayout:
|
|
103
|
+
autoSizeColumnsInLayout: autosize,
|
|
104
104
|
},
|
|
105
105
|
predefinedConfig: {
|
|
106
106
|
Layout: {
|
|
@@ -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: {
|
|
@@ -7,6 +7,7 @@ import { EmitterCallback } from '../Utilities/Emitter';
|
|
|
7
7
|
import { AdaptablePlugin } from '../AdaptableOptions/AdaptablePlugin';
|
|
8
8
|
import { AgGridAdapter } from './AgGridAdapter';
|
|
9
9
|
import { IDataService } from '../Utilities/Services/Interface/IDataService';
|
|
10
|
+
import { AdaptableState } from '../PredefinedConfig/AdaptableState';
|
|
10
11
|
import { IAdaptableStore } from '../Redux/Store/Interface/IAdaptableStore';
|
|
11
12
|
import { ICalculatedColumnExpressionService } from '../Utilities/Services/Interface/ICalculatedColumnExpressionService';
|
|
12
13
|
import { IEntitlementService } from '../Utilities/Services/Interface/IEntitlementService';
|
|
@@ -134,6 +135,7 @@ export declare class AdaptableAgGrid implements IAdaptable {
|
|
|
134
135
|
*/
|
|
135
136
|
static _initInternal(config: AdaptableInitInternalConfig): Promise<AdaptableApi>;
|
|
136
137
|
private _initAdaptableAgGrid;
|
|
138
|
+
normalizeAdaptableState(state: AdaptableState, gridOptions: GridOptions): AdaptableState;
|
|
137
139
|
private normaliseLayoutState;
|
|
138
140
|
private normaliseToolPanelState;
|
|
139
141
|
refreshQuickFilter(): void;
|
|
@@ -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
|
/**
|
|
@@ -309,15 +310,14 @@ class AdaptableAgGrid {
|
|
|
309
310
|
* e.g. adding default Layout, migrating deprecated state, etc.
|
|
310
311
|
*/
|
|
311
312
|
postLoadHook: (state) => {
|
|
312
|
-
if (this.adaptableOptions.autoMigrateState) {
|
|
313
|
+
if (this.adaptableOptions.stateOptions.autoMigrateState) {
|
|
313
314
|
state = AdaptableUpgradeHelper_1.AdaptableUpgradeHelper.migrateAdaptableState(state, {
|
|
314
315
|
// version 16 actually includes all versions up until 16
|
|
315
316
|
fromVersion: 16,
|
|
316
317
|
logger: this.logger,
|
|
317
318
|
});
|
|
318
319
|
}
|
|
319
|
-
state = this.
|
|
320
|
-
state = this.normaliseToolPanelState(state);
|
|
320
|
+
state = this.normalizeAdaptableState(state, config.gridOptions);
|
|
321
321
|
return state;
|
|
322
322
|
},
|
|
323
323
|
});
|
|
@@ -392,10 +392,15 @@ class AdaptableAgGrid {
|
|
|
392
392
|
perfInitAdaptableAgGrid.end();
|
|
393
393
|
return Promise.resolve(this.api);
|
|
394
394
|
}
|
|
395
|
-
|
|
395
|
+
normalizeAdaptableState(state, gridOptions) {
|
|
396
|
+
state = this.normaliseLayoutState(state, gridOptions);
|
|
397
|
+
state = this.normaliseToolPanelState(state);
|
|
398
|
+
return state;
|
|
399
|
+
}
|
|
400
|
+
normaliseLayoutState(state, gridOptions) {
|
|
396
401
|
var _a, _b, _c, _d, _e, _f;
|
|
397
402
|
if (this.shouldCreateDefaultLayout(state, this.adaptableOptions)) {
|
|
398
|
-
const defaultLayout = this.createDefaultLayout(state,
|
|
403
|
+
const defaultLayout = this.createDefaultLayout(state, gridOptions.columnDefs);
|
|
399
404
|
const layoutState = state.Layout || {};
|
|
400
405
|
const availableLayouts = layoutState.Layouts || [];
|
|
401
406
|
availableLayouts.push(defaultLayout);
|
|
@@ -431,7 +436,7 @@ class AdaptableAgGrid {
|
|
|
431
436
|
* logic where layout is applied, it is easier and
|
|
432
437
|
* less error prone to just remove it.
|
|
433
438
|
*/
|
|
434
|
-
if (
|
|
439
|
+
if (gridOptions.rowModelType === 'viewport') {
|
|
435
440
|
(_f = state.Layout.Layouts) === null || _f === void 0 ? void 0 : _f.forEach((layout) => {
|
|
436
441
|
if (layout.RowGroupedColumns) {
|
|
437
442
|
delete layout.RowGroupedColumns;
|
|
@@ -2203,53 +2208,20 @@ class AdaptableAgGrid {
|
|
|
2203
2208
|
});
|
|
2204
2209
|
this.deriveAdaptableColumnStateFromAgGrid();
|
|
2205
2210
|
}
|
|
2206
|
-
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState,
|
|
2211
|
+
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState, layout) {
|
|
2212
|
+
layout = layout || this.api.layoutApi.getCurrentLayout();
|
|
2213
|
+
visibleColumnList = visibleColumnList || layout.Columns;
|
|
2207
2214
|
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;
|
|
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
|
+
});
|
|
2253
2225
|
}
|
|
2254
2226
|
getDistinctValuesForColumn(column, distinctValuesParams) {
|
|
2255
2227
|
let gridCells = this.getGridCellsForPermittedValues(column, distinctValuesParams);
|
|
@@ -3190,10 +3162,6 @@ class AdaptableAgGrid {
|
|
|
3190
3162
|
layout.PinnedColumnsMap = layout.PinnedColumnsMap || {};
|
|
3191
3163
|
layout.PinnedColumnsMap[actionRowColumn.colId] = actionRowColumn.pinned;
|
|
3192
3164
|
}
|
|
3193
|
-
const layoutColumnsMap = layout.Columns.reduce((acc, colId) => {
|
|
3194
|
-
acc[colId] = true;
|
|
3195
|
-
return acc;
|
|
3196
|
-
}, {});
|
|
3197
3165
|
const columnsState = this.agGridAdapter.getAgGridApi().getColumnState();
|
|
3198
3166
|
const columnsStateIndexes = {};
|
|
3199
3167
|
const columnsStateMap = columnsState.reduce((acc, colState, index) => {
|
|
@@ -3225,20 +3193,19 @@ class AdaptableAgGrid {
|
|
|
3225
3193
|
.getPivotResultColumns()) === null || _b === void 0 ? void 0 : _b.map((column) => column.getColId())) || [];
|
|
3226
3194
|
let isChanged = false;
|
|
3227
3195
|
const colsToAutoSize = {};
|
|
3228
|
-
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState,
|
|
3196
|
+
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState, layout);
|
|
3229
3197
|
newColumnsState = newColumnsState
|
|
3230
3198
|
.map((colState) => {
|
|
3231
3199
|
var _a, _b, _c;
|
|
3232
3200
|
const { colId } = colState;
|
|
3233
3201
|
const oldColState = columnsStateMap[colId];
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
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);
|
|
3238
3205
|
if (layout.ColumnWidthMap && layout.ColumnWidthMap[colId] != null) {
|
|
3239
3206
|
newColState.width = layout.ColumnWidthMap[colId];
|
|
3240
3207
|
}
|
|
3241
|
-
else if (!hide) {
|
|
3208
|
+
else if (!colState.hide) {
|
|
3242
3209
|
// autosize only the columns which are part of the selected layout
|
|
3243
3210
|
colsToAutoSize[colId] = true;
|
|
3244
3211
|
}
|
|
@@ -3247,11 +3214,7 @@ class AdaptableAgGrid {
|
|
|
3247
3214
|
}
|
|
3248
3215
|
newColState.rowGroupIndex =
|
|
3249
3216
|
groupedColumnsIndexesMap[colId] != null ? groupedColumnsIndexesMap[colId] : null;
|
|
3250
|
-
const previousRowGroup = newColState.rowGroup;
|
|
3251
3217
|
newColState.rowGroup = newColState.rowGroupIndex != null;
|
|
3252
|
-
if (!previousRowGroup && newColState.rowGroup) {
|
|
3253
|
-
this.agGridColumnAdapter.triggerSetupColumnKeyCreator(colId);
|
|
3254
|
-
}
|
|
3255
3218
|
const normalizePinned = (pinnedValue) => {
|
|
3256
3219
|
if (typeof pinnedValue === 'string') {
|
|
3257
3220
|
return pinnedValue;
|
|
@@ -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;
|
|
@@ -14,7 +14,6 @@ const DefaultAdaptableOptions = {
|
|
|
14
14
|
adaptableStateKey: undefined,
|
|
15
15
|
primaryKey: '',
|
|
16
16
|
autogeneratePrimaryKey: false,
|
|
17
|
-
autoMigrateState: true,
|
|
18
17
|
userName: GeneralConstants.USER_NAME,
|
|
19
18
|
predefinedConfig: undefined,
|
|
20
19
|
alertOptions: {
|
|
@@ -148,7 +147,6 @@ const DefaultAdaptableOptions = {
|
|
|
148
147
|
customSortOptions: { customSortComparers: undefined },
|
|
149
148
|
dataSetOptions: { dataSets: GeneralConstants_1.EMPTY_ARRAY },
|
|
150
149
|
groupingOptions: {
|
|
151
|
-
balancedGroupsKey: undefined,
|
|
152
150
|
restoreUngroupedColumns: false,
|
|
153
151
|
autoOrderGroupedColumns: true,
|
|
154
152
|
},
|
|
@@ -248,6 +246,7 @@ const DefaultAdaptableOptions = {
|
|
|
248
246
|
loadState: undefined,
|
|
249
247
|
persistState: undefined,
|
|
250
248
|
clearState: undefined,
|
|
249
|
+
autoMigrateState: true,
|
|
251
250
|
},
|
|
252
251
|
teamSharingOptions: {
|
|
253
252
|
enableTeamSharing: false,
|
|
@@ -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,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortColumnStateForVisibleColumns = void 0;
|
|
4
|
+
function insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset = 0, lastVisibleOffset = 0) {
|
|
5
|
+
const prevColState = result[result.length - 1 - offset];
|
|
6
|
+
if (!prevColState) {
|
|
7
|
+
result.splice(result.length - lastVisibleOffset, 0, colState);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (prevColState.hide) {
|
|
11
|
+
insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset + 1,
|
|
12
|
+
/* do not advance this as, as we've encountered a hidden column*/ lastVisibleOffset);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const prevCol_visibilityIndex = visibleColumnsIndexes[prevColState.colId];
|
|
16
|
+
const currentCol_visibilityIndex = visibleColumnsIndexes[colState.colId];
|
|
17
|
+
if (currentCol_visibilityIndex < prevCol_visibilityIndex) {
|
|
18
|
+
insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset + 1,
|
|
19
|
+
/*make sure we sync with the normal offset, as we've hit a visible col*/ offset + 1);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
result.splice(result.length - lastVisibleOffset, 0, colState);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This method takes a column state and the list of visible columns
|
|
27
|
+
* and returns a new column state that respects the order of the visible columns
|
|
28
|
+
* while trying to keep the hidden columns in their original order.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
function sortColumnStateForVisibleColumns(columnState, visibleColumns) {
|
|
32
|
+
const visibleColumnsIndexes = visibleColumns.reduce((acc, colId, index) => {
|
|
33
|
+
acc[colId] = index;
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
const result = [];
|
|
37
|
+
for (let i = 0, len = columnState.length; i < len; i++) {
|
|
38
|
+
const colState = columnState[i];
|
|
39
|
+
const colVisible = visibleColumnsIndexes[colState.colId] != null;
|
|
40
|
+
if (!colVisible) {
|
|
41
|
+
// for cols not present in this layout, we keep them
|
|
42
|
+
// where they are
|
|
43
|
+
result.push(colState);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
insertAtCorrectIndex(result, colState, visibleColumnsIndexes);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
exports.sortColumnStateForVisibleColumns = sortColumnStateForVisibleColumns;
|
package/src/env.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
4
|
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" || '',
|
|
5
|
-
PUBLISH_TIMESTAMP:
|
|
6
|
-
VERSION: "18.0.0-canary.
|
|
5
|
+
PUBLISH_TIMESTAMP: 1712232556015 || Date.now(),
|
|
6
|
+
VERSION: "18.0.0-canary.22" || '--current-version--',
|
|
7
7
|
};
|