@crystaldesign/product-handler 24.13.0-beta.9 → 24.13.0-rc.0

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