@adaptabletools/adaptable 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 +19 -6
- 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 +7 -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 +1 -0
- 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 +120 -0
- package/src/agGrid/defaultAdaptableOptions.js +1 -2
- 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 +29 -23
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -1
|
@@ -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 },
|
|
@@ -7,7 +7,7 @@ import { ColumnSelector } from '../Components/Selectors/ColumnSelector';
|
|
|
7
7
|
import { AdaptableAgGrid } from '../../agGrid/AdaptableAgGrid';
|
|
8
8
|
export const TransposedPopup = (props) => {
|
|
9
9
|
const adaptable = useAdaptable();
|
|
10
|
-
const { transposedColumnId, hideTransposedColumn, visibleColumns, visibleRows } = props.popupProps;
|
|
10
|
+
const { transposedColumnId, hideTransposedColumn, visibleColumns, visibleRows, autosize } = props.popupProps;
|
|
11
11
|
const rowNodes = React.useMemo(() => {
|
|
12
12
|
return props.popupProps.visibleRows
|
|
13
13
|
? adaptable.api.gridApi.getVisibleRowNodes()
|
|
@@ -96,7 +96,7 @@ export const TransposedPopup = (props) => {
|
|
|
96
96
|
},
|
|
97
97
|
layoutOptions: {
|
|
98
98
|
createDefaultLayout: false,
|
|
99
|
-
autoSizeColumnsInLayout:
|
|
99
|
+
autoSizeColumnsInLayout: autosize,
|
|
100
100
|
},
|
|
101
101
|
predefinedConfig: {
|
|
102
102
|
Layout: {
|
|
@@ -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: {
|
|
@@ -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;
|
|
@@ -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
|
/**
|
|
@@ -305,15 +306,14 @@ export class AdaptableAgGrid {
|
|
|
305
306
|
* e.g. adding default Layout, migrating deprecated state, etc.
|
|
306
307
|
*/
|
|
307
308
|
postLoadHook: (state) => {
|
|
308
|
-
if (this.adaptableOptions.autoMigrateState) {
|
|
309
|
+
if (this.adaptableOptions.stateOptions.autoMigrateState) {
|
|
309
310
|
state = AdaptableUpgradeHelper.migrateAdaptableState(state, {
|
|
310
311
|
// version 16 actually includes all versions up until 16
|
|
311
312
|
fromVersion: 16,
|
|
312
313
|
logger: this.logger,
|
|
313
314
|
});
|
|
314
315
|
}
|
|
315
|
-
state = this.
|
|
316
|
-
state = this.normaliseToolPanelState(state);
|
|
316
|
+
state = this.normalizeAdaptableState(state, config.gridOptions);
|
|
317
317
|
return state;
|
|
318
318
|
},
|
|
319
319
|
});
|
|
@@ -388,10 +388,15 @@ export class AdaptableAgGrid {
|
|
|
388
388
|
perfInitAdaptableAgGrid.end();
|
|
389
389
|
return Promise.resolve(this.api);
|
|
390
390
|
}
|
|
391
|
-
|
|
391
|
+
normalizeAdaptableState(state, gridOptions) {
|
|
392
|
+
state = this.normaliseLayoutState(state, gridOptions);
|
|
393
|
+
state = this.normaliseToolPanelState(state);
|
|
394
|
+
return state;
|
|
395
|
+
}
|
|
396
|
+
normaliseLayoutState(state, gridOptions) {
|
|
392
397
|
var _a, _b, _c, _d, _e, _f;
|
|
393
398
|
if (this.shouldCreateDefaultLayout(state, this.adaptableOptions)) {
|
|
394
|
-
const defaultLayout = this.createDefaultLayout(state,
|
|
399
|
+
const defaultLayout = this.createDefaultLayout(state, gridOptions.columnDefs);
|
|
395
400
|
const layoutState = state.Layout || {};
|
|
396
401
|
const availableLayouts = layoutState.Layouts || [];
|
|
397
402
|
availableLayouts.push(defaultLayout);
|
|
@@ -427,7 +432,7 @@ export class AdaptableAgGrid {
|
|
|
427
432
|
* logic where layout is applied, it is easier and
|
|
428
433
|
* less error prone to just remove it.
|
|
429
434
|
*/
|
|
430
|
-
if (
|
|
435
|
+
if (gridOptions.rowModelType === 'viewport') {
|
|
431
436
|
(_f = state.Layout.Layouts) === null || _f === void 0 ? void 0 : _f.forEach((layout) => {
|
|
432
437
|
if (layout.RowGroupedColumns) {
|
|
433
438
|
delete layout.RowGroupedColumns;
|
|
@@ -2199,53 +2204,20 @@ export class AdaptableAgGrid {
|
|
|
2199
2204
|
});
|
|
2200
2205
|
this.deriveAdaptableColumnStateFromAgGrid();
|
|
2201
2206
|
}
|
|
2202
|
-
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState,
|
|
2207
|
+
getSortedColumnStateForVisibleColumns(visibleColumnList, columnState, layout) {
|
|
2208
|
+
layout = layout || this.api.layoutApi.getCurrentLayout();
|
|
2209
|
+
visibleColumnList = visibleColumnList || layout.Columns;
|
|
2203
2210
|
columnState = columnState || this.agGridAdapter.getAgGridApi().getColumnState();
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
acc[colId] = index;
|
|
2215
|
-
return acc;
|
|
2216
|
-
}, {});
|
|
2217
|
-
const result = [...columnState]
|
|
2218
|
-
.sort((colState1, colState2) => {
|
|
2219
|
-
const colId1 = colState1.colId;
|
|
2220
|
-
const colId2 = colState2.colId;
|
|
2221
|
-
const originalIndex1 = columnsStateIndexes[colId1];
|
|
2222
|
-
const originalIndex2 = columnsStateIndexes[colId2];
|
|
2223
|
-
if (pivotMode) {
|
|
2224
|
-
const isRowGroup1 = this.api.columnApi.isAutoRowGroupColumn(colId1);
|
|
2225
|
-
const isRowGroup2 = this.api.columnApi.isAutoRowGroupColumn(colId2);
|
|
2226
|
-
if (isRowGroup1 && isRowGroup2) {
|
|
2227
|
-
return 1;
|
|
2228
|
-
}
|
|
2229
|
-
if (isRowGroup1) {
|
|
2230
|
-
return -1;
|
|
2231
|
-
}
|
|
2232
|
-
if (isRowGroup2) {
|
|
2233
|
-
return 1;
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
if (newVisibleColumnsMap[colId1] != null && newVisibleColumnsMap[colId2] == null) {
|
|
2237
|
-
return -1;
|
|
2238
|
-
}
|
|
2239
|
-
if (newVisibleColumnsMap[colId1] == null && newVisibleColumnsMap[colId2] != null) {
|
|
2240
|
-
return 1;
|
|
2241
|
-
}
|
|
2242
|
-
if (newVisibleColumnsMap[colId1] == null && newVisibleColumnsMap[colId2] == null) {
|
|
2243
|
-
return originalIndex1 - originalIndex2;
|
|
2244
|
-
}
|
|
2245
|
-
return newVisibleColumnsMap[colState1.colId] - newVisibleColumnsMap[colState2.colId];
|
|
2246
|
-
})
|
|
2247
|
-
.map((colState) => (Object.assign(Object.assign({}, colState), { hide: NewVisibleColumnIdsMap[colState.colId] == null })));
|
|
2248
|
-
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
|
+
});
|
|
2249
2221
|
}
|
|
2250
2222
|
getDistinctValuesForColumn(column, distinctValuesParams) {
|
|
2251
2223
|
let gridCells = this.getGridCellsForPermittedValues(column, distinctValuesParams);
|
|
@@ -3186,10 +3158,6 @@ export class AdaptableAgGrid {
|
|
|
3186
3158
|
layout.PinnedColumnsMap = layout.PinnedColumnsMap || {};
|
|
3187
3159
|
layout.PinnedColumnsMap[actionRowColumn.colId] = actionRowColumn.pinned;
|
|
3188
3160
|
}
|
|
3189
|
-
const layoutColumnsMap = layout.Columns.reduce((acc, colId) => {
|
|
3190
|
-
acc[colId] = true;
|
|
3191
|
-
return acc;
|
|
3192
|
-
}, {});
|
|
3193
3161
|
const columnsState = this.agGridAdapter.getAgGridApi().getColumnState();
|
|
3194
3162
|
const columnsStateIndexes = {};
|
|
3195
3163
|
const columnsStateMap = columnsState.reduce((acc, colState, index) => {
|
|
@@ -3221,20 +3189,19 @@ export class AdaptableAgGrid {
|
|
|
3221
3189
|
.getPivotResultColumns()) === null || _b === void 0 ? void 0 : _b.map((column) => column.getColId())) || [];
|
|
3222
3190
|
let isChanged = false;
|
|
3223
3191
|
const colsToAutoSize = {};
|
|
3224
|
-
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState,
|
|
3192
|
+
let newColumnsState = this.getSortedColumnStateForVisibleColumns(columnsToShow, columnsState, layout);
|
|
3225
3193
|
newColumnsState = newColumnsState
|
|
3226
3194
|
.map((colState) => {
|
|
3227
3195
|
var _a, _b, _c;
|
|
3228
3196
|
const { colId } = colState;
|
|
3229
3197
|
const oldColState = columnsStateMap[colId];
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
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);
|
|
3234
3201
|
if (layout.ColumnWidthMap && layout.ColumnWidthMap[colId] != null) {
|
|
3235
3202
|
newColState.width = layout.ColumnWidthMap[colId];
|
|
3236
3203
|
}
|
|
3237
|
-
else if (!hide) {
|
|
3204
|
+
else if (!colState.hide) {
|
|
3238
3205
|
// autosize only the columns which are part of the selected layout
|
|
3239
3206
|
colsToAutoSize[colId] = true;
|
|
3240
3207
|
}
|
|
@@ -3243,11 +3210,7 @@ export class AdaptableAgGrid {
|
|
|
3243
3210
|
}
|
|
3244
3211
|
newColState.rowGroupIndex =
|
|
3245
3212
|
groupedColumnsIndexesMap[colId] != null ? groupedColumnsIndexesMap[colId] : null;
|
|
3246
|
-
const previousRowGroup = newColState.rowGroup;
|
|
3247
3213
|
newColState.rowGroup = newColState.rowGroupIndex != null;
|
|
3248
|
-
if (!previousRowGroup && newColState.rowGroup) {
|
|
3249
|
-
this.agGridColumnAdapter.triggerSetupColumnKeyCreator(colId);
|
|
3250
|
-
}
|
|
3251
3214
|
const normalizePinned = (pinnedValue) => {
|
|
3252
3215
|
if (typeof pinnedValue === 'string') {
|
|
3253
3216
|
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;
|
|
@@ -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
|
+
}
|
|
@@ -10,7 +10,6 @@ const DefaultAdaptableOptions = {
|
|
|
10
10
|
adaptableStateKey: undefined,
|
|
11
11
|
primaryKey: '',
|
|
12
12
|
autogeneratePrimaryKey: false,
|
|
13
|
-
autoMigrateState: true,
|
|
14
13
|
userName: GeneralConstants.USER_NAME,
|
|
15
14
|
predefinedConfig: undefined,
|
|
16
15
|
alertOptions: {
|
|
@@ -144,7 +143,6 @@ const DefaultAdaptableOptions = {
|
|
|
144
143
|
customSortOptions: { customSortComparers: undefined },
|
|
145
144
|
dataSetOptions: { dataSets: EMPTY_ARRAY },
|
|
146
145
|
groupingOptions: {
|
|
147
|
-
balancedGroupsKey: undefined,
|
|
148
146
|
restoreUngroupedColumns: false,
|
|
149
147
|
autoOrderGroupedColumns: true,
|
|
150
148
|
},
|
|
@@ -244,6 +242,7 @@ const DefaultAdaptableOptions = {
|
|
|
244
242
|
loadState: undefined,
|
|
245
243
|
persistState: undefined,
|
|
246
244
|
clearState: undefined,
|
|
245
|
+
autoMigrateState: true,
|
|
247
246
|
},
|
|
248
247
|
teamSharingOptions: {
|
|
249
248
|
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,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: 1712232524555 || Date.now(),
|
|
4
|
+
VERSION: "18.0.0-canary.22" || '--current-version--',
|
|
5
5
|
};
|