@veloceapps/sdk 6.0.0-26 → 6.0.0-28
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.
- package/bundles/veloceapps-sdk-core.umd.js +48 -1
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
- package/cms/vendor-map.d.ts +1 -0
- package/core/utils/line-item.utils.d.ts +1 -0
- package/esm2015/core/utils/line-item.utils.js +17 -2
- package/fesm2015/veloceapps-sdk-core.js +18 -2
- package/fesm2015/veloceapps-sdk-core.js.map +1 -1
- package/package.json +1 -1
@@ -666,7 +666,7 @@
|
|
666
666
|
};
|
667
667
|
var replaceLineItem = function (lineItem, replaceTo) {
|
668
668
|
if (lineItem.id === replaceTo.id) {
|
669
|
-
return Object.assign({}, replaceTo);
|
669
|
+
return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
|
670
670
|
}
|
671
671
|
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
|
672
672
|
if (li.id === replaceTo.id) {
|
@@ -678,6 +678,51 @@
|
|
678
678
|
return li;
|
679
679
|
}) });
|
680
680
|
};
|
681
|
+
var recalculateCardinalityVariables = function (original, updated) {
|
682
|
+
var e_1, _c, _d, e_2, _e;
|
683
|
+
var _a;
|
684
|
+
var cardinalityVariables = {};
|
685
|
+
try {
|
686
|
+
for (var _f = __values(updated.lineItems), _g = _f.next(); !_g.done; _g = _f.next()) {
|
687
|
+
var li = _g.value;
|
688
|
+
var cardinalityVariableName = "#CV-" + li.type + "@" + li.port;
|
689
|
+
cardinalityVariables = Object.assign(Object.assign({}, cardinalityVariables), (_d = {}, _d[cardinalityVariableName] = ((_a = cardinalityVariables[cardinalityVariableName]) !== null && _a !== void 0 ? _a : 0) + li.qty, _d));
|
690
|
+
}
|
691
|
+
}
|
692
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
693
|
+
finally {
|
694
|
+
try {
|
695
|
+
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
|
696
|
+
}
|
697
|
+
finally { if (e_1) throw e_1.error; }
|
698
|
+
}
|
699
|
+
var _loop_1 = function (li) {
|
700
|
+
if (updated.lineItems.some(function (_c) {
|
701
|
+
var id = _c.id, qty = _c.qty;
|
702
|
+
return li.id === id && li.qty === qty;
|
703
|
+
})) {
|
704
|
+
var cardinalityVariableName = "#CV-" + li.type + "@" + li.port;
|
705
|
+
delete cardinalityVariables[cardinalityVariableName];
|
706
|
+
}
|
707
|
+
};
|
708
|
+
try {
|
709
|
+
for (var _h = __values(original.lineItems), _j = _h.next(); !_j.done; _j = _h.next()) {
|
710
|
+
var li = _j.value;
|
711
|
+
_loop_1(li);
|
712
|
+
}
|
713
|
+
}
|
714
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
715
|
+
finally {
|
716
|
+
try {
|
717
|
+
if (_j && !_j.done && (_e = _h.return)) _e.call(_h);
|
718
|
+
}
|
719
|
+
finally { if (e_2) throw e_2.error; }
|
720
|
+
}
|
721
|
+
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, Object.entries(cardinalityVariables).map(function (_c) {
|
722
|
+
var _d = __read(_c, 2), name = _d[0], value = _d[1];
|
723
|
+
return ({ name: name, value: value });
|
724
|
+
})) });
|
725
|
+
};
|
681
726
|
var mapAttributes = function (attributes) {
|
682
727
|
return attributes.reduce(function (acc, _c) {
|
683
728
|
var _d;
|
@@ -766,6 +811,7 @@
|
|
766
811
|
insertLineItem: insertLineItem,
|
767
812
|
removeLineItem: removeLineItem,
|
768
813
|
replaceLineItem: replaceLineItem,
|
814
|
+
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
769
815
|
mapAttributes: mapAttributes,
|
770
816
|
getAttributes: getAttributes,
|
771
817
|
upsertAttributes: upsertAttributes,
|
@@ -1845,6 +1891,7 @@
|
|
1845
1891
|
exports.mapAttributes = mapAttributes;
|
1846
1892
|
exports.multiplyLineItems = multiplyLineItems;
|
1847
1893
|
exports.patchAttributes = patchAttributes;
|
1894
|
+
exports.recalculateCardinalityVariables = recalculateCardinalityVariables;
|
1848
1895
|
exports.removeLineItem = removeLineItem;
|
1849
1896
|
exports.replaceLineItem = replaceLineItem;
|
1850
1897
|
exports.upsertAttributes = upsertAttributes;
|