@contrail/data-grouping 1.0.32 → 1.0.34

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.
@@ -9,7 +9,7 @@ class DataGroupGenerator {
9
9
  const options = (sort === null || sort === void 0 ? void 0 : sort.options) || null;
10
10
  const map = new Map();
11
11
  const sortingArray = [];
12
- data.forEach((obj) => {
12
+ data.forEach(obj => {
13
13
  if (!obj) {
14
14
  return;
15
15
  }
@@ -29,7 +29,7 @@ class DataGroupGenerator {
29
29
  key = value.id || value.name || value;
30
30
  }
31
31
  if (Array.isArray(value) && !groupMultiSelectInSeparateFrame) {
32
- value.forEach((arrayValue) => {
32
+ value.forEach(arrayValue => {
33
33
  map[arrayValue] = arrayValue;
34
34
  if (!sortingArray.includes(arrayValue)) {
35
35
  sortingArray.push(arrayValue);
@@ -45,13 +45,13 @@ class DataGroupGenerator {
45
45
  });
46
46
  const distinctValues = [...Object.values(map)];
47
47
  distinctValues.sort((v1, v2) => {
48
- const val1 = v1 && typeof v1 === 'object' ? v1.name : v1;
49
- const val2 = v2 && typeof v2 === 'object' ? v2.name : v2;
48
+ const val1 = v1 && typeof v1 === 'object' ? v1.name.toLowerCase() : String(v1).toLowerCase();
49
+ const val2 = v2 && typeof v2 === 'object' ? v2.name.toLowerCase() : String(v2).toLowerCase();
50
50
  switch (sortKey) {
51
51
  case 'asc':
52
- return val1 > val2 ? 1 : -1;
52
+ return val1 > val2 ? 1 : val1 < val2 ? -1 : 0;
53
53
  case 'desc':
54
- return val1 < val2 ? 1 : -1;
54
+ return val1 < val2 ? 1 : val1 > val2 ? -1 : 0;
55
55
  case 'list_order_asc':
56
56
  return options.indexOf(val1) - options.indexOf(val2);
57
57
  case 'list_order_desc':
@@ -70,10 +70,10 @@ class DataGroupGenerator {
70
70
  const rootAltIndex = util_1.StringUtil.convertToCamelCase(groupingProperty.typeRootSlug);
71
71
  const slugAltIndex = groupingProperty.propertyDefinition.slug;
72
72
  const sort = groupingProperty.sort || 'asc';
73
- const options = ((_b = (_a = groupingProperty.propertyDefinition) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.map((x) => x.value)) || null;
73
+ const options = ((_b = (_a = groupingProperty.propertyDefinition) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.map(x => x.value)) || null;
74
74
  let distinctValues = this.getDistinctValues(data, rootIndex, slugIndex, rootAltIndex, slugAltIndex, groupMultiSelectInSeparateFrame, { sortKey: sort, options });
75
75
  for (let val of distinctValues) {
76
- const groupData = data.filter((obj) => {
76
+ const groupData = data.filter(obj => {
77
77
  const objVal = util_1.ObjectUtil.getBySlugs(obj, rootIndex, slugIndex) || util_1.ObjectUtil.getBySlugs(obj, rootAltIndex, slugAltIndex);
78
78
  if (Array.isArray(val) && Array.isArray(objVal)) {
79
79
  return val.sort().join() === objVal.sort().join();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/data-grouping",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
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",