@crystaldesign/product-handler 24.12.0-beta.9 → 24.12.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.
@@ -26,9 +26,6 @@ var _excluded = ["value"];
26
26
  var _ProductHandlerAbstract;
27
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
-
30
- //const LOG = initLog('CORE');
31
-
32
29
  var TRANSLATED_FILEDS = ['info', 'modelName', 'technicalDescription', 'shortDescription', 'shortTechnicalDescription'];
33
30
  var ProductHandlerAbstract = /*#__PURE__*/function () {
34
31
  function ProductHandlerAbstract(LOG, t, openModal, closeModal) {
@@ -43,6 +40,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
43
40
  _defineProperty(this, "_apiKey", void 0);
44
41
  _defineProperty(this, "_catalogService", '');
45
42
  _defineProperty(this, "_mediaService", '');
43
+ _defineProperty(this, "_api2", '');
44
+ _defineProperty(this, "_sessionGuid", '');
46
45
  _defineProperty(this, "_organization", {});
47
46
  }
48
47
  return _createClass(ProductHandlerAbstract, [{
@@ -69,6 +68,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
69
68
  set: function set(val) {
70
69
  this._mediaService = val;
71
70
  }
71
+ }, {
72
+ key: "api2",
73
+ get: function get() {
74
+ return this._api2;
75
+ },
76
+ set: function set(val) {
77
+ this._api2 = val;
78
+ }
79
+ }, {
80
+ key: "sessionGuid",
81
+ get: function get() {
82
+ return this._sessionGuid;
83
+ }
72
84
  }, {
73
85
  key: "organization",
74
86
  get: function get() {
@@ -115,7 +127,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
115
127
  value: (function () {
116
128
  var _createAndSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
117
129
  var _basket$ProductSetNam;
118
- var basket, catalogData, availableLanguages, currentLang, createdState, baseData, data;
130
+ var basket, catalogData, availableLanguages, currentLang, createdState, data;
119
131
  return _regeneratorRuntime.wrap(function _callee$(_context) {
120
132
  while (1) switch (_context.prev = _context.next) {
121
133
  case 0:
@@ -123,6 +135,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
123
135
  _context.next = 3;
124
136
  return this.loadProducts({
125
137
  basket: basket,
138
+ divaNr: basket.DivaNr,
126
139
  catalogData: catalogData,
127
140
  productData: [],
128
141
  availableLanguages: availableLanguages,
@@ -132,10 +145,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
132
145
  createdState = _context.sent;
133
146
  createdState.baseData.shortDescription = (_basket$ProductSetNam = basket.ProductSetName) !== null && _basket$ProductSetNam !== void 0 ? _basket$ProductSetNam : basket.SetName;
134
147
  createdState.baseData.shortDescription_locales = basket.SetName_locales;
135
- baseData = _objectSpread({}, createdState.baseData);
148
+ _objectSpread({}, createdState.baseData);
136
149
  _context.next = 9;
137
150
  return this.prepareData({
138
- baseData: baseData,
151
+ basket: basket,
152
+ baseData: createdState.baseData,
139
153
  classificationData: createdState.classificationData,
140
154
  variantData: createdState.variantData,
141
155
  oldClassificationData: createdState.oldClassificationData
@@ -143,9 +157,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
143
157
  case 9:
144
158
  data = _context.sent;
145
159
  _context.next = 12;
146
- return this.saveBasketAndProducts(_objectSpread(_objectSpread({}, data), {}, {
147
- basket: basket
148
- }));
160
+ return this.saveProducts(_objectSpread({}, data));
149
161
  case 12:
150
162
  return _context.abrupt("return", _context.sent);
151
163
  case 13:
@@ -171,86 +183,71 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
171
183
  key: "loadProducts",
172
184
  value: (function () {
173
185
  var _loadProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
174
- var _baseProduct9,
186
+ var _this = this,
187
+ _baseProduct,
188
+ _basket$getProductCon,
189
+ _baseProduct2,
190
+ _baseProduct3,
191
+ _baseProduct$divaNr,
192
+ _baseProduct4,
193
+ _dataByBasket$price$a,
194
+ _dataByBasket$price,
195
+ _baseProduct5,
196
+ _dataByBasket$image,
197
+ _baseProduct6,
198
+ _dataByBasket$image2D,
199
+ _baseProduct7,
200
+ _dataByBasket$docking,
201
+ _baseProduct8,
202
+ _baseProduct$organiza,
203
+ _baseProduct9,
204
+ _this$organization$pa,
205
+ _this$organization$pa2,
206
+ _baseProduct$createdB,
175
207
  _baseProduct10,
208
+ _this$user,
176
209
  _baseProduct11,
177
210
  _baseProduct12,
178
211
  _baseProduct13,
179
212
  _baseProduct14,
213
+ _dataByBasket$orderTe,
180
214
  _baseProduct15,
215
+ _dataByBasket$technic,
181
216
  _baseProduct16,
182
217
  _baseProduct17,
183
- _baseProduct18,
184
- _baseProduct19,
185
- _baseProduct20,
186
- _baseProduct21,
187
- _baseProduct22,
188
- _baseProduct23,
189
- _baseProduct24,
190
- _baseProduct25,
191
- _baseProduct26,
192
- _baseProduct$width,
193
- _baseProduct27,
194
- _basket$SetPlannerInf,
195
- _basket$OrderSets$0$B,
196
- _baseProduct$height,
197
- _baseProduct28,
198
- _basket$SetPlannerInf2,
199
- _basket$OrderSets$0$B2,
200
- _baseProduct$depth,
201
- _baseProduct29,
202
- _basket$SetPlannerInf3,
203
- _basket$OrderSets$0$B3,
204
- _baseProduct$weight,
205
- _baseProduct30,
206
- _price$addedPrice,
207
- _baseProduct31,
208
- _baseProduct32,
209
- _baseProduct33,
210
- _basket$SetPlannerInf4,
211
- _basket$SetPlannerInf5,
212
- _baseProduct34,
213
- _baseProduct35,
214
- _baseProduct36,
215
- _baseProduct37,
216
- _baseProduct38,
217
- _baseProduct39,
218
- _baseProduct$brand,
219
- _baseProduct40,
220
- _baseProduct$organiza,
221
- _baseProduct41,
222
- _this$organization$pa,
223
- _this$organization$pa2,
224
- _baseProduct42,
225
- _baseProduct$createdB,
226
- _baseProduct43,
227
- _this$user,
228
- _baseProduct44,
229
- _baseProduct45,
230
- _baseProduct46,
231
- _baseProduct47,
232
- _baseProduct48,
233
- _baseProduct49,
234
- _baseProduct50,
235
- _this = this;
236
- var basket, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, editedBasket, products, baseProduct, variantProducts, isSet, dockingPoints, orderDescription, orderDescription_locales, catalogDataName, catalogDataBrand, catalogDataDescription, catalogDataName_locales, catalogDataDescription_locales, i, c, key, _key, articles, delivery, _baseProduct$delivery, _baseProduct, _baseProduct$delivery2, _baseProduct2, _baseProduct$delivery3, _baseProduct3, _baseProduct$delivery4, _baseProduct4, _baseProduct$delivery5, _baseProduct5, _ref3, _baseProduct$delivery6, _baseProduct6, _fieldConfiguration$d, _ref4, _baseProduct$delivery7, _baseProduct7, _fieldConfiguration$d2, _ref5, _baseProduct$delivery8, _baseProduct8, _fieldConfiguration$d3, config, packages, ismanual, price, oldClassificationData, _i, variant, _key2, oldUniqueHash, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, _this$LOG, _basket$OrderSets$0$C3, _basket$OrderSets$0$F, usedConfigVariants, newVariantPosition, variantPositions, currentVariantPos, differingOPTs, _basket$OrderSets$0$C4, opts, _i2, initializedOptMap;
218
+ _ref3,
219
+ _baseProduct$configur3,
220
+ _baseProduct18;
221
+ var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
237
222
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
238
223
  while (1) switch (_context2.prev = _context2.next) {
239
224
  case 0:
240
- basket = _ref2.basket, catalogData = _ref2.catalogData, productData = _ref2.productData, classificationFields = _ref2.classificationFields, fieldConfiguration = _ref2.fieldConfiguration, customBaseFields = _ref2.customBaseFields, classificationConfig = _ref2.classificationConfig, _ref2$availableLangua = _ref2.availableLanguages, availableLanguages = _ref2$availableLangua === void 0 ? ['de', 'fr', 'it', 'en'] : _ref2$availableLangua, _ref2$currentLang = _ref2.currentLang, currentLang = _ref2$currentLang === void 0 ? 'de' : _ref2$currentLang, editedBasket = _ref2.editedBasket;
225
+ basket = _ref2.basket, divaNr = _ref2.divaNr, catalogData = _ref2.catalogData, productData = _ref2.productData, classificationFields = _ref2.classificationFields, fieldConfiguration = _ref2.fieldConfiguration, customBaseFields = _ref2.customBaseFields, classificationConfig = _ref2.classificationConfig, _ref2$availableLangua = _ref2.availableLanguages, availableLanguages = _ref2$availableLangua === void 0 ? ['de', 'fr', 'it', 'en'] : _ref2$availableLangua, _ref2$currentLang = _ref2.currentLang, currentLang = _ref2$currentLang === void 0 ? 'de' : _ref2$currentLang;
226
+ if (!(!productData && !divaNr)) {
227
+ _context2.next = 3;
228
+ break;
229
+ }
230
+ throw new Error('this should not happen');
231
+ case 3:
241
232
  if (productData) {
242
- _context2.next = 5;
233
+ _context2.next = 7;
243
234
  break;
244
235
  }
245
- _context2.next = 4;
246
- return this.apiGetProducts(basket.DivaNr);
247
- case 4:
236
+ _context2.next = 6;
237
+ return this.apiGetProducts(divaNr);
238
+ case 6:
248
239
  productData = _context2.sent;
249
- case 5:
240
+ case 7:
250
241
  products = {
251
242
  data: productData,
252
243
  total: productData.length
253
244
  };
245
+ if (!(!products.data.length && !basket)) {
246
+ _context2.next = 10;
247
+ break;
248
+ }
249
+ throw new Error('If product does not exist yet, basket must be provided');
250
+ case 10:
254
251
  baseProduct = undefined;
255
252
  variantProducts = [];
256
253
  if (products.total == 1) {
@@ -263,263 +260,77 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
263
260
  return !p.baseProduct;
264
261
  });
265
262
  }
266
- if (!(products.total && !baseProduct)) {
267
- _context2.next = 11;
263
+ if (catalogData) {
264
+ _context2.next = 23;
268
265
  break;
269
266
  }
270
- throw new Error('If existing products are fetched, there has to be atleast a base product.');
271
- case 11:
272
- isSet = !!basket.SetPlannerInfos;
273
- dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
274
- orderDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
275
- return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
276
- }, '') : basket.OrderSets[0].VariantDescription;
277
- orderDescription_locales = basket.OrderSets[0].VariantDescription_locales;
278
- catalogDataName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
279
- return c.name;
280
- }).filter(function (name) {
281
- return name;
282
- }).join(' - ');
283
- catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
284
- return c.brand;
285
- }).filter(function (brand) {
286
- return brand;
287
- }).join(' - ');
288
- catalogDataDescription = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
289
- return c.description;
290
- }).filter(function (description) {
291
- return description;
292
- }).join('<br/>');
293
- catalogDataName_locales = {};
294
- catalogDataDescription_locales = {};
295
- for (i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
296
- c = catalogData[i];
297
- for (key in c.name_locales) {
298
- if (!catalogDataName_locales[key]) {
299
- catalogDataName_locales[key] = c.name_locales[key];
300
- } else {
301
- catalogDataName_locales[key] = catalogDataName_locales[key] + ' - ' + c.name_locales[key];
302
- }
303
- }
304
- for (_key in c.description_locales) {
305
- if (!catalogDataDescription_locales[_key]) {
306
- catalogDataDescription_locales[_key] = c.description_locales[_key];
307
- } else {
308
- catalogDataDescription_locales[_key] = catalogDataDescription_locales[_key] + ' - ' + c.description_locales[_key];
309
- }
310
- }
311
- }
312
- articles = [];
313
- if (isSet) {
314
- articles = basket.OrderSets.flatMap(function (os) {
315
- return os.OrderLines.map(function (ol) {
316
- var _ol$VariantBasketData;
317
- return {
318
- articleCodex: ol.ArticleCodex,
319
- catalogCodex: os.CatalogCodex,
320
- variantValues: (_ol$VariantBasketData = ol.VariantBasketDatas) === null || _ol$VariantBasketData === void 0 ? void 0 : _ol$VariantBasketData.map(function (vb) {
321
- return {
322
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
323
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
324
- };
325
- })
326
- };
327
- });
328
- });
329
- } else {
330
- articles = basket.OrderSets[0].OrderLines.map(function (ol) {
331
- var _ol$VariantBasketData2;
332
- return {
333
- articleCodex: ol.ArticleCodex,
334
- catalogCodex: basket.OrderSets[0].CatalogCodex,
335
- variantValues: (_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (vb) {
336
- return {
337
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
338
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
339
- };
340
- })
341
- };
342
- });
267
+ if (!baseProduct) {
268
+ _context2.next = 20;
269
+ break;
343
270
  }
344
- if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
345
- config = {
346
- addedPackageWeight: 0,
347
- addedPackageHeight: 0,
348
- addedPackageWidth: 0,
349
- addedPackageDepth: 0,
350
- defaultDeliveryTime: 0,
351
- defaultDeliveryPrice: 0,
352
- defaultInstallationPrice: 0
353
- };
354
- if (typeof fieldConfiguration.delivery != 'boolean') {
355
- config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
356
- }
357
- packages = [];
358
- basket.OrderSets.flatMap(function (os) {
359
- return os.OrderLines;
360
- }).forEach(function (ol) {
361
- packages.push({
362
- height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
363
- width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
364
- depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
365
- weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
366
- });
367
- });
368
- delivery = {
369
- estPackages: packages,
370
- estMaxPackages: (_baseProduct$delivery = (_baseProduct = baseProduct) === null || _baseProduct === void 0 || (_baseProduct = _baseProduct.delivery) === null || _baseProduct === void 0 ? void 0 : _baseProduct.estMaxPackages) !== null && _baseProduct$delivery !== void 0 ? _baseProduct$delivery : packages.length,
371
- estMaxPackageWeight: (_baseProduct$delivery2 = (_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 || (_baseProduct2 = _baseProduct2.delivery) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2.estMaxPackageWeight) !== null && _baseProduct$delivery2 !== void 0 ? _baseProduct$delivery2 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
372
- return p.weight;
373
- }).filter(function (f) {
374
- return f;
375
- })))),
376
- estMaxPackageHeight: (_baseProduct$delivery3 = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 || (_baseProduct3 = _baseProduct3.delivery) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.estMaxPackageHeight) !== null && _baseProduct$delivery3 !== void 0 ? _baseProduct$delivery3 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
377
- return p.height;
378
- }).filter(function (f) {
379
- return f;
380
- })))),
381
- estMaxPackageWidth: (_baseProduct$delivery4 = (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 || (_baseProduct4 = _baseProduct4.delivery) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.estMaxPackageWidth) !== null && _baseProduct$delivery4 !== void 0 ? _baseProduct$delivery4 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
382
- return p.width;
383
- }).filter(function (f) {
384
- return f;
385
- })))),
386
- estMaxPackageDepth: (_baseProduct$delivery5 = (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 || (_baseProduct5 = _baseProduct5.delivery) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.estMaxPackageDepth) !== null && _baseProduct$delivery5 !== void 0 ? _baseProduct$delivery5 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
387
- return p.depth;
388
- }).filter(function (f) {
389
- return f;
390
- })))),
391
- deliveryTime: (_ref3 = (_baseProduct$delivery6 = (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 || (_baseProduct6 = _baseProduct6.delivery) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.deliveryTime) !== null && _baseProduct$delivery6 !== void 0 ? _baseProduct$delivery6 : (_fieldConfiguration$d = fieldConfiguration.delivery) === null || _fieldConfiguration$d === void 0 ? void 0 : _fieldConfiguration$d.defaultDeliveryTime) !== null && _ref3 !== void 0 ? _ref3 : 0,
392
- deliveryPrice: (_ref4 = (_baseProduct$delivery7 = (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 || (_baseProduct7 = _baseProduct7.delivery) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.deliveryPrice) !== null && _baseProduct$delivery7 !== void 0 ? _baseProduct$delivery7 : (_fieldConfiguration$d2 = fieldConfiguration.delivery) === null || _fieldConfiguration$d2 === void 0 ? void 0 : _fieldConfiguration$d2.defaultDeliveryPrice) !== null && _ref4 !== void 0 ? _ref4 : 0,
393
- installationPrice: (_ref5 = (_baseProduct$delivery8 = (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 || (_baseProduct8 = _baseProduct8.delivery) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.installationPrice) !== null && _baseProduct$delivery8 !== void 0 ? _baseProduct$delivery8 : (_fieldConfiguration$d3 = fieldConfiguration.delivery) === null || _fieldConfiguration$d3 === void 0 ? void 0 : _fieldConfiguration$d3.defaultInstallationPrice) !== null && _ref5 !== void 0 ? _ref5 : 0
394
- };
271
+ _context2.next = 17;
272
+ return Promise.all((_baseProduct$configur = (_baseProduct$configur2 = baseProduct.configuration) === null || _baseProduct$configur2 === void 0 ? void 0 : _baseProduct$configur2.OrderSets.map(function (os) {
273
+ return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
274
+ })) !== null && _baseProduct$configur !== void 0 ? _baseProduct$configur : []);
275
+ case 17:
276
+ catalogData = _context2.sent;
277
+ _context2.next = 23;
278
+ break;
279
+ case 20:
280
+ _context2.next = 22;
281
+ return Promise.all((_basket$OrderSets$map = basket === null || basket === void 0 ? void 0 : basket.OrderSets.map(function (os) {
282
+ return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
283
+ })) !== null && _basket$OrderSets$map !== void 0 ? _basket$OrderSets$map : []);
284
+ case 22:
285
+ catalogData = _context2.sent;
286
+ case 23:
287
+ if (!(products.total && !baseProduct)) {
288
+ _context2.next = 25;
289
+ break;
395
290
  }
396
- ismanual = ((_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.calculatedPrice) !== ((_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.addedPrice);
397
- price = {
398
- calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
399
- addedPrice: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.addedPrice,
400
- discountPrice: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.discountedPrice
401
- };
402
- if (!((_baseProduct13 = baseProduct) !== null && _baseProduct13 !== void 0 && _baseProduct13.calculatedPrice)) price = ProductHandlerAbstract.calcPrice(basket === null || basket === void 0 ? void 0 : basket.SummaryPrice, basket === null || basket === void 0 ? void 0 : basket.Discounts, (_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.calculatedPrice, ismanual);
403
-
404
- //to remember what for position was previously set for the classification
291
+ throw new Error('If existing products are fetched, there has to be atleast a base product.');
292
+ case 25:
293
+ dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
405
294
  oldClassificationData = {};
406
- for (_i = 0; _i < products.data.length; _i++) {
407
- variant = products.data[_i];
295
+ for (i = 0; i < products.data.length; i++) {
296
+ variant = products.data[i];
408
297
  oldClassificationData[variant._id] = {};
409
- for (_key2 in variant) {
410
- if (_key2.startsWith('dc_') && variant[_key2].optionPosition !== undefined) {
411
- oldClassificationData[variant._id][_key2] = variant[_key2];
298
+ for (key in variant) {
299
+ if (key.startsWith('dc_') && variant[key].optionPosition !== undefined) {
300
+ oldClassificationData[variant._id][key] = variant[key];
412
301
  }
413
302
  }
414
303
  }
415
- oldUniqueHash = (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.uniqueHash;
416
- baseData = {
417
- _id: ((_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16._id) || nanoid(),
418
- divaNr: basket === null || basket === void 0 ? void 0 : basket.DivaNr,
419
- modelName: ((_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.modelName) || catalogDataName,
420
- info: ((_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.info) || catalogDataDescription,
421
- technicalDescription: ((_baseProduct19 = baseProduct) === null || _baseProduct19 === void 0 ? void 0 : _baseProduct19.technicalDescription) || orderDescription,
422
- shortTechnicalDescription: (_baseProduct20 = baseProduct) === null || _baseProduct20 === void 0 ? void 0 : _baseProduct20.shortTechnicalDescription,
423
- modelName_locales: ((_baseProduct21 = baseProduct) === null || _baseProduct21 === void 0 ? void 0 : _baseProduct21.modelName_locales) || catalogDataName_locales,
424
- info_locales: ((_baseProduct22 = baseProduct) === null || _baseProduct22 === void 0 ? void 0 : _baseProduct22.info_locales) || catalogDataDescription_locales,
425
- technicalDescription_locales: ((_baseProduct23 = baseProduct) === null || _baseProduct23 === void 0 ? void 0 : _baseProduct23.technicalDescription_locales) || orderDescription_locales,
426
- shortTechnicalDescription_locales: (_baseProduct24 = baseProduct) === null || _baseProduct24 === void 0 ? void 0 : _baseProduct24.shortTechnicalDescription_locales,
427
- orderDescription: orderDescription,
428
- shortDescription: (_baseProduct25 = baseProduct) === null || _baseProduct25 === void 0 ? void 0 : _baseProduct25.shortDescription,
429
- shortDescription_locales: (_baseProduct26 = baseProduct) === null || _baseProduct26 === void 0 ? void 0 : _baseProduct26.shortDescription_locales,
430
- width: (_baseProduct$width = (_baseProduct27 = baseProduct) === null || _baseProduct27 === void 0 ? void 0 : _baseProduct27.width) !== null && _baseProduct$width !== void 0 ? _baseProduct$width : isSet ? (_basket$SetPlannerInf = basket.SetPlannerInfos) === null || _basket$SetPlannerInf === void 0 || (_basket$SetPlannerInf = _basket$SetPlannerInf.BBox) === null || _basket$SetPlannerInf === void 0 ? void 0 : _basket$SetPlannerInf.X : (_basket$OrderSets$0$B = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B === void 0 ? void 0 : _basket$OrderSets$0$B.X,
431
- height: (_baseProduct$height = (_baseProduct28 = baseProduct) === null || _baseProduct28 === void 0 ? void 0 : _baseProduct28.height) !== null && _baseProduct$height !== void 0 ? _baseProduct$height : isSet ? (_basket$SetPlannerInf2 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf2 === void 0 || (_basket$SetPlannerInf2 = _basket$SetPlannerInf2.BBox) === null || _basket$SetPlannerInf2 === void 0 ? void 0 : _basket$SetPlannerInf2.Z : (_basket$OrderSets$0$B2 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B2 === void 0 ? void 0 : _basket$OrderSets$0$B2.Z,
432
- depth: (_baseProduct$depth = (_baseProduct29 = baseProduct) === null || _baseProduct29 === void 0 ? void 0 : _baseProduct29.depth) !== null && _baseProduct$depth !== void 0 ? _baseProduct$depth : isSet ? (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 || (_basket$SetPlannerInf3 = _basket$SetPlannerInf3.BBox) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.Y : (_basket$OrderSets$0$B3 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B3 === void 0 ? void 0 : _basket$OrderSets$0$B3.Y,
433
- weight: (_baseProduct$weight = (_baseProduct30 = baseProduct) === null || _baseProduct30 === void 0 ? void 0 : _baseProduct30.weight) !== null && _baseProduct$weight !== void 0 ? _baseProduct$weight : basket.OrderSets.flatMap(function (os) {
434
- return os.OrderLines.map(function (ol) {
435
- return ol.Weight;
436
- }).filter(function (f) {
437
- return f;
438
- });
439
- }).reduce(function (sum, v) {
440
- return sum + v;
441
- }, 0),
442
- calculatedPrice: price.calculatedPrice,
443
- delivery: delivery,
444
- addedPrice: (_price$addedPrice = price.addedPrice) !== null && _price$addedPrice !== void 0 ? _price$addedPrice : (_baseProduct31 = baseProduct) === null || _baseProduct31 === void 0 ? void 0 : _baseProduct31.addedPrice,
445
- discountedPrice: (_baseProduct32 = baseProduct) === null || _baseProduct32 === void 0 ? void 0 : _baseProduct32.discountedPrice,
446
- percentageDiscount: (_baseProduct33 = baseProduct) === null || _baseProduct33 === void 0 ? void 0 : _baseProduct33.percentageDiscount,
447
- articles: articles,
448
- image: isSet ? (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg3D : basket.OrderSets[0].SetImage,
449
- image2D: isSet ? (_basket$SetPlannerInf5 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf5 === void 0 ? void 0 : _basket$SetPlannerInf5.SetPlannerImg2D : basket.OrderSets[0].Set2DImage,
450
- catalogId: isSet ? basket.OrderSets.map(function (os) {
451
- return os.CatalogGUID;
452
- }) : [basket.OrderSets[0].CatalogGUID],
453
- collection: isSet ? basket.OrderSets.map(function (os) {
454
- return os.AccountName;
455
- }) : [basket.OrderSets[0].AccountName],
456
- collectionId: isSet ? basket.OrderSets.map(function (os) {
457
- return os.CollectionGUID;
458
- }) : [basket.OrderSets[0].CollectionGUID],
459
- catCodex: isSet ? basket.OrderSets.map(function (os) {
460
- return os.CatalogCodex;
461
- }) : [basket.OrderSets[0].CatalogCodex],
462
- supplierId: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
463
- return c.supplierGuid;
464
- }).filter(function (c) {
465
- return c;
466
- }),
467
- retailCatalogNr: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
468
- return c.retailCatalogNr;
469
- }).filter(function (c) {
470
- return c;
471
- }),
472
- supplierArticleNr: basket.OrderSets.flatMap(function (os) {
473
- return os.OrderLines.map(function (ol) {
474
- return ol.ConfigArticleCodex;
475
- }).filter(function (f) {
476
- return f;
477
- });
478
- }).filter(function (f) {
479
- return f;
480
- }),
481
- retailCatalogArticleNr: basket.OrderSets.flatMap(function (os) {
482
- return os.OrderLines.map(function (ol) {
483
- return ol.RetailArticleNr;
484
- }).filter(function (f) {
485
- return f;
486
- });
487
- }).filter(function (f) {
488
- return f;
489
- }),
490
- livingArea: (_baseProduct34 = baseProduct) === null || _baseProduct34 === void 0 ? void 0 : _baseProduct34.livingArea,
491
- mainCategory: (_baseProduct35 = baseProduct) === null || _baseProduct35 === void 0 ? void 0 : _baseProduct35.mainCategory,
492
- subCategory: (_baseProduct36 = baseProduct) === null || _baseProduct36 === void 0 ? void 0 : _baseProduct36.subCategory,
493
- retailerArticleNr: (_baseProduct37 = baseProduct) === null || _baseProduct37 === void 0 ? void 0 : _baseProduct37.retailerArticleNr,
494
- dockingPoints: dockingPoints,
495
- media: (_baseProduct38 = baseProduct) === null || _baseProduct38 === void 0 ? void 0 : _baseProduct38.media,
496
- affiliate: (_baseProduct39 = baseProduct) === null || _baseProduct39 === void 0 ? void 0 : _baseProduct39.affiliate,
497
- brand: (_baseProduct$brand = (_baseProduct40 = baseProduct) === null || _baseProduct40 === void 0 ? void 0 : _baseProduct40.brand) !== null && _baseProduct$brand !== void 0 ? _baseProduct$brand : catalogDataBrand,
304
+ oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
305
+ configuration = (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2.configuration;
306
+ baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
307
+ _id: ((_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3._id) || nanoid(),
308
+ divaNr: (_baseProduct$divaNr = (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr,
309
+ addedPrice: (_dataByBasket$price$a = dataByBasket === null || dataByBasket === void 0 || (_dataByBasket$price = dataByBasket.price) === null || _dataByBasket$price === void 0 ? void 0 : _dataByBasket$price.addedPrice) !== null && _dataByBasket$price$a !== void 0 ? _dataByBasket$price$a : (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.addedPrice,
310
+ image: (_dataByBasket$image = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image) !== null && _dataByBasket$image !== void 0 ? _dataByBasket$image : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.image,
311
+ image2D: (_dataByBasket$image2D = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image2D) !== null && _dataByBasket$image2D !== void 0 ? _dataByBasket$image2D : (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.image2D,
312
+ configuration: configuration,
313
+ dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.dockingPoints,
498
314
  currency: DivaUtils.defaultPriceFormat.currency,
499
- organizationId: (_baseProduct$organiza = (_baseProduct41 = baseProduct) === null || _baseProduct41 === void 0 ? void 0 : _baseProduct41.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
315
+ organizationId: (_baseProduct$organiza = (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
500
316
  inheritedOrganizations: [].concat(_toConsumableArray((_this$organization$pa = (_this$organization$pa2 = this.organization.parentOrganizations) === null || _this$organization$pa2 === void 0 ? void 0 : _this$organization$pa2.map(function (o) {
501
317
  return o._id;
502
318
  })) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
503
- created: (_baseProduct42 = baseProduct) === null || _baseProduct42 === void 0 ? void 0 : _baseProduct42.created,
504
- createdBy: (_baseProduct$createdB = (_baseProduct43 = baseProduct) === null || _baseProduct43 === void 0 ? void 0 : _baseProduct43.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
505
- createdBy_displayText: (_baseProduct44 = baseProduct) === null || _baseProduct44 === void 0 ? void 0 : _baseProduct44.createdBy_displayText,
506
- archived: (_baseProduct45 = baseProduct) !== null && _baseProduct45 !== void 0 && _baseProduct45.archived ? (_baseProduct46 = baseProduct) === null || _baseProduct46 === void 0 ? void 0 : _baseProduct46.archived : false,
507
- isTopseller: !!((_baseProduct47 = baseProduct) !== null && _baseProduct47 !== void 0 && _baseProduct47.isTopseller),
508
- orderText: basket.getEKText(true),
509
- classificationInfo: (_baseProduct48 = baseProduct) === null || _baseProduct48 === void 0 ? void 0 : _baseProduct48.classificationInfo,
510
- modelInfoPageWeight: (_baseProduct49 = baseProduct) === null || _baseProduct49 === void 0 ? void 0 : _baseProduct49.modelInfoPageWeight,
511
- uniqueHash: isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
512
- return os.SetHash;
513
- }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject)
514
- };
515
- metaData = basket.OrderSets.reduce(function (prev, curr) {
319
+ createdBy: (_baseProduct$createdB = (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
320
+ createdBy_displayText: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy_displayText,
321
+ archived: (_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.archived ? (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.archived : false,
322
+ isTopseller: !!((_baseProduct14 = baseProduct) !== null && _baseProduct14 !== void 0 && _baseProduct14.isTopseller),
323
+ orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.orderText,
324
+ technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.technicalDescription
325
+ });
326
+ metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
516
327
  return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
517
328
  }, {});
518
- metaData_locales = basket.OrderSets.reduce(function (prev, curr) {
329
+ metaData_locales = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
519
330
  return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
520
331
  }, {});
521
332
  _this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
522
- baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct50 = baseProduct) === null || _baseProduct50 === void 0 ? void 0 : _baseProduct50.customData), customData);
333
+ baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.customData), customData);
523
334
 
524
335
  //add livingarea,maincategorie,subcategorie of loaded product if not exists
525
336
  classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
@@ -535,55 +346,56 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
535
346
  removedProducts = [];
536
347
  optFields = [];
537
348
  initialSelectedFields = [];
538
- if (isSet) {
539
- (_this$LOG = this.LOG) === null || _this$LOG === void 0 || _this$LOG.warn('Variants are currently not supported for set products');
540
- } else {
541
- //iterate all existing variant products and add them to the variants
542
- usedConfigVariants = [];
543
- variantProducts.forEach(function (product) {
544
- var cv;
545
- if (editedBasket) {
546
- var _basket$OrderSets$0$C;
547
- cv = (_basket$OrderSets$0$C = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.find(function (cv) {
548
- return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
549
- });
550
- } else {
551
- var _basket$OrderSets$0$C2;
552
- cv = (_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 ? void 0 : _basket$OrderSets$0$C2.find(function (cv) {
553
- return cv.VariantID == product.variantId;
554
- });
555
- }
349
+ if (!dataByBasket.isSet) {
350
+ _context2.next = 46;
351
+ break;
352
+ }
353
+ throw new Error('Variants are currently not supported for set products');
354
+ case 46:
355
+ //iterate all existing variant products and add them to the variants
356
+ usedVariantIds = [];
357
+ variantProducts.forEach(function (product) {
358
+ var cv;
359
+ if (basket) {
360
+ var _basket$OrderSets$0$C;
361
+ cv = (_basket$OrderSets$0$C = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C === void 0 || (_basket$OrderSets$0$C = _basket$OrderSets$0$C.find(function (cv) {
362
+ return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
363
+ })) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.VariantID;
364
+ } else {
365
+ cv = product.variantId;
366
+ }
556
367
 
557
- //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
558
- if (product.originDivaNr || cv) {
559
- usedConfigVariants.push(cv);
560
- var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
561
- _variant = _this$initVariant.variant,
562
- modified = _this$initVariant.modified;
563
- variantData.push(_variant);
564
- variantDataModified.push(modified);
565
- } else {
566
- var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
567
- _variant2 = _this$initVariant2.variant,
568
- _modified = _this$initVariant2.modified;
569
- variantData.push(_variant2);
570
- variantDataModified.push(_modified);
571
- removedProducts.push(_variant2._id);
572
- }
573
- });
368
+ //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
369
+ if (product.originDivaNr || cv !== undefined) {
370
+ if (cv !== undefined) usedVariantIds.push(cv);
371
+ var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
372
+ _variant = _this$initVariant.variant,
373
+ modified = _this$initVariant.modified;
374
+ variantData.push(_variant);
375
+ variantDataModified.push(modified);
376
+ } else {
377
+ var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
378
+ _variant2 = _this$initVariant2.variant,
379
+ _modified = _this$initVariant2.modified;
380
+ variantData.push(_variant2);
381
+ variantDataModified.push(_modified);
382
+ removedProducts.push(_variant2._id);
383
+ }
384
+ });
574
385
 
575
- //now iterate all configVariants that are left and add them to the variants (new Products)
576
- newVariantPosition = variantData.filter(function (vd) {
577
- return !removedProducts.includes(vd._id);
578
- });
579
- variantPositions = newVariantPosition.map(function (element) {
580
- return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
581
- });
582
- currentVariantPos = Math.max.apply(Math, _toConsumableArray(variantPositions));
583
- (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 || _basket$OrderSets$0$C3.filter(function (cv) {
584
- return !usedConfigVariants.includes(cv);
386
+ //now iterate all configVariants that are left and add them to the variants (new Products)
387
+ newVariantPosition = variantData.filter(function (vd) {
388
+ return !removedProducts.includes(vd._id);
389
+ });
390
+ variantPositions = newVariantPosition.map(function (element) {
391
+ return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
392
+ });
393
+ currentVariantPos = Math.max.apply(Math, _toConsumableArray(variantPositions));
394
+ if (basket) {
395
+ (_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 || _basket$OrderSets$0$C2.filter(function (cv) {
396
+ return !usedVariantIds.includes(cv.VariantID);
585
397
  }).forEach(function (cv) {
586
- var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, cv, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
398
+ var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv.VariantID, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
587
399
  variant = _this$initVariant3.variant,
588
400
  modified = _this$initVariant3.modified;
589
401
  currentVariantPos = currentVariantPos + 1;
@@ -592,60 +404,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
592
404
  variantDataModified.push(modified);
593
405
  addedProducts.push(variant._id);
594
406
  });
407
+ }
595
408
 
596
- //get opt data
597
- differingOPTs = Object.entries(((_basket$OrderSets$0$F = basket.OrderSets[0].Favorites) === null || _basket$OrderSets$0$F === void 0 ? void 0 : _basket$OrderSets$0$F.VariantValues) || []).filter(function (_ref6) {
598
- var _ref7 = _slicedToArray(_ref6, 2);
599
- _ref7[0];
600
- var value = _ref7[1];
601
- return Object.keys(value).length > 1;
602
- }).map(function (_ref8) {
603
- var _ref9 = _slicedToArray(_ref8, 2),
604
- opt = _ref9[0];
605
- _ref9[1];
606
- return opt.replace('OPT', '');
607
- });
608
- if (basket.OrderSets[0].ConfigVariants) {
609
- optFields = ((_basket$OrderSets$0$C4 = basket.OrderSets[0].ConfigVariants[0]) === null || _basket$OrderSets$0$C4 === void 0 ? void 0 : _basket$OrderSets$0$C4.VariantBasketDatas.map(function (vd) {
610
- var _vd$OPTName;
611
- return {
612
- field: vd.OptionOCD ? vd.OptionOCD.substring(3) : vd.OPT,
613
- type: 'string',
614
- title: (_vd$OPTName = vd.OPTName) !== null && _vd$OPTName !== void 0 ? _vd$OPTName : vd.OPT,
615
- readOnly: true,
616
- fieldType: 'OPT'
617
- };
618
- })) || [];
619
- //remove duplicates
620
- opts = {};
621
- for (_i2 = optFields.length - 1; _i2 >= 0; _i2--) {
622
- if (!opts[optFields[_i2].field]) {
623
- opts[optFields[_i2].field] = true;
624
- } else {
625
- optFields.splice(_i2, 1);
626
- }
409
+ //get opt data
410
+ differingOPTs = Object.entries(((_ref3 = (_baseProduct$configur3 = (_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.configuration) !== null && _baseProduct$configur3 !== void 0 ? _baseProduct$configur3 : basket) === null || _ref3 === void 0 || (_ref3 = _ref3.OrderSets[0].Favorites) === null || _ref3 === void 0 ? void 0 : _ref3.VariantValues) || []).filter(function (_ref4) {
411
+ var _ref5 = _slicedToArray(_ref4, 2);
412
+ _ref5[0];
413
+ var value = _ref5[1];
414
+ return Object.keys(value).length > 1;
415
+ }).map(function (_ref6) {
416
+ var _ref7 = _slicedToArray(_ref6, 2),
417
+ opt = _ref7[0];
418
+ _ref7[1];
419
+ return opt.replace('OPT', '');
420
+ });
421
+ if (variantData) {
422
+ optFields = ((_variantData$ = variantData[0]) === null || _variantData$ === void 0 || (_variantData$ = _variantData$.configuration) === null || _variantData$ === void 0 ? void 0 : _variantData$.OrderSets[0].OrderLines[0].VariantBasketDatas.map(function (vd) {
423
+ var _catalogData, _vd$OptionOCD, _option$Name;
424
+ var option = (_catalogData = catalogData) === null || _catalogData === void 0 ? void 0 : _catalogData[0].options[(_vd$OptionOCD = vd.OptionOCD) !== null && _vd$OptionOCD !== void 0 ? _vd$OptionOCD : 'OPT' + vd.OPT];
425
+ return {
426
+ field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
427
+ type: 'string',
428
+ title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
429
+ readOnly: true,
430
+ fieldType: 'OPT'
431
+ };
432
+ })) || [];
433
+ //remove duplicates
434
+ opts = {};
435
+ for (_i = optFields.length - 1; _i >= 0; _i--) {
436
+ if (!opts[optFields[_i].field]) {
437
+ opts[optFields[_i].field] = true;
438
+ } else {
439
+ optFields.splice(_i, 1);
627
440
  }
628
441
  }
629
-
630
- //mark all fields where there are differences between the variants as initaly selected
631
- initialSelectedFields = optFields.filter(function (f) {
632
- return differingOPTs.includes(f.field);
633
- });
634
- ProductHandlerAbstract.baseDataFields.forEach(function (field) {
635
- if (variantDataModified.some(function (mod) {
636
- return mod[field.field];
637
- })) {
638
- initialSelectedFields.push(field);
639
- }
640
- });
641
- customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
642
- if (variantDataModified.some(function (mod) {
643
- return mod['customData.' + f.field];
644
- })) {
645
- initialSelectedFields.push(f);
646
- }
647
- });
648
442
  }
443
+
444
+ //mark all fields where there are differences between the variants as initaly selected
445
+ initialSelectedFields = optFields.filter(function (f) {
446
+ return differingOPTs.includes(f.field);
447
+ });
448
+ ProductHandlerAbstract.baseDataFields.forEach(function (field) {
449
+ if (variantDataModified.some(function (mod) {
450
+ return mod[field.field];
451
+ })) {
452
+ initialSelectedFields.push(field);
453
+ }
454
+ });
455
+ customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
456
+ if (variantDataModified.some(function (mod) {
457
+ return mod['customData.' + f.field];
458
+ })) {
459
+ initialSelectedFields.push(f);
460
+ }
461
+ });
649
462
  initializedOptMap = this.initOpvMap(optFields, classificationConfig, optMap);
650
463
  return _context2.abrupt("return", {
651
464
  baseData: baseData,
@@ -653,6 +466,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
653
466
  optFields: optFields,
654
467
  initialSelectedFields: initialSelectedFields,
655
468
  variantData: variantData,
469
+ catalogData: catalogData,
656
470
  optClassMap: initializedOptMap,
657
471
  addedProducts: products.total ? addedProducts : [],
658
472
  removedProducts: products.total ? removedProducts : [],
@@ -666,7 +480,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
666
480
  availableLanguages: availableLanguages,
667
481
  currentLang: currentLang
668
482
  });
669
- case 47:
483
+ case 59:
670
484
  case "end":
671
485
  return _context2.stop();
672
486
  }
@@ -677,6 +491,192 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
677
491
  }
678
492
  return loadProducts;
679
493
  }())
494
+ }, {
495
+ key: "getProductDataByBasket",
496
+ value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
497
+ var dataByBasket = {};
498
+ var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
499
+ dataByBasket.isSet = isSet;
500
+ if (basket) {
501
+ dataByBasket.hqRenderScript = basket === null || basket === void 0 ? void 0 : basket.OrderSets[0].HQRenderScript;
502
+ dataByBasket.dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
503
+ dataByBasket.technicalDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
504
+ return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
505
+ }, '') : basket.OrderSets[0].VariantDescription;
506
+ dataByBasket.technicalDescription_locales = basket.OrderSets[0].VariantDescription_locales;
507
+ dataByBasket.modelName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
508
+ return c.name;
509
+ }).filter(function (name) {
510
+ return name;
511
+ }).join(' - ');
512
+ dataByBasket.catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
513
+ return c.brand;
514
+ }).filter(function (brand) {
515
+ return brand;
516
+ }).join(' - ');
517
+ dataByBasket.info = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
518
+ return c.description;
519
+ }).filter(function (description) {
520
+ return description;
521
+ }).join('<br/>');
522
+ dataByBasket.modelName_locales = {};
523
+ for (var i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
524
+ var c = catalogData[i];
525
+ for (var key in c.name_locales) {
526
+ if (!dataByBasket.modelName_locales[key]) {
527
+ dataByBasket.modelName_locales[key] = c.name_locales[key];
528
+ } else {
529
+ dataByBasket.modelName_locales[key] = dataByBasket.modelName_locales[key] + ' - ' + c.name_locales[key];
530
+ }
531
+ }
532
+ dataByBasket.info_locales = {};
533
+ for (var _key in c.description_locales) {
534
+ if (!dataByBasket.info_locales[_key]) {
535
+ dataByBasket.info_locales[_key] = c.description_locales[_key];
536
+ } else {
537
+ dataByBasket.info_locales[_key] = dataByBasket.info_locales[_key] + ' - ' + c.description_locales[_key];
538
+ }
539
+ }
540
+ }
541
+ if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
542
+ var _baseProduct$delivery, _baseProduct$delivery2, _baseProduct$delivery3, _baseProduct$delivery4, _baseProduct$delivery5, _baseProduct$delivery6, _baseProduct$delivery7, _baseProduct$delivery8, _baseProduct$delivery9, _baseProduct$delivery10, _ref8, _baseProduct$delivery11, _baseProduct$delivery12, _fieldConfiguration$d, _ref9, _baseProduct$delivery13, _baseProduct$delivery14, _fieldConfiguration$d2, _ref10, _baseProduct$delivery15, _baseProduct$delivery16, _fieldConfiguration$d3;
543
+ var config = {
544
+ addedPackageWeight: 0,
545
+ addedPackageHeight: 0,
546
+ addedPackageWidth: 0,
547
+ addedPackageDepth: 0,
548
+ defaultDeliveryTime: 0,
549
+ defaultDeliveryPrice: 0,
550
+ defaultInstallationPrice: 0
551
+ };
552
+ if (typeof fieldConfiguration.delivery != 'boolean') {
553
+ config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
554
+ }
555
+ var packages = [];
556
+ basket.OrderSets.flatMap(function (os) {
557
+ return os.OrderLines;
558
+ }).forEach(function (ol) {
559
+ packages.push({
560
+ height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
561
+ width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
562
+ depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
563
+ weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
564
+ });
565
+ });
566
+ dataByBasket.delivery = {
567
+ estPackages: packages,
568
+ estMaxPackages: (_baseProduct$delivery = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery2 = baseProduct.delivery) === null || _baseProduct$delivery2 === void 0 ? void 0 : _baseProduct$delivery2.estMaxPackages) !== null && _baseProduct$delivery !== void 0 ? _baseProduct$delivery : packages.length,
569
+ estMaxPackageWeight: (_baseProduct$delivery3 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery4 = baseProduct.delivery) === null || _baseProduct$delivery4 === void 0 ? void 0 : _baseProduct$delivery4.estMaxPackageWeight) !== null && _baseProduct$delivery3 !== void 0 ? _baseProduct$delivery3 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
570
+ return p.weight;
571
+ }).filter(function (f) {
572
+ return f;
573
+ })))),
574
+ estMaxPackageHeight: (_baseProduct$delivery5 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery6 = baseProduct.delivery) === null || _baseProduct$delivery6 === void 0 ? void 0 : _baseProduct$delivery6.estMaxPackageHeight) !== null && _baseProduct$delivery5 !== void 0 ? _baseProduct$delivery5 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
575
+ return p.height;
576
+ }).filter(function (f) {
577
+ return f;
578
+ })))),
579
+ estMaxPackageWidth: (_baseProduct$delivery7 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery8 = baseProduct.delivery) === null || _baseProduct$delivery8 === void 0 ? void 0 : _baseProduct$delivery8.estMaxPackageWidth) !== null && _baseProduct$delivery7 !== void 0 ? _baseProduct$delivery7 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
580
+ return p.width;
581
+ }).filter(function (f) {
582
+ return f;
583
+ })))),
584
+ estMaxPackageDepth: (_baseProduct$delivery9 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery10 = baseProduct.delivery) === null || _baseProduct$delivery10 === void 0 ? void 0 : _baseProduct$delivery10.estMaxPackageDepth) !== null && _baseProduct$delivery9 !== void 0 ? _baseProduct$delivery9 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
585
+ return p.depth;
586
+ }).filter(function (f) {
587
+ return f;
588
+ })))),
589
+ deliveryTime: (_ref8 = (_baseProduct$delivery11 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery12 = baseProduct.delivery) === null || _baseProduct$delivery12 === void 0 ? void 0 : _baseProduct$delivery12.deliveryTime) !== null && _baseProduct$delivery11 !== void 0 ? _baseProduct$delivery11 : (_fieldConfiguration$d = fieldConfiguration.delivery) === null || _fieldConfiguration$d === void 0 ? void 0 : _fieldConfiguration$d.defaultDeliveryTime) !== null && _ref8 !== void 0 ? _ref8 : 0,
590
+ deliveryPrice: (_ref9 = (_baseProduct$delivery13 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery14 = baseProduct.delivery) === null || _baseProduct$delivery14 === void 0 ? void 0 : _baseProduct$delivery14.deliveryPrice) !== null && _baseProduct$delivery13 !== void 0 ? _baseProduct$delivery13 : (_fieldConfiguration$d2 = fieldConfiguration.delivery) === null || _fieldConfiguration$d2 === void 0 ? void 0 : _fieldConfiguration$d2.defaultDeliveryPrice) !== null && _ref9 !== void 0 ? _ref9 : 0,
591
+ installationPrice: (_ref10 = (_baseProduct$delivery15 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery16 = baseProduct.delivery) === null || _baseProduct$delivery16 === void 0 ? void 0 : _baseProduct$delivery16.installationPrice) !== null && _baseProduct$delivery15 !== void 0 ? _baseProduct$delivery15 : (_fieldConfiguration$d3 = fieldConfiguration.delivery) === null || _fieldConfiguration$d3 === void 0 ? void 0 : _fieldConfiguration$d3.defaultInstallationPrice) !== null && _ref10 !== void 0 ? _ref10 : 0
592
+ };
593
+ }
594
+ var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
595
+ var price = {
596
+ calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
597
+ addedPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice,
598
+ discountPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.discountedPrice
599
+ };
600
+ if (!(baseProduct !== null && baseProduct !== void 0 && baseProduct.calculatedPrice)) {
601
+ price = ProductHandlerAbstract.calcPrice(basket === null || basket === void 0 ? void 0 : basket.SummaryPrice, basket === null || basket === void 0 ? void 0 : basket.Discounts, baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice, ismanual);
602
+ }
603
+ dataByBasket.price = price;
604
+ dataByBasket.calculatedPrice = price.calculatedPrice;
605
+ if (isSet) {
606
+ var _basket$SetPlannerInf, _basket$SetPlannerInf2, _basket$OrderSets$0$B, _basket$SetPlannerInf3, _basket$SetPlannerInf4;
607
+ dataByBasket.width = (_basket$SetPlannerInf = basket.SetPlannerInfos) === null || _basket$SetPlannerInf === void 0 || (_basket$SetPlannerInf = _basket$SetPlannerInf.BBox) === null || _basket$SetPlannerInf === void 0 ? void 0 : _basket$SetPlannerInf.X;
608
+ dataByBasket.height = (_basket$SetPlannerInf2 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf2 === void 0 || (_basket$SetPlannerInf2 = _basket$SetPlannerInf2.BBox) === null || _basket$SetPlannerInf2 === void 0 ? void 0 : _basket$SetPlannerInf2.Z;
609
+ dataByBasket.depth = basket === null || basket === void 0 || (_basket$OrderSets$0$B = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B === void 0 ? void 0 : _basket$OrderSets$0$B.Y;
610
+ dataByBasket.image = (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.SetPlannerImg3D;
611
+ dataByBasket.image2D = (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg2D;
612
+ dataByBasket.catalogId = basket.OrderSets.map(function (os) {
613
+ return os.CatalogGUID;
614
+ });
615
+ dataByBasket.collection = basket.OrderSets.map(function (os) {
616
+ return os.AccountName;
617
+ });
618
+ dataByBasket.collectionId = basket.OrderSets.map(function (os) {
619
+ return os.CollectionGUID;
620
+ });
621
+ dataByBasket.catCodex = basket.OrderSets.map(function (os) {
622
+ return os.CatalogCodex;
623
+ });
624
+ } else {
625
+ var _basket$OrderSets$0$B2, _basket$OrderSets$0$B3, _basket$OrderSets$0$B4;
626
+ dataByBasket.width = basket === null || basket === void 0 || (_basket$OrderSets$0$B2 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B2 === void 0 ? void 0 : _basket$OrderSets$0$B2.X;
627
+ dataByBasket.height = basket === null || basket === void 0 || (_basket$OrderSets$0$B3 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B3 === void 0 ? void 0 : _basket$OrderSets$0$B3.Z;
628
+ dataByBasket.depth = basket === null || basket === void 0 || (_basket$OrderSets$0$B4 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B4 === void 0 ? void 0 : _basket$OrderSets$0$B4.Y;
629
+ dataByBasket.image = basket.OrderSets[0].SetImage;
630
+ dataByBasket.image2D = basket.OrderSets[0].Set2DImage;
631
+ dataByBasket.catalogId = [basket.OrderSets[0].CatalogGUID];
632
+ dataByBasket.collection = [basket.OrderSets[0].AccountName];
633
+ dataByBasket.collectionId = [basket.OrderSets[0].CollectionGUID];
634
+ dataByBasket.catCodex = [basket.OrderSets[0].CatalogCodex];
635
+ }
636
+ dataByBasket.weight = basket === null || basket === void 0 ? void 0 : basket.OrderSets.flatMap(function (os) {
637
+ return os.OrderLines.map(function (ol) {
638
+ return ol.Weight;
639
+ }).filter(function (f) {
640
+ return f;
641
+ });
642
+ }).reduce(function (sum, v) {
643
+ return sum + v;
644
+ }, 0);
645
+ dataByBasket.supplierId = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
646
+ return c.supplierGuid;
647
+ }).filter(function (c) {
648
+ return c;
649
+ });
650
+ dataByBasket.retailCatalogNr = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
651
+ return c.retailCatalogNr;
652
+ }).filter(function (c) {
653
+ return c;
654
+ });
655
+ dataByBasket.supplierArticleNr = basket.OrderSets.flatMap(function (os) {
656
+ return os.OrderLines.map(function (ol) {
657
+ return ol.ConfigArticleCodex;
658
+ }).filter(function (f) {
659
+ return f;
660
+ });
661
+ }).filter(function (f) {
662
+ return f;
663
+ });
664
+ dataByBasket.retailCatalogArticleNr = basket.OrderSets.flatMap(function (os) {
665
+ return os.OrderLines.map(function (ol) {
666
+ return ol.RetailArticleNr;
667
+ }).filter(function (f) {
668
+ return f;
669
+ });
670
+ }).filter(function (f) {
671
+ return f;
672
+ });
673
+ dataByBasket.orderText = basket.getEKText(true);
674
+ dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
675
+ return os.SetHash;
676
+ }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
677
+ }
678
+ return dataByBasket;
679
+ }
680
680
  }, {
681
681
  key: "checkAndAddClassificationConfigCategories",
682
682
  value: function checkAndAddClassificationConfigCategories(baseProduct, classificationConfig) {
@@ -737,11 +737,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
737
737
  key: "mapCategory",
738
738
  value: function mapCategory(value, translations) {
739
739
  var _translations$find2;
740
- var _ref10 = (_translations$find2 = translations === null || translations === void 0 ? void 0 : translations.find(function (t) {
740
+ var _ref11 = (_translations$find2 = translations === null || translations === void 0 ? void 0 : translations.find(function (t) {
741
741
  return t.value == value;
742
742
  })) !== null && _translations$find2 !== void 0 ? _translations$find2 : {};
743
- _ref10.value;
744
- var translation = _objectWithoutProperties(_ref10, _excluded);
743
+ _ref11.value;
744
+ var translation = _objectWithoutProperties(_ref11, _excluded);
745
745
  if (Object.keys(translation).length) {
746
746
  return translation;
747
747
  }
@@ -765,13 +765,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
765
765
  }, {
766
766
  key: "prepareData",
767
767
  value: function () {
768
- var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref11) {
768
+ var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref12) {
769
769
  var _this3 = this;
770
- var baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref11$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;
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
771
  return _regeneratorRuntime.wrap(function _callee3$(_context4) {
772
772
  while (1) switch (_context4.prev = _context4.next) {
773
773
  case 0:
774
- baseData = _ref11.baseData, classificationData = _ref11.classificationData, variantData = _ref11.variantData, removedProducts = _ref11.removedProducts, removedMedia = _ref11.removedMedia, classificationFields = _ref11.classificationFields, fieldConfiguration = _ref11.fieldConfiguration, optMap = _ref11.optMap, _ref11$oldClassificat = _ref11.oldClassificationData, oldClassificationData = _ref11$oldClassificat === void 0 ? {} : _ref11$oldClassificat, originProductId = _ref11.originProductId;
774
+ 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
775
  products = [];
776
776
  originProduct = undefined;
777
777
  if (!originProductId) {
@@ -816,10 +816,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
816
816
  }
817
817
  this.trimStrings(baseData);
818
818
  //the base product is constructed, based on baseData and classification data
819
- baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref12) {
820
- var _ref13 = _slicedToArray(_ref12, 2),
821
- key = _ref13[0],
822
- value = _ref13[1];
819
+ baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref13) {
820
+ var _ref14 = _slicedToArray(_ref13, 2),
821
+ key = _ref14[0],
822
+ value = _ref14[1];
823
823
  prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
824
824
  return prev;
825
825
  }, {})), {}, {
@@ -831,11 +831,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
831
831
  });
832
832
  if (!originProduct && baseData.customData) {
833
833
  //convert all customData to objects with value and translations, if they exists
834
- Object.entries(baseData.customData).forEach(function (_ref14) {
834
+ Object.entries(baseData.customData).forEach(function (_ref15) {
835
835
  var _baseProduct$customDa;
836
- var _ref15 = _slicedToArray(_ref14, 2),
837
- key = _ref15[0],
838
- value = _ref15[1];
836
+ var _ref16 = _slicedToArray(_ref15, 2),
837
+ key = _ref16[0],
838
+ value = _ref16[1];
839
839
  if (!((_baseProduct$customDa = baseProduct.customData[key]) !== null && _baseProduct$customDa !== void 0 && _baseProduct$customDa.value)) {
840
840
  var _fieldConfiguration$a;
841
841
  baseProduct.customData[key] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$a = fieldConfiguration.additional) === null || _fieldConfiguration$a === void 0 || (_fieldConfiguration$a = _fieldConfiguration$a[key]) === null || _fieldConfiguration$a === void 0 ? void 0 : _fieldConfiguration$a.values);
@@ -844,17 +844,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
844
844
  }
845
845
  if (optMap) {
846
846
  //save to class fields the information to which opt it maps
847
- Object.entries(optMap).filter(function (_ref16) {
848
- var _ref17 = _slicedToArray(_ref16, 2);
849
- _ref17[0];
850
- var value = _ref17[1];
847
+ Object.entries(optMap).filter(function (_ref17) {
848
+ var _ref18 = _slicedToArray(_ref17, 2);
849
+ _ref18[0];
850
+ var value = _ref18[1];
851
851
  return value;
852
- }).forEach(function (_ref18) {
853
- var _baseProduct51;
854
- var _ref19 = _slicedToArray(_ref18, 2),
855
- key = _ref19[0],
856
- value = _ref19[1];
857
- return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct51 = baseProduct["dc_".concat(key)]) !== null && _baseProduct51 !== void 0 ? _baseProduct51 : {}), {}, {
852
+ }).forEach(function (_ref19) {
853
+ var _baseProduct19;
854
+ var _ref20 = _slicedToArray(_ref19, 2),
855
+ key = _ref20[0],
856
+ value = _ref20[1];
857
+ return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct19 = baseProduct["dc_".concat(key)]) !== null && _baseProduct19 !== void 0 ? _baseProduct19 : {}), {}, {
858
858
  opt: value.field
859
859
  });
860
860
  });
@@ -939,8 +939,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
939
939
  baseProduct.parent = baseProduct._id;
940
940
  }
941
941
  _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
942
- var _originProduct;
943
- var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, product, _this3$openModal, _this3$t, k, _savedMedia;
942
+ var _basket$getProductCon2, _originProduct, _configuration$OrderS;
943
+ var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k, _savedMedia;
944
944
  return _regeneratorRuntime.wrap(function _loop$(_context3) {
945
945
  while (1) switch (_context3.prev = _context3.next) {
946
946
  case 0:
@@ -953,11 +953,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
953
953
  case 3:
954
954
  varinatBase = {};
955
955
  classData = {};
956
- Object.entries(vd).forEach(function (_ref20) {
956
+ Object.entries(vd).forEach(function (_ref21) {
957
957
  var _optMap$key;
958
- var _ref21 = _slicedToArray(_ref20, 2),
959
- key = _ref21[0],
960
- value = _ref21[1];
958
+ var _ref22 = _slicedToArray(_ref21, 2),
959
+ key = _ref22[0],
960
+ value = _ref22[1];
961
961
  //save those fields that are specified as class fields
962
962
  if (classificationFields !== null && classificationFields !== void 0 && classificationFields.includes(key) && (value || optMap !== null && optMap !== void 0 && (_optMap$key = optMap[key]) !== null && _optMap$key !== void 0 && _optMap$key.field)) {
963
963
  classData["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
@@ -971,16 +971,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
971
971
  });
972
972
  if (optMap) {
973
973
  //save to class fields the information to which opt it maps
974
- Object.entries(optMap).filter(function (_ref22) {
975
- var _ref23 = _slicedToArray(_ref22, 2);
976
- _ref23[0];
977
- var value = _ref23[1];
974
+ Object.entries(optMap).filter(function (_ref23) {
975
+ var _ref24 = _slicedToArray(_ref23, 2);
976
+ _ref24[0];
977
+ var value = _ref24[1];
978
978
  return value;
979
- }).forEach(function (_ref24) {
979
+ }).forEach(function (_ref25) {
980
980
  var _oldClassificationDat, _oldClassificationDat2, _value$field, _value$field2, _value$field3, _value$field4;
981
- var _ref25 = _slicedToArray(_ref24, 2),
982
- key = _ref25[0],
983
- value = _ref25[1];
981
+ var _ref26 = _slicedToArray(_ref25, 2),
982
+ key = _ref26[0],
983
+ value = _ref26[1];
984
984
  return classData["dc_".concat(key)] = _objectSpread(_objectSpread(_objectSpread({}, (_oldClassificationDat = (_oldClassificationDat2 = oldClassificationData[vd._id]) === null || _oldClassificationDat2 === void 0 ? void 0 : _oldClassificationDat2["dc_".concat(key)]) !== null && _oldClassificationDat !== void 0 ? _oldClassificationDat : {}), classData["dc_".concat(key)]), {}, {
985
985
  opt: value.field,
986
986
  opv: (_value$field = vd[value.field]) === null || _value$field === void 0 ? void 0 : _value$field.codex,
@@ -996,11 +996,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
996
996
  if (vd.customData) {
997
997
  customData = {};
998
998
  //convert all customData to objects with value and translations, if they exists
999
- Object.entries(vd.customData).forEach(function (_ref26) {
999
+ Object.entries(vd.customData).forEach(function (_ref27) {
1000
1000
  var _vd$customData, _fieldConfiguration$a2;
1001
- var _ref27 = _slicedToArray(_ref26, 2),
1002
- key = _ref27[0],
1003
- value = _ref27[1];
1001
+ var _ref28 = _slicedToArray(_ref27, 2),
1002
+ key = _ref28[0],
1003
+ value = _ref28[1];
1004
1004
  if (!((_vd$customData = vd.customData) !== null && _vd$customData !== void 0 && (_vd$customData = _vd$customData[key]) !== null && _vd$customData !== void 0 && _vd$customData.value)) customData[key] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$a2 = fieldConfiguration.additional) === null || _fieldConfiguration$a2 === void 0 || (_fieldConfiguration$a2 = _fieldConfiguration$a2[key]) === null || _fieldConfiguration$a2 === void 0 ? void 0 : _fieldConfiguration$a2.values);
1005
1005
  });
1006
1006
  }
@@ -1025,6 +1025,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1025
1025
  _id: productId
1026
1026
  };
1027
1027
  }
1028
+ configuration = (_basket$getProductCon2 = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration(typeof vd.variantId == 'string' ? Number(vd.variantId) : vd.variantId)) !== null && _basket$getProductCon2 !== void 0 ? _basket$getProductCon2 : vd.configuration;
1028
1029
  product = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, preparedProduct), varinatBase), classData), {}, {
1029
1030
  customData: originProduct ? _objectSpread(_objectSpread({}, (_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.customData), {}, {
1030
1031
  SAP_EINA_LIFNR: {
@@ -1049,6 +1050,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1049
1050
  modelName_locales: vd.modelName_locales,
1050
1051
  shortDescription_locales: vd.shortDescription_locales,
1051
1052
  width: vd.width,
1053
+ 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,
1052
1055
  height: vd.height,
1053
1056
  depth: vd.depth,
1054
1057
  calculatedPrice: vd.calculatedPrice,
@@ -1059,7 +1062,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1059
1062
  variantPosition: variantPos,
1060
1063
  image: vd.image,
1061
1064
  image2D: vd.image2D,
1062
- articles: vd.articles,
1063
1065
  affiliate: vd.affiliate,
1064
1066
  originDivaNr: vd.originDivaNr,
1065
1067
  organizationId: baseProduct.organizationId,
@@ -1071,7 +1073,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1071
1073
  uniqueHash: vd.uniqueHash
1072
1074
  });
1073
1075
  if (!vd.media) {
1074
- _context3.next = 27;
1076
+ _context3.next = 28;
1075
1077
  break;
1076
1078
  }
1077
1079
  product.media = [];
@@ -1081,14 +1083,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1081
1083
  dontRenderForm: true
1082
1084
  });
1083
1085
  k = 0;
1084
- case 19:
1086
+ case 20:
1085
1087
  if (!(k < vd.media.length)) {
1086
- _context3.next = 27;
1088
+ _context3.next = 28;
1087
1089
  break;
1088
1090
  }
1089
- _context3.next = 22;
1091
+ _context3.next = 23;
1090
1092
  return _this3.saveProductMedia(vd.media[k], baseProduct.organizationId);
1091
- case 22:
1093
+ case 23:
1092
1094
  _savedMedia = _context3.sent;
1093
1095
  if (_savedMedia) {
1094
1096
  product.media.push(_savedMedia);
@@ -1105,14 +1107,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1105
1107
  "class": vd.media[k]["class"]
1106
1108
  });
1107
1109
  }
1108
- case 24:
1110
+ case 25:
1109
1111
  k++;
1110
- _context3.next = 19;
1112
+ _context3.next = 20;
1111
1113
  break;
1112
- case 27:
1114
+ case 28:
1113
1115
  //add the variant product it the list of products to be saved
1114
1116
  products.push(product);
1115
- case 28:
1117
+ case 29:
1116
1118
  case "end":
1117
1119
  return _context3.stop();
1118
1120
  }
@@ -1161,43 +1163,66 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1161
1163
  }
1162
1164
  }
1163
1165
  }, {
1164
- key: "saveBasketAndProducts",
1166
+ key: "saveProducts",
1165
1167
  value: function () {
1166
- var _saveBasketAndProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref28) {
1167
- var products, removedProducts, basket, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1168
+ var _saveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref29) {
1169
+ var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1168
1170
  return _regeneratorRuntime.wrap(function _callee4$(_context5) {
1169
1171
  while (1) switch (_context5.prev = _context5.next) {
1170
1172
  case 0:
1171
- products = _ref28.products, removedProducts = _ref28.removedProducts, basket = _ref28.basket, awaitPDF = _ref28.awaitPDF;
1173
+ products = _ref29.products, removedProducts = _ref29.removedProducts, awaitPDF = _ref29.awaitPDF;
1172
1174
  if (this.jwt) {
1173
1175
  _context5.next = 3;
1174
1176
  break;
1175
1177
  }
1176
1178
  throw new Error('jwt not set');
1177
1179
  case 3:
1178
- _context5.prev = 3;
1179
- _context5.next = 6;
1180
- return this.apiSaveBasketAndProducts(this.catalogService, this.jwt, products, awaitPDF, basket, removedProducts);
1181
- case 6:
1180
+ this.setFirstVariant(products);
1181
+ _context5.prev = 4;
1182
+ _context5.next = 7;
1183
+ return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
1184
+ case 7:
1182
1185
  savedProducts = _context5.sent;
1183
1186
  (_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
1184
1187
  return _context5.abrupt("return", savedProducts);
1185
- case 11:
1186
- _context5.prev = 11;
1187
- _context5.t0 = _context5["catch"](3);
1188
+ case 12:
1189
+ _context5.prev = 12;
1190
+ _context5.t0 = _context5["catch"](4);
1188
1191
  (_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
1189
1192
  throw new Error(_context5.t0.message);
1190
- case 15:
1193
+ case 16:
1191
1194
  case "end":
1192
1195
  return _context5.stop();
1193
1196
  }
1194
- }, _callee4, this, [[3, 11]]);
1197
+ }, _callee4, this, [[4, 12]]);
1195
1198
  }));
1196
- function saveBasketAndProducts(_x4) {
1197
- return _saveBasketAndProducts.apply(this, arguments);
1199
+ function saveProducts(_x4) {
1200
+ return _saveProducts.apply(this, arguments);
1198
1201
  }
1199
- return saveBasketAndProducts;
1200
- }()
1202
+ return saveProducts;
1203
+ }() //variant with lowest variantId gets a flag for filtering purposes
1204
+ }, {
1205
+ key: "setFirstVariant",
1206
+ value: function setFirstVariant(products) {
1207
+ var _variants$;
1208
+ products.map(function (p) {
1209
+ return p.firstVariant = false;
1210
+ });
1211
+ var variants = products.filter(function (p) {
1212
+ return p.variantId !== undefined;
1213
+ });
1214
+ if (!(variants !== null && variants !== void 0 && variants.length)) return;
1215
+ var firstVariant = variants[0];
1216
+ var lowestId = (_variants$ = variants[0]) === null || _variants$ === void 0 ? void 0 : _variants$.variantId;
1217
+ for (var i = 0; i < variants.length; i++) {
1218
+ if (lowestId > variants[i].variantId) {
1219
+ lowestId = variants[i].variantId;
1220
+ firstVariant = variants[i];
1221
+ }
1222
+ }
1223
+ firstVariant.firstVariant = true;
1224
+ }
1225
+
1201
1226
  /**
1202
1227
  * Calculates the inital state of one varinat data entry
1203
1228
  *
@@ -1207,42 +1232,48 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1207
1232
  */
1208
1233
  }, {
1209
1234
  key: "initVariant",
1210
- value: function initVariant(baseData, baseClassification, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1211
- var _cv$VariantDescriptio, _cv$VariantDescriptio2, _baseData$articles, _classificationFields;
1212
- var _this$parseClassifica = this.parseClassificationFields(product),
1235
+ value: function initVariant(baseData, baseClassification, availableLanguages, catalogData, basket, cv, variantProduct, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1236
+ var _basket$OrderSets$0$C3, _ref31, _variantProduct$confi, _classificationFields;
1237
+ var _this$parseClassifica = this.parseClassificationFields(variantProduct),
1213
1238
  parsedProduct = _this$parseClassifica.product;
1214
- var _ref29 = cv || {},
1215
- VariantID = _ref29.VariantID,
1216
- SetImage = _ref29.SetImage,
1217
- Set2DImage = _ref29.Set2DImage,
1218
- SetPrice = _ref29.SetPrice,
1219
- VariantBasketDatas = _ref29.VariantBasketDatas,
1220
- BBox = _ref29.BBox,
1221
- MetaData = _ref29.MetaData,
1222
- MetaData_locales = _ref29.MetaData_locales,
1223
- Variant = _ref29.Variant,
1224
- SetHash = _ref29.SetHash,
1225
- Diva3DProject = _ref29.Diva3DProject;
1239
+ var _ref30 = (basket === null || basket === void 0 || (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 ? void 0 : _basket$OrderSets$0$C3.find(function (vd) {
1240
+ return vd.VariantID === cv;
1241
+ })) || {
1242
+ VariantBasketDatas: ProductHandlerAbstract.getVariantBasketDatasByOrderlines((_ref31 = variantProduct === null || variantProduct === void 0 || (_variantProduct$confi = variantProduct.configuration) === null || _variantProduct$confi === void 0 ? void 0 : _variantProduct$confi.OrderSets[0].OrderLines) !== null && _ref31 !== void 0 ? _ref31 : [], catalogData)
1243
+ },
1244
+ VariantID = _ref30.VariantID,
1245
+ SetImage = _ref30.SetImage,
1246
+ Set2DImage = _ref30.Set2DImage,
1247
+ SetPrice = _ref30.SetPrice,
1248
+ VariantBasketDatas = _ref30.VariantBasketDatas,
1249
+ BBox = _ref30.BBox,
1250
+ MetaData = _ref30.MetaData,
1251
+ MetaData_locales = _ref30.MetaData_locales,
1252
+ Variant = _ref30.Variant,
1253
+ SetHash = _ref30.SetHash,
1254
+ Diva3DProject = _ref30.Diva3DProject,
1255
+ VariantDescription_locales = _ref30.VariantDescription_locales,
1256
+ VariantDescription = _ref30.VariantDescription;
1226
1257
  //total and summary price are currently not avialable per varinat,
1227
1258
  //most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
1228
1259
  //we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
1229
1260
 
1230
- var ismanual = (product === null || product === void 0 ? void 0 : product.calculatedPrice) !== (product === null || product === void 0 ? void 0 : product.addedPrice);
1231
- var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], product === null || product === void 0 ? void 0 : product.calculatedPrice, ismanual);
1261
+ 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);
1232
1263
  var addedPrice;
1233
1264
  if (SetPrice == baseData.calculatedPrice) {
1234
1265
  addedPrice = baseData.addedPrice;
1235
1266
  } else {
1236
1267
  addedPrice = price.calculatedPrice;
1237
1268
  }
1238
- var isManual = (product === null || product === void 0 ? void 0 : product.addedPrice) !== (product === null || product === void 0 ? void 0 : product.calculatedPrice);
1269
+ var isManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice);
1239
1270
  if (isManual) {
1240
- addedPrice = product === null || product === void 0 ? void 0 : product.addedPrice;
1271
+ addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1241
1272
  }
1242
- var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, product, classificationConfig, customBaseFields),
1273
+ var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1243
1274
  classificationData = _this$parseMetaDataAn2.classificationData,
1244
1275
  customData = _this$parseMetaDataAn2.customData;
1245
- customData = _objectSpread(_objectSpread({}, product === null || product === void 0 ? void 0 : product.customData), customData);
1276
+ customData = _objectSpread(_objectSpread({}, variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.customData), customData);
1246
1277
  var variant = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseData), {}, {
1247
1278
  media: undefined,
1248
1279
  //set media undefined, just in case "baseData" has media but "parsedProduct" does not have media to overwrite it
@@ -1252,8 +1283,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1252
1283
  width: BBox === null || BBox === void 0 ? void 0 : BBox.X,
1253
1284
  height: BBox === null || BBox === void 0 ? void 0 : BBox.Z,
1254
1285
  depth: BBox === null || BBox === void 0 ? void 0 : BBox.Y,
1255
- technicalDescription: (_cv$VariantDescriptio = cv === null || cv === void 0 ? void 0 : cv.VariantDescription) !== null && _cv$VariantDescriptio !== void 0 ? _cv$VariantDescriptio : baseData.technicalDescription,
1256
- technicalDescription_locales: (_cv$VariantDescriptio2 = cv === null || cv === void 0 ? void 0 : cv.VariantDescription_locales) !== null && _cv$VariantDescriptio2 !== void 0 ? _cv$VariantDescriptio2 : baseData.technicalDescription_locales
1286
+ technicalDescription: VariantDescription !== null && VariantDescription !== void 0 ? VariantDescription : baseData.technicalDescription,
1287
+ technicalDescription_locales: VariantDescription_locales !== null && VariantDescription_locales !== void 0 ? VariantDescription_locales : baseData.technicalDescription_locales
1257
1288
  }, parsedProduct), {}, {
1258
1289
  customData: customData
1259
1290
  }, classificationData), {}, {
@@ -1262,18 +1293,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1262
1293
  //only if cv is not defined fallback to the values in product
1263
1294
  addedPrice: addedPrice,
1264
1295
  calculatedPrice: price.calculatedPrice,
1265
- articles: VariantBasketDatas ? (_baseData$articles = baseData.articles) === null || _baseData$articles === void 0 ? void 0 : _baseData$articles.map(function (art) {
1266
- return _objectSpread(_objectSpread({}, art), {}, {
1267
- variantValues: VariantBasketDatas === null || VariantBasketDatas === void 0 ? void 0 : VariantBasketDatas.filter(function (vb) {
1268
- return !vb.IsDescribingState;
1269
- }).map(function (vb) {
1270
- return {
1271
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
1272
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
1273
- };
1274
- })
1275
- });
1276
- }) : parsedProduct.articles,
1277
1296
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1278
1297
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1279
1298
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1363,10 +1382,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1363
1382
  key: "initOpvMap",
1364
1383
  value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
1365
1384
  var optMap = {};
1366
- Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref30) {
1367
- var _ref31 = _slicedToArray(_ref30, 2),
1368
- c = _ref31[0],
1369
- optMapping = _ref31[1].optMapping;
1385
+ Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref32) {
1386
+ var _ref33 = _slicedToArray(_ref32, 2),
1387
+ c = _ref33[0],
1388
+ optMapping = _ref33[1].optMapping;
1370
1389
  var optField;
1371
1390
  if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
1372
1391
  optField = optFields.find(function (opt) {
@@ -1427,16 +1446,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1427
1446
  var _classificationConfig;
1428
1447
  //add metadata defined as classification to classificationdata
1429
1448
  var metadataAsClassification = {};
1430
- Object.entries(metaData).filter(function (_ref32) {
1431
- var _ref33 = _slicedToArray(_ref32, 1),
1432
- key = _ref33[0];
1449
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref34) {
1450
+ var _ref35 = _slicedToArray(_ref34, 1),
1451
+ key = _ref35[0];
1433
1452
  return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
1434
1453
  })
1435
1454
  //if it is defiend as multi field, use full array otherwise only first element of array
1436
- .forEach(function (_ref34) {
1437
- var _ref35 = _slicedToArray(_ref34, 2),
1438
- key = _ref35[0],
1439
- value = _ref35[1];
1455
+ .forEach(function (_ref36) {
1456
+ var _ref37 = _slicedToArray(_ref36, 2),
1457
+ key = _ref37[0],
1458
+ value = _ref37[1];
1440
1459
  return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
1441
1460
  });
1442
1461
 
@@ -1446,14 +1465,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1446
1465
  optMap = _this$parseClassifica2.optMap;
1447
1466
  var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
1448
1467
  var customData = {};
1449
- Object.entries(metaData).filter(function (_ref36) {
1450
- var _ref37 = _slicedToArray(_ref36, 1),
1451
- key = _ref37[0];
1468
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref38) {
1469
+ var _ref39 = _slicedToArray(_ref38, 1),
1470
+ key = _ref39[0];
1452
1471
  return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
1453
- }).forEach(function (_ref38) {
1454
- var _ref39 = _slicedToArray(_ref38, 2),
1455
- key = _ref39[0],
1456
- value = _ref39[1];
1472
+ }).forEach(function (_ref40) {
1473
+ var _ref41 = _slicedToArray(_ref40, 2),
1474
+ key = _ref41[0],
1475
+ value = _ref41[1];
1457
1476
  var langs = {};
1458
1477
  if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
1459
1478
  for (var i = 0; i < metaData_locales[key].length; i++) {
@@ -1485,19 +1504,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1485
1504
 
1486
1505
  //repare customData
1487
1506
  //if it is defiend as multi field, use full array otherwise only first element of array
1488
- Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref40) {
1489
- var _ref41 = _slicedToArray(_ref40, 1),
1490
- key = _ref41[0];
1507
+ Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref42) {
1508
+ var _ref43 = _slicedToArray(_ref42, 1),
1509
+ key = _ref43[0];
1491
1510
  return customData[key] != undefined;
1492
- }).forEach(function (_ref42) {
1493
- var _ref43 = _slicedToArray(_ref42, 2),
1494
- key = _ref43[0],
1495
- value = _ref43[1];
1511
+ }).forEach(function (_ref44) {
1512
+ var _ref45 = _slicedToArray(_ref44, 2),
1513
+ key = _ref45[0],
1514
+ value = _ref45[1];
1496
1515
  if (value.multi && !Array.isArray(customData[key])) {
1497
1516
  customData[key] = [customData[key]];
1498
1517
  } else if (!value.multi && Array.isArray(customData[key])) {
1499
- var _key3;
1500
- customData[key] = (_key3 = customData[key]) === null || _key3 === void 0 ? void 0 : _key3[0];
1518
+ var _key2;
1519
+ customData[key] = (_key2 = customData[key]) === null || _key2 === void 0 ? void 0 : _key2[0];
1501
1520
  }
1502
1521
  });
1503
1522
  return {
@@ -1622,52 +1641,200 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1622
1641
  }
1623
1642
  return apiGetProducts;
1624
1643
  }()
1644
+ }, {
1645
+ key: "apiGetCatalogData",
1646
+ value: function () {
1647
+ var _apiGetCatalogData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(catalogCodex, catalogId, language, accountId) {
1648
+ var _response$CollectionG, _response$Properties, _response$Properties2;
1649
+ var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
1650
+ return _regeneratorRuntime.wrap(function _callee7$(_context8) {
1651
+ while (1) switch (_context8.prev = _context8.next) {
1652
+ case 0:
1653
+ _context8.next = 2;
1654
+ return this.apiAccountLogin(accountId, catalogId);
1655
+ case 2:
1656
+ currentAccountSessionId = _context8.sent;
1657
+ if (currentAccountSessionId) {
1658
+ _context8.next = 5;
1659
+ break;
1660
+ }
1661
+ return _context8.abrupt("return");
1662
+ case 5:
1663
+ fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
1664
+ _context8.next = 8;
1665
+ return fetch(fullUrl, {
1666
+ headers: {
1667
+ sessionGuid: currentAccountSessionId
1668
+ }
1669
+ }).then(function (res) {
1670
+ if (res.status !== 200) {
1671
+ throw new Error('Collections not loaded.');
1672
+ }
1673
+ return res.json();
1674
+ });
1675
+ case 8:
1676
+ response = _context8.sent;
1677
+ if (!response.Error) {
1678
+ _context8.next = 11;
1679
+ break;
1680
+ }
1681
+ throw new Error(response.Error);
1682
+ case 11:
1683
+ actCatalogInfoData = {
1684
+ lang: language,
1685
+ guid: response.GUID,
1686
+ name: response.Name,
1687
+ name_locales: response.Name_locales,
1688
+ codex: catalogCodex,
1689
+ accountLogo: response.AccountLogo,
1690
+ description: response.LongDescription,
1691
+ description_locales: response.LongDescription_locales,
1692
+ hasPlanner: response.HasIDMPlanner == 'True',
1693
+ brand: response.Brandname,
1694
+ supplierGuid: response.SupplierGUID,
1695
+ retailCatalogNr: response.RetailCatalogNr,
1696
+ accountGuid: (_response$CollectionG = response.CollectionGuid) !== null && _response$CollectionG !== void 0 ? _response$CollectionG : response.AccountGuid,
1697
+ options: response.Options,
1698
+ optionValues: response.Optionvalues,
1699
+ currency: response.currency,
1700
+ has3D: !!((_response$Properties = response.Properties) !== null && _response$Properties !== void 0 && (_response$Properties = _response$Properties.find(function (p) {
1701
+ return p.Codex == 'DIVA3D_RENDERING';
1702
+ })) !== null && _response$Properties !== void 0 && _response$Properties.Value),
1703
+ images: [],
1704
+ documents: [],
1705
+ accountSessionId: response.AccountSessionGuid,
1706
+ arReady: !!((_response$Properties2 = response.Properties) !== null && _response$Properties2 !== void 0 && (_response$Properties2 = _response$Properties2.find(function (p) {
1707
+ return p.Codex == 'DIVA3D_AR_READY';
1708
+ })) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
1709
+ };
1710
+ return _context8.abrupt("return", actCatalogInfoData);
1711
+ case 13:
1712
+ case "end":
1713
+ return _context8.stop();
1714
+ }
1715
+ }, _callee7, this);
1716
+ }));
1717
+ function apiGetCatalogData(_x9, _x10, _x11, _x12) {
1718
+ return _apiGetCatalogData.apply(this, arguments);
1719
+ }
1720
+ return apiGetCatalogData;
1721
+ }()
1722
+ }, {
1723
+ key: "apiAccountLogin",
1724
+ value: function () {
1725
+ var _apiAccountLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(accountId, catalogId) {
1726
+ var fullUrl, response, fallbackUrl, fallbackResponse;
1727
+ return _regeneratorRuntime.wrap(function _callee8$(_context9) {
1728
+ while (1) switch (_context9.prev = _context9.next) {
1729
+ case 0:
1730
+ fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
1731
+ _context9.t0 = fetch;
1732
+ _context9.t1 = fullUrl;
1733
+ _context9.next = 5;
1734
+ return this.sessionGuid;
1735
+ case 5:
1736
+ _context9.t2 = _context9.sent;
1737
+ _context9.t3 = {
1738
+ sessionGuid: _context9.t2
1739
+ };
1740
+ _context9.t4 = {
1741
+ headers: _context9.t3
1742
+ };
1743
+ _context9.next = 10;
1744
+ return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
1745
+ if (res.status !== 200) {
1746
+ throw new Error('Collections not loaded.');
1747
+ }
1748
+ return res.json();
1749
+ });
1750
+ case 10:
1751
+ response = _context9.sent;
1752
+ if (!response.SessionGUID) {
1753
+ _context9.next = 13;
1754
+ break;
1755
+ }
1756
+ return _context9.abrupt("return", response.SessionGUID);
1757
+ case 13:
1758
+ fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
1759
+ _context9.t5 = fetch;
1760
+ _context9.t6 = fallbackUrl;
1761
+ _context9.next = 18;
1762
+ return this.sessionGuid;
1763
+ case 18:
1764
+ _context9.t7 = _context9.sent;
1765
+ _context9.t8 = {
1766
+ sessionGuid: _context9.t7
1767
+ };
1768
+ _context9.t9 = {
1769
+ headers: _context9.t8
1770
+ };
1771
+ _context9.next = 23;
1772
+ return (0, _context9.t5)(_context9.t6, _context9.t9).then(function (res) {
1773
+ if (res.status !== 200) {
1774
+ throw new Error('Collections not loaded.');
1775
+ }
1776
+ return res.json();
1777
+ });
1778
+ case 23:
1779
+ fallbackResponse = _context9.sent;
1780
+ return _context9.abrupt("return", fallbackResponse.SessionGUID);
1781
+ case 25:
1782
+ case "end":
1783
+ return _context9.stop();
1784
+ }
1785
+ }, _callee8, this);
1786
+ }));
1787
+ function apiAccountLogin(_x13, _x14) {
1788
+ return _apiAccountLogin.apply(this, arguments);
1789
+ }
1790
+ return apiAccountLogin;
1791
+ }()
1625
1792
  }, {
1626
1793
  key: "apiGetProductVariants",
1627
1794
  value: function () {
1628
- var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, full) {
1795
+ var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, full) {
1629
1796
  var _res2;
1630
1797
  var fullUrl, res, resData;
1631
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
1632
- while (1) switch (_context8.prev = _context8.next) {
1798
+ return _regeneratorRuntime.wrap(function _callee9$(_context10) {
1799
+ while (1) switch (_context10.prev = _context10.next) {
1633
1800
  case 0:
1634
1801
  fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
1635
- _context8.prev = 1;
1636
- _context8.next = 4;
1802
+ _context10.prev = 1;
1803
+ _context10.next = 4;
1637
1804
  return axios.get(fullUrl, {
1638
1805
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1639
1806
  'Content-Type': 'application/json'
1640
1807
  })
1641
1808
  });
1642
1809
  case 4:
1643
- res = _context8.sent;
1644
- _context8.next = 7;
1810
+ res = _context10.sent;
1811
+ _context10.next = 7;
1645
1812
  return res.data;
1646
1813
  case 7:
1647
- resData = _context8.sent;
1648
- _context8.next = 13;
1814
+ resData = _context10.sent;
1815
+ _context10.next = 13;
1649
1816
  break;
1650
1817
  case 10:
1651
- _context8.prev = 10;
1652
- _context8.t0 = _context8["catch"](1);
1818
+ _context10.prev = 10;
1819
+ _context10.t0 = _context10["catch"](1);
1653
1820
  throw new Error('Could not get existing products', {
1654
- cause: _context8.t0
1821
+ cause: _context10.t0
1655
1822
  });
1656
1823
  case 13:
1657
1824
  if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
1658
- _context8.next = 15;
1825
+ _context10.next = 15;
1659
1826
  break;
1660
1827
  }
1661
- return _context8.abrupt("return", resData);
1828
+ return _context10.abrupt("return", resData);
1662
1829
  case 15:
1663
1830
  throw new Error(resData.error);
1664
1831
  case 16:
1665
1832
  case "end":
1666
- return _context8.stop();
1833
+ return _context10.stop();
1667
1834
  }
1668
- }, _callee7, this, [[1, 10]]);
1835
+ }, _callee9, this, [[1, 10]]);
1669
1836
  }));
