@contrail/data-grouping 1.0.14 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,14 +12,17 @@ class DataGroupGenerator {
|
|
12
12
|
}
|
13
13
|
let key = util_1.ObjectUtil.getByPath(obj, index);
|
14
14
|
let value = key;
|
15
|
+
if (!value) {
|
16
|
+
return;
|
17
|
+
}
|
15
18
|
if (key && value && typeof key === 'object') {
|
16
19
|
key = value.id || value.name || value;
|
17
20
|
}
|
18
21
|
map[key] = value;
|
19
22
|
});
|
20
23
|
const distinctValues = [...(Object.values(map))].sort((v1, v2) => {
|
21
|
-
let val1 = (typeof v1 === 'object') ? v1.name : v1;
|
22
|
-
let val2 = (typeof v2 === 'object') ? v2.name : v2;
|
24
|
+
let val1 = (v1 && typeof v1 === 'object') ? v1.name : v1;
|
25
|
+
let val2 = (v2 && typeof v2 === 'object') ? v2.name : v2;
|
23
26
|
return val1 > val2 ? 1 : -1;
|
24
27
|
});
|
25
28
|
return distinctValues;
|
@@ -33,10 +36,10 @@ class DataGroupGenerator {
|
|
33
36
|
const group = {
|
34
37
|
data: [],
|
35
38
|
subGroups: [],
|
36
|
-
|
39
|
+
propertyValues: {},
|
37
40
|
name: ''
|
38
41
|
};
|
39
|
-
group.
|
42
|
+
group.propertyValues[groupingProperty.property.slug] = val;
|
40
43
|
const label = new types_1.PropertyValueFormatter().formatValueForProperty(val, groupingProperty.property);
|
41
44
|
group.name = label;
|
42
45
|
if (currentDepth === groupingProperties.length - 1) {
|
@@ -53,7 +56,7 @@ class DataGroupGenerator {
|
|
53
56
|
rootGroup: {
|
54
57
|
subGroups: [],
|
55
58
|
name: "root",
|
56
|
-
|
59
|
+
propertyValues: {},
|
57
60
|
data: [],
|
58
61
|
},
|
59
62
|
groupingProperties,
|
@@ -74,7 +77,7 @@ class DataGroupGenerator {
|
|
74
77
|
data: groupData,
|
75
78
|
subGroups: [],
|
76
79
|
name: parentGroup.name,
|
77
|
-
|
80
|
+
propertyValues: parentGroup.propertyValues,
|
78
81
|
};
|
79
82
|
groups.push(group);
|
80
83
|
}
|
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,6 +14,12 @@ 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;
|
package/package.json
CHANGED