@contrail/data-grouping 1.0.16 → 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,6 +31,7 @@ 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 = {
|
@@ -39,7 +40,13 @@ class DataGroupGenerator {
|
|
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,7 +58,7 @@ 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: [],
|
package/lib/interfaces.d.ts
CHANGED
package/package.json
CHANGED