1670
- function apiGetProductVariants(_x9, _x10) {
1837
+ function apiGetProductVariants(_x15, _x16) {
1671
1838
  return _apiGetProductVariants.apply(this, arguments);
1672
1839
  }
1673
1840
  return apiGetProductVariants;
@@ -1675,7 +1842,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1675
1842
  }, {
1676
1843
  key: "apiGetProductByFilter",
1677
1844
  value: function () {
1678
- var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(filter) {
1845
+ var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(filter) {
1679
1846
  var _res3;
1680
1847
  var limit,
1681
1848
  useFilter,
@@ -1684,39 +1851,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1684
1851
  res,
1685
1852
  resData,
1686
1853
  filterParam,
1687
- _args9 = arguments;
1688
- return _regeneratorRuntime.wrap(function _callee8$(_context9) {
1689
- while (1) switch (_context9.prev = _context9.next) {
1854
+ _args11 = arguments;
1855
+ return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1856
+ while (1) switch (_context11.prev = _context11.next) {
1690
1857
  case 0:
1691
- limit = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 1;
1692
- useFilter = _args9.length > 2 ? _args9[2] : undefined;
1693
- hierarchy = _args9.length > 3 ? _args9[3] : undefined;
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;
1694
1861
  fullUrl = this.catalogService + '/v1/products';
1695
- _context9.prev = 4;
1862
+ _context11.prev = 4;
1696
1863
  filterParam = useFilter ? 'filter' : 'search';
1697
- _context9.next = 8;
1864
+ _context11.next = 8;
1698
1865
  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), {
1699
1866
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1700
1867
  'Content-Type': 'application/json'
1701
1868
  })
1702
1869
  });
1703
1870
  case 8:
1704
- res = _context9.sent;
1705
- _context9.next = 11;
1871
+ res = _context11.sent;
1872
+ _context11.next = 11;
1706
1873
  return res.data;
1707
1874
  case 11:
1708
- resData = _context9.sent;
1709
- _context9.next = 17;
1875
+ resData = _context11.sent;
1876
+ _context11.next = 17;
1710
1877
  break;
1711
1878
  case 14:
1712
- _context9.prev = 14;
1713
- _context9.t0 = _context9["catch"](4);
1879
+ _context11.prev = 14;
1880
+ _context11.t0 = _context11["catch"](4);
1714
1881
  throw new Error('Could not get existing products', {
1715
- cause: _context9.t0
1882
+ cause: _context11.t0
1716
1883
  });
1717
1884
  case 17:
1718
1885
  if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
1719
- _context9.next = 20;
1886
+ _context11.next = 20;
1720
1887
  break;
1721
1888
  }
1722
1889
  //in order to be backwardscompatible we must transform old products here
@@ -1729,16 +1896,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1729
1896
  }
1730
1897
  return d;
1731
1898
  });
