@contrail/data-grouping 1.0.15 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,6 @@ import { DataGroup, DataGroupStructure, DataGroupingProperty } from "../interfac
|
|
2
2
|
export declare class DataGroupGenerator {
|
3
3
|
static getDistinctValues(data: any, index: any): any[];
|
4
4
|
static buildChildDataGroups(data: any, parentGroup: DataGroup, groupingProperties: Array<DataGroupingProperty>, leafNodeDataCount: any, currentDepth: any): void;
|
5
|
-
static buildDataGroupStructure(data: Array<any>, groupingProperties: Array<DataGroupingProperty>, leafNodeDataCount: number
|
5
|
+
static buildDataGroupStructure(data: Array<any>, groupingProperties: Array<DataGroupingProperty>, leafNodeDataCount: number): DataGroupStructure;
|
6
6
|
static createPartitionedGroupsFromData(parentGroup: DataGroup, data: Array<any>, leafNodeDataCount: number): Array<DataGroup>;
|
7
7
|
}
|
@@ -31,15 +31,22 @@ class DataGroupGenerator {
|
|
31
31
|
const groupingProperty = groupingProperties[currentDepth];
|
32
32
|
const index = groupingProperty.scope + "." + groupingProperty.property.slug;
|
33
33
|
const distinctValues = this.getDistinctValues(data, index);
|
34
|
+
console.log("distinctValues: ", distinctValues);
|
34
35
|
for (let val of distinctValues) {
|
35
36
|
const groupData = data.filter(obj => util_1.ObjectUtil.getByPath(obj, index) === val);
|
36
37
|
const group = {
|
37
38
|
data: [],
|
38
39
|
subGroups: [],
|
39
|
-
|
40
|
+
propertyValues: {},
|
40
41
|
name: ''
|
41
42
|
};
|
42
|
-
|
43
|
+
if (groupingProperty.scopeIdentityProperty === true && groupData.length) {
|
44
|
+
const details = groupData[0][groupingProperty.scope];
|
45
|
+
group.propertyValues = Object.assign({}, details);
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
group.propertyValues[groupingProperty.property.slug] = val;
|
49
|
+
}
|
43
50
|
const label = new types_1.PropertyValueFormatter().formatValueForProperty(val, groupingProperty.property);
|
44
51
|
group.name = label;
|
45
52
|
if (currentDepth === groupingProperties.length - 1) {
|
@@ -51,12 +58,12 @@ class DataGroupGenerator {
|
|
51
58
|
parentGroup.subGroups.push(group);
|
52
59
|
}
|
53
60
|
}
|
54
|
-
static buildDataGroupStructure(data, groupingProperties, leafNodeDataCount
|
61
|
+
static buildDataGroupStructure(data, groupingProperties, leafNodeDataCount) {
|
55
62
|
const structure = {
|
56
63
|
rootGroup: {
|
57
64
|
subGroups: [],
|
58
65
|
name: "root",
|
59
|
-
|
66
|
+
propertyValues: {},
|
60
67
|
data: [],
|
61
68
|
},
|
62
69
|
groupingProperties,
|
@@ -77,7 +84,7 @@ class DataGroupGenerator {
|
|
77
84
|
data: groupData,
|
78
85
|
subGroups: [],
|
79
86
|
name: parentGroup.name,
|
80
|
-
|
87
|
+
propertyValues: parentGroup.propertyValues,
|
81
88
|
};
|
82
89
|
groups.push(group);
|
83
90
|
}
|
package/lib/interfaces.d.ts
CHANGED
@@ -2,7 +2,10 @@ import { TypeProperty } from "@contrail/types";
|
|
2
2
|
export interface DataGroup {
|
3
3
|
subGroups: Array<DataGroup>;
|
4
4
|
name: string;
|
5
|
-
|
5
|
+
propertyValues: {
|
6
|
+
[key: string]: any;
|
7
|
+
};
|
8
|
+
aggregateValues?: {
|
6
9
|
[key: string]: any;
|
7
10
|
};
|
8
11
|
data: Array<any>;
|
@@ -11,10 +14,17 @@ export interface DataGroupStructure {
|
|
11
14
|
rootGroup: DataGroup;
|
12
15
|
depth: number;
|
13
16
|
groupingProperties: Array<DataGroupingProperty>;
|
17
|
+
aggregationProperties?: Array<DataGroupingProperty>;
|
18
|
+
sourceDataDefinition?: {
|
19
|
+
sourceDataReference: string;
|
20
|
+
filterDefinition?: any;
|
21
|
+
sortDefinition?: any;
|
22
|
+
};
|
14
23
|
}
|
15
24
|
export interface DataGroupingProperty {
|
16
25
|
property: TypeProperty;
|
17
26
|
values?: Array<string>;
|
18
27
|
scope: string;
|
19
28
|
sort: string;
|
29
|
+
scopeIdentityProperty?: boolean;
|
20
30
|
}
|
package/package.json
CHANGED