@adaptabletools/adaptable 12.2.0-canary.0 → 12.2.1
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/bundle.cjs.js +77 -77
- package/package.json +1 -1
- package/publishTimestamp.d.ts +1 -1
- package/publishTimestamp.js +1 -1
- package/src/AdaptableOptions/AdaptableQLOptions.d.ts +2 -2
- package/src/AdaptableOptions/FinancePluginOptions.d.ts +5 -11
- package/src/AdaptableOptions/GeneralOptions.d.ts +19 -1
- package/src/AdaptableOptions/LayoutOptions.d.ts +1 -10
- package/src/Api/Implementation/CellSummaryApiImpl.d.ts +5 -0
- package/src/Api/Implementation/CellSummaryApiImpl.js +23 -1
- package/src/Api/Implementation/InternalApiImpl.js +1 -1
- package/src/Api/Implementation/LayoutApiImpl.js +2 -2
- package/src/Utilities/Defaults/DefaultAdaptableOptions.js +1 -0
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +1 -1
- package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizard.js +0 -1
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +2 -2
- package/src/View/CellSummary/CellSummaryViewPanel.js +1 -1
- package/src/View/Components/EntityRulesEditor/index.js +1 -1
- package/src/agGrid/Adaptable.d.ts +1 -1
- package/src/agGrid/Adaptable.js +13 -33
- package/src/agGrid/weightedAverage.d.ts +3 -0
- package/src/agGrid/weightedAverage.js +75 -41
- package/src/metamodel/adaptable.metamodel.d.ts +12 -15
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/src/types.d.ts +2 -2
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.1",
|
|
4
4
|
"description": "Powerful data-agnostic HTML5 datagrid add-on that sits on top of an underlying grid component and provides all the rich functionality that advanced users expect from their DataGrids and Data Tables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
package/publishTimestamp.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: 1661859148986;
|
|
2
2
|
export default _default;
|
package/publishTimestamp.js
CHANGED
|
@@ -19,13 +19,13 @@ export interface AdaptableQLOptions {
|
|
|
19
19
|
*
|
|
20
20
|
* @defaultValue undefined
|
|
21
21
|
* @gridInfoItem
|
|
22
|
-
* @deprecated use `
|
|
22
|
+
* @deprecated use `evaluateAdaptableQLExternally()` instead
|
|
23
23
|
*/
|
|
24
24
|
externallyEvaluatedModules?: AdaptableQLModules;
|
|
25
25
|
/**
|
|
26
26
|
* Whether a specific expression (or all expressions in a given module) must be evaluated on the server
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
evaluateAdaptableQLExternally?: (context: EvaluateExpressionExternallyContext) => boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Options for managing Expressions in AdaptableQL
|
|
31
31
|
*
|
|
@@ -37,14 +37,14 @@ export interface FinancePluginOptions {
|
|
|
37
37
|
*/
|
|
38
38
|
customFDC3Intents?: CustomFDC3Intent[];
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
41
|
-
* Columns to use a Weighted Average aggregation
|
|
42
|
-
*/
|
|
43
|
-
weightedAverageColumns?: WeightedAverageColumn[];
|
|
44
40
|
/**
|
|
45
41
|
* Intents to which to subscribe.
|
|
46
42
|
*/
|
|
47
43
|
availableFDC3Intents?: (FDC3Intent | CustomFDC3Intent)[];
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated - use Weighted Average Layout Aggregation
|
|
46
|
+
*/
|
|
47
|
+
weightedAverageColumns?: WeightedAverageColumn[];
|
|
48
48
|
/**
|
|
49
49
|
* Called when an intent from `availableIntents` is raised.
|
|
50
50
|
*/
|
|
@@ -55,16 +55,10 @@ export interface FinancePluginOptions {
|
|
|
55
55
|
onFDC3Context?: (context: FDC3Context, adaptableApi: AdaptableApi) => void;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* @deprecated - use Weighted Average Layout Aggregation
|
|
59
59
|
*/
|
|
60
60
|
export interface WeightedAverageColumn {
|
|
61
|
-
/**
|
|
62
|
-
* Column which will contain the aggregation
|
|
63
|
-
*/
|
|
64
61
|
columnId: string;
|
|
65
|
-
/**
|
|
66
|
-
* Column used to perform the aggreation calculation
|
|
67
|
-
*/
|
|
68
62
|
weightedColumnId: string;
|
|
69
63
|
}
|
|
70
64
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { AdaptableForm, AdaptableObject, AdaptableScope } from '../../types';
|
|
1
|
+
import { AdaptableColumn, AdaptableForm, AdaptableObject, AdaptableScope, BaseContext } from '../../types';
|
|
2
2
|
import { AdaptableComparerFunction } from '../PredefinedConfig/Common/AdaptableComparerFunction';
|
|
3
3
|
import { AlternativeModuleName } from '../PredefinedConfig/Common/AlternativeModuleName';
|
|
4
4
|
import { FormContext } from '../PredefinedConfig/Common/FormContext';
|
|
5
5
|
import { CellSummaryOperation } from '../PredefinedConfig/Common/CellSummary';
|
|
6
|
+
import { KeyCreatorParams } from '@ag-grid-community/all-modules';
|
|
6
7
|
/**
|
|
7
8
|
* General options for configuring AdapTable including managing Primary Keys
|
|
8
9
|
*/
|
|
@@ -60,6 +61,10 @@ export interface GeneralOptions {
|
|
|
60
61
|
* Collection of Data Sets to provide Data to AdapTable
|
|
61
62
|
*/
|
|
62
63
|
dataSets?: DataSet[];
|
|
64
|
+
/**
|
|
65
|
+
* Value to use for 'Unbalanced Groups' (string columns)
|
|
66
|
+
*/
|
|
67
|
+
unbalancedGroupsKey?: string | ((context: UnbalancedGroupsKeyContext) => string);
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
70
|
* Comparer object for Column Values - used for custom sorting
|
|
@@ -100,3 +105,16 @@ export interface DataSetFormContext extends FormContext {
|
|
|
100
105
|
*/
|
|
101
106
|
dataSet: DataSet;
|
|
102
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Context used when setting a value for Unbalanced Row Groups
|
|
110
|
+
*/
|
|
111
|
+
export interface UnbalancedGroupsKeyContext extends BaseContext {
|
|
112
|
+
/**
|
|
113
|
+
* Adaptable Column being grouped
|
|
114
|
+
*/
|
|
115
|
+
adaptableColumn: AdaptableColumn;
|
|
116
|
+
/**
|
|
117
|
+
* AG Grid's Key Creator Params
|
|
118
|
+
*/
|
|
119
|
+
params: KeyCreatorParams;
|
|
120
|
+
}
|
|
@@ -9,8 +9,7 @@ import { BaseSchedule } from '../PredefinedConfig/Common/Schedule';
|
|
|
9
9
|
import { Layout } from '../PredefinedConfig/LayoutState';
|
|
10
10
|
import { AdaptableModule } from '../PredefinedConfig/Common/Types';
|
|
11
11
|
import { AdaptableObjectTag } from '../PredefinedConfig/Common/AdaptableObject';
|
|
12
|
-
import {
|
|
13
|
-
import { KeyCreatorParams } from '@ag-grid-community/all-modules';
|
|
12
|
+
import { BaseContext } from '../../types';
|
|
14
13
|
/**
|
|
15
14
|
* Options for configuring Layouts; these manage Column visibility, order, sorting, grouping and width
|
|
16
15
|
*
|
|
@@ -65,10 +64,6 @@ export interface LayoutOptions {
|
|
|
65
64
|
* Options for leveraging Object Tags to extend Layouts
|
|
66
65
|
*/
|
|
67
66
|
layoutTagOptions?: LayoutTagOptions;
|
|
68
|
-
/**
|
|
69
|
-
* When defined ungrouped rows are grouped under this key.
|
|
70
|
-
*/
|
|
71
|
-
groupUnbalancedGroupsUnderKey?: string | ((context: GroupUnbalancedGroupsUnderKeyContext) => string);
|
|
72
67
|
}
|
|
73
68
|
export interface LayoutTagOptions {
|
|
74
69
|
/**
|
|
@@ -135,7 +130,3 @@ export interface AutoGenerateTagsForLayoutsContext extends BaseContext {
|
|
|
135
130
|
*/
|
|
136
131
|
objectTags: AdaptableObjectTag[];
|
|
137
132
|
}
|
|
138
|
-
export interface GroupUnbalancedGroupsUnderKeyContext extends BaseContext {
|
|
139
|
-
adaptableColumn: AdaptableColumn;
|
|
140
|
-
params: KeyCreatorParams;
|
|
141
|
-
}
|
|
@@ -9,4 +9,9 @@ export declare class CellSummaryApiImpl extends ApiBase implements CellSummaryAp
|
|
|
9
9
|
setCurrentCellSummaryOperation(operation: SummaryOperation | string): void;
|
|
10
10
|
getCellSummaryOperationValue(operation: SummaryOperation | string): any;
|
|
11
11
|
getCurrentCellSummaryOperationValue(): any;
|
|
12
|
+
/**
|
|
13
|
+
* Weighted average is availabe only if the current layout has at leat a Weighted Average aggregation defined.
|
|
14
|
+
*/
|
|
15
|
+
private isWeightedAvetageCellSummaryAvailable;
|
|
16
|
+
private getWeightedAverageCellSummaryOperation;
|
|
12
17
|
}
|
|
@@ -6,12 +6,21 @@ const ApiBase_1 = require("./ApiBase");
|
|
|
6
6
|
const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
|
|
7
7
|
const SystemRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/SystemRedux"));
|
|
8
8
|
const Enums_1 = require("../../PredefinedConfig/Common/Enums");
|
|
9
|
+
const weightedAverage_1 = require("../../agGrid/weightedAverage");
|
|
9
10
|
class CellSummaryApiImpl extends ApiBase_1.ApiBase {
|
|
10
11
|
getCurrentCellSummaryOperation() {
|
|
11
12
|
return this.getAdaptableState().System.CellSummaryOperation;
|
|
12
13
|
}
|
|
13
14
|
getCellSummaryOperationDefinitions() {
|
|
14
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
let cellSummaryOperations = (_a = this.getGeneralOptions().cellSummaryOperations) !== null && _a !== void 0 ? _a : [];
|
|
17
|
+
if (this.isWeightedAvetageCellSummaryAvailable()) {
|
|
18
|
+
cellSummaryOperations = [
|
|
19
|
+
...cellSummaryOperations,
|
|
20
|
+
this.getWeightedAverageCellSummaryOperation(),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
return cellSummaryOperations;
|
|
15
24
|
}
|
|
16
25
|
showCellSummaryPopup() {
|
|
17
26
|
this.showModulePopup(ModuleConstants.CellSummaryModuleId);
|
|
@@ -52,5 +61,18 @@ class CellSummaryApiImpl extends ApiBase_1.ApiBase {
|
|
|
52
61
|
: cellSummaryOperation.operationName;
|
|
53
62
|
return this.getCellSummaryOperationValue(summaryOperation);
|
|
54
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Weighted average is availabe only if the current layout has at leat a Weighted Average aggregation defined.
|
|
66
|
+
*/
|
|
67
|
+
isWeightedAvetageCellSummaryAvailable() {
|
|
68
|
+
const currentLayout = this.getAdaptableApi().layoutApi.getCurrentLayout();
|
|
69
|
+
return Object.values(currentLayout.AggregationColumns).some((aggCol) => typeof aggCol === 'object' && aggCol.type === 'weightedAverage');
|
|
70
|
+
}
|
|
71
|
+
getWeightedAverageCellSummaryOperation() {
|
|
72
|
+
return {
|
|
73
|
+
operationName: 'Weighted Avg',
|
|
74
|
+
operationFunction: weightedAverage_1.cellSummaryWeightedAverage,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
55
77
|
}
|
|
56
78
|
exports.CellSummaryApiImpl = CellSummaryApiImpl;
|
|
@@ -307,7 +307,7 @@ class InternalApiImpl extends ApiBase_1.ApiBase {
|
|
|
307
307
|
// fallback to deprecated property
|
|
308
308
|
return this.runModuleInAdaptableQL(module);
|
|
309
309
|
}
|
|
310
|
-
const evaluateExpressionExternallyFn = (_a = this.getAdaptableQLOptions()) === null || _a === void 0 ? void 0 : _a.
|
|
310
|
+
const evaluateExpressionExternallyFn = (_a = this.getAdaptableQLOptions()) === null || _a === void 0 ? void 0 : _a.evaluateAdaptableQLExternally;
|
|
311
311
|
if (typeof evaluateExpressionExternallyFn !== 'function') {
|
|
312
312
|
return true;
|
|
313
313
|
}
|
|
@@ -106,7 +106,7 @@ class LayoutApiImpl extends ApiBase_1.ApiBase {
|
|
|
106
106
|
currentLayout = this.getAdaptableState().Grid.CurrentLayout || currentLayout;
|
|
107
107
|
}
|
|
108
108
|
if (currentLayout) {
|
|
109
|
-
this.
|
|
109
|
+
this.createOrUpdateLayout(currentLayout);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
doesLayoutExist(layout) {
|
|
@@ -244,7 +244,7 @@ class LayoutApiImpl extends ApiBase_1.ApiBase {
|
|
|
244
244
|
return acc;
|
|
245
245
|
}, {}),
|
|
246
246
|
}, gridState.Columns);
|
|
247
|
-
this.
|
|
247
|
+
this.createOrUpdateLayout(defaultLayout);
|
|
248
248
|
return defaultLayout;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
@@ -29,7 +29,7 @@ exports.aggregatedExpressionFunctions = [
|
|
|
29
29
|
exports.aggregatedScalarExpressionFunctions = {
|
|
30
30
|
CUMUL: {
|
|
31
31
|
handler(args, context) {
|
|
32
|
-
const aggregationParameter = expressionFunctionUtils_1.extractParameter('CUMUL', 'aggregationScalar', ['SUM', '
|
|
32
|
+
const aggregationParameter = expressionFunctionUtils_1.extractParameter('CUMUL', 'aggregationScalar', ['SUM', 'PERCENTAGE', 'AVG', 'MIN', 'MAX'], args);
|
|
33
33
|
const overColumnParameter = expressionFunctionUtils_1.extractParameter('CUMUL', 'operand', ['OVER'], args);
|
|
34
34
|
const cumulationExpressionEvaluation = mapAggregationToCumulation(aggregationParameter, overColumnParameter, context);
|
|
35
35
|
const result = {
|
|
@@ -61,7 +61,6 @@ const ConfigurationWizard = (props) => {
|
|
|
61
61
|
});
|
|
62
62
|
}, []);
|
|
63
63
|
const financePlugin = (_b = (_a = adaptableOptions.plugins) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, (plugin) => plugin.pluginId === 'finance');
|
|
64
|
-
console.log({ adaptableOptions });
|
|
65
64
|
let sections = [
|
|
66
65
|
{
|
|
67
66
|
title: 'Columns',
|
|
@@ -79,10 +79,10 @@ const CalculatedColumnExpressionWizardSection = (props) => {
|
|
|
79
79
|
React.createElement(QueryTab, { value: "ScalarExpression", type: selectedTab, label: "Scalar" }),
|
|
80
80
|
React.createElement(Tabs_1.Tabs.Content, { value: 'ScalarExpression' },
|
|
81
81
|
React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'scalar', module: moduleInfo.ModuleName, style: { paddingLeft: 0 }, value: data.Query.ScalarExpression, onChange: (ScalarExpression) => setCalculatedColumnExpression({ ScalarExpression }), initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), isFullExpression: true, api: api })),
|
|
82
|
-
React.createElement(QueryTab, { value: "AggregatedScalarExpression", type: selectedTab, label: "
|
|
82
|
+
React.createElement(QueryTab, { value: "AggregatedScalarExpression", type: selectedTab, label: "Aggregated Scalar" }),
|
|
83
83
|
React.createElement(Tabs_1.Tabs.Content, { value: 'AggregatedScalarExpression' },
|
|
84
84
|
React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'aggregatedScalar', module: moduleInfo.ModuleName, style: { paddingLeft: 0 }, value: data.Query.AggregatedScalarExpression, onChange: (AggregatedScalarExpression) => setCalculatedColumnExpression({ AggregatedScalarExpression }), initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), isFullExpression: true, api: api })),
|
|
85
|
-
React.createElement(QueryTab, { value: "CumulativeAggregateExpression", type: selectedTab, label: "
|
|
85
|
+
React.createElement(QueryTab, { value: "CumulativeAggregateExpression", type: selectedTab, label: "Cumulative" }),
|
|
86
86
|
React.createElement(Tabs_1.Tabs.Content, { value: 'CumulativeAggregateExpression' },
|
|
87
87
|
React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'cumulativeAggregatedScalar', module: moduleInfo.ModuleName, style: { paddingLeft: 0 }, value: data.Query.AggregatedScalarExpression, onChange: (AggregatedScalarExpression) => setCalculatedColumnExpression({ AggregatedScalarExpression }), initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), isFullExpression: true, api: api }))));
|
|
88
88
|
};
|
|
@@ -38,7 +38,7 @@ class CellSummaryViewPanelComponent extends React.Component {
|
|
|
38
38
|
onClick: () => this.props.onCellSummaryOperationChange(summaryOperation),
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
|
-
const cellSummaryOperationDefinitions = this.props.api.
|
|
41
|
+
const cellSummaryOperationDefinitions = this.props.api.cellSummaryApi.getCellSummaryOperationDefinitions();
|
|
42
42
|
const operationDefinitions = ArrayExtensions_1.default.IsNullOrEmpty(cellSummaryOperationDefinitions)
|
|
43
43
|
? []
|
|
44
44
|
: cellSummaryOperationDefinitions.map((operationDefinition) => {
|
|
@@ -191,7 +191,7 @@ const EntityRulesEditor = (props) => {
|
|
|
191
191
|
showObservable ? (React.createElement(QueryTab, { value: "ObservableExpression", type: type, label: "Observable" })) : null,
|
|
192
192
|
showObservable ? (React.createElement(Tabs_1.Tabs.Content, { value: 'ObservableExpression', paddingLeft: 0 },
|
|
193
193
|
React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'observable', module: module, value: data.Rule.ObservableExpression, onChange: setReactiveExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null,
|
|
194
|
-
showAggregation ? (React.createElement(QueryTab, { value: "AggregatedBooleanExpression", type: type, label: "
|
|
194
|
+
showAggregation ? (React.createElement(QueryTab, { value: "AggregatedBooleanExpression", type: type, label: "Aggregated Boolean" })) : null,
|
|
195
195
|
showAggregation ? (React.createElement(Tabs_1.Tabs.Content, { value: 'AggregatedBooleanExpression', paddingLeft: 0 },
|
|
196
196
|
React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'aggregatedBoolean', module: module, value: data.Rule.AggregatedBooleanExpression, onChange: setAggregationExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null)));
|
|
197
197
|
};
|
|
@@ -226,7 +226,7 @@ export declare class Adaptable implements IAdaptable {
|
|
|
226
226
|
private mapColumnDefs;
|
|
227
227
|
private getColDefsForSpecialColumns;
|
|
228
228
|
getColDefsForFreeTextColumns(): ColDef[];
|
|
229
|
-
setupColumnValueGetter({ col
|
|
229
|
+
setupColumnValueGetter({ col }: ColumnSetupInfo): void;
|
|
230
230
|
setupColumnAggFunc({ col }: ColumnSetupInfo): void;
|
|
231
231
|
private getColDefsForRowEditColumns;
|
|
232
232
|
getColDefsForActionColumns(): ColDef[];
|
package/src/agGrid/Adaptable.js
CHANGED
|
@@ -1233,7 +1233,7 @@ class Adaptable {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
persistLayout(layout) {
|
|
1235
1235
|
if (this.api.layoutApi.shouldAutoSaveLayout(layout)) {
|
|
1236
|
-
this.api.layoutApi.
|
|
1236
|
+
this.api.layoutApi.createOrUpdateLayout(layout);
|
|
1237
1237
|
}
|
|
1238
1238
|
else {
|
|
1239
1239
|
this.api.internalApi.updateCurrentDraftLayout(layout);
|
|
@@ -1266,7 +1266,10 @@ class Adaptable {
|
|
|
1266
1266
|
const sortModelMap = ((_a = layout.ColumnSorts) !== null && _a !== void 0 ? _a : []).reduce((acc, customSort) => {
|
|
1267
1267
|
const colId = customSort.ColumnId;
|
|
1268
1268
|
if (!layoutColumnsMap[colId]) {
|
|
1269
|
-
|
|
1269
|
+
// pivot layouts may have no pivot columns, only aggregation columns
|
|
1270
|
+
if (layout.AggregationColumns[colId] == undefined) {
|
|
1271
|
+
return acc;
|
|
1272
|
+
}
|
|
1270
1273
|
}
|
|
1271
1274
|
acc[colId] = {
|
|
1272
1275
|
colId,
|
|
@@ -1466,7 +1469,6 @@ class Adaptable {
|
|
|
1466
1469
|
plugin.afterSetLayout(this, layout);
|
|
1467
1470
|
}
|
|
1468
1471
|
});
|
|
1469
|
-
// this.api.layoutApi.fireLayoutUpdatedEvent(layout, 'UpdatedLayout');
|
|
1470
1472
|
}
|
|
1471
1473
|
/*
|
|
1472
1474
|
* This is the opposite of setLayout
|
|
@@ -1539,7 +1541,6 @@ class Adaptable {
|
|
|
1539
1541
|
if (this.api.layoutApi.areExpandedRowGroupsSavedInLayouts()) {
|
|
1540
1542
|
layout.ExpandedRowGroupValues = this.getExpandRowGroupsKeys();
|
|
1541
1543
|
}
|
|
1542
|
-
// this.api.layoutApi.fireLayoutUpdatedEvent(layout, 'UpdatedLayout');
|
|
1543
1544
|
this.persistLayout(layout);
|
|
1544
1545
|
}
|
|
1545
1546
|
// This method returns selected cells ONLY (if selection mode is cells or multiple cells).
|
|
@@ -2196,31 +2197,10 @@ class Adaptable {
|
|
|
2196
2197
|
return newColDef;
|
|
2197
2198
|
});
|
|
2198
2199
|
}
|
|
2199
|
-
setupColumnValueGetter({ col
|
|
2200
|
+
setupColumnValueGetter({ col }) {
|
|
2201
|
+
// need this here if we want plugins to intercept
|
|
2200
2202
|
this.setColDefProperty(col, 'valueGetter', (userValue) => {
|
|
2201
|
-
return
|
|
2202
|
-
const columnId = abColumn.columnId;
|
|
2203
|
-
let evaluatedUserValue = userValue;
|
|
2204
|
-
if (typeof userValue === 'function') {
|
|
2205
|
-
evaluatedUserValue = userValue(params);
|
|
2206
|
-
}
|
|
2207
|
-
const defaultValue = evaluatedUserValue
|
|
2208
|
-
? evaluatedUserValue
|
|
2209
|
-
: (params === null || params === void 0 ? void 0 : params.data)
|
|
2210
|
-
? params.data[columnId]
|
|
2211
|
-
: undefined;
|
|
2212
|
-
const adaptableAggFunc = this.getActiveAdaptableAggFuncForCol(columnId);
|
|
2213
|
-
if (adaptableAggFunc && adaptableAggFunc.type === 'weightedAverage' && !params.node.group) {
|
|
2214
|
-
const weightedColumnId = adaptableAggFunc.weightedColumnId;
|
|
2215
|
-
return {
|
|
2216
|
-
[columnId]: defaultValue,
|
|
2217
|
-
[weightedColumnId]: params.data[weightedColumnId],
|
|
2218
|
-
toString: () => (defaultValue ? `${defaultValue}` : ''),
|
|
2219
|
-
valueOf: () => defaultValue,
|
|
2220
|
-
};
|
|
2221
|
-
}
|
|
2222
|
-
return defaultValue;
|
|
2223
|
-
};
|
|
2203
|
+
return userValue;
|
|
2224
2204
|
});
|
|
2225
2205
|
}
|
|
2226
2206
|
setupColumnAggFunc({ col }) {
|
|
@@ -3348,17 +3328,17 @@ class Adaptable {
|
|
|
3348
3328
|
return userPropertyValue(params);
|
|
3349
3329
|
}
|
|
3350
3330
|
const value = params.value;
|
|
3351
|
-
const
|
|
3352
|
-
if (!
|
|
3331
|
+
const unbalancedGroupsKey = (_a = adaptableOptions.generalOptions) === null || _a === void 0 ? void 0 : _a.unbalancedGroupsKey;
|
|
3332
|
+
if (!unbalancedGroupsKey) {
|
|
3353
3333
|
return value;
|
|
3354
3334
|
}
|
|
3355
|
-
let groupUnbalancedGroupsUnderKeyValue = typeof
|
|
3356
|
-
?
|
|
3335
|
+
let groupUnbalancedGroupsUnderKeyValue = typeof unbalancedGroupsKey === 'function'
|
|
3336
|
+
? unbalancedGroupsKey({
|
|
3357
3337
|
adaptableApi: adaptableApi,
|
|
3358
3338
|
adaptableColumn: abColumn,
|
|
3359
3339
|
params,
|
|
3360
3340
|
})
|
|
3361
|
-
:
|
|
3341
|
+
: unbalancedGroupsKey;
|
|
3362
3342
|
return value === null || value === undefined ? groupUnbalancedGroupsUnderKeyValue : value;
|
|
3363
3343
|
};
|
|
3364
3344
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { IAggFuncParams } from '@ag-grid-community/all-modules';
|
|
2
|
+
import { CellSummaryOperationContext } from '../types';
|
|
3
|
+
export declare const getNumericValue: (input: unknown) => number | null;
|
|
2
4
|
export declare const weightedAverage: (params: IAggFuncParams, columnId: string, weightColumnId: string) => {
|
|
3
5
|
[x: string]: number | (() => number | "");
|
|
4
6
|
toString: () => number | "";
|
|
5
7
|
valueOf: () => number;
|
|
6
8
|
};
|
|
9
|
+
export declare const cellSummaryWeightedAverage: ({ numericColumns, selectedCellInfo, adaptableApi, }: CellSummaryOperationContext) => any;
|
|
@@ -1,66 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.weightedAverage = void 0;
|
|
3
|
+
exports.cellSummaryWeightedAverage = exports.weightedAverage = exports.getNumericValue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const FormatHelper_1 = tslib_1.__importDefault(require("../Utilities/Helpers/FormatHelper"));
|
|
6
|
+
const toNumber_1 = tslib_1.__importDefault(require("lodash/toNumber"));
|
|
7
|
+
const getNumericValue = (input) => {
|
|
8
|
+
if (typeof input === 'number') {
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
const numericValue = toNumber_1.default(input);
|
|
12
|
+
return isNaN(numericValue) ? null : numericValue;
|
|
13
|
+
};
|
|
14
|
+
exports.getNumericValue = getNumericValue;
|
|
6
15
|
const weightedAverage = (params, columnId, weightColumnId) => {
|
|
16
|
+
const { api: gridApi, rowNode: groupRowNode } = params;
|
|
7
17
|
let weightedColumnValueSum = 0;
|
|
8
18
|
let columnValueSum = 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const columnValue = StringExtensions_1.default.IsNotNullOrEmpty(rawColumnValue)
|
|
19
|
-
? Number(value[columnId])
|
|
20
|
-
: null;
|
|
21
|
-
const rawWeightedColumnValue = value[weightColumnId];
|
|
22
|
-
if (typeof rawWeightedColumnValue === 'object') {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const weightedColumnValue = StringExtensions_1.default.IsNotNullOrEmpty(rawWeightedColumnValue)
|
|
26
|
-
? Number(value[weightColumnId])
|
|
27
|
-
: null;
|
|
28
|
-
if (params.rowNode.leafGroup) {
|
|
29
|
-
if (weightedColumnValue !== null) {
|
|
30
|
-
weightedColumnValueSum += weightedColumnValue;
|
|
31
|
-
}
|
|
32
|
-
if (columnValue !== null && weightedColumnValue !== null) {
|
|
33
|
-
columnValueSum += weightedColumnValue * columnValue;
|
|
34
|
-
}
|
|
19
|
+
// TODO AFL: improve performance by using the intermediary aggregated values (for nested groups)
|
|
20
|
+
groupRowNode.allLeafChildren.forEach((rowNode) => {
|
|
21
|
+
// when editing values might be converted to strings
|
|
22
|
+
const rawColumnValue = gridApi.getValue(columnId, rowNode);
|
|
23
|
+
const columnValue = exports.getNumericValue(rawColumnValue);
|
|
24
|
+
const rawWeightedColumnValue = gridApi.getValue(weightColumnId, rowNode);
|
|
25
|
+
const weightedColumnValue = exports.getNumericValue(rawWeightedColumnValue);
|
|
26
|
+
if (weightedColumnValue !== null) {
|
|
27
|
+
weightedColumnValueSum += weightedColumnValue;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
weightedColumnValueSum += weightedColumnValue;
|
|
39
|
-
}
|
|
40
|
-
if (columnValue !== null) {
|
|
41
|
-
columnValueSum += columnValue;
|
|
42
|
-
}
|
|
29
|
+
if (columnValue !== null) {
|
|
30
|
+
columnValueSum += columnValue * weightedColumnValue;
|
|
43
31
|
}
|
|
44
32
|
});
|
|
45
33
|
return {
|
|
46
34
|
toString: () => {
|
|
47
|
-
const
|
|
35
|
+
const result = columnValueSum / weightedColumnValueSum;
|
|
48
36
|
// 0 / 0 = NaN
|
|
49
|
-
if (isNaN(
|
|
37
|
+
if (isNaN(result)) {
|
|
50
38
|
return '';
|
|
51
39
|
}
|
|
52
|
-
return
|
|
40
|
+
return result;
|
|
53
41
|
},
|
|
54
42
|
valueOf: () => {
|
|
55
|
-
const
|
|
43
|
+
const result = columnValueSum / weightedColumnValueSum;
|
|
56
44
|
// 0 / 0 = NaN
|
|
57
|
-
if (isNaN(
|
|
45
|
+
if (isNaN(result)) {
|
|
58
46
|
return 0;
|
|
59
47
|
}
|
|
60
|
-
return
|
|
48
|
+
return result;
|
|
61
49
|
},
|
|
62
50
|
[columnId]: columnValueSum,
|
|
63
51
|
[weightColumnId]: weightedColumnValueSum,
|
|
64
52
|
};
|
|
65
53
|
};
|
|
66
54
|
exports.weightedAverage = weightedAverage;
|
|
55
|
+
const cellSummaryWeightedAverage = ({ numericColumns, selectedCellInfo, adaptableApi, }) => {
|
|
56
|
+
if ((numericColumns === null || numericColumns === void 0 ? void 0 : numericColumns.length) != 1) {
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
const columnId = numericColumns[0];
|
|
60
|
+
const currentLayout = adaptableApi.layoutApi.getCurrentLayout();
|
|
61
|
+
const selectedColumnAgg = currentLayout.AggregationColumns[columnId];
|
|
62
|
+
if (!selectedColumnAgg ||
|
|
63
|
+
typeof selectedColumnAgg !== 'object' ||
|
|
64
|
+
selectedColumnAgg.type !== 'weightedAverage') {
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
const weightedColumnId = selectedColumnAgg.weightedColumnId;
|
|
68
|
+
if (weightedColumnId) {
|
|
69
|
+
let sumWeightedValue = 0;
|
|
70
|
+
let sumPrimaryValues = 0;
|
|
71
|
+
let isValid = true;
|
|
72
|
+
selectedCellInfo.gridCells.forEach((gridCell) => {
|
|
73
|
+
if (adaptableApi.gridApi.isGroupRowNode(gridCell.rowNode)) {
|
|
74
|
+
isValid = false;
|
|
75
|
+
}
|
|
76
|
+
if (isValid) {
|
|
77
|
+
const weightedGridCell = adaptableApi.gridApi.getGridCellFromRowNode(gridCell.rowNode, weightedColumnId);
|
|
78
|
+
sumWeightedValue += weightedGridCell.rawValue;
|
|
79
|
+
sumPrimaryValues += weightedGridCell.rawValue * gridCell.normalisedValue;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (isValid) {
|
|
83
|
+
const formatColumn = adaptableApi.formatColumnApi.getFormatColumnForColumnId(columnId);
|
|
84
|
+
if (formatColumn && formatColumn.DisplayFormat) {
|
|
85
|
+
const options = formatColumn.DisplayFormat
|
|
86
|
+
.Options;
|
|
87
|
+
if (options) {
|
|
88
|
+
return FormatHelper_1.default.NumberFormatter(sumPrimaryValues / sumWeightedValue, options);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return FormatHelper_1.default.NumberFormatter(sumPrimaryValues / sumWeightedValue, {
|
|
92
|
+
FractionDigits: 2,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.cellSummaryWeightedAverage = cellSummaryWeightedAverage;
|
|
@@ -3609,15 +3609,6 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
3609
3609
|
gridInfo: string;
|
|
3610
3610
|
defaultValue: string;
|
|
3611
3611
|
reference?: undefined;
|
|
3612
|
-
} | {
|
|
3613
|
-
name: string;
|
|
3614
|
-
kind: string;
|
|
3615
|
-
description: string;
|
|
3616
|
-
uiLabel: string;
|
|
3617
|
-
isOptional: boolean;
|
|
3618
|
-
gridInfo?: undefined;
|
|
3619
|
-
defaultValue?: undefined;
|
|
3620
|
-
reference?: undefined;
|
|
3621
3612
|
} | {
|
|
3622
3613
|
name: string;
|
|
3623
3614
|
kind: string;
|
|
@@ -4927,6 +4918,18 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
4927
4918
|
kind: string;
|
|
4928
4919
|
description: string;
|
|
4929
4920
|
};
|
|
4921
|
+
UnbalancedGroupsKeyContext: {
|
|
4922
|
+
name: string;
|
|
4923
|
+
kind: string;
|
|
4924
|
+
description: string;
|
|
4925
|
+
properties: {
|
|
4926
|
+
name: string;
|
|
4927
|
+
kind: string;
|
|
4928
|
+
description: string;
|
|
4929
|
+
uiLabel: string;
|
|
4930
|
+
reference: string;
|
|
4931
|
+
}[];
|
|
4932
|
+
};
|
|
4930
4933
|
UserInterfaceApi: {
|
|
4931
4934
|
name: string;
|
|
4932
4935
|
kind: string;
|
|
@@ -5032,11 +5035,5 @@ export declare const ADAPTABLE_METAMODEL: {
|
|
|
5032
5035
|
name: string;
|
|
5033
5036
|
kind: string;
|
|
5034
5037
|
description: string;
|
|
5035
|
-
properties: {
|
|
5036
|
-
name: string;
|
|
5037
|
-
kind: string;
|
|
5038
|
-
description: string;
|
|
5039
|
-
uiLabel: string;
|
|
5040
|
-
}[];
|
|
5041
5038
|
};
|
|
5042
5039
|
};
|