1732
- return _context9.abrupt("return", resData);
1899
+ return _context11.abrupt("return", resData);
1733
1900
  case 20:
1734
1901
  throw new Error(resData.error);
1735
1902
  case 21:
1736
1903
  case "end":
1737
- return _context9.stop();
1904
+ return _context11.stop();
1738
1905
  }
1739
- }, _callee8, this, [[4, 14]]);
1906
+ }, _callee10, this, [[4, 14]]);
1740
1907
  }));
1741
- function apiGetProductByFilter(_x11) {
1908
+ function apiGetProductByFilter(_x17) {
1742
1909
  return _apiGetProductByFilter.apply(this, arguments);
1743
1910
  }
1744
1911
  return apiGetProductByFilter;
@@ -1746,51 +1913,51 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1746
1913
  }, {
1747
1914
  key: "apiSetCustomFlag",
1748
1915
  value: function () {
1749
- var _apiSetCustomFlag = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, flagName, organizationId, dependsOn) {
1916
+ var _apiSetCustomFlag = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(id, flagName, organizationId, dependsOn) {
1750
1917
  var _res4;
1751
1918
  var fullUrl, res, resData;
1752
- return _regeneratorRuntime.wrap(function _callee9$(_context10) {
1753
- while (1) switch (_context10.prev = _context10.next) {
1919
+ return _regeneratorRuntime.wrap(function _callee11$(_context12) {
1920
+ while (1) switch (_context12.prev = _context12.next) {
1754
1921
  case 0:
1755
1922
  fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/' + flagName);
1756
1923
  fullUrl.searchParams.append('organizationId', organizationId);
1757
1924
  if (dependsOn) fullUrl.searchParams.append('dependsOn', dependsOn);
1758
- _context10.prev = 3;
1759
- _context10.next = 6;
1925
+ _context12.prev = 3;
1926
+ _context12.next = 6;
1760
1927
  return axios.post(fullUrl.toString(), undefined, {
1761
1928
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1762
1929
  'Content-Type': 'application/json'
1763
1930
  })
1764
1931
  });
1765
1932
  case 6:
1766
- res = _context10.sent;
1767
- _context10.next = 9;
1933
+ res = _context12.sent;
1934
+ _context12.next = 9;
1768
1935
  return res.data;
1769
1936
  case 9:
1770
- resData = _context10.sent;
1771
- _context10.next = 15;
1937
+ resData = _context12.sent;
1938
+ _context12.next = 15;
1772
1939
  break;
1773
1940
  case 12:
1774
- _context10.prev = 12;
1775
- _context10.t0 = _context10["catch"](3);
1941
+ _context12.prev = 12;
1942
+ _context12.t0 = _context12["catch"](3);
1776
1943
  throw new Error('Could not get existing products', {
1777
- cause: _context10.t0
1944
+ cause: _context12.t0
1778
1945
  });
1779
1946
  case 15:
1780
1947
  if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
1781
- _context10.next = 17;
1948
+ _context12.next = 17;
1782
1949
  break;
1783
1950
  }
1784
- return _context10.abrupt("return", resData);
1951
+ return _context12.abrupt("return", resData);
1785
1952
  case 17:
1786
1953
  throw new Error(resData.error);
1787
1954
  case 18:
1788
1955
  case "end":
1789
- return _context10.stop();
1956
+ return _context12.stop();
1790
1957
  }
1791
- }, _callee9, this, [[3, 12]]);
1958
+ }, _callee11, this, [[3, 12]]);
1792
1959
  }));
