@contrail/data-grouping 1.0.37 → 1.0.39
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 = (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.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
|
}
|
@@ -34,7 +34,7 @@ class DataGroupGenerator {
|
|
34
34
|
key = value.id || value.name || value;
|
35
35
|
}
|
36
36
|
if (Array.isArray(value) && !groupMultiSelectInSeparateFrame) {
|
37
|
-
value.forEach(arrayValue => {
|
37
|
+
value.forEach((arrayValue) => {
|
38
38
|
map[arrayValue] = arrayValue;
|
39
39
|
if (!sortingArray.includes(arrayValue)) {
|
40
40
|
sortingArray.push(arrayValue);
|
@@ -56,15 +56,17 @@ class DataGroupGenerator {
|
|
56
56
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
57
57
|
const val1 = v1 && typeof v1 === 'object' ? (_a = v1 === null || v1 === void 0 ? void 0 : v1.name) === null || _a === void 0 ? void 0 : _a.toLowerCase() : (_b = String(v1)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
58
58
|
const val2 = v2 && typeof v2 === 'object' ? (_c = v2 === null || v2 === void 0 ? void 0 : v2.name) === null || _c === void 0 ? void 0 : _c.toLowerCase() : (_d = String(v2)) === null || _d === void 0 ? void 0 : _d.toLowerCase();
|
59
|
+
const rawVal1 = v1 && typeof v1 === 'object' ? v1.name : String(v1);
|
60
|
+
const rawVal2 = v2 && typeof v2 === 'object' ? v2.name : String(v2);
|
59
61
|
switch (sortOrder) {
|
60
|
-
case
|
62
|
+
case types_1.TypePropertySortOrder.ASCENDING:
|
61
63
|
return val1 > val2 ? 1 : val1 < val2 ? -1 : 0;
|
62
|
-
case
|
64
|
+
case types_1.TypePropertySortOrder.DESCENDING:
|
63
65
|
return val1 < val2 ? 1 : val1 > val2 ? -1 : 0;
|
64
|
-
case
|
65
|
-
return ((_e = optionsMap.get(
|
66
|
-
case
|
67
|
-
return ((_g = optionsMap.get(
|
66
|
+
case types_1.TypePropertySortOrder.LIST_ORDER_ASCENDING:
|
67
|
+
return ((_e = optionsMap.get(rawVal1)) !== null && _e !== void 0 ? _e : 0) - ((_f = optionsMap.get(rawVal2)) !== null && _f !== void 0 ? _f : 0);
|
68
|
+
case types_1.TypePropertySortOrder.LIST_ORDER_DESCENDING:
|
69
|
+
return ((_g = optionsMap.get(rawVal2)) !== null && _g !== void 0 ? _g : 0) - ((_h = optionsMap.get(rawVal1)) !== null && _h !== void 0 ? _h : 0);
|
68
70
|
default:
|
69
71
|
return sortingArray.indexOf(val1) - sortingArray.indexOf(val2);
|
70
72
|
}
|
@@ -80,10 +82,10 @@ class DataGroupGenerator {
|
|
80
82
|
const rootAltIndex = util_1.StringUtil.convertToCamelCase(groupingProperty.typeRootSlug);
|
81
83
|
const slugAltIndex = groupingProperty.propertyDefinition.slug;
|
82
84
|
const sort = groupingProperty.sort || types_1.TypePropertySortOrder.ASCENDING;
|
83
|
-
const options = ((_c = (_b = groupingProperty.propertyDefinition) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.map(x => x.value)) || null;
|
85
|
+
const options = ((_c = (_b = groupingProperty.propertyDefinition) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.map((x) => x.value)) || null;
|
84
86
|
let distinctValues = this.getDistinctValues(data, rootIndex, slugIndex, rootAltIndex, slugAltIndex, groupMultiSelectInSeparateFrame, { sortOrder: sort, options }, isDateProperty);
|
85
87
|
for (let val of distinctValues) {
|
86
|
-
const groupData = data.filter(obj => {
|
88
|
+
const groupData = data.filter((obj) => {
|
87
89
|
const objVal = util_1.ObjectUtil.getBySlugs(obj, rootIndex, slugIndex) || util_1.ObjectUtil.getBySlugs(obj, rootAltIndex, slugAltIndex);
|
88
90
|
if (isDateProperty) {
|
89
91
|
const objDate = new Date(objVal).toISOString().split('T')[0];
|
package/package.json
CHANGED