@contrail/util 1.0.44 → 1.0.46
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.
|
@@ -33,8 +33,8 @@ function areItemPropertyValuesEqual(property, itemOne, itemTwo) {
|
|
|
33
33
|
const propertyValueOne = itemOne[propertyKey];
|
|
34
34
|
const propertyValueTwo = itemTwo[propertyKey];
|
|
35
35
|
if (property.propertyType === types_1.PropertyType.MultiSelect) {
|
|
36
|
-
const propertyValueOneAsArray =
|
|
37
|
-
const propertyValueTwoAsArray =
|
|
36
|
+
const propertyValueOneAsArray = getMultiSelectValueAsArray(propertyValueOne);
|
|
37
|
+
const propertyValueTwoAsArray = getMultiSelectValueAsArray(propertyValueTwo);
|
|
38
38
|
return areArraysEqualIgnoreOrder(propertyValueOneAsArray, propertyValueTwoAsArray);
|
|
39
39
|
}
|
|
40
40
|
if (property.propertyType === types_1.PropertyType.SizeRange) {
|
|
@@ -58,10 +58,7 @@ function areSizeRangesEqual(sizeRangeOne, sizeRangeTwo) {
|
|
|
58
58
|
return result.length === 0;
|
|
59
59
|
}
|
|
60
60
|
function areArraysEqualIgnoreOrder(arrayOne, arrayTwo) {
|
|
61
|
-
if (
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if ((arrayOne === null || arrayOne === void 0 ? void 0 : arrayOne.length) !== (arrayTwo === null || arrayTwo === void 0 ? void 0 : arrayTwo.length)) {
|
|
61
|
+
if (arrayOne.length !== arrayTwo.length) {
|
|
65
62
|
return false;
|
|
66
63
|
}
|
|
67
64
|
const sortedArray1 = arrayOne.slice().sort();
|
|
@@ -75,3 +72,13 @@ function getPropertyKey(property) {
|
|
|
75
72
|
}
|
|
76
73
|
return property.slug;
|
|
77
74
|
}
|
|
75
|
+
function getMultiSelectValueAsArray(multiSelectValue) {
|
|
76
|
+
if (!multiSelectValue)
|
|
77
|
+
return [];
|
|
78
|
+
if (typeof multiSelectValue === 'string') {
|
|
79
|
+
if (multiSelectValue.trim().length === 0)
|
|
80
|
+
return [];
|
|
81
|
+
return multiSelectValue.split(',');
|
|
82
|
+
}
|
|
83
|
+
return multiSelectValue;
|
|
84
|
+
}
|
|
@@ -37,13 +37,16 @@ function getObjectDiffs(before, after, prefix) {
|
|
|
37
37
|
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
else if (Array.isArray(beforeVal)) {
|
|
40
|
+
else if (Array.isArray(beforeVal) && Array.isArray(afterVal)) {
|
|
41
41
|
const beforeArray = [...beforeVal].sort(sortFunc);
|
|
42
42
|
const afterArray = [...afterVal].sort(sortFunc);
|
|
43
43
|
if (JSON.stringify(beforeArray) !== JSON.stringify(afterArray)) {
|
|
44
44
|
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
else if (Array.isArray(beforeVal) && !Array.isArray(afterVal)) {
|
|
48
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
49
|
+
}
|
|
47
50
|
else {
|
|
48
51
|
const nestedObjectDiffs = getObjectDiffs(beforeVal, afterVal, prefix + commonProperty + '.');
|
|
49
52
|
diffs.push(...nestedObjectDiffs);
|