1793
- function apiSetCustomFlag(_x12, _x13, _x14, _x15) {
1960
+ function apiSetCustomFlag(_x18, _x19, _x20, _x21) {
1794
1961
  return _apiSetCustomFlag.apply(this, arguments);
1795
1962
  }
1796
1963
  return apiSetCustomFlag;
@@ -1798,10 +1965,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1798
1965
  }, {
1799
1966
  key: "apiDeleteProducts",
1800
1967
  value: function () {
1801
- var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(products) {
1968
+ var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(products) {
1802
1969
  var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
1803
- return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1804
- while (1) switch (_context11.prev = _context11.next) {
1970
+ return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1971
+ while (1) switch (_context13.prev = _context13.next) {
1805
1972
  case 0:
1806
1973
  fullUrl = this.catalogService + '/products';
1807
1974
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1812,7 +1979,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1812
1979
  i = 0;
1813
1980
  case 5:
1814
1981
  if (!(i < productsInChunks.length)) {
1815
- _context11.next = 13;
1982
+ _context13.next = 13;
1816
1983
  break;
1817
1984
  }
1818
1985
  promises = productsInChunks[i].map(function (p) {
@@ -1834,19 +2001,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1834
2001
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
1835
2002
  dontRenderForm: true
1836
2003
  });
1837
- _context11.next = 10;
2004
+ _context13.next = 10;
1838
2005
  return Promise.all(promises);
1839
2006
  case 10:
1840
2007
  i++;
1841
- _context11.next = 5;
2008
+ _context13.next = 5;
1842
2009
  break;
1843
2010
  case 13:
1844
2011
  case "end":
1845
- return _context11.stop();
2012
+ return _context13.stop();
1846
2013
  }
1847
- }, _callee10, this);
2014
+ }, _callee12, this);
1848
2015
  }));
