@veloceapps/sdk 3.0.14 → 3.0.16
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/veloce-sdk-cms.umd.js +93 -87
- package/bundles/veloce-sdk-cms.umd.js.map +1 -1
- package/bundles/veloce-sdk.umd.js +8 -6
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/cms/modules/flow-configuration/services/flow-configuration.service.d.ts +2 -2
- package/cms/modules/flow-configuration/services/flow-update.service.d.ts +4 -5
- package/esm2015/cms/modules/flow-configuration/services/flow-configuration.service.js +7 -5
- package/esm2015/cms/modules/flow-configuration/services/flow-update.service.js +74 -70
- package/esm2015/src/components/header/cart-overlay/cart-overlay.component.js +9 -7
- package/fesm2015/veloce-sdk-cms.js +78 -73
- package/fesm2015/veloce-sdk-cms.js.map +1 -1
- package/fesm2015/veloce-sdk.js +8 -6
- package/fesm2015/veloce-sdk.js.map +1 -1
- package/package.json +1 -1
|
@@ -1792,18 +1792,36 @@
|
|
|
1792
1792
|
var FlowUpdateService = /** @class */ (function () {
|
|
1793
1793
|
function FlowUpdateService() {
|
|
1794
1794
|
}
|
|
1795
|
-
FlowUpdateService.prototype.update = function (
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1795
|
+
FlowUpdateService.prototype.update = function (rootLineItems, updates) {
|
|
1796
|
+
var _this = this;
|
|
1797
|
+
var remainingUpdates = __spreadArray([], __read(updates));
|
|
1798
|
+
var currentLevel = rootLineItems;
|
|
1799
|
+
while (currentLevel.length && remainingUpdates.length) {
|
|
1800
|
+
currentLevel.forEach(function (li) {
|
|
1801
|
+
var unhandledUpdates = [];
|
|
1802
|
+
remainingUpdates.forEach(function (update) {
|
|
1803
|
+
var updated = false;
|
|
1804
|
+
switch (update.dataType) {
|
|
1805
|
+
case 'LINEITEM':
|
|
1806
|
+
updated = _this.applyLineItemUpdate(li, update);
|
|
1807
|
+
break;
|
|
1808
|
+
case 'CHARGE':
|
|
1809
|
+
updated = _this.applyChargeUpdate(li, update);
|
|
1810
|
+
break;
|
|
1811
|
+
case 'GROUP_CHARGE':
|
|
1812
|
+
updated = _this.applyChargeGroupUpdate(li, update);
|
|
1813
|
+
break;
|
|
1814
|
+
default:
|
|
1815
|
+
// Unknown dataType. Do not try to handle it anymore
|
|
1816
|
+
updated = true;
|
|
1817
|
+
}
|
|
1818
|
+
if (!updated) {
|
|
1819
|
+
unhandledUpdates.push(update);
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
remainingUpdates = unhandledUpdates;
|
|
1823
|
+
});
|
|
1824
|
+
currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
|
|
1807
1825
|
}
|
|
1808
1826
|
};
|
|
1809
1827
|
FlowUpdateService.prototype.delete = function (lineItems, id) {
|
|
@@ -1823,77 +1841,64 @@
|
|
|
1823
1841
|
var filtered = lineItems.filter(function (lineItem) { return !idsToRemove.includes(lineItem.id); });
|
|
1824
1842
|
return filtered.map(function (lineItem) { return new LineItemWorker(lineItem).remove(id).li; });
|
|
1825
1843
|
};
|
|
1826
|
-
FlowUpdateService.prototype.
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
var
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
return
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
else if (params.dataType === 'CHARGE') {
|
|
1885
|
-
updated = Object.assign(Object.assign({}, lineItem), { chargeItems: lineItem.chargeItems.map(function (chargeItem) {
|
|
1886
|
-
return chargeItem.id === params.id ? Object.assign(Object.assign({}, chargeItem), { priceAdjustment: params.newValue }) : chargeItem;
|
|
1887
|
-
}) });
|
|
1888
|
-
}
|
|
1889
|
-
else if (params.dataType === 'GROUP_CHARGE') {
|
|
1890
|
-
updated = Object.assign(Object.assign({}, lineItem), { chargeGroupItems: lineItem.chargeGroupItems.map(function (chargeGroupItem) {
|
|
1891
|
-
return chargeGroupItem.id === params.id
|
|
1892
|
-
? Object.assign(Object.assign({}, chargeGroupItem), { priceAdjustment: params.newValue }) : chargeGroupItem;
|
|
1893
|
-
}) });
|
|
1894
|
-
}
|
|
1895
|
-
var updatedRootLineItem = updated ? new LineItemWorker(rootLineItem).replace(updated).li : rootLineItem;
|
|
1896
|
-
return updatedRootLineItem;
|
|
1844
|
+
FlowUpdateService.prototype.applyLineItemUpdate = function (lineItem, update) {
|
|
1845
|
+
if (lineItem.id !== update.id) {
|
|
1846
|
+
return false;
|
|
1847
|
+
}
|
|
1848
|
+
switch (update.attributeType) {
|
|
1849
|
+
case 'QTY':
|
|
1850
|
+
lineItem.qty = update.newValue;
|
|
1851
|
+
break;
|
|
1852
|
+
case 'EFFECTIVE_START_DATE':
|
|
1853
|
+
lineItem.effectiveStartDate = moment__default["default"](update.newValue).format('YYYY-MM-DD');
|
|
1854
|
+
break;
|
|
1855
|
+
case 'END_DATE':
|
|
1856
|
+
lineItem.endDate = moment__default["default"](update.newValue).format('YYYY-MM-DD');
|
|
1857
|
+
break;
|
|
1858
|
+
case 'PRICE_ADJUSTMENT':
|
|
1859
|
+
{
|
|
1860
|
+
var _a = __read(lineItem.chargeItems, 1), charge = _a[0];
|
|
1861
|
+
if (charge) {
|
|
1862
|
+
charge.priceAdjustment = update.newValue;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
break;
|
|
1866
|
+
default:
|
|
1867
|
+
throw new Error("Not suppored AttributeType for LineItem update: " + update.attributeType);
|
|
1868
|
+
}
|
|
1869
|
+
return true;
|
|
1870
|
+
};
|
|
1871
|
+
FlowUpdateService.prototype.applyChargeUpdate = function (lineItem, update) {
|
|
1872
|
+
var foundCharge = lineItem.chargeItems.find(function (_a) {
|
|
1873
|
+
var id = _a.id;
|
|
1874
|
+
return id === update.id;
|
|
1875
|
+
});
|
|
1876
|
+
if (!foundCharge) {
|
|
1877
|
+
return false;
|
|
1878
|
+
}
|
|
1879
|
+
if (update.attributeType === 'PRICE_ADJUSTMENT') {
|
|
1880
|
+
foundCharge.priceAdjustment = update.newValue;
|
|
1881
|
+
}
|
|
1882
|
+
else {
|
|
1883
|
+
throw new Error("Not suppored AttributeType for Charge Item update: " + update.attributeType);
|
|
1884
|
+
}
|
|
1885
|
+
return true;
|
|
1886
|
+
};
|
|
1887
|
+
FlowUpdateService.prototype.applyChargeGroupUpdate = function (lineItem, update) {
|
|
1888
|
+
var foundChargeGroup = lineItem.chargeGroupItems.find(function (_a) {
|
|
1889
|
+
var id = _a.id;
|
|
1890
|
+
return id === update.id;
|
|
1891
|
+
});
|
|
1892
|
+
if (!foundChargeGroup) {
|
|
1893
|
+
return false;
|
|
1894
|
+
}
|
|
1895
|
+
if (update.attributeType === 'PRICE_ADJUSTMENT') {
|
|
1896
|
+
foundChargeGroup.priceAdjustment = update.newValue;
|
|
1897
|
+
}
|
|
1898
|
+
else {
|
|
1899
|
+
throw new Error("Not suppored AttributeType for Charge Group Item update: " + update.attributeType);
|
|
1900
|
+
}
|
|
1901
|
+
return true;
|
|
1897
1902
|
};
|
|
1898
1903
|
return FlowUpdateService;
|
|
1899
1904
|
}());
|
|
@@ -1930,12 +1935,13 @@
|
|
|
1930
1935
|
FlowConfigurationService.prototype.calculate = function (currentState) {
|
|
1931
1936
|
this.calculate$(currentState).subscribe();
|
|
1932
1937
|
};
|
|
1933
|
-
FlowConfigurationService.prototype.update$ = function (
|
|
1938
|
+
FlowConfigurationService.prototype.update$ = function (updates) {
|
|
1934
1939
|
var _this = this;
|
|
1935
|
-
|
|
1940
|
+
var lineItems = lodash.cloneDeep(this.lineItems.value);
|
|
1941
|
+
return rxjs.of([]).pipe(rxjs.tap(function () { return _this.updateService.update(lineItems, updates); }), this.handleError(), rxjs.switchMap(function () { return _this.calculate$(lineItems); }));
|
|
1936
1942
|
};
|
|
1937
|
-
FlowConfigurationService.prototype.update = function (
|
|
1938
|
-
this.update$(
|
|
1943
|
+
FlowConfigurationService.prototype.update = function (updates) {
|
|
1944
|
+
this.update$(updates).subscribe();
|
|
1939
1945
|
};
|
|
1940
1946
|
FlowConfigurationService.prototype.delete$ = function (ids) {
|
|
1941
1947
|
var _this = this;
|