@contrail/data-grouping 1.0.17 → 1.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,9 +29,8 @@ class DataGroupGenerator {
29
29
  }
30
30
  static buildChildDataGroups(data, parentGroup, groupingProperties, leafNodeDataCount, currentDepth) {
31
31
  const groupingProperty = groupingProperties[currentDepth];
32
- const index = groupingProperty.scope + "." + groupingProperty.property.slug;
32
+ const index = groupingProperty.typeRootSlug + "." + groupingProperty.propertyDefinition.slug;
33
33
  const distinctValues = this.getDistinctValues(data, index);
34
- console.log("distinctValues: ", distinctValues);
35
34
  for (let val of distinctValues) {
36
35
  const groupData = data.filter(obj => util_1.ObjectUtil.getByPath(obj, index) === val);
37
36
  const group = {
@@ -40,14 +39,12 @@ class DataGroupGenerator {
40
39
  propertyValues: {},
41
40
  name: ''
42
41
  };
43
- if (groupingProperty.scopeIdentityProperty === true && groupData.length) {
44
- const details = groupData[0][groupingProperty.scope];
42
+ if (groupData.length > 0) {
43
+ const details = groupData[0];
45
44
  group.propertyValues = Object.assign({}, details);
46
45
  }
47
- else {
48
- group.propertyValues[groupingProperty.property.slug] = val;
49
- }
50
- const label = new types_1.PropertyValueFormatter().formatValueForProperty(val, groupingProperty.property);
46
+ group.propertyValues[groupingProperty.propertyDefinition.slug] = val;
47
+ const label = new types_1.PropertyValueFormatter().formatValueForProperty(val, groupingProperty.propertyDefinition);
51
48
  group.name = label;
52
49
  if (currentDepth === groupingProperties.length - 1) {
53
50
  group.subGroups = this.createPartitionedGroupsFromData(group, groupData, leafNodeDataCount);
@@ -22,9 +22,8 @@ export interface DataGroupStructure {
22
22
  };
23
23
  }
24
24
  export interface DataGroupingProperty {
25
- property: TypeProperty;
25
+ propertyDefinition: TypeProperty;
26
26
  values?: Array<string>;
27
- scope: string;
27
+ typeRootSlug: string;
28
28
  sort: string;
29
- scopeIdentityProperty?: boolean;
30
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/data-grouping",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Utilities and interfaces for grouping data into hierarchial data structures based on properties.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",