1849
- function apiDeleteProducts(_x16) {
2016
+ function apiDeleteProducts(_x22) {
1850
2017
  return _apiDeleteProducts.apply(this, arguments);
1851
2018
  }
1852
2019
  return apiDeleteProducts;
@@ -1863,12 +2030,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1863
2030
  }, {
1864
2031
  key: "apiLoadProductVariantsGrouped",
1865
2032
  value: function () {
1866
- var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref44) {
1867
- var limit, skip, fields, _ref44$search, search, sort, abortController, fullUrl, headers, promise;
1868
- return _regeneratorRuntime.wrap(function _callee11$(_context12) {
1869
- while (1) switch (_context12.prev = _context12.next) {
2033
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref46) {
2034
+ var limit, skip, fields, _ref46$search, search, sort, abortController, fullUrl, headers, promise;
2035
+ return _regeneratorRuntime.wrap(function _callee13$(_context14) {
2036
+ while (1) switch (_context14.prev = _context14.next) {
1870
2037
  case 0:
1871
- limit = _ref44.limit, skip = _ref44.skip, fields = _ref44.fields, _ref44$search = _ref44.search, search = _ref44$search === void 0 ? [] : _ref44$search, sort = _ref44.sort, _ref44.showAllProducts, abortController = _ref44.abortController;
2038
+ 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;
1872
2039
  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) : '');
1873
2040
  headers = {
1874
2041
  'Content-Type': 'application/json'
@@ -1890,32 +2057,64 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1890
2057
  reject('Error loading products grouped by variants: ' + error.message);
1891
2058
  });
1892
2059
  });
1893
- _context12.next = 7;
2060
+ _context14.next = 7;
1894
2061
  return promise;
1895
2062
  case 7:
1896
- return _context12.abrupt("return", _context12.sent);
2063
+ return _context14.abrupt("return", _context14.sent);
1897
2064
  case 8:
1898
2065
  case "end":
1899
- return _context12.stop();
2066
+ return _context14.stop();
1900
2067
  }
1901
- }, _callee11, this);
2068
+ }, _callee13, this);
1902
2069
  }));
