@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/cjs/index.js
CHANGED
|
@@ -776,49 +776,55 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
776
776
|
*/
|
|
777
777
|
}, {
|
|
778
778
|
key: "saveProductMedia",
|
|
779
|
-
value: function saveProductMedia(productmedia, organizationId) {
|
|
779
|
+
value: function saveProductMedia(productmedia, organizationId, refCount) {
|
|
780
780
|
return Promise.resolve(undefined);
|
|
781
781
|
}
|
|
782
|
+
}, {
|
|
783
|
+
key: "saveMedias",
|
|
784
|
+
value: function saveMedias(mediasToSave, organizationId) {
|
|
785
|
+
return Promise.resolve({});
|
|
786
|
+
}
|
|
782
787
|
}, {
|
|
783
788
|
key: "prepareData",
|
|
784
789
|
value: function () {
|
|
785
790
|
var _prepareData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref12) {
|
|
786
791
|
var _this3 = this;
|
|
787
|
-
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,
|
|
788
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee3$(
|
|
789
|
-
while (1) switch (
|
|
792
|
+
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;
|
|
793
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context5) {
|
|
794
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
790
795
|
case 0:
|
|
791
796
|
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;
|
|
792
797
|
products = [];
|
|
793
798
|
originProduct = undefined;
|
|
799
|
+
mediasToSave = [];
|
|
794
800
|
if (!originProductId) {
|
|
795
|
-
|
|
801
|
+
_context5.next = 16;
|
|
796
802
|
break;
|
|
797
803
|
}
|
|
798
|
-
|
|
804
|
+
_context5.next = 7;
|
|
799
805
|
return this.apiGetProductByFilter([{
|
|
800
806
|
id: '_id',
|
|
801
807
|
op: 'eq',
|
|
802
808
|
value: originProductId
|
|
803
809
|
}], undefined, true);
|
|
804
|
-
case
|
|
805
|
-
result =
|
|
810
|
+
case 7:
|
|
811
|
+
result = _context5.sent;
|
|
806
812
|
originProduct = result.data[0];
|
|
807
813
|
if (originProduct) {
|
|
808
|
-
|
|
814
|
+
_context5.next = 11;
|
|
809
815
|
break;
|
|
810
816
|
}
|
|
811
817
|
throw new Error('Origin Product not found');
|
|
812
|
-
case
|
|
818
|
+
case 11:
|
|
813
819
|
sapEinaLifNr = originProduct.customData.SAP_EINA_LIFNR.value;
|
|
814
820
|
sapEineEkgrp = originProduct.customData.SAP_EINE_EKGRP.value;
|
|
815
821
|
if (!(!sapEinaLifNr || !sapEineEkgrp)) {
|
|
816
|
-
|
|
822
|
+
_context5.next = 16;
|
|
817
823
|
break;
|
|
818
824
|
}
|
|
819
825
|
(_this$closeModal = this.closeModal) === null || _this$closeModal === void 0 || _this$closeModal.call(this);
|
|
820
826
|
throw new Error('LiefNr or EkGrp not found');
|
|
821
|
-
case
|
|
827
|
+
case 16:
|
|
822
828
|
if (originProduct) {
|
|
823
829
|
baseData = _objectSpread(_objectSpread(_objectSpread({}, originProduct), baseData), {}, {
|
|
824
830
|
classificationInfo: originProduct.classificationInfo,
|
|
@@ -879,14 +885,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
879
885
|
|
|
880
886
|
//media removed from the products is deleted from the server
|
|
881
887
|
j = 0;
|
|
882
|
-
case
|
|
888
|
+
case 22:
|
|
883
889
|
if (!(removedMedia && j < removedMedia.length)) {
|
|
884
|
-
|
|
890
|
+
_context5.next = 31;
|
|
885
891
|
break;
|
|
886
892
|
}
|
|
887
893
|
mediaRef = removedMedia[j];
|
|
888
894
|
if (!mediaRef.ref) {
|
|
889
|
-
|
|
895
|
+
_context5.next = 28;
|
|
890
896
|
break;
|
|
891
897
|
}
|
|
892
898
|
(_this$openModal = this.openModal) === null || _this$openModal === void 0 || _this$openModal.call(this, {
|
|
@@ -894,54 +900,29 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
894
900
|
title: (_this$t = this.t) === null || _this$t === void 0 ? void 0 : _this$t.call(this, 'productcreator.remove_old_media_refs'),
|
|
895
901
|
dontRenderForm: true
|
|
896
902
|
});
|
|
897
|
-
|
|
903
|
+
_context5.next = 28;
|
|
898
904
|
return this.apiRemoveMedia(this.mediaService, mediaRef.ref, this.jwt);
|
|
899
|
-
case
|
|
905
|
+
case 28:
|
|
900
906
|
j++;
|
|
901
|
-
|
|
907
|
+
_context5.next = 22;
|
|
902
908
|
break;
|
|
903
|
-
case
|
|
904
|
-
if (
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
title: (_this$t2 = this.t) === null || _this$t2 === void 0 ? void 0 : _this$t2.call(this, 'productcreator.save_media'),
|
|
919
|
-
dontRenderForm: true
|
|
920
|
-
});
|
|
921
|
-
_context4.next = 37;
|
|
922
|
-
return this.saveProductMedia(baseData.media[_j], baseProduct.organizationId);
|
|
923
|
-
case 37:
|
|
924
|
-
savedMedia = _context4.sent;
|
|
925
|
-
if (savedMedia) {
|
|
926
|
-
baseProduct.media.push(savedMedia);
|
|
927
|
-
} else {
|
|
928
|
-
//otherwise the file already exists on the server
|
|
929
|
-
baseProduct.media.push({
|
|
930
|
-
url: baseData.media[_j].url,
|
|
931
|
-
thumbnail: baseData.media[_j].thumbnail,
|
|
932
|
-
ref: baseData.media[_j].ref,
|
|
933
|
-
mediaType: baseData.media[_j].mediaType,
|
|
934
|
-
functionType: baseData.media[_j].functionType,
|
|
935
|
-
description: baseData.media[_j].description,
|
|
936
|
-
name: baseData.media[_j].name,
|
|
937
|
-
"class": baseData.media[_j]["class"]
|
|
938
|
-
});
|
|
909
|
+
case 31:
|
|
910
|
+
if (baseData.media) {
|
|
911
|
+
baseProduct.media = [];
|
|
912
|
+
for (_j = 0; _j < baseData.media.length; _j++) {
|
|
913
|
+
//if a new media is added, the file is present in media object and needs to be saved to the server
|
|
914
|
+
(_this$openModal2 = this.openModal) === null || _this$openModal2 === void 0 || _this$openModal2.call(this, {
|
|
915
|
+
progress: _j / baseData.media.length / 6 + 2 / 6,
|
|
916
|
+
title: (_this$t2 = this.t) === null || _this$t2 === void 0 ? void 0 : _this$t2.call(this, 'productcreator.save_media'),
|
|
917
|
+
dontRenderForm: true
|
|
918
|
+
});
|
|
919
|
+
mediasToSave.push({
|
|
920
|
+
media: baseData.media[_j],
|
|
921
|
+
id: baseData._id
|
|
922
|
+
});
|
|
923
|
+
}
|
|
939
924
|
}
|
|
940
|
-
|
|
941
|
-
_j++;
|
|
942
|
-
_context4.next = 33;
|
|
943
|
-
break;
|
|
944
|
-
case 42:
|
|
925
|
+
|
|
945
926
|
//orderDescription is only needed in FE to display it, it should not be stored to the server
|
|
946
927
|
delete baseProduct.orderDescription;
|
|
947
928
|
|
|
@@ -957,7 +938,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
957
938
|
}
|
|
958
939
|
_loop = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop() {
|
|
959
940
|
var _basket$getProductCon2, _originProduct;
|
|
960
|
-
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k
|
|
941
|
+
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k;
|
|
961
942
|
return _regeneratorRuntime__default["default"].wrap(function _loop$(_context3) {
|
|
962
943
|
while (1) switch (_context3.prev = _context3.next) {
|
|
963
944
|
case 0:
|
|
@@ -1088,79 +1069,91 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1088
1069
|
archived: baseProduct.archived ? baseProduct.archived : false,
|
|
1089
1070
|
uniqueHash: vd.uniqueHash
|
|
1090
1071
|
});
|
|
1091
|
-
if (
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
progress: _j2 / variantData.length / 6 + 3 / 6,
|
|
1098
|
-
title: (_this3$t = _this3.t) === null || _this3$t === void 0 ? void 0 : _this3$t.call(_this3, 'productcreator.save_media_variants'),
|
|
1099
|
-
dontRenderForm: true
|
|
1100
|
-
});
|
|
1101
|
-
k = 0;
|
|
1102
|
-
case 20:
|
|
1103
|
-
if (!(k < vd.media.length)) {
|
|
1104
|
-
_context3.next = 28;
|
|
1105
|
-
break;
|
|
1106
|
-
}
|
|
1107
|
-
_context3.next = 23;
|
|
1108
|
-
return _this3.saveProductMedia(vd.media[k], baseProduct.organizationId);
|
|
1109
|
-
case 23:
|
|
1110
|
-
_savedMedia = _context3.sent;
|
|
1111
|
-
if (_savedMedia) {
|
|
1112
|
-
product.media.push(_savedMedia);
|
|
1113
|
-
} else {
|
|
1114
|
-
//otherwise the file already exists on the server
|
|
1115
|
-
product.media.push({
|
|
1116
|
-
url: vd.media[k].url,
|
|
1117
|
-
thumbnail: vd.media[k].thumbnail,
|
|
1118
|
-
ref: vd.media[k].ref,
|
|
1119
|
-
mediaType: vd.media[k].mediaType,
|
|
1120
|
-
functionType: vd.media[k].functionType,
|
|
1121
|
-
description: vd.media[k].description,
|
|
1122
|
-
name: vd.media[k].name,
|
|
1123
|
-
"class": vd.media[k]["class"]
|
|
1072
|
+
if (vd.media) {
|
|
1073
|
+
product.media = [];
|
|
1074
|
+
(_this3$openModal = _this3.openModal) === null || _this3$openModal === void 0 || _this3$openModal.call(_this3, {
|
|
1075
|
+
progress: _j2 / variantData.length / 6 + 3 / 6,
|
|
1076
|
+
title: (_this3$t = _this3.t) === null || _this3$t === void 0 ? void 0 : _this3$t.call(_this3, 'productcreator.save_media_variants'),
|
|
1077
|
+
dontRenderForm: true
|
|
1124
1078
|
});
|
|
1079
|
+
for (k = 0; k < vd.media.length; k++) {
|
|
1080
|
+
mediasToSave.push({
|
|
1081
|
+
media: vd.media[k],
|
|
1082
|
+
id: vd._id
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1125
1085
|
}
|
|
1126
|
-
case 25:
|
|
1127
|
-
k++;
|
|
1128
|
-
_context3.next = 20;
|
|
1129
|
-
break;
|
|
1130
|
-
case 28:
|
|
1131
1086
|
//add the variant product it the list of products to be saved
|
|
1132
1087
|
products.push(product);
|
|
1133
|
-
case
|
|
1088
|
+
case 18:
|
|
1134
1089
|
case "end":
|
|
1135
1090
|
return _context3.stop();
|
|
1136
1091
|
}
|
|
1137
1092
|
}, _loop);
|
|
1138
1093
|
});
|
|
1139
1094
|
_j2 = 0;
|
|
1140
|
-
case
|
|
1095
|
+
case 37:
|
|
1141
1096
|
if (!(variantData && _j2 < variantData.length)) {
|
|
1142
|
-
|
|
1097
|
+
_context5.next = 44;
|
|
1143
1098
|
break;
|
|
1144
1099
|
}
|
|
1145
|
-
return
|
|
1146
|
-
case
|
|
1147
|
-
if (!
|
|
1148
|
-
|
|
1100
|
+
return _context5.delegateYield(_loop(), "t0", 39);
|
|
1101
|
+
case 39:
|
|
1102
|
+
if (!_context5.t0) {
|
|
1103
|
+
_context5.next = 41;
|
|
1149
1104
|
break;
|
|
1150
1105
|
}
|
|
1151
|
-
return
|
|
1152
|
-
case
|
|
1106
|
+
return _context5.abrupt("continue", 41);
|
|
1107
|
+
case 41:
|
|
1153
1108
|
_j2++;
|
|
1154
|
-
|
|
1109
|
+
_context5.next = 37;
|
|
1110
|
+
break;
|
|
1111
|
+
case 44:
|
|
1112
|
+
_context5.next = 46;
|
|
1113
|
+
return this.saveMedias(mediasToSave, baseData.organizationId);
|
|
1114
|
+
case 46:
|
|
1115
|
+
mediasForProducts = _context5.sent;
|
|
1116
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop2(productId) {
|
|
1117
|
+
var p;
|
|
1118
|
+
return _regeneratorRuntime__default["default"].wrap(function _loop2$(_context4) {
|
|
1119
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1120
|
+
case 0:
|
|
1121
|
+
mediasForProducts[productId];
|
|
1122
|
+
p = products.find(function (p) {
|
|
1123
|
+
return p._id == productId;
|
|
1124
|
+
});
|
|
1125
|
+
if (p) {
|
|
1126
|
+
_context4.next = 4;
|
|
1127
|
+
break;
|
|
1128
|
+
}
|
|
1129
|
+
throw Error('Product with id ' + productId + ' not fount during saving');
|
|
1130
|
+
case 4:
|
|
1131
|
+
p.media = mediasForProducts[productId].medias;
|
|
1132
|
+
case 5:
|
|
1133
|
+
case "end":
|
|
1134
|
+
return _context4.stop();
|
|
1135
|
+
}
|
|
1136
|
+
}, _loop2);
|
|
1137
|
+
});
|
|
1138
|
+
_context5.t1 = _regeneratorRuntime__default["default"].keys(mediasForProducts);
|
|
1139
|
+
case 49:
|
|
1140
|
+
if ((_context5.t2 = _context5.t1()).done) {
|
|
1141
|
+
_context5.next = 54;
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
productId = _context5.t2.value;
|
|
1145
|
+
return _context5.delegateYield(_loop2(productId), "t3", 52);
|
|
1146
|
+
case 52:
|
|
1147
|
+
_context5.next = 49;
|
|
1155
1148
|
break;
|
|
1156
1149
|
case 54:
|
|
1157
|
-
return
|
|
1150
|
+
return _context5.abrupt("return", {
|
|
1158
1151
|
products: products,
|
|
1159
1152
|
removedProducts: removedProducts
|
|
1160
1153
|
});
|
|
1161
1154
|
case 55:
|
|
1162
1155
|
case "end":
|
|
1163
|
-
return
|
|
1156
|
+
return _context5.stop();
|
|
1164
1157
|
}
|
|
1165
1158
|
}, _callee3, this);
|
|
1166
1159
|
}));
|
|
@@ -1183,32 +1176,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1183
1176
|
value: function () {
|
|
1184
1177
|
var _saveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref29) {
|
|
1185
1178
|
var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
|
|
1186
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee4$(
|
|
1187
|
-
while (1) switch (
|
|
1179
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context6) {
|
|
1180
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1188
1181
|
case 0:
|
|
1189
1182
|
products = _ref29.products, removedProducts = _ref29.removedProducts, awaitPDF = _ref29.awaitPDF;
|
|
1190
1183
|
if (this.jwt) {
|
|
1191
|
-
|
|
1184
|
+
_context6.next = 3;
|
|
1192
1185
|
break;
|
|
1193
1186
|
}
|
|
1194
1187
|
throw new Error('jwt not set');
|
|
1195
1188
|
case 3:
|
|
1196
1189
|
this.setFirstVariant(products);
|
|
1197
|
-
|
|
1198
|
-
|
|
1190
|
+
_context6.prev = 4;
|
|
1191
|
+
_context6.next = 7;
|
|
1199
1192
|
return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
|
|
1200
1193
|
case 7:
|
|
1201
|
-
savedProducts =
|
|
1194
|
+
savedProducts = _context6.sent;
|
|
1202
1195
|
(_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
|
|
1203
|
-
return
|
|
1196
|
+
return _context6.abrupt("return", savedProducts);
|
|
1204
1197
|
case 12:
|
|
1205
|
-
|
|
1206
|
-
|
|
1198
|
+
_context6.prev = 12;
|
|
1199
|
+
_context6.t0 = _context6["catch"](4);
|
|
1207
1200
|
(_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
|
|
1208
|
-
throw new Error(
|
|
1201
|
+
throw new Error(_context6.t0.message);
|
|
1209
1202
|
case 16:
|
|
1210
1203
|
case "end":
|
|
1211
|
-
return
|
|
1204
|
+
return _context6.stop();
|
|
1212
1205
|
}
|
|
1213
1206
|
}, _callee4, this, [[4, 12]]);
|
|
1214
1207
|
}));
|
|
@@ -1546,35 +1539,35 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1546
1539
|
value: function () {
|
|
1547
1540
|
var _apiRemoveMedia = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(serviceUrl, ref, jwt) {
|
|
1548
1541
|
var url, response;
|
|
1549
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee5$(
|
|
1550
|
-
while (1) switch (
|
|
1542
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context7) {
|
|
1543
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1551
1544
|
case 0:
|
|
1552
1545
|
url = new URL("".concat(serviceUrl, "/v1/mediaitems/refs/") + ref);
|
|
1553
|
-
|
|
1554
|
-
|
|
1546
|
+
_context7.prev = 1;
|
|
1547
|
+
_context7.next = 4;
|
|
1555
1548
|
return axios__default["default"]["delete"](url.toString(), {
|
|
1556
1549
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1557
1550
|
'Content-Type': 'application/json'
|
|
1558
1551
|
})
|
|
1559
1552
|
});
|
|
1560
1553
|
case 4:
|
|
1561
|
-
response =
|
|
1554
|
+
response = _context7.sent;
|
|
1562
1555
|
if (!((response === null || response === void 0 ? void 0 : response.status) == 200)) {
|
|
1563
|
-
|
|
1556
|
+
_context7.next = 7;
|
|
1564
1557
|
break;
|
|
1565
1558
|
}
|
|
1566
|
-
return
|
|
1559
|
+
return _context7.abrupt("return", response.data);
|
|
1567
1560
|
case 7:
|
|
1568
1561
|
throw new Error('Could not remove Media');
|
|
1569
1562
|
case 10:
|
|
1570
|
-
|
|
1571
|
-
|
|
1563
|
+
_context7.prev = 10;
|
|
1564
|
+
_context7.t0 = _context7["catch"](1);
|
|
1572
1565
|
throw new Error('Could not remove Media', {
|
|
1573
|
-
cause:
|
|
1566
|
+
cause: _context7.t0
|
|
1574
1567
|
});
|
|
1575
1568
|
case 13:
|
|
1576
1569
|
case "end":
|
|
1577
|
-
return
|
|
1570
|
+
return _context7.stop();
|
|
1578
1571
|
}
|
|
1579
1572
|
}, _callee5, this, [[1, 10]]);
|
|
1580
1573
|
}));
|
|
@@ -1603,34 +1596,34 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1603
1596
|
var _apiGetProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(divanrOrID) {
|
|
1604
1597
|
var _res;
|
|
1605
1598
|
var fullUrl, res, resData;
|
|
1606
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee6$(
|
|
1607
|
-
while (1) switch (
|
|
1599
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context8) {
|
|
1600
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1608
1601
|
case 0:
|
|
1609
1602
|
fullUrl = this.catalogService + '/v1/products/' + divanrOrID + '/list';
|
|
1610
|
-
|
|
1611
|
-
|
|
1603
|
+
_context8.prev = 1;
|
|
1604
|
+
_context8.next = 4;
|
|
1612
1605
|
return axios__default["default"].get(fullUrl, {
|
|
1613
1606
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1614
1607
|
'Content-Type': 'application/json'
|
|
1615
1608
|
})
|
|
1616
1609
|
});
|
|
1617
1610
|
case 4:
|
|
1618
|
-
res =
|
|
1619
|
-
|
|
1611
|
+
res = _context8.sent;
|
|
1612
|
+
_context8.next = 7;
|
|
1620
1613
|
return res.data;
|
|
1621
1614
|
case 7:
|
|
1622
|
-
resData =
|
|
1623
|
-
|
|
1615
|
+
resData = _context8.sent;
|
|
1616
|
+
_context8.next = 13;
|
|
1624
1617
|
break;
|
|
1625
1618
|
case 10:
|
|
1626
|
-
|
|
1627
|
-
|
|
1619
|
+
_context8.prev = 10;
|
|
1620
|
+
_context8.t0 = _context8["catch"](1);
|
|
1628
1621
|
throw new Error('Could not get existing products', {
|
|
1629
|
-
cause:
|
|
1622
|
+
cause: _context8.t0
|
|
1630
1623
|
});
|
|
1631
1624
|
case 13:
|
|
1632
1625
|
if (!(((_res = res) === null || _res === void 0 ? void 0 : _res.status) == 200)) {
|
|
1633
|
-
|
|
1626
|
+
_context8.next = 16;
|
|
1634
1627
|
break;
|
|
1635
1628
|
}
|
|
1636
1629
|
//in order to be backwardscompatible we must transform old products here
|
|
@@ -1643,12 +1636,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1643
1636
|
}
|
|
1644
1637
|
return d;
|
|
1645
1638
|
});
|
|
1646
|
-
return
|
|
1639
|
+
return _context8.abrupt("return", resData);
|
|
1647
1640
|
case 16:
|
|
1648
1641
|
throw new Error(resData.error);
|
|
1649
1642
|
case 17:
|
|
1650
1643
|
case "end":
|
|
1651
|
-
return
|
|
1644
|
+
return _context8.stop();
|
|
1652
1645
|
}
|
|
1653
1646
|
}, _callee6, this, [[1, 10]]);
|
|
1654
1647
|
}));
|
|
@@ -1663,21 +1656,21 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1663
1656
|
var _apiGetCatalogData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(catalogCodex, catalogId, language, accountId) {
|
|
1664
1657
|
var _response$CollectionG, _response$Properties, _response$Properties2;
|
|
1665
1658
|
var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
|
|
1666
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee7$(
|
|
1667
|
-
while (1) switch (
|
|
1659
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context9) {
|
|
1660
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1668
1661
|
case 0:
|
|
1669
|
-
|
|
1662
|
+
_context9.next = 2;
|
|
1670
1663
|
return this.apiAccountLogin(accountId, catalogId);
|
|
1671
1664
|
case 2:
|
|
1672
|
-
currentAccountSessionId =
|
|
1665
|
+
currentAccountSessionId = _context9.sent;
|
|
1673
1666
|
if (currentAccountSessionId) {
|
|
1674
|
-
|
|
1667
|
+
_context9.next = 5;
|
|
1675
1668
|
break;
|
|
1676
1669
|
}
|
|
1677
|
-
return
|
|
1670
|
+
return _context9.abrupt("return");
|
|
1678
1671
|
case 5:
|
|
1679
1672
|
fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
|
|
1680
|
-
|
|
1673
|
+
_context9.next = 8;
|
|
1681
1674
|
return fetch(fullUrl, {
|
|
1682
1675
|
headers: {
|
|
1683
1676
|
sessionGuid: currentAccountSessionId
|
|
@@ -1689,9 +1682,9 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1689
1682
|
return res.json();
|
|
1690
1683
|
});
|
|
1691
1684
|
case 8:
|
|
1692
|
-
response =
|
|
1685
|
+
response = _context9.sent;
|
|
1693
1686
|
if (!response.Error) {
|
|
1694
|
-
|
|
1687
|
+
_context9.next = 11;
|
|
1695
1688
|
break;
|
|
1696
1689
|
}
|
|
1697
1690
|
throw new Error(response.Error);
|
|
@@ -1724,10 +1717,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1724
1717
|
return p.Codex == 'DIVA3D_AR_READY';
|
|
1725
1718
|
})) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
|
|
1726
1719
|
};
|
|
1727
|
-
return
|
|
1720
|
+
return _context9.abrupt("return", actCatalogInfoData);
|
|
1728
1721
|
case 13:
|
|
1729
1722
|
case "end":
|
|
1730
|
-
return
|
|
1723
|
+
return _context9.stop();
|
|
1731
1724
|
}
|
|
1732
1725
|
}, _callee7, this);
|
|
1733
1726
|
}));
|
|
@@ -1741,63 +1734,63 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1741
1734
|
value: function () {
|
|
1742
1735
|
var _apiAccountLogin = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(accountId, catalogId) {
|
|
1743
1736
|
var fullUrl, response, fallbackUrl, fallbackResponse;
|
|
1744
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee8$(
|
|
1745
|
-
while (1) switch (
|
|
1737
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context10) {
|
|
1738
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1746
1739
|
case 0:
|
|
1747
1740
|
fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1741
|
+
_context10.t0 = fetch;
|
|
1742
|
+
_context10.t1 = fullUrl;
|
|
1743
|
+
_context10.next = 5;
|
|
1751
1744
|
return this.sessionGuid;
|
|
1752
1745
|
case 5:
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
sessionGuid:
|
|
1746
|
+
_context10.t2 = _context10.sent;
|
|
1747
|
+
_context10.t3 = {
|
|
1748
|
+
sessionGuid: _context10.t2
|
|
1756
1749
|
};
|
|
1757
|
-
|
|
1758
|
-
headers:
|
|
1750
|
+
_context10.t4 = {
|
|
1751
|
+
headers: _context10.t3
|
|
1759
1752
|
};
|
|
1760
|
-
|
|
1761
|
-
return (0,
|
|
1753
|
+
_context10.next = 10;
|
|
1754
|
+
return (0, _context10.t0)(_context10.t1, _context10.t4).then(function (res) {
|
|
1762
1755
|
if (res.status !== 200) {
|
|
1763
1756
|
throw new Error('Collections not loaded.');
|
|
1764
1757
|
}
|
|
1765
1758
|
return res.json();
|
|
1766
1759
|
});
|
|
1767
1760
|
case 10:
|
|
1768
|
-
response =
|
|
1761
|
+
response = _context10.sent;
|
|
1769
1762
|
if (!response.SessionGUID) {
|
|
1770
|
-
|
|
1763
|
+
_context10.next = 13;
|
|
1771
1764
|
break;
|
|
1772
1765
|
}
|
|
1773
|
-
return
|
|
1766
|
+
return _context10.abrupt("return", response.SessionGUID);
|
|
1774
1767
|
case 13:
|
|
1775
1768
|
fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1769
|
+
_context10.t5 = fetch;
|
|
1770
|
+
_context10.t6 = fallbackUrl;
|
|
1771
|
+
_context10.next = 18;
|
|
1779
1772
|
return this.sessionGuid;
|
|
1780
1773
|
case 18:
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
sessionGuid:
|
|
1774
|
+
_context10.t7 = _context10.sent;
|
|
1775
|
+
_context10.t8 = {
|
|
1776
|
+
sessionGuid: _context10.t7
|
|
1784
1777
|
};
|
|
1785
|
-
|
|
1786
|
-
headers:
|
|
1778
|
+
_context10.t9 = {
|
|
1779
|
+
headers: _context10.t8
|
|
1787
1780
|
};
|
|
1788
|
-
|
|
1789
|
-
return (0,
|
|
1781
|
+
_context10.next = 23;
|
|
1782
|
+
return (0, _context10.t5)(_context10.t6, _context10.t9).then(function (res) {
|
|
1790
1783
|
if (res.status !== 200) {
|
|
1791
1784
|
throw new Error('Collections not loaded.');
|
|
1792
1785
|
}
|
|
1793
1786
|
return res.json();
|
|
1794
1787
|
});
|
|
1795
1788
|
case 23:
|
|
1796
|
-
fallbackResponse =
|
|
1797
|
-
return
|
|
1789
|
+
fallbackResponse = _context10.sent;
|
|
1790
|
+
return _context10.abrupt("return", fallbackResponse.SessionGUID);
|
|
1798
1791
|
case 25:
|
|
1799
1792
|
case "end":
|
|
1800
|
-
return
|
|
1793
|
+
return _context10.stop();
|
|
1801
1794
|
}
|
|
1802
1795
|
}, _callee8, this);
|
|
1803
1796
|
}));
|
|
@@ -1812,42 +1805,42 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1812
1805
|
var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(id, full) {
|
|
1813
1806
|
var _res2;
|
|
1814
1807
|
var fullUrl, res, resData;
|
|
1815
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee9$(
|
|
1816
|
-
while (1) switch (
|
|
1808
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context11) {
|
|
1809
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1817
1810
|
case 0:
|
|
1818
1811
|
fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
|
|
1819
|
-
|
|
1820
|
-
|
|
1812
|
+
_context11.prev = 1;
|
|
1813
|
+
_context11.next = 4;
|
|
1821
1814
|
return axios__default["default"].get(fullUrl, {
|
|
1822
1815
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1823
1816
|
'Content-Type': 'application/json'
|
|
1824
1817
|
})
|
|
1825
1818
|
});
|
|
1826
1819
|
case 4:
|
|
1827
|
-
res =
|
|
1828
|
-
|
|
1820
|
+
res = _context11.sent;
|
|
1821
|
+
_context11.next = 7;
|
|
1829
1822
|
return res.data;
|
|
1830
1823
|
case 7:
|
|
1831
|
-
resData =
|
|
1832
|
-
|
|
1824
|
+
resData = _context11.sent;
|
|
1825
|
+
_context11.next = 13;
|
|
1833
1826
|
break;
|
|
1834
1827
|
case 10:
|
|
1835
|
-
|
|
1836
|
-
|
|
1828
|
+
_context11.prev = 10;
|
|
1829
|
+
_context11.t0 = _context11["catch"](1);
|
|
1837
1830
|
throw new Error('Could not get existing products', {
|
|
1838
|
-
cause:
|
|
1831
|
+
cause: _context11.t0
|
|
1839
1832
|
});
|
|
1840
1833
|
case 13:
|
|
1841
1834
|
if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
|
|
1842
|
-
|
|
1835
|
+
_context11.next = 15;
|
|
1843
1836
|
break;
|
|
1844
1837
|
}
|
|
1845
|
-
return
|
|
1838
|
+
return _context11.abrupt("return", resData);
|
|
1846
1839
|
case 15:
|
|
1847
1840
|
throw new Error(resData.error);
|
|
1848
1841
|
case 16:
|
|
1849
1842
|
case "end":
|
|
1850
|
-
return
|
|
1843
|
+
return _context11.stop();
|
|
1851
1844
|
}
|
|
1852
1845
|
}, _callee9, this, [[1, 10]]);
|
|
1853
1846
|
}));
|
|
@@ -1868,39 +1861,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1868
1861
|
res,
|
|
1869
1862
|
resData,
|
|
1870
1863
|
filterParam,
|
|
1871
|
-
|
|
1872
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee10$(
|
|
1873
|
-
while (1) switch (
|
|
1864
|
+
_args12 = arguments;
|
|
1865
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context12) {
|
|
1866
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1874
1867
|
case 0:
|
|
1875
|
-
limit =
|
|
1876
|
-
useFilter =
|
|
1877
|
-
hierarchy =
|
|
1868
|
+
limit = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : 1;
|
|
1869
|
+
useFilter = _args12.length > 2 ? _args12[2] : undefined;
|
|
1870
|
+
hierarchy = _args12.length > 3 ? _args12[3] : undefined;
|
|
1878
1871
|
fullUrl = this.catalogService + '/v1/products';
|
|
1879
|
-
|
|
1872
|
+
_context12.prev = 4;
|
|
1880
1873
|
filterParam = useFilter ? 'filter' : 'search';
|
|
1881
|
-
|
|
1874
|
+
_context12.next = 8;
|
|
1882
1875
|
return axios__default["default"].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), {
|
|
1883
1876
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1884
1877
|
'Content-Type': 'application/json'
|
|
1885
1878
|
})
|
|
1886
1879
|
});
|
|
1887
1880
|
case 8:
|
|
1888
|
-
res =
|
|
1889
|
-
|
|
1881
|
+
res = _context12.sent;
|
|
1882
|
+
_context12.next = 11;
|
|
1890
1883
|
return res.data;
|
|
1891
1884
|
case 11:
|
|
1892
|
-
resData =
|
|
1893
|
-
|
|
1885
|
+
resData = _context12.sent;
|
|
1886
|
+
_context12.next = 17;
|
|
1894
1887
|
break;
|
|
1895
1888
|
case 14:
|
|
1896
|
-
|
|
1897
|
-
|
|
1889
|
+
_context12.prev = 14;
|
|
1890
|
+
_context12.t0 = _context12["catch"](4);
|
|
1898
1891
|
throw new Error('Could not get existing products', {
|
|
1899
|
-
cause:
|
|
1892
|
+
cause: _context12.t0
|
|
1900
1893
|
});
|
|
1901
1894
|
case 17:
|
|
1902
1895
|
if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
|
|
1903
|
-
|
|
1896
|
+
_context12.next = 20;
|
|
1904
1897
|
break;
|
|
1905
1898
|
}
|
|
1906
1899
|
//in order to be backwardscompatible we must transform old products here
|
|
@@ -1913,12 +1906,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1913
1906
|
}
|
|
1914
1907
|
return d;
|
|
1915
1908
|
});
|
|
1916
|
-
return
|
|
1909
|
+
return _context12.abrupt("return", resData);
|
|
1917
1910
|
case 20:
|
|
1918
1911
|
throw new Error(resData.error);
|
|
1919
1912
|
case 21:
|
|
1920
1913
|
case "end":
|
|
1921
|
-
return
|
|
1914
|
+
return _context12.stop();
|
|
1922
1915
|
}
|
|
1923
1916
|
}, _callee10, this, [[4, 14]]);
|
|
1924
1917
|
}));
|
|
@@ -1933,43 +1926,43 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1933
1926
|
var _apiActivateProduct = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(id, organizationId) {
|
|
1934
1927
|
var _res4;
|
|
1935
1928
|
var fullUrl, res, resData;
|
|
1936
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee11$(
|
|
1937
|
-
while (1) switch (
|
|
1929
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context13) {
|
|
1930
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1938
1931
|
case 0:
|
|
1939
1932
|
fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/activate');
|
|
1940
1933
|
fullUrl.searchParams.append('organizationId', organizationId);
|
|
1941
|
-
|
|
1942
|
-
|
|
1934
|
+
_context13.prev = 2;
|
|
1935
|
+
_context13.next = 5;
|
|
1943
1936
|
return axios__default["default"].post(fullUrl.toString(), undefined, {
|
|
1944
1937
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1945
1938
|
'Content-Type': 'application/json'
|
|
1946
1939
|
})
|
|
1947
1940
|
});
|
|
1948
1941
|
case 5:
|
|
1949
|
-
res =
|
|
1950
|
-
|
|
1942
|
+
res = _context13.sent;
|
|
1943
|
+
_context13.next = 8;
|
|
1951
1944
|
return res.data;
|
|
1952
1945
|
case 8:
|
|
1953
|
-
resData =
|
|
1954
|
-
|
|
1946
|
+
resData = _context13.sent;
|
|
1947
|
+
_context13.next = 14;
|
|
1955
1948
|
break;
|
|
1956
1949
|
case 11:
|
|
1957
|
-
|
|
1958
|
-
|
|
1950
|
+
_context13.prev = 11;
|
|
1951
|
+
_context13.t0 = _context13["catch"](2);
|
|
1959
1952
|
throw new Error('Error on activate product', {
|
|
1960
|
-
cause:
|
|
1953
|
+
cause: _context13.t0
|
|
1961
1954
|
});
|
|
1962
1955
|
case 14:
|
|
1963
1956
|
if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
|
|
1964
|
-
|
|
1957
|
+
_context13.next = 16;
|
|
1965
1958
|
break;
|
|
1966
1959
|
}
|
|
1967
|
-
return
|
|
1960
|
+
return _context13.abrupt("return", resData);
|
|
1968
1961
|
case 16:
|
|
1969
1962
|
throw new Error(resData.error);
|
|
1970
1963
|
case 17:
|
|
1971
1964
|
case "end":
|
|
1972
|
-
return
|
|
1965
|
+
return _context13.stop();
|
|
1973
1966
|
}
|
|
1974
1967
|
}, _callee11, this, [[2, 11]]);
|
|
1975
1968
|
}));
|
|
@@ -1983,8 +1976,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1983
1976
|
value: function () {
|
|
1984
1977
|
var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(products) {
|
|
1985
1978
|
var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
|
|
1986
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee12$(
|
|
1987
|
-
while (1) switch (
|
|
1979
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context14) {
|
|
1980
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1988
1981
|
case 0:
|
|
1989
1982
|
fullUrl = this.catalogService + '/products';
|
|
1990
1983
|
fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
|
|
@@ -1995,7 +1988,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1995
1988
|
i = 0;
|
|
1996
1989
|
case 5:
|
|
1997
1990
|
if (!(i < productsInChunks.length)) {
|
|
1998
|
-
|
|
1991
|
+
_context14.next = 13;
|
|
1999
1992
|
break;
|
|
2000
1993
|
}
|
|
2001
1994
|
promises = productsInChunks[i].map(function (p) {
|
|
@@ -2017,15 +2010,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2017
2010
|
title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
|
|
2018
2011
|
dontRenderForm: true
|
|
2019
2012
|
});
|
|
2020
|
-
|
|
2013
|
+
_context14.next = 10;
|
|
2021
2014
|
return Promise.all(promises);
|
|
2022
2015
|
case 10:
|
|
2023
2016
|
i++;
|
|
2024
|
-
|
|
2017
|
+
_context14.next = 5;
|
|
2025
2018
|
break;
|
|
2026
2019
|
case 13:
|
|
2027
2020
|
case "end":
|
|
2028
|
-
return
|
|
2021
|
+
return _context14.stop();
|
|
2029
2022
|
}
|
|
2030
2023
|
}, _callee12, this);
|
|
2031
2024
|
}));
|
|
@@ -2048,8 +2041,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2048
2041
|
value: function () {
|
|
2049
2042
|
var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(_ref46) {
|
|
2050
2043
|
var limit, skip, fields, _ref46$search, search, sort, abortController, fullUrl, headers, promise;
|
|
2051
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee13$(
|
|
2052
|
-
while (1) switch (
|
|
2044
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context15) {
|
|
2045
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2053
2046
|
case 0:
|
|
2054
2047
|
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;
|
|
2055
2048
|
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__default["default"].fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search ? '&search=' + DivaUtils__default["default"].fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils__default["default"].fixedEncodeURIComponent(sort) : '');
|
|
@@ -2073,13 +2066,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2073
2066
|
reject('Error loading products grouped by variants: ' + error.message);
|
|
2074
2067
|
});
|
|
2075
2068
|
});
|
|
2076
|
-
|
|
2069
|
+
_context15.next = 7;
|
|
2077
2070
|
return promise;
|
|
2078
2071
|
case 7:
|
|
2079
|
-
return
|
|
2072
|
+
return _context15.abrupt("return", _context15.sent);
|
|
2080
2073
|
case 8:
|
|
2081
2074
|
case "end":
|
|
2082
|
-
return
|
|
2075
|
+
return _context15.stop();
|
|
2083
2076
|
}
|
|
2084
2077
|
}, _callee13, this);
|
|
2085
2078
|
}));
|
|
@@ -2092,9 +2085,9 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2092
2085
|
key: "apiSaveProducts",
|
|
2093
2086
|
value: function () {
|
|
2094
2087
|
var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
|
|
2095
|
-
var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2,
|
|
2096
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee14$(
|
|
2097
|
-
while (1) switch (
|
|
2088
|
+
var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop3, j;
|
|
2089
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context17) {
|
|
2090
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2098
2091
|
case 0:
|
|
2099
2092
|
fullUrl = serverUrl + '/v1/products/groups';
|
|
2100
2093
|
BATCH_SIZE = 40;
|
|
@@ -2103,34 +2096,34 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2103
2096
|
i = 0;
|
|
2104
2097
|
case 5:
|
|
2105
2098
|
if (!(i < products.length)) {
|
|
2106
|
-
|
|
2099
|
+
_context17.next = 15;
|
|
2107
2100
|
break;
|
|
2108
2101
|
}
|
|
2109
2102
|
if (!products[i].baseProduct) {
|
|
2110
|
-
|
|
2103
|
+
_context17.next = 9;
|
|
2111
2104
|
break;
|
|
2112
2105
|
}
|
|
2113
2106
|
baseProduct = products[i];
|
|
2114
|
-
return
|
|
2107
|
+
return _context17.abrupt("continue", 12);
|
|
2115
2108
|
case 9:
|
|
2116
2109
|
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++;
|
|
2117
2110
|
if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
|
|
2118
2111
|
productsPackages[groupIndex].push(products[i]);
|
|
2119
2112
|
case 12:
|
|
2120
2113
|
i++;
|
|
2121
|
-
|
|
2114
|
+
_context17.next = 5;
|
|
2122
2115
|
break;
|
|
2123
2116
|
case 15:
|
|
2124
2117
|
responseProducts = [];
|
|
2125
2118
|
_i2 = 0;
|
|
2126
2119
|
case 17:
|
|
2127
2120
|
if (!(_i2 < productsPackages.length)) {
|
|
2128
|
-
|
|
2121
|
+
_context17.next = 40;
|
|
2129
2122
|
break;
|
|
2130
2123
|
}
|
|
2131
2124
|
if (baseProduct) productsPackages[_i2].unshift(baseProduct);
|
|
2132
|
-
|
|
2133
|
-
|
|
2125
|
+
_context17.prev = 19;
|
|
2126
|
+
_context17.next = 22;
|
|
2134
2127
|
return fetch(fullUrl, {
|
|
2135
2128
|
method: 'PUT',
|
|
2136
2129
|
headers: {
|
|
@@ -2150,23 +2143,23 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2150
2143
|
return res.json();
|
|
2151
2144
|
});
|
|
2152
2145
|
case 22:
|
|
2153
|
-
response =
|
|
2146
|
+
response = _context17.sent;
|
|
2154
2147
|
if (!response.Error) {
|
|
2155
|
-
|
|
2148
|
+
_context17.next = 25;
|
|
2156
2149
|
break;
|
|
2157
2150
|
}
|
|
2158
2151
|
throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
|
|
2159
2152
|
case 25:
|
|
2160
|
-
|
|
2153
|
+
_context17.next = 30;
|
|
2161
2154
|
break;
|
|
2162
2155
|
case 27:
|
|
2163
|
-
|
|
2164
|
-
|
|
2156
|
+
_context17.prev = 27;
|
|
2157
|
+
_context17.t0 = _context17["catch"](19);
|
|
2165
2158
|
throw Error(status);
|
|
2166
2159
|
case 30:
|
|
2167
|
-
|
|
2168
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
2169
|
-
while (1) switch (
|
|
2160
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop3(j) {
|
|
2161
|
+
return _regeneratorRuntime__default["default"].wrap(function _loop3$(_context16) {
|
|
2162
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2170
2163
|
case 0:
|
|
2171
2164
|
if (response.products[j].baseProduct) baseProduct = response.products[j];
|
|
2172
2165
|
if (!responseProducts.find(function (p) {
|
|
@@ -2176,30 +2169,30 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2176
2169
|
}
|
|
2177
2170
|
case 2:
|
|
2178
2171
|
case "end":
|
|
2179
|
-
return
|
|
2172
|
+
return _context16.stop();
|
|
2180
2173
|
}
|
|
2181
|
-
},
|
|
2174
|
+
}, _loop3);
|
|
2182
2175
|
});
|
|
2183
2176
|
j = 0;
|
|
2184
2177
|
case 32:
|
|
2185
2178
|
if (!(j < response.products.length)) {
|
|
2186
|
-
|
|
2179
|
+
_context17.next = 37;
|
|
2187
2180
|
break;
|
|
2188
2181
|
}
|
|
2189
|
-
return
|
|
2182
|
+
return _context17.delegateYield(_loop3(j), "t1", 34);
|
|
2190
2183
|
case 34:
|
|
2191
2184
|
j++;
|
|
2192
|
-
|
|
2185
|
+
_context17.next = 32;
|
|
2193
2186
|
break;
|
|
2194
2187
|
case 37:
|
|
2195
2188
|
_i2++;
|
|
2196
|
-
|
|
2189
|
+
_context17.next = 17;
|
|
2197
2190
|
break;
|
|
2198
2191
|
case 40:
|
|
2199
|
-
return
|
|
2192
|
+
return _context17.abrupt("return", responseProducts);
|
|
2200
2193
|
case 41:
|
|
2201
2194
|
case "end":
|
|
2202
|
-
return
|
|
2195
|
+
return _context17.stop();
|
|
2203
2196
|
}
|
|
2204
2197
|
}, _callee14, null, [[19, 27]]);
|
|
2205
2198
|
}));
|
|
@@ -2253,7 +2246,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2253
2246
|
return true;
|
|
2254
2247
|
}
|
|
2255
2248
|
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 : [];
|
|
2256
|
-
var
|
|
2249
|
+
var _loop4 = function _loop4() {
|
|
2257
2250
|
var article = orderlines[i];
|
|
2258
2251
|
var orderLine = orderLines.find(function (ol) {
|
|
2259
2252
|
return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
|
|
@@ -2264,7 +2257,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2264
2257
|
};
|
|
2265
2258
|
}
|
|
2266
2259
|
if (article.VariantBasketDatas.length) {
|
|
2267
|
-
var
|
|
2260
|
+
var _loop5 = function _loop5() {
|
|
2268
2261
|
var varinatValue = article.VariantBasketDatas[j];
|
|
2269
2262
|
if (!varinatData.find(function (vb) {
|
|
2270
2263
|
return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
|
|
@@ -2278,14 +2271,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2278
2271
|
},
|
|
2279
2272
|
_ret2;
|
|
2280
2273
|
for (var j = 0; j < article.VariantBasketDatas.length; j++) {
|
|
2281
|
-
_ret2 =
|
|
2274
|
+
_ret2 = _loop5();
|
|
2282
2275
|
if (_ret2) return _ret2.v;
|
|
2283
2276
|
}
|
|
2284
2277
|
}
|
|
2285
2278
|
},
|
|
2286
2279
|
_ret;
|
|
2287
2280
|
for (var i = 0; i < orderlines.length; i++) {
|
|
2288
|
-
_ret =
|
|
2281
|
+
_ret = _loop4();
|
|
2289
2282
|
if (_ret) return _ret.v;
|
|
2290
2283
|
}
|
|
2291
2284
|
return true;
|
|
@@ -2363,7 +2356,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2363
2356
|
//calculate defaultShortDescription from template string
|
|
2364
2357
|
var shortDescriptionTemplate = (_configurationData$sh = configurationData === null || configurationData === void 0 ? void 0 : configurationData.shortDescription) !== null && _configurationData$sh !== void 0 ? _configurationData$sh : '${modelName} ${subCategory} ${mainColor}';
|
|
2365
2358
|
var parts = shortDescriptionTemplate.split(/\${|}/);
|
|
2366
|
-
var
|
|
2359
|
+
var _loop6 = function _loop6() {
|
|
2367
2360
|
var _classificationConfig2, _classificationConfig4, _value;
|
|
2368
2361
|
var field = parts[i];
|
|
2369
2362
|
var value;
|
|
@@ -2395,7 +2388,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2395
2388
|
shortDescriptionTemplate = shortDescriptionTemplate.replace("${".concat(field, "}"), (_value = value) !== null && _value !== void 0 ? _value : '');
|
|
2396
2389
|
};
|
|
2397
2390
|
for (var i = 1; i < parts.length; i = i + 2) {
|
|
2398
|
-
|
|
2391
|
+
_loop6();
|
|
2399
2392
|
}
|
|
2400
2393
|
|
|
2401
2394
|
//as long as shortDescription is not modified by user, autocalc it
|
|
@@ -2430,8 +2423,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2430
2423
|
value: function () {
|
|
2431
2424
|
var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
|
|
2432
2425
|
var values, apiUrl, i, apiResult, _i3, value, text;
|
|
2433
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee15$(
|
|
2434
|
-
while (1) switch (
|
|
2426
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context18) {
|
|
2427
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2435
2428
|
case 0:
|
|
2436
2429
|
values = [];
|
|
2437
2430
|
apiUrl = dataSource.url;
|
|
@@ -2440,7 +2433,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2440
2433
|
apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
|
|
2441
2434
|
}
|
|
2442
2435
|
}
|
|
2443
|
-
|
|
2436
|
+
_context18.next = 5;
|
|
2444
2437
|
return fetch(apiUrl, {
|
|
2445
2438
|
headers: {
|
|
2446
2439
|
sessionGuid: sessionGuid
|
|
@@ -2452,7 +2445,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2452
2445
|
return res.json();
|
|
2453
2446
|
});
|
|
2454
2447
|
case 5:
|
|
2455
|
-
apiResult =
|
|
2448
|
+
apiResult = _context18.sent;
|
|
2456
2449
|
if (dataSource.useKey) {
|
|
2457
2450
|
apiResult = apiResult[dataSource.useKey];
|
|
2458
2451
|
}
|
|
@@ -2464,10 +2457,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2464
2457
|
text: text
|
|
2465
2458
|
});
|
|
2466
2459
|
}
|
|
2467
|
-
return
|
|
2460
|
+
return _context18.abrupt("return", values);
|
|
2468
2461
|
case 9:
|
|
2469
2462
|
case "end":
|
|
2470
|
-
return
|
|
2463
|
+
return _context18.stop();
|
|
2471
2464
|
}
|
|
2472
2465
|
}, _callee15);
|
|
2473
2466
|
}));
|
|
@@ -2488,7 +2481,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2488
2481
|
key: "getVariantBasketDatasByOrderlines",
|
|
2489
2482
|
value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
|
|
2490
2483
|
var variantBasketDatas = [];
|
|
2491
|
-
var
|
|
2484
|
+
var _loop7 = function _loop7() {
|
|
2492
2485
|
var ol = orderLines[i];
|
|
2493
2486
|
var catalog = catalogData.find(function (c) {
|
|
2494
2487
|
return c.codex === ol.CatalogCodex;
|
|
@@ -2511,7 +2504,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2511
2504
|
}
|
|
2512
2505
|
};
|
|
2513
2506
|
for (var i = 0; i < orderLines.length; i++) {
|
|
2514
|
-
if (
|
|
2507
|
+
if (_loop7()) continue;
|
|
2515
2508
|
}
|
|
2516
2509
|
return variantBasketDatas;
|
|
2517
2510
|
}
|