@contrail/data-grouping 1.0.22 → 1.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ const types_1 = require("@contrail/types");
6
6
  class DataGroupGenerator {
7
7
  static getDistinctValues(data, index, altIndex = null, groupMultiSelectInSeparateFrame = false) {
8
8
  const map = new Map();
9
+ const sortingArray = [];
9
10
  data.forEach(obj => {
10
11
  if (!obj) {
11
12
  return;
@@ -28,16 +29,22 @@ class DataGroupGenerator {
28
29
  if (Array.isArray(value) && !groupMultiSelectInSeparateFrame) {
29
30
  value.forEach(arrayValue => {
30
31
  map[arrayValue] = arrayValue;
32
+ if (!sortingArray.includes(arrayValue)) {
33
+ sortingArray.push(arrayValue);
34
+ }
31
35
  });
32
36
  }
33
37
  else {
34
38
  map[key] = value;
39
+ if (!sortingArray.includes(value)) {
40
+ sortingArray.push(value);
41
+ }
35
42
  }
36
43
  });
37
44
  const distinctValues = [...(Object.values(map))].sort((v1, v2) => {
38
45
  let val1 = (v1 && typeof v1 === 'object') ? v1.name : v1;
39
46
  let val2 = (v2 && typeof v2 === 'object') ? v2.name : v2;
40
- return val1 > val2 ? 1 : -1;
47
+ return sortingArray.indexOf(val1) - sortingArray.indexOf(val2);
41
48
  });
42
49
  return distinctValues;
43
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/data-grouping",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
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",