1903
- function apiLoadProductVariantsGrouped(_x17) {
2070
+ function apiLoadProductVariantsGrouped(_x23) {
1904
2071
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
1905
2072
  }
1906
2073
  return apiLoadProductVariantsGrouped;
1907
2074
  }()
1908
2075
  }, {
1909
- key: "apiSaveBasketAndProducts",
2076
+ key: "apiSaveProducts",
1910
2077
  value: function () {
1911
- var _apiSaveBasketAndProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(serverUrl, jwt, products, awaitPDF, basket, removedProductIds) {
1912
- var fullUrl, response, status;
1913
- return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1914
- while (1) switch (_context13.prev = _context13.next) {
2078
+ var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2079
+ var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop2, j;
2080
+ return _regeneratorRuntime.wrap(function _callee14$(_context16) {
2081
+ while (1) switch (_context16.prev = _context16.next) {
1915
2082
  case 0:
1916
2083
  fullUrl = serverUrl + '/v1/products/groups';
1917
- _context13.prev = 1;
1918
- _context13.next = 4;
2084
+ BATCH_SIZE = 40;
2085
+ productsPackages = [];
2086
+ groupIndex = 0;
2087
+ i = 0;
2088
+ case 5:
2089
+ if (!(i < products.length)) {
2090
+ _context16.next = 15;
2091
+ break;
2092
+ }
2093
+ if (!products[i].baseProduct) {
2094
+ _context16.next = 9;
2095
+ break;
2096
+ }
2097
+ baseProduct = products[i];
2098
+ return _context16.abrupt("continue", 12);
2099
+ case 9:
2100
+ if (BATCH_SIZE < ((_productsPackages$gro = (_productsPackages$gro2 = productsPackages[groupIndex]) === null || _productsPackages$gro2 === void 0 ? void 0 : _productsPackages$gro2.length) !== null && _productsPackages$gro !== void 0 ? _productsPackages$gro : 0)) groupIndex++;
2101
+ if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2102
+ productsPackages[groupIndex].push(products[i]);
2103
+ case 12:
2104
+ i++;
2105
+ _context16.next = 5;
2106
+ break;
2107
+ case 15:
2108
+ responseProducts = [];
2109
+ _i2 = 0;
2110
+ case 17:
2111
+ if (!(_i2 < productsPackages.length)) {
2112
+ _context16.next = 40;
2113
+ break;
2114
+ }
2115
+ if (baseProduct) productsPackages[_i2].unshift(baseProduct);
2116
+ _context16.prev = 19;
2117
+ _context16.next = 22;
1919
2118
  return fetch(fullUrl, {
1920
2119
  method: 'PUT',
1921
2120
  headers: {
@@ -1923,8 +2122,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1923
2122
  'Content-Type': 'application/json'
1924
2123
  },
1925
2124
  body: JSON.stringify({
1926
- basket: basket ? basket.getAsJson() : undefined,
1927
- products: products,
2125
+ products: productsPackages[_i2],
1928
2126
  removedProductIds: removedProductIds,
1929
2127
  awaitPDF: awaitPDF
1930
2128
  })
@@ -1935,32 +2133,64 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1935
2133
  }
1936
2134
  return res.json();
1937
2135
  });
1938
- case 4:
1939
- response = _context13.sent;
2136
+ case 22:
2137
+ response = _context16.sent;
1940
2138
  if (!response.Error) {
1941
- _context13.next = 7;
2139
+ _context16.next = 25;
1942
2140
  break;
1943
2141
  }
1944
2142
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
1945
- case 7:
1946
- _context13.next = 12;
2143
+ case 25:
2144
+ _context16.next = 30;
1947
2145
  break;
1948
- case 9:
1949
- _context13.prev = 9;
1950
- _context13.t0 = _context13["catch"](1);
2146
+ case 27:
2147
+ _context16.prev = 27;
2148
+ _context16.t0 = _context16["catch"](19);
1951
2149
  throw Error(status);
1952
- case 12:
1953
- return _context13.abrupt("return", response.products);
1954
- case 13:
2150
+ case 30:
2151
+ _loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2(j) {
2152
+ return _regeneratorRuntime.wrap(function _loop2$(_context15) {
2153
+ while (1) switch (_context15.prev = _context15.next) {
2154
+ case 0:
2155
+ if (response.products[_i2].baseProduct) baseProduct = response.products[_i2];
2156
+ if (!responseProducts.find(function (p) {
2157
+ return p._id == response.products[j]._id;
2158
+ })) {
2159
+ responseProducts.push(response.products[j]);
2160
+ }
2161
+ case 2:
2162
+ case "end":
2163
+ return _context15.stop();
2164
+ }
2165
+ }, _loop2);
2166
+ });
2167
+ j = 0;
2168
+ case 32:
2169
+ if (!(j < response.products.length)) {
2170
+ _context16.next = 37;
2171
+ break;
2172
+ }
2173
+ return _context16.delegateYield(_loop2(j), "t1", 34);
2174
+ case 34:
2175
+ j++;
2176
+ _context16.next = 32;
2177
+ break;
2178
+ case 37:
2179
+ _i2++;
2180
+ _context16.next = 17;
2181
+ break;
2182
+ case 40:
2183
+ return _context16.abrupt("return", responseProducts);
2184
+ case 41:
1955
2185
  case "end":
1956
- return _context13.stop();
2186
+ return _context16.stop();
1957
2187
  }
1958
- }, _callee12, null, [[1, 9]]);
2188
+ }, _callee14, null, [[19, 27]]);
1959
2189
  }));
