@crystaldesign/product-handler 24.13.0-beta.13 → 24.13.0-beta.14
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/build/esm/index.js
CHANGED
|
@@ -758,49 +758,55 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
758
758
|
*/
|
|
759
759
|
}, {
|
|
760
760
|
key: "saveProductMedia",
|
|
761
|
-
value: function saveProductMedia(productmedia, organizationId) {
|
|
761
|
+
value: function saveProductMedia(productmedia, organizationId, refCount) {
|
|
762
762
|
return Promise.resolve(undefined);
|
|
763
763
|
}
|
|
764
|
+
}, {
|
|
765
|
+
key: "saveMedias",
|
|
766
|
+
value: function saveMedias(mediasToSave, organizationId) {
|
|
767
|
+
return Promise.resolve({});
|
|
768
|
+
}
|
|
764
769
|
}, {
|
|
765
770
|
key: "prepareData",
|
|
766
771
|
value: function () {
|
|
767
772
|
var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref12) {
|
|
768
773
|
var _this3 = this;
|
|
769
|
-
var basket, baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref12$oldClassificat, oldClassificationData, originProductId, products, originProduct, sapEinaLifNr, sapEineEkgrp, result, _this$closeModal, _originProduct$percen, _originProduct$discou, _baseData$variantId, _originProduct$create, _originProduct$create2, _originProduct$create3, baseProduct, j, mediaRef, _this$openModal, _this$t, _j, _this$openModal2, _this$t2,
|
|
770
|
-
return _regeneratorRuntime.wrap(function _callee3$(
|
|
771
|
-
while (1) switch (
|
|
774
|
+
var basket, baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref12$oldClassificat, oldClassificationData, originProductId, products, originProduct, mediasToSave, sapEinaLifNr, sapEineEkgrp, result, _this$closeModal, _originProduct$percen, _originProduct$discou, _baseData$variantId, _originProduct$create, _originProduct$create2, _originProduct$create3, baseProduct, j, mediaRef, _this$openModal, _this$t, _j, _this$openModal2, _this$t2, _loop, _j2, mediasForProducts, _loop2, productId;
|
|
775
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context5) {
|
|
776
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
772
777
|
case 0:
|
|
773
778
|
basket = _ref12.basket, baseData = _ref12.baseData, classificationData = _ref12.classificationData, variantData = _ref12.variantData, removedProducts = _ref12.removedProducts, removedMedia = _ref12.removedMedia, classificationFields = _ref12.classificationFields, fieldConfiguration = _ref12.fieldConfiguration, optMap = _ref12.optMap, _ref12$oldClassificat = _ref12.oldClassificationData, oldClassificationData = _ref12$oldClassificat === void 0 ? {} : _ref12$oldClassificat, originProductId = _ref12.originProductId;
|
|
774
779
|
products = [];
|
|
775
780
|
originProduct = undefined;
|
|
781
|
+
mediasToSave = [];
|
|
776
782
|
if (!originProductId) {
|
|
777
|
-
|
|
783
|
+
_context5.next = 16;
|
|
778
784
|
break;
|
|
779
785
|
}
|
|
780
|
-
|
|
786
|
+
_context5.next = 7;
|
|
781
787
|
return this.apiGetProductByFilter([{
|
|
782
788
|
id: '_id',
|
|
783
789
|
op: 'eq',
|
|
784
790
|
value: originProductId
|
|
785
791
|
}], undefined, true);
|
|
786
|
-
case
|
|
787
|
-
result =
|
|
792
|
+
case 7:
|
|
793
|
+
result = _context5.sent;
|
|
788
794
|
originProduct = result.data[0];
|
|
789
795
|
if (originProduct) {
|
|
790
|
-
|
|
796
|
+
_context5.next = 11;
|
|
791
797
|
break;
|
|
792
798
|
}
|
|
793
799
|
throw new Error('Origin Product not found');
|
|
794
|
-
case
|
|
800
|
+
case 11:
|
|
795
801
|
sapEinaLifNr = originProduct.customData.SAP_EINA_LIFNR.value;
|
|
796
802
|
sapEineEkgrp = originProduct.customData.SAP_EINE_EKGRP.value;
|
|
797
803
|
if (!(!sapEinaLifNr || !sapEineEkgrp)) {
|
|
798
|
-
|
|
804
|
+
_context5.next = 16;
|
|
799
805
|
break;
|
|
800
806
|
}
|
|
801
807
|
(_this$closeModal = this.closeModal) === null || _this$closeModal === void 0 || _this$closeModal.call(this);
|
|
802
808
|
throw new Error('LiefNr or EkGrp not found');
|
|
803
|
-
case
|
|
809
|
+
case 16:
|
|
804
810
|
if (originProduct) {
|
|
805
811
|
baseData = _objectSpread(_objectSpread(_objectSpread({}, originProduct), baseData), {}, {
|
|
806
812
|
classificationInfo: originProduct.classificationInfo,
|
|
@@ -861,14 +867,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
861
867
|
|
|
862
868
|
//media removed from the products is deleted from the server
|
|
863
869
|
j = 0;
|
|
864
|
-
case
|
|
870
|
+
case 22:
|
|
865
871
|
if (!(removedMedia && j < removedMedia.length)) {
|
|
866
|
-
|
|
872
|
+
_context5.next = 31;
|
|
867
873
|
break;
|
|
868
874
|
}
|
|
869
875
|
mediaRef = removedMedia[j];
|
|
870
876
|
if (!mediaRef.ref) {
|
|
871
|
-
|
|
877
|
+
_context5.next = 28;
|
|
872
878
|
break;
|
|
873
879
|
}
|
|
874
880
|
(_this$openModal = this.openModal) === null || _this$openModal === void 0 || _this$openModal.call(this, {
|
|
@@ -876,54 +882,29 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
876
882
|
title: (_this$t = this.t) === null || _this$t === void 0 ? void 0 : _this$t.call(this, 'productcreator.remove_old_media_refs'),
|
|
877
883
|
dontRenderForm: true
|
|
878
884
|
});
|
|
879
|
-
|
|
885
|
+
_context5.next = 28;
|
|
880
886
|
return this.apiRemoveMedia(this.mediaService, mediaRef.ref, this.jwt);
|
|
881
|
-
case
|
|
887
|
+
case 28:
|
|
882
888
|
j++;
|
|
883
|
-
|
|
889
|
+
_context5.next = 22;
|
|
884
890
|
break;
|
|
885
|
-
case
|
|
886
|
-
if (
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
title: (_this$t2 = this.t) === null || _this$t2 === void 0 ? void 0 : _this$t2.call(this, 'productcreator.save_media'),
|
|
901
|
-
dontRenderForm: true
|
|
902
|
-
});
|
|
903
|
-
_context4.next = 37;
|
|
904
|
-
return this.saveProductMedia(baseData.media[_j], baseProduct.organizationId);
|
|
905
|
-
case 37:
|
|
906
|
-
savedMedia = _context4.sent;
|
|
907
|
-
if (savedMedia) {
|
|
908
|
-
baseProduct.media.push(savedMedia);
|
|
909
|
-
} else {
|
|
910
|
-
//otherwise the file already exists on the server
|
|
911
|
-
baseProduct.media.push({
|
|
912
|
-
url: baseData.media[_j].url,
|
|
913
|
-
thumbnail: baseData.media[_j].thumbnail,
|
|
914
|
-
ref: baseData.media[_j].ref,
|
|
915
|
-
mediaType: baseData.media[_j].mediaType,
|
|
916
|
-
functionType: baseData.media[_j].functionType,
|
|
917
|
-
description: baseData.media[_j].description,
|
|
918
|
-
name: baseData.media[_j].name,
|
|
919
|
-
"class": baseData.media[_j]["class"]
|
|
920
|
-
});
|
|
891
|
+
case 31:
|
|
892
|
+
if (baseData.media) {
|
|
893
|
+
baseProduct.media = [];
|
|
894
|
+
for (_j = 0; _j < baseData.media.length; _j++) {
|
|
895
|
+
//if a new media is added, the file is present in media object and needs to be saved to the server
|
|
896
|
+
(_this$openModal2 = this.openModal) === null || _this$openModal2 === void 0 || _this$openModal2.call(this, {
|
|
897
|
+
progress: _j / baseData.media.length / 6 + 2 / 6,
|
|
898
|
+
title: (_this$t2 = this.t) === null || _this$t2 === void 0 ? void 0 : _this$t2.call(this, 'productcreator.save_media'),
|
|
899
|
+
dontRenderForm: true
|
|
900
|
+
});
|
|
901
|
+
mediasToSave.push({
|
|
902
|
+
media: baseData.media[_j],
|
|
903
|
+
id: baseData._id
|
|
904
|
+
});
|
|
905
|
+
}
|
|
921
906
|
}
|
|
922
|
-
|
|
923
|
-
_j++;
|
|
924
|
-
_context4.next = 33;
|
|
925
|
-
break;
|
|
926
|
-
case 42:
|
|
907
|
+
|
|
927
908
|
//orderDescription is only needed in FE to display it, it should not be stored to the server
|
|
928
909
|
delete baseProduct.orderDescription;
|
|
929
910
|
|
|
@@ -939,7 +920,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
939
920
|
}
|
|
940
921
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
941
922
|
var _basket$getProductCon2, _originProduct;
|
|
942
|
-
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k
|
|
923
|
+
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k;
|
|
943
924
|
return _regeneratorRuntime.wrap(function _loop$(_context3) {
|
|
944
925
|
while (1) switch (_context3.prev = _context3.next) {
|
|
945
926
|
case 0:
|
|
@@ -1070,79 +1051,91 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1070
1051
|
archived: baseProduct.archived ? baseProduct.archived : false,
|
|
1071
1052
|
uniqueHash: vd.uniqueHash
|
|
1072
1053
|
});
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
progress: _j2 / variantData.length / 6 + 3 / 6,
|
|
1080
|
-
title: (_this3$t = _this3.t) === null || _this3$t === void 0 ? void 0 : _this3$t.call(_this3, 'productcreator.save_media_variants'),
|
|
1081
|
-
dontRenderForm: true
|
|
1082
|
-
});
|
|
1083
|
-
k = 0;
|
|
1084
|
-
case 20:
|
|
1085
|
-
if (!(k < vd.media.length)) {
|
|
1086
|
-
_context3.next = 28;
|
|
1087
|
-
break;
|
|
1088
|
-
}
|
|
1089
|
-
_context3.next = 23;
|
|
1090
|
-
return _this3.saveProductMedia(vd.media[k], baseProduct.organizationId);
|
|
1091
|
-
case 23:
|
|
1092
|
-
_savedMedia = _context3.sent;
|
|
1093
|
-
if (_savedMedia) {
|
|
1094
|
-
product.media.push(_savedMedia);
|
|
1095
|
-
} else {
|
|
1096
|
-
//otherwise the file already exists on the server
|
|
1097
|
-
product.media.push({
|
|
1098
|
-
url: vd.media[k].url,
|
|
1099
|
-
thumbnail: vd.media[k].thumbnail,
|
|
1100
|
-
ref: vd.media[k].ref,
|
|
1101
|
-
mediaType: vd.media[k].mediaType,
|
|
1102
|
-
functionType: vd.media[k].functionType,
|
|
1103
|
-
description: vd.media[k].description,
|
|
1104
|
-
name: vd.media[k].name,
|
|
1105
|
-
"class": vd.media[k]["class"]
|
|
1054
|
+
if (vd.media) {
|
|
1055
|
+
product.media = [];
|
|
1056
|
+
(_this3$openModal = _this3.openModal) === null || _this3$openModal === void 0 || _this3$openModal.call(_this3, {
|
|
1057
|
+
progress: _j2 / variantData.length / 6 + 3 / 6,
|
|
1058
|
+
title: (_this3$t = _this3.t) === null || _this3$t === void 0 ? void 0 : _this3$t.call(_this3, 'productcreator.save_media_variants'),
|
|
1059
|
+
dontRenderForm: true
|
|
1106
1060
|
});
|
|
1061
|
+
for (k = 0; k < vd.media.length; k++) {
|
|
1062
|
+
mediasToSave.push({
|
|
1063
|
+
media: vd.media[k],
|
|
1064
|
+
id: vd._id
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1107
1067
|
}
|
|
1108
|
-
case 25:
|
|
1109
|
-
k++;
|
|
1110
|
-
_context3.next = 20;
|
|
1111
|
-
break;
|
|
1112
|
-
case 28:
|
|
1113
1068
|
//add the variant product it the list of products to be saved
|
|
1114
1069
|
products.push(product);
|
|
1115
|
-
case
|
|
1070
|
+
case 18:
|
|
1116
1071
|
case "end":
|
|
1117
1072
|
return _context3.stop();
|
|
1118
1073
|
}
|
|
1119
1074
|
}, _loop);
|
|
1120
1075
|
});
|
|
1121
1076
|
_j2 = 0;
|
|
1122
|
-
case
|
|
1077
|
+
case 37:
|
|
1123
1078
|
if (!(variantData && _j2 < variantData.length)) {
|
|
1124
|
-
|
|
1079
|
+
_context5.next = 44;
|
|
1125
1080
|
break;
|
|
1126
1081
|
}
|
|
1127
|
-
return
|
|
1128
|
-
case
|
|
1129
|
-
if (!
|
|
1130
|
-
|
|
1082
|
+
return _context5.delegateYield(_loop(), "t0", 39);
|
|
1083
|
+
case 39:
|
|
1084
|
+
if (!_context5.t0) {
|
|
1085
|
+
_context5.next = 41;
|
|
1131
1086
|
break;
|
|
1132
1087
|
}
|
|
1133
|
-
return
|
|
1134
|
-
case
|
|
1088
|
+
return _context5.abrupt("continue", 41);
|
|
1089
|
+
case 41:
|
|
1135
1090
|
_j2++;
|
|
1136
|
-
|
|
1091
|
+
_context5.next = 37;
|
|
1092
|
+
break;
|
|
1093
|
+
case 44:
|
|
1094
|
+
_context5.next = 46;
|
|
1095
|
+
return this.saveMedias(mediasToSave, baseData.organizationId);
|
|
1096
|
+
case 46:
|
|
1097
|
+
mediasForProducts = _context5.sent;
|
|
1098
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2(productId) {
|
|
1099
|
+
var p;
|
|
1100
|
+
return _regeneratorRuntime.wrap(function _loop2$(_context4) {
|
|
1101
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1102
|
+
case 0:
|
|
1103
|
+
mediasForProducts[productId];
|
|
1104
|
+
p = products.find(function (p) {
|
|
1105
|
+
return p._id == productId;
|
|
1106
|
+
});
|
|
1107
|
+
if (p) {
|
|
1108
|
+
_context4.next = 4;
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
throw Error('Product with id ' + productId + ' not fount during saving');
|
|
1112
|
+
case 4:
|
|
1113
|
+
p.media = mediasForProducts[productId].medias;
|
|
1114
|
+
case 5:
|
|
1115
|
+
case "end":
|
|
1116
|
+
return _context4.stop();
|
|
1117
|
+
}
|
|
1118
|
+
}, _loop2);
|
|
1119
|
+
});
|
|
1120
|
+
_context5.t1 = _regeneratorRuntime.keys(mediasForProducts);
|
|
1121
|
+
case 49:
|
|
1122
|
+
if ((_context5.t2 = _context5.t1()).done) {
|
|
1123
|
+
_context5.next = 54;
|
|
1124
|
+
break;
|
|
1125
|
+
}
|
|
1126
|
+
productId = _context5.t2.value;
|
|
1127
|
+
return _context5.delegateYield(_loop2(productId), "t3", 52);
|
|
1128
|
+
case 52:
|
|
1129
|
+
_context5.next = 49;
|
|
1137
1130
|
break;
|
|
1138
1131
|
case 54:
|
|
1139
|
-
return
|
|
1132
|
+
return _context5.abrupt("return", {
|
|
1140
1133
|
products: products,
|
|
1141
1134
|
removedProducts: removedProducts
|
|
1142
1135
|
});
|
|
1143
1136
|
case 55:
|
|
1144
1137
|
case "end":
|
|
1145
|
-
return
|
|
1138
|
+
return _context5.stop();
|
|
1146
1139
|
}
|
|
1147
1140
|
}, _callee3, this);
|
|
1148
1141
|
}));
|
|
@@ -1165,32 +1158,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1165
1158
|
value: function () {
|
|
1166
1159
|
var _saveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref29) {
|
|
1167
1160
|
var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
|
|
1168
|
-
return _regeneratorRuntime.wrap(function _callee4$(
|
|
1169
|
-
while (1) switch (
|
|
1161
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context6) {
|
|
1162
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1170
1163
|
case 0:
|
|
1171
1164
|
products = _ref29.products, removedProducts = _ref29.removedProducts, awaitPDF = _ref29.awaitPDF;
|
|
1172
1165
|
if (this.jwt) {
|
|
1173
|
-
|
|
1166
|
+
_context6.next = 3;
|
|
1174
1167
|
break;
|
|
1175
1168
|
}
|
|
1176
1169
|
throw new Error('jwt not set');
|
|
1177
1170
|
case 3:
|
|
1178
1171
|
this.setFirstVariant(products);
|
|
1179
|
-
|
|
1180
|
-
|
|
1172
|
+
_context6.prev = 4;
|
|
1173
|
+
_context6.next = 7;
|
|
1181
1174
|
return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
|
|
1182
1175
|
case 7:
|
|
1183
|
-
savedProducts =
|
|
1176
|
+
savedProducts = _context6.sent;
|
|
1184
1177
|
(_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
|
|
1185
|
-
return
|
|
1178
|
+
return _context6.abrupt("return", savedProducts);
|
|
1186
1179
|
case 12:
|
|
1187
|
-
|
|
1188
|
-
|
|
1180
|
+
_context6.prev = 12;
|
|
1181
|
+
_context6.t0 = _context6["catch"](4);
|
|
1189
1182
|
(_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
|
|
1190
|
-
throw new Error(
|
|
1183
|
+
throw new Error(_context6.t0.message);
|
|
1191
1184
|
case 16:
|
|
1192
1185
|
case "end":
|
|
1193
|
-
return
|
|
1186
|
+
return _context6.stop();
|
|
1194
1187
|
}
|
|
1195
1188
|
}, _callee4, this, [[4, 12]]);
|
|
1196
1189
|
}));
|
|
@@ -1528,35 +1521,35 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1528
1521
|
value: function () {
|
|
1529
1522
|
var _apiRemoveMedia = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(serviceUrl, ref, jwt) {
|
|
1530
1523
|
var url, response;
|
|
1531
|
-
return _regeneratorRuntime.wrap(function _callee5$(
|
|
1532
|
-
while (1) switch (
|
|
1524
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context7) {
|
|
1525
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1533
1526
|
case 0:
|
|
1534
1527
|
url = new URL("".concat(serviceUrl, "/v1/mediaitems/refs/") + ref);
|
|
1535
|
-
|
|
1536
|
-
|
|
1528
|
+
_context7.prev = 1;
|
|
1529
|
+
_context7.next = 4;
|
|
1537
1530
|
return axios["delete"](url.toString(), {
|
|
1538
1531
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1539
1532
|
'Content-Type': 'application/json'
|
|
1540
1533
|
})
|
|
1541
1534
|
});
|
|
1542
1535
|
case 4:
|
|
1543
|
-
response =
|
|
1536
|
+
response = _context7.sent;
|
|
1544
1537
|
if (!((response === null || response === void 0 ? void 0 : response.status) == 200)) {
|
|
1545
|
-
|
|
1538
|
+
_context7.next = 7;
|
|
1546
1539
|
break;
|
|
1547
1540
|
}
|
|
1548
|
-
return
|
|
1541
|
+
return _context7.abrupt("return", response.data);
|
|
1549
1542
|
case 7:
|
|
1550
1543
|
throw new Error('Could not remove Media');
|
|
1551
1544
|
case 10:
|
|
1552
|
-
|
|
1553
|
-
|
|
1545
|
+
_context7.prev = 10;
|
|
1546
|
+
_context7.t0 = _context7["catch"](1);
|
|
1554
1547
|
throw new Error('Could not remove Media', {
|
|
1555
|
-
cause:
|
|
1548
|
+
cause: _context7.t0
|
|
1556
1549
|
});
|
|
1557
1550
|
case 13:
|
|
1558
1551
|
case "end":
|
|
1559
|
-
return
|
|
1552
|
+
return _context7.stop();
|
|
1560
1553
|
}
|
|
1561
1554
|
}, _callee5, this, [[1, 10]]);
|
|
1562
1555
|
}));
|
|
@@ -1585,34 +1578,34 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1585
1578
|
var _apiGetProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(divanrOrID) {
|
|
1586
1579
|
var _res;
|
|
1587
1580
|
var fullUrl, res, resData;
|
|
1588
|
-
return _regeneratorRuntime.wrap(function _callee6$(
|
|
1589
|
-
while (1) switch (
|
|
1581
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context8) {
|
|
1582
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1590
1583
|
case 0:
|
|
1591
1584
|
fullUrl = this.catalogService + '/v1/products/' + divanrOrID + '/list';
|
|
1592
|
-
|
|
1593
|
-
|
|
1585
|
+
_context8.prev = 1;
|
|
1586
|
+
_context8.next = 4;
|
|
1594
1587
|
return axios.get(fullUrl, {
|
|
1595
1588
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1596
1589
|
'Content-Type': 'application/json'
|
|
1597
1590
|
})
|
|
1598
1591
|
});
|
|
1599
1592
|
case 4:
|
|
1600
|
-
res =
|
|
1601
|
-
|
|
1593
|
+
res = _context8.sent;
|
|
1594
|
+
_context8.next = 7;
|
|
1602
1595
|
return res.data;
|
|
1603
1596
|
case 7:
|
|
1604
|
-
resData =
|
|
1605
|
-
|
|
1597
|
+
resData = _context8.sent;
|
|
1598
|
+
_context8.next = 13;
|
|
1606
1599
|
break;
|
|
1607
1600
|
case 10:
|
|
1608
|
-
|
|
1609
|
-
|
|
1601
|
+
_context8.prev = 10;
|
|
1602
|
+
_context8.t0 = _context8["catch"](1);
|
|
1610
1603
|
throw new Error('Could not get existing products', {
|
|
1611
|
-
cause:
|
|
1604
|
+
cause: _context8.t0
|
|
1612
1605
|
});
|
|
1613
1606
|
case 13:
|
|
1614
1607
|
if (!(((_res = res) === null || _res === void 0 ? void 0 : _res.status) == 200)) {
|
|
1615
|
-
|
|
1608
|
+
_context8.next = 16;
|
|
1616
1609
|
break;
|
|
1617
1610
|
}
|
|
1618
1611
|
//in order to be backwardscompatible we must transform old products here
|
|
@@ -1625,12 +1618,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1625
1618
|
}
|
|
1626
1619
|
return d;
|
|
1627
1620
|
});
|
|
1628
|
-
return
|
|
1621
|
+
return _context8.abrupt("return", resData);
|
|
1629
1622
|
case 16:
|
|
1630
1623
|
throw new Error(resData.error);
|
|
1631
1624
|
case 17:
|
|
1632
1625
|
case "end":
|
|
1633
|
-
return
|
|
1626
|
+
return _context8.stop();
|
|
1634
1627
|
}
|
|
1635
1628
|
}, _callee6, this, [[1, 10]]);
|
|
1636
1629
|
}));
|
|
@@ -1645,21 +1638,21 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1645
1638
|
var _apiGetCatalogData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(catalogCodex, catalogId, language, accountId) {
|
|
1646
1639
|
var _response$CollectionG, _response$Properties, _response$Properties2;
|
|
1647
1640
|
var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
|
|
1648
|
-
return _regeneratorRuntime.wrap(function _callee7$(
|
|
1649
|
-
while (1) switch (
|
|
1641
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context9) {
|
|
1642
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1650
1643
|
case 0:
|
|
1651
|
-
|
|
1644
|
+
_context9.next = 2;
|
|
1652
1645
|
return this.apiAccountLogin(accountId, catalogId);
|
|
1653
1646
|
case 2:
|
|
1654
|
-
currentAccountSessionId =
|
|
1647
|
+
currentAccountSessionId = _context9.sent;
|
|
1655
1648
|
if (currentAccountSessionId) {
|
|
1656
|
-
|
|
1649
|
+
_context9.next = 5;
|
|
1657
1650
|
break;
|
|
1658
1651
|
}
|
|
1659
|
-
return
|
|
1652
|
+
return _context9.abrupt("return");
|
|
1660
1653
|
case 5:
|
|
1661
1654
|
fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
|
|
1662
|
-
|
|
1655
|
+
_context9.next = 8;
|
|
1663
1656
|
return fetch(fullUrl, {
|
|
1664
1657
|
headers: {
|
|
1665
1658
|
sessionGuid: currentAccountSessionId
|
|
@@ -1671,9 +1664,9 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1671
1664
|
return res.json();
|
|
1672
1665
|
});
|
|
1673
1666
|
case 8:
|
|
1674
|
-
response =
|
|
1667
|
+
response = _context9.sent;
|
|
1675
1668
|
if (!response.Error) {
|
|
1676
|
-
|
|
1669
|
+
_context9.next = 11;
|
|
1677
1670
|
break;
|
|
1678
1671
|
}
|
|
1679
1672
|
throw new Error(response.Error);
|
|
@@ -1706,10 +1699,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1706
1699
|
return p.Codex == 'DIVA3D_AR_READY';
|
|
1707
1700
|
})) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
|
|
1708
1701
|
};
|
|
1709
|
-
return
|
|
1702
|
+
return _context9.abrupt("return", actCatalogInfoData);
|
|
1710
1703
|
case 13:
|
|
1711
1704
|
case "end":
|
|
1712
|
-
return
|
|
1705
|
+
return _context9.stop();
|
|
1713
1706
|
}
|
|
1714
1707
|
}, _callee7, this);
|
|
1715
1708
|
}));
|
|
@@ -1723,63 +1716,63 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1723
1716
|
value: function () {
|
|
1724
1717
|
var _apiAccountLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(accountId, catalogId) {
|
|
1725
1718
|
var fullUrl, response, fallbackUrl, fallbackResponse;
|
|
1726
|
-
return _regeneratorRuntime.wrap(function _callee8$(
|
|
1727
|
-
while (1) switch (
|
|
1719
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context10) {
|
|
1720
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1728
1721
|
case 0:
|
|
1729
1722
|
fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1723
|
+
_context10.t0 = fetch;
|
|
1724
|
+
_context10.t1 = fullUrl;
|
|
1725
|
+
_context10.next = 5;
|
|
1733
1726
|
return this.sessionGuid;
|
|
1734
1727
|
case 5:
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
sessionGuid:
|
|
1728
|
+
_context10.t2 = _context10.sent;
|
|
1729
|
+
_context10.t3 = {
|
|
1730
|
+
sessionGuid: _context10.t2
|
|
1738
1731
|
};
|
|
1739
|
-
|
|
1740
|
-
headers:
|
|
1732
|
+
_context10.t4 = {
|
|
1733
|
+
headers: _context10.t3
|
|
1741
1734
|
};
|
|
1742
|
-
|
|
1743
|
-
return (0,
|
|
1735
|
+
_context10.next = 10;
|
|
1736
|
+
return (0, _context10.t0)(_context10.t1, _context10.t4).then(function (res) {
|
|
1744
1737
|
if (res.status !== 200) {
|
|
1745
1738
|
throw new Error('Collections not loaded.');
|
|
1746
1739
|
}
|
|
1747
1740
|
return res.json();
|
|
1748
1741
|
});
|
|
1749
1742
|
case 10:
|
|
1750
|
-
response =
|
|
1743
|
+
response = _context10.sent;
|
|
1751
1744
|
if (!response.SessionGUID) {
|
|
1752
|
-
|
|
1745
|
+
_context10.next = 13;
|
|
1753
1746
|
break;
|
|
1754
1747
|
}
|
|
1755
|
-
return
|
|
1748
|
+
return _context10.abrupt("return", response.SessionGUID);
|
|
1756
1749
|
case 13:
|
|
1757
1750
|
fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1751
|
+
_context10.t5 = fetch;
|
|
1752
|
+
_context10.t6 = fallbackUrl;
|
|
1753
|
+
_context10.next = 18;
|
|
1761
1754
|
return this.sessionGuid;
|
|
1762
1755
|
case 18:
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
sessionGuid:
|
|
1756
|
+
_context10.t7 = _context10.sent;
|
|
1757
|
+
_context10.t8 = {
|
|
1758
|
+
sessionGuid: _context10.t7
|
|
1766
1759
|
};
|
|
1767
|
-
|
|
1768
|
-
headers:
|
|
1760
|
+
_context10.t9 = {
|
|
1761
|
+
headers: _context10.t8
|
|
1769
1762
|
};
|
|
1770
|
-
|
|
1771
|
-
return (0,
|
|
1763
|
+
_context10.next = 23;
|
|
1764
|
+
return (0, _context10.t5)(_context10.t6, _context10.t9).then(function (res) {
|
|
1772
1765
|
if (res.status !== 200) {
|
|
1773
1766
|
throw new Error('Collections not loaded.');
|
|
1774
1767
|
}
|
|
1775
1768
|
return res.json();
|
|
1776
1769
|
});
|
|
1777
1770
|
case 23:
|
|
1778
|
-
fallbackResponse =
|
|
1779
|
-
return
|
|
1771
|
+
fallbackResponse = _context10.sent;
|
|
1772
|
+
return _context10.abrupt("return", fallbackResponse.SessionGUID);
|
|
1780
1773
|
case 25:
|
|
1781
1774
|
case "end":
|
|
1782
|
-
return
|
|
1775
|
+
return _context10.stop();
|
|
1783
1776
|
}
|
|
1784
1777
|
}, _callee8, this);
|
|
1785
1778
|
}));
|
|
@@ -1794,42 +1787,42 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1794
1787
|
var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, full) {
|
|
1795
1788
|
var _res2;
|
|
1796
1789
|
var fullUrl, res, resData;
|
|
1797
|
-
return _regeneratorRuntime.wrap(function _callee9$(
|
|
1798
|
-
while (1) switch (
|
|
1790
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context11) {
|
|
1791
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1799
1792
|
case 0:
|
|
1800
1793
|
fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
|
|
1801
|
-
|
|
1802
|
-
|
|
1794
|
+
_context11.prev = 1;
|
|
1795
|
+
_context11.next = 4;
|
|
1803
1796
|
return axios.get(fullUrl, {
|
|
1804
1797
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1805
1798
|
'Content-Type': 'application/json'
|
|
1806
1799
|
})
|
|
1807
1800
|
});
|
|
1808
1801
|
case 4:
|
|
1809
|
-
res =
|
|
1810
|
-
|
|
1802
|
+
res = _context11.sent;
|
|
1803
|
+
_context11.next = 7;
|
|
1811
1804
|
return res.data;
|
|
1812
1805
|
case 7:
|
|
1813
|
-
resData =
|
|
1814
|
-
|
|
1806
|
+
resData = _context11.sent;
|
|
1807
|
+
_context11.next = 13;
|
|
1815
1808
|
break;
|
|
1816
1809
|
case 10:
|
|
1817
|
-
|
|
1818
|
-
|
|
1810
|
+
_context11.prev = 10;
|
|
1811
|
+
_context11.t0 = _context11["catch"](1);
|
|
1819
1812
|
throw new Error('Could not get existing products', {
|
|
1820
|
-
cause:
|
|
1813
|
+
cause: _context11.t0
|
|
1821
1814
|
});
|
|
1822
1815
|
case 13:
|
|
1823
1816
|
if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
|
|
1824
|
-
|
|
1817
|
+
_context11.next = 15;
|
|
1825
1818
|
break;
|
|
1826
1819
|
}
|
|
1827
|
-
return
|
|
1820
|
+
return _context11.abrupt("return", resData);
|
|
1828
1821
|
case 15:
|
|
1829
1822
|
throw new Error(resData.error);
|
|
1830
1823
|
case 16:
|
|
1831
1824
|
case "end":
|
|
1832
|
-
return
|
|
1825
|
+
return _context11.stop();
|
|
1833
1826
|
}
|
|
1834
1827
|
}, _callee9, this, [[1, 10]]);
|
|
1835
1828
|
}));
|
|
@@ -1850,39 +1843,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1850
1843
|
res,
|
|
1851
1844
|
resData,
|
|
1852
1845
|
filterParam,
|
|
1853
|
-
|
|
1854
|
-
return _regeneratorRuntime.wrap(function _callee10$(
|
|
1855
|
-
while (1) switch (
|
|
1846
|
+
_args12 = arguments;
|
|
1847
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context12) {
|
|
1848
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1856
1849
|
case 0:
|
|
1857
|
-
limit =
|
|
1858
|
-
useFilter =
|
|
1859
|
-
hierarchy =
|
|
1850
|
+
limit = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : 1;
|
|
1851
|
+
useFilter = _args12.length > 2 ? _args12[2] : undefined;
|
|
1852
|
+
hierarchy = _args12.length > 3 ? _args12[3] : undefined;
|
|
1860
1853
|
fullUrl = this.catalogService + '/v1/products';
|
|
1861
|
-
|
|
1854
|
+
_context12.prev = 4;
|
|
1862
1855
|
filterParam = useFilter ? 'filter' : 'search';
|
|
1863
|
-
|
|
1856
|
+
_context12.next = 8;
|
|
1864
1857
|
return axios.get("".concat(fullUrl, "?organizationIds=").concat(this.organization._id, "&").concat(filterParam, "=").concat(encodeURIComponent(this.parseFilter(filter)), "&limit=").concat(limit, "&hierarchy=").concat(hierarchy !== null && hierarchy !== void 0 ? hierarchy : false), {
|
|
1865
1858
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1866
1859
|
'Content-Type': 'application/json'
|
|
1867
1860
|
})
|
|
1868
1861
|
});
|
|
1869
1862
|
case 8:
|
|
1870
|
-
res =
|
|
1871
|
-
|
|
1863
|
+
res = _context12.sent;
|
|
1864
|
+
_context12.next = 11;
|
|
1872
1865
|
return res.data;
|
|
1873
1866
|
case 11:
|
|
1874
|
-
resData =
|
|
1875
|
-
|
|
1867
|
+
resData = _context12.sent;
|
|
1868
|
+
_context12.next = 17;
|
|
1876
1869
|
break;
|
|
1877
1870
|
case 14:
|
|
1878
|
-
|
|
1879
|
-
|
|
1871
|
+
_context12.prev = 14;
|
|
1872
|
+
_context12.t0 = _context12["catch"](4);
|
|
1880
1873
|
throw new Error('Could not get existing products', {
|
|
1881
|
-
cause:
|
|
1874
|
+
cause: _context12.t0
|
|
1882
1875
|
});
|
|
1883
1876
|
case 17:
|
|
1884
1877
|
if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
|
|
1885
|
-
|
|
1878
|
+
_context12.next = 20;
|
|
1886
1879
|
break;
|
|
1887
1880
|
}
|
|
1888
1881
|
//in order to be backwardscompatible we must transform old products here
|
|
@@ -1895,12 +1888,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1895
1888
|
}
|
|
1896
1889
|
return d;
|
|
1897
1890
|
});
|
|
1898
|
-
return
|
|
1891
|
+
return _context12.abrupt("return", resData);
|
|
1899
1892
|
case 20:
|
|
1900
1893
|
throw new Error(resData.error);
|
|
1901
1894
|
case 21:
|
|
1902
1895
|
case "end":
|
|
1903
|
-
return
|
|
1896
|
+
return _context12.stop();
|
|
1904
1897
|
}
|
|
1905
1898
|
}, _callee10, this, [[4, 14]]);
|
|
1906
1899
|
}));
|
|
@@ -1915,43 +1908,43 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1915
1908
|
var _apiActivateProduct = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(id, organizationId) {
|
|
1916
1909
|
var _res4;
|
|
1917
1910
|
var fullUrl, res, resData;
|
|
1918
|
-
return _regeneratorRuntime.wrap(function _callee11$(
|
|
1919
|
-
while (1) switch (
|
|
1911
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context13) {
|
|
1912
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1920
1913
|
case 0:
|
|
1921
1914
|
fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/activate');
|
|
1922
1915
|
fullUrl.searchParams.append('organizationId', organizationId);
|
|
1923
|
-
|
|
1924
|
-
|
|
1916
|
+
_context13.prev = 2;
|
|
1917
|
+
_context13.next = 5;
|
|
1925
1918
|
return axios.post(fullUrl.toString(), undefined, {
|
|
1926
1919
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1927
1920
|
'Content-Type': 'application/json'
|
|
1928
1921
|
})
|
|
1929
1922
|
});
|
|
1930
1923
|
case 5:
|
|
1931
|
-
res =
|
|
1932
|
-
|
|
1924
|
+
res = _context13.sent;
|
|
1925
|
+
_context13.next = 8;
|
|
1933
1926
|
return res.data;
|
|
1934
1927
|
case 8:
|
|
1935
|
-
resData =
|
|
1936
|
-
|
|
1928
|
+
resData = _context13.sent;
|
|
1929
|
+
_context13.next = 14;
|
|
1937
1930
|
break;
|
|
1938
1931
|
case 11:
|
|
1939
|
-
|
|
1940
|
-
|
|
1932
|
+
_context13.prev = 11;
|
|
1933
|
+
_context13.t0 = _context13["catch"](2);
|
|
1941
1934
|
throw new Error('Error on activate product', {
|
|
1942
|
-
cause:
|
|
1935
|
+
cause: _context13.t0
|
|
1943
1936
|
});
|
|
1944
1937
|
case 14:
|
|
1945
1938
|
if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
|
|
1946
|
-
|
|
1939
|
+
_context13.next = 16;
|
|
1947
1940
|
break;
|
|
1948
1941
|
}
|
|
1949
|
-
return
|
|
1942
|
+
return _context13.abrupt("return", resData);
|
|
1950
1943
|
case 16:
|
|
1951
1944
|
throw new Error(resData.error);
|
|
1952
1945
|
case 17:
|
|
1953
1946
|
case "end":
|
|
1954
|
-
return
|
|
1947
|
+
return _context13.stop();
|
|
1955
1948
|
}
|
|
1956
1949
|
}, _callee11, this, [[2, 11]]);
|
|
1957
1950
|
}));
|
|
@@ -1965,8 +1958,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1965
1958
|
value: function () {
|
|
1966
1959
|
var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(products) {
|
|
1967
1960
|
var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
|
|
1968
|
-
return _regeneratorRuntime.wrap(function _callee12$(
|
|
1969
|
-
while (1) switch (
|
|
1961
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context14) {
|
|
1962
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1970
1963
|
case 0:
|
|
1971
1964
|
fullUrl = this.catalogService + '/products';
|
|
1972
1965
|
fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
|
|
@@ -1977,7 +1970,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1977
1970
|
i = 0;
|
|
1978
1971
|
case 5:
|
|
1979
1972
|
if (!(i < productsInChunks.length)) {
|
|
1980
|
-
|
|
1973
|
+
_context14.next = 13;
|
|
1981
1974
|
break;
|
|
1982
1975
|
}
|
|
1983
1976
|
promises = productsInChunks[i].map(function (p) {
|
|
@@ -1999,15 +1992,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1999
1992
|
title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
|
|
2000
1993
|
dontRenderForm: true
|
|
2001
1994
|
});
|
|
2002
|
-
|
|
1995
|
+
_context14.next = 10;
|
|
2003
1996
|
return Promise.all(promises);
|
|
2004
1997
|
case 10:
|
|
2005
1998
|
i++;
|
|
2006
|
-
|
|
1999
|
+
_context14.next = 5;
|
|
2007
2000
|
break;
|
|
2008
2001
|
case 13:
|
|
2009
2002
|
case "end":
|
|
2010
|
-
return
|
|
2003
|
+
return _context14.stop();
|
|
2011
2004
|
}
|
|
2012
2005
|
}, _callee12, this);
|
|
2013
2006
|
}));
|
|
@@ -2030,8 +2023,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2030
2023
|
value: function () {
|
|
2031
2024
|
var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref46) {
|
|
2032
2025
|
var limit, skip, fields, _ref46$search, search, sort, abortController, fullUrl, headers, promise;
|
|
2033
|
-
return _regeneratorRuntime.wrap(function _callee13$(
|
|
2034
|
-
while (1) switch (
|
|
2026
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context15) {
|
|
2027
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2035
2028
|
case 0:
|
|
2036
2029
|
limit = _ref46.limit, skip = _ref46.skip, fields = _ref46.fields, _ref46$search = _ref46.search, search = _ref46$search === void 0 ? [] : _ref46$search, sort = _ref46.sort, _ref46.showAllProducts, abortController = _ref46.abortController;
|
|
2037
2030
|
fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils.fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '');
|
|
@@ -2055,13 +2048,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2055
2048
|
reject('Error loading products grouped by variants: ' + error.message);
|
|
2056
2049
|
});
|
|
2057
2050
|
});
|
|
2058
|
-
|
|
2051
|
+
_context15.next = 7;
|
|
2059
2052
|
return promise;
|
|
2060
2053
|
case 7:
|
|
2061
|
-
return
|
|
2054
|
+
return _context15.abrupt("return", _context15.sent);
|
|
2062
2055
|
case 8:
|
|
2063
2056
|
case "end":
|
|
2064
|
-
return
|
|
2057
|
+
return _context15.stop();
|
|
2065
2058
|
}
|
|
2066
2059
|
}, _callee13, this);
|
|
2067
2060
|
}));
|
|
@@ -2074,9 +2067,9 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2074
2067
|
key: "apiSaveProducts",
|
|
2075
2068
|
value: function () {
|
|
2076
2069
|
var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
|
|
2077
|
-
var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2,
|
|
2078
|
-
return _regeneratorRuntime.wrap(function _callee14$(
|
|
2079
|
-
while (1) switch (
|
|
2070
|
+
var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop3, j;
|
|
2071
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context17) {
|
|
2072
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2080
2073
|
case 0:
|
|
2081
2074
|
fullUrl = serverUrl + '/v1/products/groups';
|
|
2082
2075
|
BATCH_SIZE = 40;
|
|
@@ -2085,34 +2078,34 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2085
2078
|
i = 0;
|
|
2086
2079
|
case 5:
|
|
2087
2080
|
if (!(i < products.length)) {
|
|
2088
|
-
|
|
2081
|
+
_context17.next = 15;
|
|
2089
2082
|
break;
|
|
2090
2083
|
}
|
|
2091
2084
|
if (!products[i].baseProduct) {
|
|
2092
|
-
|
|
2085
|
+
_context17.next = 9;
|
|
2093
2086
|
break;
|
|
2094
2087
|
}
|
|
2095
2088
|
baseProduct = products[i];
|
|
2096
|
-
return
|
|
2089
|
+
return _context17.abrupt("continue", 12);
|
|
2097
2090
|
case 9:
|
|
2098
2091
|
if (BATCH_SIZE < ((_productsPackages$gro = (_productsPackages$gro2 = productsPackages[groupIndex]) === null || _productsPackages$gro2 === void 0 ? void 0 : _productsPackages$gro2.length) !== null && _productsPackages$gro !== void 0 ? _productsPackages$gro : 0)) groupIndex++;
|
|
2099
2092
|
if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
|
|
2100
2093
|
productsPackages[groupIndex].push(products[i]);
|
|
2101
2094
|
case 12:
|
|
2102
2095
|
i++;
|
|
2103
|
-
|
|
2096
|
+
_context17.next = 5;
|
|
2104
2097
|
break;
|
|
2105
2098
|
case 15:
|
|
2106
2099
|
responseProducts = [];
|
|
2107
2100
|
_i2 = 0;
|
|
2108
2101
|
case 17:
|
|
2109
2102
|
if (!(_i2 < productsPackages.length)) {
|
|
2110
|
-
|
|
2103
|
+
_context17.next = 40;
|
|
2111
2104
|
break;
|
|
2112
2105
|
}
|
|
2113
2106
|
if (baseProduct) productsPackages[_i2].unshift(baseProduct);
|
|
2114
|
-
|
|
2115
|
-
|
|
2107
|
+
_context17.prev = 19;
|
|
2108
|
+
_context17.next = 22;
|
|
2116
2109
|
return fetch(fullUrl, {
|
|
2117
2110
|
method: 'PUT',
|
|
2118
2111
|
headers: {
|
|
@@ -2132,23 +2125,23 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2132
2125
|
return res.json();
|
|
2133
2126
|
});
|
|
2134
2127
|
case 22:
|
|
2135
|
-
response =
|
|
2128
|
+
response = _context17.sent;
|
|
2136
2129
|
if (!response.Error) {
|
|
2137
|
-
|
|
2130
|
+
_context17.next = 25;
|
|
2138
2131
|
break;
|
|
2139
2132
|
}
|
|
2140
2133
|
throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
|
|
2141
2134
|
case 25:
|
|
2142
|
-
|
|
2135
|
+
_context17.next = 30;
|
|
2143
2136
|
break;
|
|
2144
2137
|
case 27:
|
|
2145
|
-
|
|
2146
|
-
|
|
2138
|
+
_context17.prev = 27;
|
|
2139
|
+
_context17.t0 = _context17["catch"](19);
|
|
2147
2140
|
throw Error(status);
|
|
2148
2141
|
case 30:
|
|
2149
|
-
|
|
2150
|
-
return _regeneratorRuntime.wrap(function
|
|
2151
|
-
while (1) switch (
|
|
2142
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3(j) {
|
|
2143
|
+
return _regeneratorRuntime.wrap(function _loop3$(_context16) {
|
|
2144
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2152
2145
|
case 0:
|
|
2153
2146
|
if (response.products[j].baseProduct) baseProduct = response.products[j];
|
|
2154
2147
|
if (!responseProducts.find(function (p) {
|
|
@@ -2158,30 +2151,30 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2158
2151
|
}
|
|
2159
2152
|
case 2:
|
|
2160
2153
|
case "end":
|
|
2161
|
-
return
|
|
2154
|
+
return _context16.stop();
|
|
2162
2155
|
}
|
|
2163
|
-
},
|
|
2156
|
+
}, _loop3);
|
|
2164
2157
|
});
|
|
2165
2158
|
j = 0;
|
|
2166
2159
|
case 32:
|
|
2167
2160
|
if (!(j < response.products.length)) {
|
|
2168
|
-
|
|
2161
|
+
_context17.next = 37;
|
|
2169
2162
|
break;
|
|
2170
2163
|
}
|
|
2171
|
-
return
|
|
2164
|
+
return _context17.delegateYield(_loop3(j), "t1", 34);
|
|
2172
2165
|
case 34:
|
|
2173
2166
|
j++;
|
|
2174
|
-
|
|
2167
|
+
_context17.next = 32;
|
|
2175
2168
|
break;
|
|
2176
2169
|
case 37:
|
|
2177
2170
|
_i2++;
|
|
2178
|
-
|
|
2171
|
+
_context17.next = 17;
|
|
2179
2172
|
break;
|
|
2180
2173
|
case 40:
|
|
2181
|
-
return
|
|
2174
|
+
return _context17.abrupt("return", responseProducts);
|
|
2182
2175
|
case 41:
|
|
2183
2176
|
case "end":
|
|
2184
|
-
return
|
|
2177
|
+
return _context17.stop();
|
|
2185
2178
|
}
|
|
2186
2179
|
}, _callee14, null, [[19, 27]]);
|
|
2187
2180
|
}));
|
|
@@ -2235,7 +2228,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2235
2228
|
return true;
|
|
2236
2229
|
}
|
|
2237
2230
|
var orderlines = (_product$configuratio2 = (_product$configuratio3 = product.configuration) === null || _product$configuratio3 === void 0 ? void 0 : _product$configuratio3.OrderSets[0].OrderLines) !== null && _product$configuratio2 !== void 0 ? _product$configuratio2 : [];
|
|
2238
|
-
var
|
|
2231
|
+
var _loop4 = function _loop4() {
|
|
2239
2232
|
var article = orderlines[i];
|
|
2240
2233
|
var orderLine = orderLines.find(function (ol) {
|
|
2241
2234
|
return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
|
|
@@ -2246,7 +2239,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2246
2239
|
};
|
|
2247
2240
|
}
|
|
2248
2241
|
if (article.VariantBasketDatas.length) {
|
|
2249
|
-
var
|
|
2242
|
+
var _loop5 = function _loop5() {
|
|
2250
2243
|
var varinatValue = article.VariantBasketDatas[j];
|
|
2251
2244
|
if (!varinatData.find(function (vb) {
|
|
2252
2245
|
return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
|
|
@@ -2260,14 +2253,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2260
2253
|
},
|
|
2261
2254
|
_ret2;
|
|
2262
2255
|
for (var j = 0; j < article.VariantBasketDatas.length; j++) {
|
|
2263
|
-
_ret2 =
|
|
2256
|
+
_ret2 = _loop5();
|
|
2264
2257
|
if (_ret2) return _ret2.v;
|
|
2265
2258
|
}
|
|
2266
2259
|
}
|
|
2267
2260
|
},
|
|
2268
2261
|
_ret;
|
|
2269
2262
|
for (var i = 0; i < orderlines.length; i++) {
|
|
2270
|
-
_ret =
|
|
2263
|
+
_ret = _loop4();
|
|
2271
2264
|
if (_ret) return _ret.v;
|
|
2272
2265
|
}
|
|
2273
2266
|
return true;
|
|
@@ -2345,7 +2338,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2345
2338
|
//calculate defaultShortDescription from template string
|
|
2346
2339
|
var shortDescriptionTemplate = (_configurationData$sh = configurationData === null || configurationData === void 0 ? void 0 : configurationData.shortDescription) !== null && _configurationData$sh !== void 0 ? _configurationData$sh : '${modelName} ${subCategory} ${mainColor}';
|
|
2347
2340
|
var parts = shortDescriptionTemplate.split(/\${|}/);
|
|
2348
|
-
var
|
|
2341
|
+
var _loop6 = function _loop6() {
|
|
2349
2342
|
var _classificationConfig2, _classificationConfig4, _value;
|
|
2350
2343
|
var field = parts[i];
|
|
2351
2344
|
var value;
|
|
@@ -2377,7 +2370,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2377
2370
|
shortDescriptionTemplate = shortDescriptionTemplate.replace("${".concat(field, "}"), (_value = value) !== null && _value !== void 0 ? _value : '');
|
|
2378
2371
|
};
|
|
2379
2372
|
for (var i = 1; i < parts.length; i = i + 2) {
|
|
2380
|
-
|
|
2373
|
+
_loop6();
|
|
2381
2374
|
}
|
|
2382
2375
|
|
|
2383
2376
|
//as long as shortDescription is not modified by user, autocalc it
|
|
@@ -2412,8 +2405,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2412
2405
|
value: function () {
|
|
2413
2406
|
var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
|
|
2414
2407
|
var values, apiUrl, i, apiResult, _i3, value, text;
|
|
2415
|
-
return _regeneratorRuntime.wrap(function _callee15$(
|
|
2416
|
-
while (1) switch (
|
|
2408
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context18) {
|
|
2409
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2417
2410
|
case 0:
|
|
2418
2411
|
values = [];
|
|
2419
2412
|
apiUrl = dataSource.url;
|
|
@@ -2422,7 +2415,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2422
2415
|
apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
|
|
2423
2416
|
}
|
|
2424
2417
|
}
|
|
2425
|
-
|
|
2418
|
+
_context18.next = 5;
|
|
2426
2419
|
return fetch(apiUrl, {
|
|
2427
2420
|
headers: {
|
|
2428
2421
|
sessionGuid: sessionGuid
|
|
@@ -2434,7 +2427,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2434
2427
|
return res.json();
|
|
2435
2428
|
});
|
|
2436
2429
|
case 5:
|
|
2437
|
-
apiResult =
|
|
2430
|
+
apiResult = _context18.sent;
|
|
2438
2431
|
if (dataSource.useKey) {
|
|
2439
2432
|
apiResult = apiResult[dataSource.useKey];
|
|
2440
2433
|
}
|
|
@@ -2446,10 +2439,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2446
2439
|
text: text
|
|
2447
2440
|
});
|
|
2448
2441
|
}
|
|
2449
|
-
return
|
|
2442
|
+
return _context18.abrupt("return", values);
|
|
2450
2443
|
case 9:
|
|
2451
2444
|
case "end":
|
|
2452
|
-
return
|
|
2445
|
+
return _context18.stop();
|
|
2453
2446
|
}
|
|
2454
2447
|
}, _callee15);
|
|
2455
2448
|
}));
|
|
@@ -2470,7 +2463,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2470
2463
|
key: "getVariantBasketDatasByOrderlines",
|
|
2471
2464
|
value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
|
|
2472
2465
|
var variantBasketDatas = [];
|
|
2473
|
-
var
|
|
2466
|
+
var _loop7 = function _loop7() {
|
|
2474
2467
|
var ol = orderLines[i];
|
|
2475
2468
|
var catalog = catalogData.find(function (c) {
|
|
2476
2469
|
return c.codex === ol.CatalogCodex;
|
|
@@ -2493,7 +2486,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2493
2486
|
}
|
|
2494
2487
|
};
|
|
2495
2488
|
for (var i = 0; i < orderLines.length; i++) {
|
|
2496
|
-
if (
|
|
2489
|
+
if (_loop7()) continue;
|
|
2497
2490
|
}
|
|
2498
2491
|
return variantBasketDatas;
|
|
2499
2492
|
}
|