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