1960
- function apiSaveBasketAndProducts(_x18, _x19, _x20, _x21, _x22, _x23) {
1961
- return _apiSaveBasketAndProducts.apply(this, arguments);
2190
+ function apiSaveProducts(_x24, _x25, _x26, _x27, _x28) {
2191
+ return _apiSaveProducts.apply(this, arguments);
1962
2192
  }
1963
- return apiSaveBasketAndProducts;
2193
+ return apiSaveProducts;
1964
2194
  }()
1965
2195
  }, {
1966
2196
  key: "parseFilter",
@@ -1992,54 +2222,54 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1992
2222
  }], [{
1993
2223
  key: "isSameProduct",
1994
2224
  value: function isSameProduct(product, setHash, diva3dProject, orderLines, varinatData, catalogCodex) {
1995
- var _product$articles;
2225
+ var _product$configuratio, _product$configuratio2, _product$configuratio3;
1996
2226
  //For new products we store the setHash and Diva3DProject in order to determine if the product changed.
1997
2227
  if (product.uniqueHash !== undefined) {
1998
2228
  return product.uniqueHash === 'v1' + setHash + (diva3dProject ? md5(diva3dProject) : '');
1999
2229
  }
2000
2230
 
2001
2231
  //For older products without setHash we use the old comparison logic
2002
- if (((_product$articles = product.articles) === null || _product$articles === void 0 ? void 0 : _product$articles.length) != (orderLines === null || orderLines === void 0 ? void 0 : orderLines.length)) {
2232
+ if (((_product$configuratio = product.configuration) === null || _product$configuratio === void 0 || (_product$configuratio = _product$configuratio.OrderSets[0].OrderLines) === null || _product$configuratio === void 0 ? void 0 : _product$configuratio.length) != (orderLines === null || orderLines === void 0 ? void 0 : orderLines.length)) {
2003
2233
  return false;
2004
2234
  }
2005
2235
  if (!varinatData) {
2006
2236
  //the old logic was only for variants, not for base products
2007
2237
  return true;
2008
2238
  }
2009
- var _loop2 = function _loop2() {
2010
- var _article$variantValue;
2011
- var article = product.articles[i];
2239
+ var orderlines = (_product$configuratio2 = (_product$configuratio3 = product.configuration) === null || _product$configuratio3 === void 0 ? void 0 : _product$configuratio3.OrderSets[0].OrderLines) !== null && _product$configuratio2 !== void 0 ? _product$configuratio2 : [];
2240
+ var _loop3 = function _loop3() {
2241
+ var article = orderlines[i];
2012
2242
  var orderLine = orderLines.find(function (ol) {
2013
- return ol.ArticleCodex == article.articleCodex && catalogCodex == article.catalogCodex;
2243
+ return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
2014
2244
  });
2015
- if (!orderLine || ((_article$variantValue = article.variantValues) === null || _article$variantValue === void 0 ? void 0 : _article$variantValue.length) != (varinatData === null || varinatData === void 0 ? void 0 : varinatData.length)) {
2245
+ if (!orderLine) {
2016
2246
  return {
2017
2247
  v: false
2018
2248
  };
2019
2249
  }
2020
- var _loop3 = function _loop3() {
2021
- var varinatValue = article.variantValues[j];
2022
- if (!(varinatData !== null && varinatData !== void 0 && varinatData.find(function (vb) {
2023
- return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2024
- }))) {
2025
- return {
2026
- v: {
2027
- v: false
2028
- }
2029
- };
2030
- }
2031
- },
2032
- _ret2;
2033
- for (var j = 0; j < (((_article$variantValue2 = article.variantValues) === null || _article$variantValue2 === void 0 ? void 0 : _article$variantValue2.length) || 0); j++) {
2034
- var _article$variantValue2;
2035
- _ret2 = _loop3();
2036
- if (_ret2) return _ret2.v;
2250
+ if (article.VariantBasketDatas.length) {
2251
+ var _loop4 = function _loop4() {
2252
+ var varinatValue = article.VariantBasketDatas[j];
2253
+ if (!varinatData.find(function (vb) {
2254
+ return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2255
+ })) {
2256
+ return {
2257
+ v: {
2258
+ v: false
2259
+ }
2260
+ };
2261
+ }
2262
+ },
2263
+ _ret2;
2264
+ for (var j = 0; j < article.VariantBasketDatas.length; j++) {
2265
+ _ret2 = _loop4();
2266
+ if (_ret2) return _ret2.v;
2267
+ }
2037
2268
  }
2038
2269
  },
2039
2270
  _ret;
2040
- for (var i = 0; i < ((_product$articles$len = (_product$articles2 = product.articles) === null || _product$articles2 === void 0 ? void 0 : _product$articles2.length) !== null && _product$articles$len !== void 0 ? _product$articles$len : 0); i++) {
2041
- var _product$articles$len, _product$articles2;
2042
- _ret = _loop2();
2271
+ for (var i = 0; i < orderlines.length; i++) {
2272
+ _ret = _loop3();
2043
2273
  if (_ret) return _ret.v;
2044
2274
  }
2045
2275
  return true;
@@ -2117,7 +2347,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2117
2347
  //calculate defaultShortDescription from template string
2118
2348
  var shortDescriptionTemplate = (_configurationData$sh = configurationData === null || configurationData === void 0 ? void 0 : configurationData.shortDescription) !== null && _configurationData$sh !== void 0 ? _configurationData$sh : '${modelName} ${subCategory} ${mainColor}';
2119
2349
  var parts = shortDescriptionTemplate.split(/\${|}/);
2120
- var _loop4 = function _loop4() {
2350
+ var _loop5 = function _loop5() {
2121
2351
  var _classificationConfig2, _classificationConfig4, _value;
2122
2352
  var field = parts[i];
2123
2353
  var value;
@@ -2149,7 +2379,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2149
2379
  shortDescriptionTemplate = shortDescriptionTemplate.replace("${".concat(field, "}"), (_value = value) !== null && _value !== void 0 ? _value : '');
2150
2380
  };
2151
2381
  for (var i = 1; i < parts.length; i = i + 2) {
2152
- _loop4();
2382
+ _loop5();
2153
2383
  }
2154
2384
 
2155
2385
  //as long as shortDescription is not modified by user, autocalc it
@@ -2165,16 +2395,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2165
2395
  }, {
2166
2396
  key: "assign",
2167
2397
  value: function assign(target) {
2168
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
2169
- sources[_key4 - 1] = arguments[_key4];
2398
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
2399
+ sources[_key3 - 1] = arguments[_key3];
2170
2400
  }
2171
2401
  return Object.assign.apply(Object, [target].concat(_toConsumableArray(sources.filter(function (s) {
2172
2402
  return s;
2173
2403
  }).map(function (x) {
2174
- return Object.fromEntries(Object.entries(x).filter(function (_ref45) {
2175
- var _ref46 = _slicedToArray(_ref45, 2);
2176
- _ref46[0];
2177
- var value = _ref46[1];
2404
+ return Object.fromEntries(Object.entries(x).filter(function (_ref47) {
2405
+ var _ref48 = _slicedToArray(_ref47, 2);
2406
+ _ref48[0];
2407
+ var value = _ref48[1];
2178
2408
  return value !== undefined;
2179
2409
  }));
2180
2410
  }))));
@@ -2182,10 +2412,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2182
2412
  }, {
2183
2413
  key: "loadSelectOptions",
2184
2414
  value: function () {
2185
- var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(sessionGuid, dataSource, additionalFilter) {
2415
+ var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2186
2416
  var values, apiUrl, i, apiResult, _i3, value, text;
2187
- return _regeneratorRuntime.wrap(function _callee13$(_context14) {
2188
- while (1) switch (_context14.prev = _context14.next) {
2417
+ return _regeneratorRuntime.wrap(function _callee15$(_context17) {
2418
+ while (1) switch (_context17.prev = _context17.next) {
2189
2419
  case 0:
2190
2420
  values = [];
2191
2421
  apiUrl = dataSource.url;
@@ -2194,7 +2424,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2194
2424
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2195
2425
  }
2196
2426
  }
2197
- _context14.next = 5;
2427
+ _context17.next = 5;
2198
2428
  return fetch(apiUrl, {
2199
2429
  headers: {
2200
2430
  sessionGuid: sessionGuid
@@ -2206,7 +2436,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2206
2436
  return res.json();
2207
2437
  });
2208
2438
  case 5:
2209
- apiResult = _context14.sent;
2439
+ apiResult = _context17.sent;
2210
2440
  if (dataSource.useKey) {
2211
2441
  apiResult = apiResult[dataSource.useKey];
2212
2442
  }
@@ -2218,14 +2448,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2218
2448
  text: text
2219
2449
  });
2220
2450
  }
2221
- return _context14.abrupt("return", values);
2451
+ return _context17.abrupt("return", values);
2222
2452
  case 9:
2223
2453
  case "end":
2224
- return _context14.stop();
2454
+ return _context17.stop();
2225
2455
  }
2226
- }, _callee13);
2456
+ }, _callee15);
2227
2457
  }));
2228
- function loadSelectOptions(_x24, _x25, _x26) {
2458
+ function loadSelectOptions(_x29, _x30, _x31) {
2229
2459
  return _loadSelectOptions.apply(this, arguments);
2230
2460
  }
2231
2461
  return loadSelectOptions;
@@ -2238,6 +2468,36 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2238
2468
  return rv;
2239
2469
  }, {});
2240
2470
  }
2471
+ }, {
2472
+ key: "getVariantBasketDatasByOrderlines",
2473
+ value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
2474
+ var variantBasketDatas = [];
2475
+ var _loop6 = function _loop6() {
2476
+ var ol = orderLines[i];
2477
+ var catalog = catalogData.find(function (c) {
2478
+ return c.codex === ol.CatalogCodex;
2479
+ });
2480
+ if (!ol.VariantBasketDatas) return 1; // continue
2481
+ for (var j = 0; j < ol.VariantBasketDatas.length; j++) {
2482
+ var v = ol.VariantBasketDatas[j];
2483
+ var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
2484
+ var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
2485
+ {
2486
+ variantBasketDatas.push({
2487
+ BasketID: ol.BasketID,
2488
+ OPT: v.OPT,
2489
+ OPV: v.OPV,
2490
+ OPTName: opt.Name,
2491
+ OPVName: opv.Name
2492
+ });
2493
+ }
2494
+ }
2495
+ };
2496
+ for (var i = 0; i < orderLines.length; i++) {
2497
+ if (_loop6()) continue;
2498
+ }
2499
+ return variantBasketDatas;
2500
+ }
2241
2501
  }]);
2242
2502
  }();
2243
2503
  _ProductHandlerAbstract = ProductHandlerAbstract;