@crystaldesign/product-handler 24.13.0-beta.12 → 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.
@@ -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, savedMedia, _loop, _j2;
771
- return _regeneratorRuntime.wrap(function _callee3$(_context4) {
772
- while (1) switch (_context4.prev = _context4.next) {
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
- _context4.next = 15;
783
+ _context5.next = 16;
779
784
  break;
780
785
  }
781
- _context4.next = 6;
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 6:
788
- result = _context4.sent;
792
+ case 7:
793
+ result = _context5.sent;
789
794
  originProduct = result.data[0];
790
795
  if (originProduct) {
791
- _context4.next = 10;
796
+ _context5.next = 11;
792
797
  break;
793
798
  }
794
799
  throw new Error('Origin Product not found');
795
- case 10:
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
- _context4.next = 15;
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 15:
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 21:
870
+ case 22:
866
871
  if (!(removedMedia && j < removedMedia.length)) {
867
- _context4.next = 30;
872
+ _context5.next = 31;
868
873
  break;
869
874
  }
870
875
  mediaRef = removedMedia[j];
871
876
  if (!mediaRef.ref) {
872
- _context4.next = 27;
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
- _context4.next = 27;
885
+ _context5.next = 28;
881
886
  return this.apiRemoveMedia(this.mediaService, mediaRef.ref, this.jwt);
882
- case 27:
887
+ case 28:
883
888
  j++;
884
- _context4.next = 21;
889
+ _context5.next = 22;
885
890
  break;
886
- case 30:
887
- if (!baseData.media) {
888
- _context4.next = 42;
889
- break;
890
- }
891
- baseProduct.media = [];
892
- _j = 0;
893
- case 33:
894
- if (!(_j < baseData.media.length)) {
895
- _context4.next = 42;
896
- break;
897
- }
898
- //if a new media is added, the file is present in media object and needs to be saved to the server
899
- (_this$openModal2 = this.openModal) === null || _this$openModal2 === void 0 || _this$openModal2.call(this, {
900
- progress: _j / baseData.media.length / 6 + 2 / 6,
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
- case 39:
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, _configuration$OrderS;
943
- var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k, _savedMedia;
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 (!vd.media) {
1076
- _context3.next = 28;
1077
- break;
1078
- }
1079
- product.media = [];
1080
- (_this3$openModal = _this3.openModal) === null || _this3$openModal === void 0 || _this3$openModal.call(_this3, {
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 29:
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 47:
1077
+ case 37:
1125
1078
  if (!(variantData && _j2 < variantData.length)) {
1126
- _context4.next = 54;
1079
+ _context5.next = 44;
1127
1080
  break;
1128
1081
  }
1129
- return _context4.delegateYield(_loop(), "t0", 49);
1130
- case 49:
1131
- if (!_context4.t0) {
1132
- _context4.next = 51;
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 _context4.abrupt("continue", 51);
1136
- case 51:
1088
+ return _context5.abrupt("continue", 41);
1089
+ case 41:
1137
1090
  _j2++;
1138
- _context4.next = 47;
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 _context4.abrupt("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 _context4.stop();
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$(_context5) {
1171
- while (1) switch (_context5.prev = _context5.next) {
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
- _context5.next = 3;
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
- _context5.prev = 4;
1182
- _context5.next = 7;
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 = _context5.sent;
1176
+ savedProducts = _context6.sent;
1186
1177
  (_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
1187
- return _context5.abrupt("return", savedProducts);
1178
+ return _context6.abrupt("return", savedProducts);
1188
1179
  case 12:
1189
- _context5.prev = 12;
1190
- _context5.t0 = _context5["catch"](4);
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(_context5.t0.message);
1183
+ throw new Error(_context6.t0.message);
1193
1184
  case 16:
1194
1185
  case "end":
1195
- return _context5.stop();
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$(_context6) {
1534
- while (1) switch (_context6.prev = _context6.next) {
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
- _context6.prev = 1;
1538
- _context6.next = 4;
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 = _context6.sent;
1536
+ response = _context7.sent;
1546
1537
  if (!((response === null || response === void 0 ? void 0 : response.status) == 200)) {
1547
- _context6.next = 7;
1538
+ _context7.next = 7;
1548
1539
  break;
1549
1540
  }
1550
- return _context6.abrupt("return", response.data);
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
- _context6.prev = 10;
1555
- _context6.t0 = _context6["catch"](1);
1545
+ _context7.prev = 10;
1546
+ _context7.t0 = _context7["catch"](1);
1556
1547
  throw new Error('Could not remove Media', {
1557
- cause: _context6.t0
1548
+ cause: _context7.t0
1558
1549
  });
1559
1550
  case 13:
1560
1551
  case "end":
1561
- return _context6.stop();
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$(_context7) {
1591
- while (1) switch (_context7.prev = _context7.next) {
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
- _context7.prev = 1;
1595
- _context7.next = 4;
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 = _context7.sent;
1603
- _context7.next = 7;
1593
+ res = _context8.sent;
1594
+ _context8.next = 7;
1604
1595
  return res.data;
1605
1596
  case 7:
1606
- resData = _context7.sent;
1607
- _context7.next = 13;
1597
+ resData = _context8.sent;
1598
+ _context8.next = 13;
1608
1599
  break;
1609
1600
  case 10:
1610
- _context7.prev = 10;
1611
- _context7.t0 = _context7["catch"](1);
1601
+ _context8.prev = 10;
1602
+ _context8.t0 = _context8["catch"](1);
1612
1603
  throw new Error('Could not get existing products', {
1613
- cause: _context7.t0
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
- _context7.next = 16;
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 _context7.abrupt("return", resData);
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 _context7.stop();
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$(_context8) {
1651
- while (1) switch (_context8.prev = _context8.next) {
1641
+ return _regeneratorRuntime.wrap(function _callee7$(_context9) {
1642
+ while (1) switch (_context9.prev = _context9.next) {
1652
1643
  case 0:
1653
- _context8.next = 2;
1644
+ _context9.next = 2;
1654
1645
  return this.apiAccountLogin(accountId, catalogId);
1655
1646
  case 2:
1656
- currentAccountSessionId = _context8.sent;
1647
+ currentAccountSessionId = _context9.sent;
1657
1648
  if (currentAccountSessionId) {
1658
- _context8.next = 5;
1649
+ _context9.next = 5;
1659
1650
  break;
1660
1651
  }
1661
- return _context8.abrupt("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
- _context8.next = 8;
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 = _context8.sent;
1667
+ response = _context9.sent;
1677
1668
  if (!response.Error) {
1678
- _context8.next = 11;
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 _context8.abrupt("return", actCatalogInfoData);
1702
+ return _context9.abrupt("return", actCatalogInfoData);
1711
1703
  case 13:
1712
1704
  case "end":
1713
- return _context8.stop();
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$(_context9) {
1728
- while (1) switch (_context9.prev = _context9.next) {
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
- _context9.t0 = fetch;
1732
- _context9.t1 = fullUrl;
1733
- _context9.next = 5;
1723
+ _context10.t0 = fetch;
1724
+ _context10.t1 = fullUrl;
1725
+ _context10.next = 5;
1734
1726
  return this.sessionGuid;
1735
1727
  case 5:
1736
- _context9.t2 = _context9.sent;
1737
- _context9.t3 = {
1738
- sessionGuid: _context9.t2
1728
+ _context10.t2 = _context10.sent;
1729
+ _context10.t3 = {
1730
+ sessionGuid: _context10.t2
1739
1731
  };
1740
- _context9.t4 = {
1741
- headers: _context9.t3
1732
+ _context10.t4 = {
1733
+ headers: _context10.t3
1742
1734
  };
1743
- _context9.next = 10;
1744
- return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
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 = _context9.sent;
1743
+ response = _context10.sent;
1752
1744
  if (!response.SessionGUID) {
1753
- _context9.next = 13;
1745
+ _context10.next = 13;
1754
1746
  break;
1755
1747
  }
1756
- return _context9.abrupt("return", response.SessionGUID);
1748
+ return _context10.abrupt("return", response.SessionGUID);
1757
1749
  case 13:
1758
1750
  fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
1759
- _context9.t5 = fetch;
1760
- _context9.t6 = fallbackUrl;
1761
- _context9.next = 18;
1751
+ _context10.t5 = fetch;
1752
+ _context10.t6 = fallbackUrl;
1753
+ _context10.next = 18;
1762
1754
  return this.sessionGuid;
1763
1755
  case 18:
1764
- _context9.t7 = _context9.sent;
1765
- _context9.t8 = {
1766
- sessionGuid: _context9.t7
1756
+ _context10.t7 = _context10.sent;
1757
+ _context10.t8 = {
1758
+ sessionGuid: _context10.t7
1767
1759
  };
1768
- _context9.t9 = {
1769
- headers: _context9.t8
1760
+ _context10.t9 = {
1761
+ headers: _context10.t8
1770
1762
  };
1771
- _context9.next = 23;
1772
- return (0, _context9.t5)(_context9.t6, _context9.t9).then(function (res) {
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 = _context9.sent;
1780
- return _context9.abrupt("return", fallbackResponse.SessionGUID);
1771
+ fallbackResponse = _context10.sent;
1772
+ return _context10.abrupt("return", fallbackResponse.SessionGUID);
1781
1773
  case 25:
1782
1774
  case "end":
1783
- return _context9.stop();
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$(_context10) {
1799
- while (1) switch (_context10.prev = _context10.next) {
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
- _context10.prev = 1;
1803
- _context10.next = 4;
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 = _context10.sent;
1811
- _context10.next = 7;
1802
+ res = _context11.sent;
1803
+ _context11.next = 7;
1812
1804
  return res.data;
1813
1805
  case 7:
1814
- resData = _context10.sent;
1815
- _context10.next = 13;
1806
+ resData = _context11.sent;
1807
+ _context11.next = 13;
1816
1808
  break;
1817
1809
  case 10:
1818
- _context10.prev = 10;
1819
- _context10.t0 = _context10["catch"](1);
1810
+ _context11.prev = 10;
1811
+ _context11.t0 = _context11["catch"](1);
1820
1812
  throw new Error('Could not get existing products', {
1821
- cause: _context10.t0
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
- _context10.next = 15;
1817
+ _context11.next = 15;
1826
1818
  break;
1827
1819
  }
1828
- return _context10.abrupt("return", resData);
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 _context10.stop();
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
- _args11 = arguments;
1855
- return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1856
- while (1) switch (_context11.prev = _context11.next) {
1846
+ _args12 = arguments;
1847
+ return _regeneratorRuntime.wrap(function _callee10$(_context12) {
1848
+ while (1) switch (_context12.prev = _context12.next) {
1857
1849
  case 0:
1858
- limit = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 1;
1859
- useFilter = _args11.length > 2 ? _args11[2] : undefined;
1860
- hierarchy = _args11.length > 3 ? _args11[3] : undefined;
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
- _context11.prev = 4;
1854
+ _context12.prev = 4;
1863
1855
  filterParam = useFilter ? 'filter' : 'search';
1864
- _context11.next = 8;
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 = _context11.sent;
1872
- _context11.next = 11;
1863
+ res = _context12.sent;
1864
+ _context12.next = 11;
1873
1865
  return res.data;
1874
1866
  case 11:
1875
- resData = _context11.sent;
1876
- _context11.next = 17;
1867
+ resData = _context12.sent;
1868
+ _context12.next = 17;
1877
1869
  break;
1878
1870
  case 14:
1879
- _context11.prev = 14;
1880
- _context11.t0 = _context11["catch"](4);
1871
+ _context12.prev = 14;
1872
+ _context12.t0 = _context12["catch"](4);
1881
1873
  throw new Error('Could not get existing products', {
1882
- cause: _context11.t0
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
- _context11.next = 20;
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 _context11.abrupt("return", resData);
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 _context11.stop();
1896
+ return _context12.stop();
1905
1897
  }
1906
1898
  }, _callee10, this, [[4, 14]]);
1907
1899
  }));
@@ -1916,43 +1908,43 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1916
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$(_context12) {
1920
- while (1) switch (_context12.prev = _context12.next) {
1911
+ return _regeneratorRuntime.wrap(function _callee11$(_context13) {
1912
+ while (1) switch (_context13.prev = _context13.next) {
1921
1913
  case 0:
1922
1914
  fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/activate');
1923
1915
  fullUrl.searchParams.append('organizationId', organizationId);
1924
- _context12.prev = 2;
1925
- _context12.next = 5;
1916
+ _context13.prev = 2;
1917
+ _context13.next = 5;
1926
1918
  return axios.post(fullUrl.toString(), undefined, {
1927
1919
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1928
1920
  'Content-Type': 'application/json'
1929
1921
  })
1930
1922
  });
1931
1923
  case 5:
1932
- res = _context12.sent;
1933
- _context12.next = 8;
1924
+ res = _context13.sent;
1925
+ _context13.next = 8;
1934
1926
  return res.data;
1935
1927
  case 8:
1936
- resData = _context12.sent;
1937
- _context12.next = 14;
1928
+ resData = _context13.sent;
1929
+ _context13.next = 14;
1938
1930
  break;
1939
1931
  case 11:
1940
- _context12.prev = 11;
1941
- _context12.t0 = _context12["catch"](2);
1932
+ _context13.prev = 11;
1933
+ _context13.t0 = _context13["catch"](2);
1942
1934
  throw new Error('Error on activate product', {
1943
- cause: _context12.t0
1935
+ cause: _context13.t0
1944
1936
  });
1945
1937
  case 14:
1946
1938
  if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
1947
- _context12.next = 16;
1939
+ _context13.next = 16;
1948
1940
  break;
1949
1941
  }
1950
- return _context12.abrupt("return", resData);
1942
+ return _context13.abrupt("return", resData);
1951
1943
  case 16:
1952
1944
  throw new Error(resData.error);
1953
1945
  case 17:
1954
1946
  case "end":
1955
- return _context12.stop();
1947
+ return _context13.stop();
1956
1948
  }
1957
1949
  }, _callee11, this, [[2, 11]]);
1958
1950
  }));
@@ -1966,8 +1958,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1966
1958
  value: function () {
1967
1959
  var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(products) {
1968
1960
  var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
1969
- return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1970
- while (1) switch (_context13.prev = _context13.next) {
1961
+ return _regeneratorRuntime.wrap(function _callee12$(_context14) {
1962
+ while (1) switch (_context14.prev = _context14.next) {
1971
1963
  case 0:
1972
1964
  fullUrl = this.catalogService + '/products';
1973
1965
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1978,7 +1970,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1978
1970
  i = 0;
1979
1971
  case 5:
1980
1972
  if (!(i < productsInChunks.length)) {
1981
- _context13.next = 13;
1973
+ _context14.next = 13;
1982
1974
  break;
1983
1975
  }
1984
1976
  promises = productsInChunks[i].map(function (p) {
@@ -2000,15 +1992,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2000
1992
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
2001
1993
  dontRenderForm: true
2002
1994
  });
2003
- _context13.next = 10;
1995
+ _context14.next = 10;
2004
1996
  return Promise.all(promises);
2005
1997
  case 10:
2006
1998
  i++;
2007
- _context13.next = 5;
1999
+ _context14.next = 5;
2008
2000
  break;
2009
2001
  case 13:
2010
2002
  case "end":
2011
- return _context13.stop();
2003
+ return _context14.stop();
2012
2004
  }
2013
2005
  }, _callee12, this);
2014
2006
  }));
@@ -2031,8 +2023,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2031
2023
  value: function () {
2032
2024
  var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref46) {
2033
2025
  var limit, skip, fields, _ref46$search, search, sort, abortController, fullUrl, headers, promise;
2034
- return _regeneratorRuntime.wrap(function _callee13$(_context14) {
2035
- while (1) switch (_context14.prev = _context14.next) {
2026
+ return _regeneratorRuntime.wrap(function _callee13$(_context15) {
2027
+ while (1) switch (_context15.prev = _context15.next) {
2036
2028
  case 0:
2037
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;
2038
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) : '');
@@ -2056,13 +2048,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2056
2048
  reject('Error loading products grouped by variants: ' + error.message);
2057
2049
  });
2058
2050
  });
2059
- _context14.next = 7;
2051
+ _context15.next = 7;
2060
2052
  return promise;
2061
2053
  case 7:
2062
- return _context14.abrupt("return", _context14.sent);
2054
+ return _context15.abrupt("return", _context15.sent);
2063
2055
  case 8:
2064
2056
  case "end":
2065
- return _context14.stop();
2057
+ return _context15.stop();
2066
2058
  }
2067
2059
  }, _callee13, this);
2068
2060
  }));
@@ -2075,9 +2067,9 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2075
2067
  key: "apiSaveProducts",
2076
2068
  value: function () {
2077
2069
  var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2078
- var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop2, j;
2079
- return _regeneratorRuntime.wrap(function _callee14$(_context16) {
2080
- while (1) switch (_context16.prev = _context16.next) {
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) {
2081
2073
  case 0:
2082
2074
  fullUrl = serverUrl + '/v1/products/groups';
2083
2075
  BATCH_SIZE = 40;
@@ -2086,34 +2078,34 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2086
2078
  i = 0;
2087
2079
  case 5:
2088
2080
  if (!(i < products.length)) {
2089
- _context16.next = 15;
2081
+ _context17.next = 15;
2090
2082
  break;
2091
2083
  }
2092
2084
  if (!products[i].baseProduct) {
2093
- _context16.next = 9;
2085
+ _context17.next = 9;
2094
2086
  break;
2095
2087
  }
2096
2088
  baseProduct = products[i];
2097
- return _context16.abrupt("continue", 12);
2089
+ return _context17.abrupt("continue", 12);
2098
2090
  case 9:
2099
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++;
2100
2092
  if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2101
2093
  productsPackages[groupIndex].push(products[i]);
2102
2094
  case 12:
2103
2095
  i++;
2104
- _context16.next = 5;
2096
+ _context17.next = 5;
2105
2097
  break;
2106
2098
  case 15:
2107
2099
  responseProducts = [];
2108
2100
  _i2 = 0;
2109
2101
  case 17:
2110
2102
  if (!(_i2 < productsPackages.length)) {
2111
- _context16.next = 40;
2103
+ _context17.next = 40;
2112
2104
  break;
2113
2105
  }
2114
2106
  if (baseProduct) productsPackages[_i2].unshift(baseProduct);
2115
- _context16.prev = 19;
2116
- _context16.next = 22;
2107
+ _context17.prev = 19;
2108
+ _context17.next = 22;
2117
2109
  return fetch(fullUrl, {
2118
2110
  method: 'PUT',
2119
2111
  headers: {
@@ -2133,25 +2125,25 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2133
2125
  return res.json();
2134
2126
  });
2135
2127
  case 22:
2136
- response = _context16.sent;
2128
+ response = _context17.sent;
2137
2129
  if (!response.Error) {
2138
- _context16.next = 25;
2130
+ _context17.next = 25;
2139
2131
  break;
2140
2132
  }
2141
2133
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
2142
2134
  case 25:
2143
- _context16.next = 30;
2135
+ _context17.next = 30;
2144
2136
  break;
2145
2137
  case 27:
2146
- _context16.prev = 27;
2147
- _context16.t0 = _context16["catch"](19);
2138
+ _context17.prev = 27;
2139
+ _context17.t0 = _context17["catch"](19);
2148
2140
  throw Error(status);
2149
2141
  case 30:
2150
- _loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2(j) {
2151
- return _regeneratorRuntime.wrap(function _loop2$(_context15) {
2152
- while (1) switch (_context15.prev = _context15.next) {
2142
+ _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3(j) {
2143
+ return _regeneratorRuntime.wrap(function _loop3$(_context16) {
2144
+ while (1) switch (_context16.prev = _context16.next) {
2153
2145
  case 0:
2154
- if (response.products[_i2].baseProduct) baseProduct = response.products[_i2];
2146
+ if (response.products[j].baseProduct) baseProduct = response.products[j];
2155
2147
  if (!responseProducts.find(function (p) {
2156
2148
  return p._id == response.products[j]._id;
2157
2149
  })) {
@@ -2159,30 +2151,30 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2159
2151
  }
2160
2152
  case 2:
2161
2153
  case "end":
2162
- return _context15.stop();
2154
+ return _context16.stop();
2163
2155
  }
2164
- }, _loop2);
2156
+ }, _loop3);
2165
2157
  });
2166
2158
  j = 0;
2167
2159
  case 32:
2168
2160
  if (!(j < response.products.length)) {
2169
- _context16.next = 37;
2161
+ _context17.next = 37;
2170
2162
  break;
2171
2163
  }
2172
- return _context16.delegateYield(_loop2(j), "t1", 34);
2164
+ return _context17.delegateYield(_loop3(j), "t1", 34);
2173
2165
  case 34:
2174
2166
  j++;
2175
- _context16.next = 32;
2167
+ _context17.next = 32;
2176
2168
  break;
2177
2169
  case 37:
2178
2170
  _i2++;
2179
- _context16.next = 17;
2171
+ _context17.next = 17;
2180
2172
  break;
2181
2173
  case 40:
2182
- return _context16.abrupt("return", responseProducts);
2174
+ return _context17.abrupt("return", responseProducts);
2183
2175
  case 41:
2184
2176
  case "end":
2185
- return _context16.stop();
2177
+ return _context17.stop();
2186
2178
  }
2187
2179
  }, _callee14, null, [[19, 27]]);
2188
2180
  }));
@@ -2236,7 +2228,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2236
2228
  return true;
2237
2229
  }
2238
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 : [];
2239
- var _loop3 = function _loop3() {
2231
+ var _loop4 = function _loop4() {
2240
2232
  var article = orderlines[i];
2241
2233
  var orderLine = orderLines.find(function (ol) {
2242
2234
  return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
@@ -2247,7 +2239,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2247
2239
  };
2248
2240
  }
2249
2241
  if (article.VariantBasketDatas.length) {
2250
- var _loop4 = function _loop4() {
2242
+ var _loop5 = function _loop5() {
2251
2243
  var varinatValue = article.VariantBasketDatas[j];
2252
2244
  if (!varinatData.find(function (vb) {
2253
2245
  return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
@@ -2261,14 +2253,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2261
2253
  },
2262
2254
  _ret2;
2263
2255
  for (var j = 0; j < article.VariantBasketDatas.length; j++) {
2264
- _ret2 = _loop4();
2256
+ _ret2 = _loop5();
2265
2257
  if (_ret2) return _ret2.v;
2266
2258
  }
2267
2259
  }
2268
2260
  },
2269
2261
  _ret;
2270
2262
  for (var i = 0; i < orderlines.length; i++) {
2271
- _ret = _loop3();
2263
+ _ret = _loop4();
2272
2264
  if (_ret) return _ret.v;
2273
2265
  }
2274
2266
  return true;
@@ -2346,7 +2338,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2346
2338
  //calculate defaultShortDescription from template string
2347
2339
  var shortDescriptionTemplate = (_configurationData$sh = configurationData === null || configurationData === void 0 ? void 0 : configurationData.shortDescription) !== null && _configurationData$sh !== void 0 ? _configurationData$sh : '${modelName} ${subCategory} ${mainColor}';
2348
2340
  var parts = shortDescriptionTemplate.split(/\${|}/);
2349
- var _loop5 = function _loop5() {
2341
+ var _loop6 = function _loop6() {
2350
2342
  var _classificationConfig2, _classificationConfig4, _value;
2351
2343
  var field = parts[i];
2352
2344
  var value;
@@ -2378,7 +2370,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2378
2370
  shortDescriptionTemplate = shortDescriptionTemplate.replace("${".concat(field, "}"), (_value = value) !== null && _value !== void 0 ? _value : '');
2379
2371
  };
2380
2372
  for (var i = 1; i < parts.length; i = i + 2) {
2381
- _loop5();
2373
+ _loop6();
2382
2374
  }
2383
2375
 
2384
2376
  //as long as shortDescription is not modified by user, autocalc it
@@ -2413,8 +2405,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2413
2405
  value: function () {
2414
2406
  var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2415
2407
  var values, apiUrl, i, apiResult, _i3, value, text;
2416
- return _regeneratorRuntime.wrap(function _callee15$(_context17) {
2417
- while (1) switch (_context17.prev = _context17.next) {
2408
+ return _regeneratorRuntime.wrap(function _callee15$(_context18) {
2409
+ while (1) switch (_context18.prev = _context18.next) {
2418
2410
  case 0:
2419
2411
  values = [];
2420
2412
  apiUrl = dataSource.url;
@@ -2423,7 +2415,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2423
2415
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2424
2416
  }
2425
2417
  }
2426
- _context17.next = 5;
2418
+ _context18.next = 5;
2427
2419
  return fetch(apiUrl, {
2428
2420
  headers: {
2429
2421
  sessionGuid: sessionGuid
@@ -2435,7 +2427,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2435
2427
  return res.json();
2436
2428
  });
2437
2429
  case 5:
2438
- apiResult = _context17.sent;
2430
+ apiResult = _context18.sent;
2439
2431
  if (dataSource.useKey) {
2440
2432
  apiResult = apiResult[dataSource.useKey];
2441
2433
  }
@@ -2447,10 +2439,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2447
2439
  text: text
2448
2440
  });
2449
2441
  }
2450
- return _context17.abrupt("return", values);
2442
+ return _context18.abrupt("return", values);
2451
2443
  case 9:
2452
2444
  case "end":
2453
- return _context17.stop();
2445
+ return _context18.stop();
2454
2446
  }
2455
2447
  }, _callee15);
2456
2448
  }));
@@ -2471,7 +2463,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2471
2463
  key: "getVariantBasketDatasByOrderlines",
2472
2464
  value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
2473
2465
  var variantBasketDatas = [];
2474
- var _loop6 = function _loop6() {
2466
+ var _loop7 = function _loop7() {
2475
2467
  var ol = orderLines[i];
2476
2468
  var catalog = catalogData.find(function (c) {
2477
2469
  return c.codex === ol.CatalogCodex;
@@ -2481,19 +2473,20 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2481
2473
  var v = ol.VariantBasketDatas[j];
2482
2474
  var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
2483
2475
  var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
2484
- {
2476
+ if (opt && opv) {
2485
2477
  variantBasketDatas.push({
2486
2478
  BasketID: ol.BasketID,
2487
2479
  OPT: v.OPT,
2488
2480
  OPV: v.OPV,
2489
2481
  OPTName: opt.Name,
2490
- OPVName: opv.Name
2482
+ OPVName: opv.Name,
2483
+ OPVImage: catalog.mediaUrl + opv.Image
2491
2484
  });
2492
2485
  }
2493
2486
  }
2494
2487
  };
2495
2488
  for (var i = 0; i < orderLines.length; i++) {
2496
- if (_loop6()) continue;
2489
+ if (_loop7()) continue;
2497
2490
  }
2498
2491
  return variantBasketDatas;
2499
2492
  }