@adaptabletools/adaptable 18.0.0-canary.21 → 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/AdaptableOptions/CommentOptions.d.ts +6 -0
- package/src/AdaptableOptions/GroupingOptions.d.ts +0 -4
- package/src/AdaptableOptions/NoteOptions.d.ts +8 -2
- package/src/Api/ColumnApi.d.ts +5 -0
- package/src/Api/Implementation/ColumnApiImpl.d.ts +3 -0
- package/src/Api/Implementation/ColumnApiImpl.js +19 -6
- 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/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/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.js +19 -60
- 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 -12
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -1
|
@@ -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: 1712232524555 || Date.now(),
|
|
4
|
+
VERSION: "18.0.0-canary.22" || '--current-version--',
|
|
5
5
|
};
|
|
@@ -1974,12 +1974,19 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
1974
1974
|
name: string;
|
|
1975
1975
|
kind: string;
|
|
1976
1976
|
desc: string;
|
|
1977
|
-
props: {
|
|
1977
|
+
props: ({
|
|
1978
1978
|
name: string;
|
|
1979
1979
|
kind: string;
|
|
1980
1980
|
desc: string;
|
|
1981
1981
|
isOpt: boolean;
|
|
1982
|
-
|
|
1982
|
+
defVal: string;
|
|
1983
|
+
} | {
|
|
1984
|
+
name: string;
|
|
1985
|
+
kind: string;
|
|
1986
|
+
desc: string;
|
|
1987
|
+
isOpt: boolean;
|
|
1988
|
+
defVal?: undefined;
|
|
1989
|
+
})[];
|
|
1983
1990
|
};
|
|
1984
1991
|
CommentState: {
|
|
1985
1992
|
name: string;
|
|
@@ -3639,14 +3646,6 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
3639
3646
|
gridInfo: string;
|
|
3640
3647
|
noCode: string;
|
|
3641
3648
|
defVal: string;
|
|
3642
|
-
} | {
|
|
3643
|
-
name: string;
|
|
3644
|
-
kind: string;
|
|
3645
|
-
desc: string;
|
|
3646
|
-
isOpt: boolean;
|
|
3647
|
-
gridInfo?: undefined;
|
|
3648
|
-
noCode?: undefined;
|
|
3649
|
-
defVal?: undefined;
|
|
3650
3649
|
} | {
|
|
3651
3650
|
name: string;
|
|
3652
3651
|
kind: string;
|
|
@@ -4040,12 +4039,19 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
4040
4039
|
name: string;
|
|
4041
4040
|
kind: string;
|
|
4042
4041
|
desc: string;
|
|
4043
|
-
props: {
|
|
4042
|
+
props: ({
|
|
4044
4043
|
name: string;
|
|
4045
4044
|
kind: string;
|
|
4046
4045
|
desc: string;
|
|
4047
4046
|
isOpt: boolean;
|
|
4048
|
-
|
|
4047
|
+
defVal: string;
|
|
4048
|
+
} | {
|
|
4049
|
+
name: string;
|
|
4050
|
+
kind: string;
|
|
4051
|
+
desc: string;
|
|
4052
|
+
isOpt: boolean;
|
|
4053
|
+
defVal?: undefined;
|
|
4054
|
+
})[];
|
|
4049
4055
|
};
|
|
4050
4056
|
NoteState: {
|
|
4051
4057
|
name: string;
|