@crystaldesign/product-handler 24.12.0-beta.9 → 24.12.0-rc.1

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.
@@ -44,9 +44,6 @@ var _excluded = ["value"];
44
44
  var _ProductHandlerAbstract;
45
45
  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; }
46
46
  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__default["default"](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; }
47
-
48
- //const LOG = initLog('CORE');
49
-
50
47
  var TRANSLATED_FILEDS = ['info', 'modelName', 'technicalDescription', 'shortDescription', 'shortTechnicalDescription'];
51
48
  var ProductHandlerAbstract = /*#__PURE__*/function () {
52
49
  function ProductHandlerAbstract(LOG, t, openModal, closeModal) {
@@ -61,6 +58,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
61
58
  _defineProperty__default["default"](this, "_apiKey", void 0);
62
59
  _defineProperty__default["default"](this, "_catalogService", '');
63
60
  _defineProperty__default["default"](this, "_mediaService", '');
61
+ _defineProperty__default["default"](this, "_api2", '');
62
+ _defineProperty__default["default"](this, "_sessionGuid", '');
64
63
  _defineProperty__default["default"](this, "_organization", {});
65
64
  }
66
65
  return _createClass__default["default"](ProductHandlerAbstract, [{
@@ -87,6 +86,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
87
86
  set: function set(val) {
88
87
  this._mediaService = val;
89
88
  }
89
+ }, {
90
+ key: "api2",
91
+ get: function get() {
92
+ return this._api2;
93
+ },
94
+ set: function set(val) {
95
+ this._api2 = val;
96
+ }
97
+ }, {
98
+ key: "sessionGuid",
99
+ get: function get() {
100
+ return this._sessionGuid;
101
+ }
90
102
  }, {
91
103
  key: "organization",
92
104
  get: function get() {
@@ -133,7 +145,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
133
145
  value: (function () {
134
146
  var _createAndSave = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref) {
135
147
  var _basket$ProductSetNam;
136
- var basket, catalogData, availableLanguages, currentLang, createdState, baseData, data;
148
+ var basket, catalogData, availableLanguages, currentLang, createdState, data;
137
149
  return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
138
150
  while (1) switch (_context.prev = _context.next) {
139
151
  case 0:
@@ -141,6 +153,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
141
153
  _context.next = 3;
142
154
  return this.loadProducts({
143
155
  basket: basket,
156
+ divaNr: basket.DivaNr,
144
157
  catalogData: catalogData,
145
158
  productData: [],
146
159
  availableLanguages: availableLanguages,
@@ -150,10 +163,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
150
163
  createdState = _context.sent;
151
164
  createdState.baseData.shortDescription = (_basket$ProductSetNam = basket.ProductSetName) !== null && _basket$ProductSetNam !== void 0 ? _basket$ProductSetNam : basket.SetName;
152
165
  createdState.baseData.shortDescription_locales = basket.SetName_locales;
153
- baseData = _objectSpread({}, createdState.baseData);
166
+ _objectSpread({}, createdState.baseData);
154
167
  _context.next = 9;
155
168
  return this.prepareData({
156
- baseData: baseData,
169
+ basket: basket,
170
+ baseData: createdState.baseData,
157
171
  classificationData: createdState.classificationData,
158
172
  variantData: createdState.variantData,
159
173
  oldClassificationData: createdState.oldClassificationData
@@ -161,9 +175,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
161
175
  case 9:
162
176
  data = _context.sent;
163
177
  _context.next = 12;
164
- return this.saveBasketAndProducts(_objectSpread(_objectSpread({}, data), {}, {
165
- basket: basket
166
- }));
178
+ return this.saveProducts(_objectSpread({}, data));
167
179
  case 12:
168
180
  return _context.abrupt("return", _context.sent);
169
181
  case 13:
@@ -189,86 +201,71 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
189
201
  key: "loadProducts",
190
202
  value: (function () {
191
203
  var _loadProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref2) {
192
- var _baseProduct9,
204
+ var _this = this,
205
+ _baseProduct,
206
+ _basket$getProductCon,
207
+ _baseProduct2,
208
+ _baseProduct3,
209
+ _baseProduct$divaNr,
210
+ _baseProduct4,
211
+ _dataByBasket$price$a,
212
+ _dataByBasket$price,
213
+ _baseProduct5,
214
+ _dataByBasket$image,
215
+ _baseProduct6,
216
+ _dataByBasket$image2D,
217
+ _baseProduct7,
218
+ _dataByBasket$docking,
219
+ _baseProduct8,
220
+ _baseProduct$organiza,
221
+ _baseProduct9,
222
+ _this$organization$pa,
223
+ _this$organization$pa2,
224
+ _baseProduct$createdB,
193
225
  _baseProduct10,
226
+ _this$user,
194
227
  _baseProduct11,
195
228
  _baseProduct12,
196
229
  _baseProduct13,
197
230
  _baseProduct14,
231
+ _dataByBasket$orderTe,
198
232
  _baseProduct15,
233
+ _dataByBasket$technic,
199
234
  _baseProduct16,
200
235
  _baseProduct17,
201
- _baseProduct18,
202
- _baseProduct19,
203
- _baseProduct20,
204
- _baseProduct21,
205
- _baseProduct22,
206
- _baseProduct23,
207
- _baseProduct24,
208
- _baseProduct25,
209
- _baseProduct26,
210
- _baseProduct$width,
211
- _baseProduct27,
212
- _basket$SetPlannerInf,
213
- _basket$OrderSets$0$B,
214
- _baseProduct$height,
215
- _baseProduct28,
216
- _basket$SetPlannerInf2,
217
- _basket$OrderSets$0$B2,
218
- _baseProduct$depth,
219
- _baseProduct29,
220
- _basket$SetPlannerInf3,
221
- _basket$OrderSets$0$B3,
222
- _baseProduct$weight,
223
- _baseProduct30,
224
- _price$addedPrice,
225
- _baseProduct31,
226
- _baseProduct32,
227
- _baseProduct33,
228
- _basket$SetPlannerInf4,
229
- _basket$SetPlannerInf5,
230
- _baseProduct34,
231
- _baseProduct35,
232
- _baseProduct36,
233
- _baseProduct37,
234
- _baseProduct38,
235
- _baseProduct39,
236
- _baseProduct$brand,
237
- _baseProduct40,
238
- _baseProduct$organiza,
239
- _baseProduct41,
240
- _this$organization$pa,
241
- _this$organization$pa2,
242
- _baseProduct42,
243
- _baseProduct$createdB,
244
- _baseProduct43,
245
- _this$user,
246
- _baseProduct44,
247
- _baseProduct45,
248
- _baseProduct46,
249
- _baseProduct47,
250
- _baseProduct48,
251
- _baseProduct49,
252
- _baseProduct50,
253
- _this = this;
254
- 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;
236
+ _ref3,
237
+ _baseProduct$configur3,
238
+ _baseProduct18;
239
+ 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;
255
240
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
256
241
  while (1) switch (_context2.prev = _context2.next) {
257
242
  case 0:
258
- 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;
243
+ 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;
244
+ if (!(!productData && !divaNr)) {
245
+ _context2.next = 3;
246
+ break;
247
+ }
248
+ throw new Error('this should not happen');
249
+ case 3:
259
250
  if (productData) {
260
- _context2.next = 5;
251
+ _context2.next = 7;
261
252
  break;
262
253
  }
263
- _context2.next = 4;
264
- return this.apiGetProducts(basket.DivaNr);
265
- case 4:
254
+ _context2.next = 6;
255
+ return this.apiGetProducts(divaNr);
256
+ case 6:
266
257
  productData = _context2.sent;
267
- case 5:
258
+ case 7:
268
259
  products = {
269
260
  data: productData,
270
261
  total: productData.length
271
262
  };
263
+ if (!(!products.data.length && !basket)) {
264
+ _context2.next = 10;
265
+ break;
266
+ }
267
+ throw new Error('If product does not exist yet, basket must be provided');
268
+ case 10:
272
269
  baseProduct = undefined;
273
270
  variantProducts = [];
274
271
  if (products.total == 1) {
@@ -281,263 +278,77 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
281
278
  return !p.baseProduct;
282
279
  });
283
280
  }
284
- if (!(products.total && !baseProduct)) {
285
- _context2.next = 11;
281
+ if (catalogData) {
282
+ _context2.next = 23;
286
283
  break;
287
284
  }
288
- throw new Error('If existing products are fetched, there has to be atleast a base product.');
289
- case 11:
290
- isSet = !!basket.SetPlannerInfos;
291
- dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
292
- orderDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
293
- return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
294
- }, '') : basket.OrderSets[0].VariantDescription;
295
- orderDescription_locales = basket.OrderSets[0].VariantDescription_locales;
296
- catalogDataName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
297
- return c.name;
298
- }).filter(function (name) {
299
- return name;
300
- }).join(' - ');
301
- catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
302
- return c.brand;
303
- }).filter(function (brand) {
304
- return brand;
305
- }).join(' - ');
306
- catalogDataDescription = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
307
- return c.description;
308
- }).filter(function (description) {
309
- return description;
310
- }).join('<br/>');
311
- catalogDataName_locales = {};
312
- catalogDataDescription_locales = {};
313
- for (i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
314
- c = catalogData[i];
315
- for (key in c.name_locales) {
316
- if (!catalogDataName_locales[key]) {
317
- catalogDataName_locales[key] = c.name_locales[key];
318
- } else {
319
- catalogDataName_locales[key] = catalogDataName_locales[key] + ' - ' + c.name_locales[key];
320
- }
321
- }
322
- for (_key in c.description_locales) {
323
- if (!catalogDataDescription_locales[_key]) {
324
- catalogDataDescription_locales[_key] = c.description_locales[_key];
325
- } else {
326
- catalogDataDescription_locales[_key] = catalogDataDescription_locales[_key] + ' - ' + c.description_locales[_key];
327
- }
328
- }
329
- }
330
- articles = [];
331
- if (isSet) {
332
- articles = basket.OrderSets.flatMap(function (os) {
333
- return os.OrderLines.map(function (ol) {
334
- var _ol$VariantBasketData;
335
- return {
336
- articleCodex: ol.ArticleCodex,
337
- catalogCodex: os.CatalogCodex,
338
- variantValues: (_ol$VariantBasketData = ol.VariantBasketDatas) === null || _ol$VariantBasketData === void 0 ? void 0 : _ol$VariantBasketData.map(function (vb) {
339
- return {
340
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
341
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
342
- };
343
- })
344
- };
345
- });
346
- });
347
- } else {
348
- articles = basket.OrderSets[0].OrderLines.map(function (ol) {
349
- var _ol$VariantBasketData2;
350
- return {
351
- articleCodex: ol.ArticleCodex,
352
- catalogCodex: basket.OrderSets[0].CatalogCodex,
353
- variantValues: (_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (vb) {
354
- return {
355
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
356
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
357
- };
358
- })
359
- };
360
- });
285
+ if (!baseProduct) {
286
+ _context2.next = 20;
287
+ break;
361
288
  }
362
- if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
363
- config = {
364
- addedPackageWeight: 0,
365
- addedPackageHeight: 0,
366
- addedPackageWidth: 0,
367
- addedPackageDepth: 0,
368
- defaultDeliveryTime: 0,
369
- defaultDeliveryPrice: 0,
370
- defaultInstallationPrice: 0
371
- };
372
- if (typeof fieldConfiguration.delivery != 'boolean') {
373
- config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
374
- }
375
- packages = [];
376
- basket.OrderSets.flatMap(function (os) {
377
- return os.OrderLines;
378
- }).forEach(function (ol) {
379
- packages.push({
380
- height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
381
- width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
382
- depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
383
- weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
384
- });
385
- });
386
- delivery = {
387
- estPackages: packages,
388
- 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,
389
- 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__default["default"](packages.map(function (p) {
390
- return p.weight;
391
- }).filter(function (f) {
392
- return f;
393
- })))),
394
- 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__default["default"](packages.map(function (p) {
395
- return p.height;
396
- }).filter(function (f) {
397
- return f;
398
- })))),
399
- 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__default["default"](packages.map(function (p) {
400
- return p.width;
401
- }).filter(function (f) {
402
- return f;
403
- })))),
404
- 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__default["default"](packages.map(function (p) {
405
- return p.depth;
406
- }).filter(function (f) {
407
- return f;
408
- })))),
409
- 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,
410
- 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,
411
- 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
412
- };
289
+ _context2.next = 17;
290
+ return Promise.all((_baseProduct$configur = (_baseProduct$configur2 = baseProduct.configuration) === null || _baseProduct$configur2 === void 0 ? void 0 : _baseProduct$configur2.OrderSets.map(function (os) {
291
+ return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
292
+ })) !== null && _baseProduct$configur !== void 0 ? _baseProduct$configur : []);
293
+ case 17:
294
+ catalogData = _context2.sent;
295
+ _context2.next = 23;
296
+ break;
297
+ case 20:
298
+ _context2.next = 22;
299
+ return Promise.all((_basket$OrderSets$map = basket === null || basket === void 0 ? void 0 : basket.OrderSets.map(function (os) {
300
+ return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
301
+ })) !== null && _basket$OrderSets$map !== void 0 ? _basket$OrderSets$map : []);
302
+ case 22:
303
+ catalogData = _context2.sent;
304
+ case 23:
305
+ if (!(products.total && !baseProduct)) {
306
+ _context2.next = 25;
307
+ break;
413
308
  }
414
- ismanual = ((_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.calculatedPrice) !== ((_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.addedPrice);
415
- price = {
416
- calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
417
- addedPrice: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.addedPrice,
418
- discountPrice: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.discountedPrice
419
- };
420
- 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);
421
-
422
- //to remember what for position was previously set for the classification
309
+ throw new Error('If existing products are fetched, there has to be atleast a base product.');
310
+ case 25:
311
+ dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
423
312
  oldClassificationData = {};
424
- for (_i = 0; _i < products.data.length; _i++) {
425
- variant = products.data[_i];
313
+ for (i = 0; i < products.data.length; i++) {
314
+ variant = products.data[i];
426
315
  oldClassificationData[variant._id] = {};
427
- for (_key2 in variant) {
428
- if (_key2.startsWith('dc_') && variant[_key2].optionPosition !== undefined) {
429
- oldClassificationData[variant._id][_key2] = variant[_key2];
316
+ for (key in variant) {
317
+ if (key.startsWith('dc_') && variant[key].optionPosition !== undefined) {
318
+ oldClassificationData[variant._id][key] = variant[key];
430
319
  }
431
320
  }
432
321
  }
433
- oldUniqueHash = (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.uniqueHash;
434
- baseData = {
435
- _id: ((_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16._id) || DivaUtils.nanoid(),
436
- divaNr: basket === null || basket === void 0 ? void 0 : basket.DivaNr,
437
- modelName: ((_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.modelName) || catalogDataName,
438
- info: ((_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.info) || catalogDataDescription,
439
- technicalDescription: ((_baseProduct19 = baseProduct) === null || _baseProduct19 === void 0 ? void 0 : _baseProduct19.technicalDescription) || orderDescription,
440
- shortTechnicalDescription: (_baseProduct20 = baseProduct) === null || _baseProduct20 === void 0 ? void 0 : _baseProduct20.shortTechnicalDescription,
441
- modelName_locales: ((_baseProduct21 = baseProduct) === null || _baseProduct21 === void 0 ? void 0 : _baseProduct21.modelName_locales) || catalogDataName_locales,
442
- info_locales: ((_baseProduct22 = baseProduct) === null || _baseProduct22 === void 0 ? void 0 : _baseProduct22.info_locales) || catalogDataDescription_locales,
443
- technicalDescription_locales: ((_baseProduct23 = baseProduct) === null || _baseProduct23 === void 0 ? void 0 : _baseProduct23.technicalDescription_locales) || orderDescription_locales,
444
- shortTechnicalDescription_locales: (_baseProduct24 = baseProduct) === null || _baseProduct24 === void 0 ? void 0 : _baseProduct24.shortTechnicalDescription_locales,
445
- orderDescription: orderDescription,
446
- shortDescription: (_baseProduct25 = baseProduct) === null || _baseProduct25 === void 0 ? void 0 : _baseProduct25.shortDescription,
447
- shortDescription_locales: (_baseProduct26 = baseProduct) === null || _baseProduct26 === void 0 ? void 0 : _baseProduct26.shortDescription_locales,
448
- 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,
449
- 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,
450
- 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,
451
- 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) {
452
- return os.OrderLines.map(function (ol) {
453
- return ol.Weight;
454
- }).filter(function (f) {
455
- return f;
456
- });
457
- }).reduce(function (sum, v) {
458
- return sum + v;
459
- }, 0),
460
- calculatedPrice: price.calculatedPrice,
461
- delivery: delivery,
462
- addedPrice: (_price$addedPrice = price.addedPrice) !== null && _price$addedPrice !== void 0 ? _price$addedPrice : (_baseProduct31 = baseProduct) === null || _baseProduct31 === void 0 ? void 0 : _baseProduct31.addedPrice,
463
- discountedPrice: (_baseProduct32 = baseProduct) === null || _baseProduct32 === void 0 ? void 0 : _baseProduct32.discountedPrice,
464
- percentageDiscount: (_baseProduct33 = baseProduct) === null || _baseProduct33 === void 0 ? void 0 : _baseProduct33.percentageDiscount,
465
- articles: articles,
466
- image: isSet ? (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg3D : basket.OrderSets[0].SetImage,
467
- image2D: isSet ? (_basket$SetPlannerInf5 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf5 === void 0 ? void 0 : _basket$SetPlannerInf5.SetPlannerImg2D : basket.OrderSets[0].Set2DImage,
468
- catalogId: isSet ? basket.OrderSets.map(function (os) {
469
- return os.CatalogGUID;
470
- }) : [basket.OrderSets[0].CatalogGUID],
471
- collection: isSet ? basket.OrderSets.map(function (os) {
472
- return os.AccountName;
473
- }) : [basket.OrderSets[0].AccountName],
474
- collectionId: isSet ? basket.OrderSets.map(function (os) {
475
- return os.CollectionGUID;
476
- }) : [basket.OrderSets[0].CollectionGUID],
477
- catCodex: isSet ? basket.OrderSets.map(function (os) {
478
- return os.CatalogCodex;
479
- }) : [basket.OrderSets[0].CatalogCodex],
480
- supplierId: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
481
- return c.supplierGuid;
482
- }).filter(function (c) {
483
- return c;
484
- }),
485
- retailCatalogNr: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
486
- return c.retailCatalogNr;
487
- }).filter(function (c) {
488
- return c;
489
- }),
490
- supplierArticleNr: basket.OrderSets.flatMap(function (os) {
491
- return os.OrderLines.map(function (ol) {
492
- return ol.ConfigArticleCodex;
493
- }).filter(function (f) {
494
- return f;
495
- });
496
- }).filter(function (f) {
497
- return f;
498
- }),
499
- retailCatalogArticleNr: basket.OrderSets.flatMap(function (os) {
500
- return os.OrderLines.map(function (ol) {
501
- return ol.RetailArticleNr;
502
- }).filter(function (f) {
503
- return f;
504
- });
505
- }).filter(function (f) {
506
- return f;
507
- }),
508
- livingArea: (_baseProduct34 = baseProduct) === null || _baseProduct34 === void 0 ? void 0 : _baseProduct34.livingArea,
509
- mainCategory: (_baseProduct35 = baseProduct) === null || _baseProduct35 === void 0 ? void 0 : _baseProduct35.mainCategory,
510
- subCategory: (_baseProduct36 = baseProduct) === null || _baseProduct36 === void 0 ? void 0 : _baseProduct36.subCategory,
511
- retailerArticleNr: (_baseProduct37 = baseProduct) === null || _baseProduct37 === void 0 ? void 0 : _baseProduct37.retailerArticleNr,
512
- dockingPoints: dockingPoints,
513
- media: (_baseProduct38 = baseProduct) === null || _baseProduct38 === void 0 ? void 0 : _baseProduct38.media,
514
- affiliate: (_baseProduct39 = baseProduct) === null || _baseProduct39 === void 0 ? void 0 : _baseProduct39.affiliate,
515
- brand: (_baseProduct$brand = (_baseProduct40 = baseProduct) === null || _baseProduct40 === void 0 ? void 0 : _baseProduct40.brand) !== null && _baseProduct$brand !== void 0 ? _baseProduct$brand : catalogDataBrand,
322
+ oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
323
+ 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;
324
+ baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
325
+ _id: ((_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3._id) || DivaUtils.nanoid(),
326
+ 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,
327
+ 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,
328
+ 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,
329
+ 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,
330
+ configuration: configuration,
331
+ dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.dockingPoints,
516
332
  currency: DivaUtils__default["default"].defaultPriceFormat.currency,
517
- organizationId: (_baseProduct$organiza = (_baseProduct41 = baseProduct) === null || _baseProduct41 === void 0 ? void 0 : _baseProduct41.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
333
+ organizationId: (_baseProduct$organiza = (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
518
334
  inheritedOrganizations: [].concat(_toConsumableArray__default["default"]((_this$organization$pa = (_this$organization$pa2 = this.organization.parentOrganizations) === null || _this$organization$pa2 === void 0 ? void 0 : _this$organization$pa2.map(function (o) {
519
335
  return o._id;
520
336
  })) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
521
- created: (_baseProduct42 = baseProduct) === null || _baseProduct42 === void 0 ? void 0 : _baseProduct42.created,
522
- 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,
523
- createdBy_displayText: (_baseProduct44 = baseProduct) === null || _baseProduct44 === void 0 ? void 0 : _baseProduct44.createdBy_displayText,
524
- archived: (_baseProduct45 = baseProduct) !== null && _baseProduct45 !== void 0 && _baseProduct45.archived ? (_baseProduct46 = baseProduct) === null || _baseProduct46 === void 0 ? void 0 : _baseProduct46.archived : false,
525
- isTopseller: !!((_baseProduct47 = baseProduct) !== null && _baseProduct47 !== void 0 && _baseProduct47.isTopseller),
526
- orderText: basket.getEKText(true),
527
- classificationInfo: (_baseProduct48 = baseProduct) === null || _baseProduct48 === void 0 ? void 0 : _baseProduct48.classificationInfo,
528
- modelInfoPageWeight: (_baseProduct49 = baseProduct) === null || _baseProduct49 === void 0 ? void 0 : _baseProduct49.modelInfoPageWeight,
529
- uniqueHash: isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
530
- return os.SetHash;
531
- }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject)
532
- };
533
- metaData = basket.OrderSets.reduce(function (prev, curr) {
337
+ 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,
338
+ createdBy_displayText: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy_displayText,
339
+ archived: (_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.archived ? (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.archived : false,
340
+ isTopseller: !!((_baseProduct14 = baseProduct) !== null && _baseProduct14 !== void 0 && _baseProduct14.isTopseller),
341
+ orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.orderText,
342
+ technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.technicalDescription
343
+ });
344
+ metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
534
345
  return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
535
346
  }, {});
536
- metaData_locales = basket.OrderSets.reduce(function (prev, curr) {
347
+ metaData_locales = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
537
348
  return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
538
349
  }, {});
539
350
  _this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
540
- baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct50 = baseProduct) === null || _baseProduct50 === void 0 ? void 0 : _baseProduct50.customData), customData);
351
+ baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.customData), customData);
541
352
 
542
353
  //add livingarea,maincategorie,subcategorie of loaded product if not exists
543
354
  classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
@@ -553,55 +364,56 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
553
364
  removedProducts = [];
554
365
  optFields = [];
555
366
  initialSelectedFields = [];
556
- if (isSet) {
557
- (_this$LOG = this.LOG) === null || _this$LOG === void 0 || _this$LOG.warn('Variants are currently not supported for set products');
558
- } else {
559
- //iterate all existing variant products and add them to the variants
560
- usedConfigVariants = [];
561
- variantProducts.forEach(function (product) {
562
- var cv;
563
- if (editedBasket) {
564
- var _basket$OrderSets$0$C;
565
- 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) {
566
- return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
567
- });
568
- } else {
569
- var _basket$OrderSets$0$C2;
570
- 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) {
571
- return cv.VariantID == product.variantId;
572
- });
573
- }
367
+ if (!dataByBasket.isSet) {
368
+ _context2.next = 46;
369
+ break;
370
+ }
371
+ throw new Error('Variants are currently not supported for set products');
372
+ case 46:
373
+ //iterate all existing variant products and add them to the variants
374
+ usedVariantIds = [];
375
+ variantProducts.forEach(function (product) {
376
+ var cv;
377
+ if (basket) {
378
+ var _basket$OrderSets$0$C;
379
+ 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) {
380
+ return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
381
+ })) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.VariantID;
382
+ } else {
383
+ cv = product.variantId;
384
+ }
574
385
 
575
- //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
576
- if (product.originDivaNr || cv) {
577
- usedConfigVariants.push(cv);
578
- var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
579
- _variant = _this$initVariant.variant,
580
- modified = _this$initVariant.modified;
581
- variantData.push(_variant);
582
- variantDataModified.push(modified);
583
- } else {
584
- var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
585
- _variant2 = _this$initVariant2.variant,
586
- _modified = _this$initVariant2.modified;
587
- variantData.push(_variant2);
588
- variantDataModified.push(_modified);
589
- removedProducts.push(_variant2._id);
590
- }
591
- });
386
+ //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
387
+ if (product.originDivaNr || cv !== undefined) {
388
+ if (cv !== undefined) usedVariantIds.push(cv);
389
+ var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
390
+ _variant = _this$initVariant.variant,
391
+ modified = _this$initVariant.modified;
392
+ variantData.push(_variant);
393
+ variantDataModified.push(modified);
394
+ } else {
395
+ var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
396
+ _variant2 = _this$initVariant2.variant,
397
+ _modified = _this$initVariant2.modified;
398
+ variantData.push(_variant2);
399
+ variantDataModified.push(_modified);
400
+ removedProducts.push(_variant2._id);
401
+ }
402
+ });
592
403
 
593
- //now iterate all configVariants that are left and add them to the variants (new Products)
594
- newVariantPosition = variantData.filter(function (vd) {
595
- return !removedProducts.includes(vd._id);
596
- });
597
- variantPositions = newVariantPosition.map(function (element) {
598
- return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
599
- });
600
- currentVariantPos = Math.max.apply(Math, _toConsumableArray__default["default"](variantPositions));
601
- (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 || _basket$OrderSets$0$C3.filter(function (cv) {
602
- return !usedConfigVariants.includes(cv);
404
+ //now iterate all configVariants that are left and add them to the variants (new Products)
405
+ newVariantPosition = variantData.filter(function (vd) {
406
+ return !removedProducts.includes(vd._id);
407
+ });
408
+ variantPositions = newVariantPosition.map(function (element) {
409
+ return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
410
+ });
411
+ currentVariantPos = Math.max.apply(Math, _toConsumableArray__default["default"](variantPositions));
412
+ if (basket) {
413
+ (_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 || _basket$OrderSets$0$C2.filter(function (cv) {
414
+ return !usedVariantIds.includes(cv.VariantID);
603
415
  }).forEach(function (cv) {
604
- var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, cv, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
416
+ var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv.VariantID, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
605
417
  variant = _this$initVariant3.variant,
606
418
  modified = _this$initVariant3.modified;
607
419
  currentVariantPos = currentVariantPos + 1;
@@ -610,60 +422,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
610
422
  variantDataModified.push(modified);
611
423
  addedProducts.push(variant._id);
612
424
  });
425
+ }
613
426
 
614
- //get opt data
615
- 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) {
616
- var _ref7 = _slicedToArray__default["default"](_ref6, 2);
617
- _ref7[0];
618
- var value = _ref7[1];
619
- return Object.keys(value).length > 1;
620
- }).map(function (_ref8) {
621
- var _ref9 = _slicedToArray__default["default"](_ref8, 2),
622
- opt = _ref9[0];
623
- _ref9[1];
624
- return opt.replace('OPT', '');
625
- });
626
- if (basket.OrderSets[0].ConfigVariants) {
627
- 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) {
628
- var _vd$OPTName;
629
- return {
630
- field: vd.OptionOCD ? vd.OptionOCD.substring(3) : vd.OPT,
631
- type: 'string',
632
- title: (_vd$OPTName = vd.OPTName) !== null && _vd$OPTName !== void 0 ? _vd$OPTName : vd.OPT,
633
- readOnly: true,
634
- fieldType: 'OPT'
635
- };
636
- })) || [];
637
- //remove duplicates
638
- opts = {};
639
- for (_i2 = optFields.length - 1; _i2 >= 0; _i2--) {
640
- if (!opts[optFields[_i2].field]) {
641
- opts[optFields[_i2].field] = true;
642
- } else {
643
- optFields.splice(_i2, 1);
644
- }
427
+ //get opt data
428
+ 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) {
429
+ var _ref5 = _slicedToArray__default["default"](_ref4, 2);
430
+ _ref5[0];
431
+ var value = _ref5[1];
432
+ return Object.keys(value).length > 1;
433
+ }).map(function (_ref6) {
434
+ var _ref7 = _slicedToArray__default["default"](_ref6, 2),
435
+ opt = _ref7[0];
436
+ _ref7[1];
437
+ return opt.replace('OPT', '');
438
+ });
439
+ if (variantData) {
440
+ 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) {
441
+ var _catalogData, _vd$OptionOCD, _option$Name;
442
+ 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];
443
+ return {
444
+ field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
445
+ type: 'string',
446
+ title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
447
+ readOnly: true,
448
+ fieldType: 'OPT'
449
+ };
450
+ })) || [];
451
+ //remove duplicates
452
+ opts = {};
453
+ for (_i = optFields.length - 1; _i >= 0; _i--) {
454
+ if (!opts[optFields[_i].field]) {
455
+ opts[optFields[_i].field] = true;
456
+ } else {
457
+ optFields.splice(_i, 1);
645
458
  }
646
459
  }
647
-
648
- //mark all fields where there are differences between the variants as initaly selected
649
- initialSelectedFields = optFields.filter(function (f) {
650
- return differingOPTs.includes(f.field);
651
- });
652
- ProductHandlerAbstract.baseDataFields.forEach(function (field) {
653
- if (variantDataModified.some(function (mod) {
654
- return mod[field.field];
655
- })) {
656
- initialSelectedFields.push(field);
657
- }
658
- });
659
- customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
660
- if (variantDataModified.some(function (mod) {
661
- return mod['customData.' + f.field];
662
- })) {
663
- initialSelectedFields.push(f);
664
- }
665
- });
666
460
  }
461
+
462
+ //mark all fields where there are differences between the variants as initaly selected
463
+ initialSelectedFields = optFields.filter(function (f) {
464
+ return differingOPTs.includes(f.field);
465
+ });
466
+ ProductHandlerAbstract.baseDataFields.forEach(function (field) {
467
+ if (variantDataModified.some(function (mod) {
468
+ return mod[field.field];
469
+ })) {
470
+ initialSelectedFields.push(field);
471
+ }
472
+ });
473
+ customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
474
+ if (variantDataModified.some(function (mod) {
475
+ return mod['customData.' + f.field];
476
+ })) {
477
+ initialSelectedFields.push(f);
478
+ }
479
+ });
667
480
  initializedOptMap = this.initOpvMap(optFields, classificationConfig, optMap);
668
481
  return _context2.abrupt("return", {
669
482
  baseData: baseData,
@@ -671,6 +484,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
671
484
  optFields: optFields,
672
485
  initialSelectedFields: initialSelectedFields,
673
486
  variantData: variantData,
487
+ catalogData: catalogData,
674
488
  optClassMap: initializedOptMap,
675
489
  addedProducts: products.total ? addedProducts : [],
676
490
  removedProducts: products.total ? removedProducts : [],
@@ -684,7 +498,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
684
498
  availableLanguages: availableLanguages,
685
499
  currentLang: currentLang
686
500
  });
687
- case 47:
501
+ case 59:
688
502
  case "end":
689
503
  return _context2.stop();
690
504
  }
@@ -695,6 +509,192 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
695
509
  }
696
510
  return loadProducts;
697
511
  }())
512
+ }, {
513
+ key: "getProductDataByBasket",
514
+ value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
515
+ var dataByBasket = {};
516
+ var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
517
+ dataByBasket.isSet = isSet;
518
+ if (basket) {
519
+ dataByBasket.hqRenderScript = basket === null || basket === void 0 ? void 0 : basket.OrderSets[0].HQRenderScript;
520
+ dataByBasket.dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
521
+ dataByBasket.technicalDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
522
+ return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
523
+ }, '') : basket.OrderSets[0].VariantDescription;
524
+ dataByBasket.technicalDescription_locales = basket.OrderSets[0].VariantDescription_locales;
525
+ dataByBasket.modelName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
526
+ return c.name;
527
+ }).filter(function (name) {
528
+ return name;
529
+ }).join(' - ');
530
+ dataByBasket.catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
531
+ return c.brand;
532
+ }).filter(function (brand) {
533
+ return brand;
534
+ }).join(' - ');
535
+ dataByBasket.info = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
536
+ return c.description;
537
+ }).filter(function (description) {
538
+ return description;
539
+ }).join('<br/>');
540
+ dataByBasket.modelName_locales = {};
541
+ for (var i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
542
+ var c = catalogData[i];
543
+ for (var key in c.name_locales) {
544
+ if (!dataByBasket.modelName_locales[key]) {
545
+ dataByBasket.modelName_locales[key] = c.name_locales[key];
546
+ } else {
547
+ dataByBasket.modelName_locales[key] = dataByBasket.modelName_locales[key] + ' - ' + c.name_locales[key];
548
+ }
549
+ }
550
+ dataByBasket.info_locales = {};
551
+ for (var _key in c.description_locales) {
552
+ if (!dataByBasket.info_locales[_key]) {
553
+ dataByBasket.info_locales[_key] = c.description_locales[_key];
554
+ } else {
555
+ dataByBasket.info_locales[_key] = dataByBasket.info_locales[_key] + ' - ' + c.description_locales[_key];
556
+ }
557
+ }
558
+ }
559
+ if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
560
+ 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;
561
+ var config = {
562
+ addedPackageWeight: 0,
563
+ addedPackageHeight: 0,
564
+ addedPackageWidth: 0,
565
+ addedPackageDepth: 0,
566
+ defaultDeliveryTime: 0,
567
+ defaultDeliveryPrice: 0,
568
+ defaultInstallationPrice: 0
569
+ };
570
+ if (typeof fieldConfiguration.delivery != 'boolean') {
571
+ config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
572
+ }
573
+ var packages = [];
574
+ basket.OrderSets.flatMap(function (os) {
575
+ return os.OrderLines;
576
+ }).forEach(function (ol) {
577
+ packages.push({
578
+ height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
579
+ width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
580
+ depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
581
+ weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
582
+ });
583
+ });
584
+ dataByBasket.delivery = {
585
+ estPackages: packages,
586
+ 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,
587
+ 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__default["default"](packages.map(function (p) {
588
+ return p.weight;
589
+ }).filter(function (f) {
590
+ return f;
591
+ })))),
592
+ 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__default["default"](packages.map(function (p) {
593
+ return p.height;
594
+ }).filter(function (f) {
595
+ return f;
596
+ })))),
597
+ 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__default["default"](packages.map(function (p) {
598
+ return p.width;
599
+ }).filter(function (f) {
600
+ return f;
601
+ })))),
602
+ 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__default["default"](packages.map(function (p) {
603
+ return p.depth;
604
+ }).filter(function (f) {
605
+ return f;
606
+ })))),
607
+ 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,
608
+ 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,
609
+ 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
610
+ };
611
+ }
612
+ var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
613
+ var price = {
614
+ calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
615
+ addedPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice,
616
+ discountPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.discountedPrice
617
+ };
618
+ if (!(baseProduct !== null && baseProduct !== void 0 && baseProduct.calculatedPrice)) {
619
+ 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);
620
+ }
621
+ dataByBasket.price = price;
622
+ dataByBasket.calculatedPrice = price.calculatedPrice;
623
+ if (isSet) {
624
+ var _basket$SetPlannerInf, _basket$SetPlannerInf2, _basket$OrderSets$0$B, _basket$SetPlannerInf3, _basket$SetPlannerInf4;
625
+ 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;
626
+ 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;
627
+ 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;
628
+ dataByBasket.image = (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.SetPlannerImg3D;
629
+ dataByBasket.image2D = (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg2D;
630
+ dataByBasket.catalogId = basket.OrderSets.map(function (os) {
631
+ return os.CatalogGUID;
632
+ });
633
+ dataByBasket.collection = basket.OrderSets.map(function (os) {
634
+ return os.AccountName;
635
+ });
636
+ dataByBasket.collectionId = basket.OrderSets.map(function (os) {
637
+ return os.CollectionGUID;
638
+ });
639
+ dataByBasket.catCodex = basket.OrderSets.map(function (os) {
640
+ return os.CatalogCodex;
641
+ });
642
+ } else {
643
+ var _basket$OrderSets$0$B2, _basket$OrderSets$0$B3, _basket$OrderSets$0$B4;
644
+ 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;
645
+ 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;
646
+ 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;
647
+ dataByBasket.image = basket.OrderSets[0].SetImage;
648
+ dataByBasket.image2D = basket.OrderSets[0].Set2DImage;
649
+ dataByBasket.catalogId = [basket.OrderSets[0].CatalogGUID];
650
+ dataByBasket.collection = [basket.OrderSets[0].AccountName];
651
+ dataByBasket.collectionId = [basket.OrderSets[0].CollectionGUID];
652
+ dataByBasket.catCodex = [basket.OrderSets[0].CatalogCodex];
653
+ }
654
+ dataByBasket.weight = basket === null || basket === void 0 ? void 0 : basket.OrderSets.flatMap(function (os) {
655
+ return os.OrderLines.map(function (ol) {
656
+ return ol.Weight;
657
+ }).filter(function (f) {
658
+ return f;
659
+ });
660
+ }).reduce(function (sum, v) {
661
+ return sum + v;
662
+ }, 0);
663
+ dataByBasket.supplierId = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
664
+ return c.supplierGuid;
665
+ }).filter(function (c) {
666
+ return c;
667
+ });
668
+ dataByBasket.retailCatalogNr = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
669
+ return c.retailCatalogNr;
670
+ }).filter(function (c) {
671
+ return c;
672
+ });
673
+ dataByBasket.supplierArticleNr = basket.OrderSets.flatMap(function (os) {
674
+ return os.OrderLines.map(function (ol) {
675
+ return ol.ConfigArticleCodex;
676
+ }).filter(function (f) {
677
+ return f;
678
+ });
679
+ }).filter(function (f) {
680
+ return f;
681
+ });
682
+ dataByBasket.retailCatalogArticleNr = basket.OrderSets.flatMap(function (os) {
683
+ return os.OrderLines.map(function (ol) {
684
+ return ol.RetailArticleNr;
685
+ }).filter(function (f) {
686
+ return f;
687
+ });
688
+ }).filter(function (f) {
689
+ return f;
690
+ });
691
+ dataByBasket.orderText = basket.getEKText(true);
692
+ dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
693
+ return os.SetHash;
694
+ }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
695
+ }
696
+ return dataByBasket;
697
+ }
698
698
  }, {
699
699
  key: "checkAndAddClassificationConfigCategories",
700
700
  value: function checkAndAddClassificationConfigCategories(baseProduct, classificationConfig) {
@@ -755,11 +755,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
755
755
  key: "mapCategory",
756
756
  value: function mapCategory(value, translations) {
757
757
  var _translations$find2;
758
- var _ref10 = (_translations$find2 = translations === null || translations === void 0 ? void 0 : translations.find(function (t) {
758
+ var _ref11 = (_translations$find2 = translations === null || translations === void 0 ? void 0 : translations.find(function (t) {
759
759
  return t.value == value;
760
760
  })) !== null && _translations$find2 !== void 0 ? _translations$find2 : {};
761
- _ref10.value;
762
- var translation = _objectWithoutProperties__default["default"](_ref10, _excluded);
761
+ _ref11.value;
762
+ var translation = _objectWithoutProperties__default["default"](_ref11, _excluded);
763
763
  if (Object.keys(translation).length) {
764
764
  return translation;
765
765
  }
@@ -783,13 +783,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
783
783
  }, {
784
784
  key: "prepareData",
785
785
  value: function () {
786
- var _prepareData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref11) {
786
+ var _prepareData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref12) {
787
787
  var _this3 = this;
788
- 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;
788
+ var basket, baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref12$oldClassificat, oldClassificationData, originProductId, products, originProduct, sapEinaLifNr, sapEineEkgrp, result, _this$closeModal, _originProduct$percen, _originProduct$discou, _baseData$variantId, _originProduct$create, _originProduct$create2, _originProduct$create3, baseProduct, j, mediaRef, _this$openModal, _this$t, _j, _this$openModal2, _this$t2, savedMedia, _loop, _j2;
789
789
  return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
790
790
  while (1) switch (_context4.prev = _context4.next) {
791
791
  case 0:
792
- 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;
792
+ basket = _ref12.basket, baseData = _ref12.baseData, classificationData = _ref12.classificationData, variantData = _ref12.variantData, removedProducts = _ref12.removedProducts, removedMedia = _ref12.removedMedia, classificationFields = _ref12.classificationFields, fieldConfiguration = _ref12.fieldConfiguration, optMap = _ref12.optMap, _ref12$oldClassificat = _ref12.oldClassificationData, oldClassificationData = _ref12$oldClassificat === void 0 ? {} : _ref12$oldClassificat, originProductId = _ref12.originProductId;
793
793
  products = [];
794
794
  originProduct = undefined;
795
795
  if (!originProductId) {
@@ -834,10 +834,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
834
834
  }
835
835
  this.trimStrings(baseData);
836
836
  //the base product is constructed, based on baseData and classification data
837
- baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref12) {
838
- var _ref13 = _slicedToArray__default["default"](_ref12, 2),
839
- key = _ref13[0],
840
- value = _ref13[1];
837
+ baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref13) {
838
+ var _ref14 = _slicedToArray__default["default"](_ref13, 2),
839
+ key = _ref14[0],
840
+ value = _ref14[1];
841
841
  prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
842
842
  return prev;
843
843
  }, {})), {}, {
@@ -849,11 +849,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
849
849
  });
850
850
  if (!originProduct && baseData.customData) {
851
851
  //convert all customData to objects with value and translations, if they exists
852
- Object.entries(baseData.customData).forEach(function (_ref14) {
852
+ Object.entries(baseData.customData).forEach(function (_ref15) {
853
853
  var _baseProduct$customDa;
854
- var _ref15 = _slicedToArray__default["default"](_ref14, 2),
855
- key = _ref15[0],
856
- value = _ref15[1];
854
+ var _ref16 = _slicedToArray__default["default"](_ref15, 2),
855
+ key = _ref16[0],
856
+ value = _ref16[1];
857
857
  if (!((_baseProduct$customDa = baseProduct.customData[key]) !== null && _baseProduct$customDa !== void 0 && _baseProduct$customDa.value)) {
858
858
  var _fieldConfiguration$a;
859
859
  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);
@@ -862,17 +862,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
862
862
  }
863
863
  if (optMap) {
864
864
  //save to class fields the information to which opt it maps
865
- Object.entries(optMap).filter(function (_ref16) {
866
- var _ref17 = _slicedToArray__default["default"](_ref16, 2);
867
- _ref17[0];
868
- var value = _ref17[1];
865
+ Object.entries(optMap).filter(function (_ref17) {
866
+ var _ref18 = _slicedToArray__default["default"](_ref17, 2);
867
+ _ref18[0];
868
+ var value = _ref18[1];
869
869
  return value;
870
- }).forEach(function (_ref18) {
871
- var _baseProduct51;
872
- var _ref19 = _slicedToArray__default["default"](_ref18, 2),
873
- key = _ref19[0],
874
- value = _ref19[1];
875
- return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct51 = baseProduct["dc_".concat(key)]) !== null && _baseProduct51 !== void 0 ? _baseProduct51 : {}), {}, {
870
+ }).forEach(function (_ref19) {
871
+ var _baseProduct19;
872
+ var _ref20 = _slicedToArray__default["default"](_ref19, 2),
873
+ key = _ref20[0],
874
+ value = _ref20[1];
875
+ return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct19 = baseProduct["dc_".concat(key)]) !== null && _baseProduct19 !== void 0 ? _baseProduct19 : {}), {}, {
876
876
  opt: value.field
877
877
  });
878
878
  });
@@ -957,8 +957,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
957
957
  baseProduct.parent = baseProduct._id;
958
958
  }
959
959
  _loop = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop() {
960
- var _originProduct;
961
- var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, product, _this3$openModal, _this3$t, k, _savedMedia;
960
+ var _basket$getProductCon2, _originProduct, _configuration$OrderS;
961
+ var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k, _savedMedia;
962
962
  return _regeneratorRuntime__default["default"].wrap(function _loop$(_context3) {
963
963
  while (1) switch (_context3.prev = _context3.next) {
964
964
  case 0:
@@ -971,11 +971,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
971
971
  case 3:
972
972
  varinatBase = {};
973
973
  classData = {};
974
- Object.entries(vd).forEach(function (_ref20) {
974
+ Object.entries(vd).forEach(function (_ref21) {
975
975
  var _optMap$key;
976
- var _ref21 = _slicedToArray__default["default"](_ref20, 2),
977
- key = _ref21[0],
978
- value = _ref21[1];
976
+ var _ref22 = _slicedToArray__default["default"](_ref21, 2),
977
+ key = _ref22[0],
978
+ value = _ref22[1];
979
979
  //save those fields that are specified as class fields
980
980
  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)) {
981
981
  classData["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
@@ -989,16 +989,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
989
989
  });
990
990
  if (optMap) {
991
991
  //save to class fields the information to which opt it maps
992
- Object.entries(optMap).filter(function (_ref22) {
993
- var _ref23 = _slicedToArray__default["default"](_ref22, 2);
994
- _ref23[0];
995
- var value = _ref23[1];
992
+ Object.entries(optMap).filter(function (_ref23) {
993
+ var _ref24 = _slicedToArray__default["default"](_ref23, 2);
994
+ _ref24[0];
995
+ var value = _ref24[1];
996
996
  return value;
997
- }).forEach(function (_ref24) {
997
+ }).forEach(function (_ref25) {
998
998
  var _oldClassificationDat, _oldClassificationDat2, _value$field, _value$field2, _value$field3, _value$field4;
999
- var _ref25 = _slicedToArray__default["default"](_ref24, 2),
1000
- key = _ref25[0],
1001
- value = _ref25[1];
999
+ var _ref26 = _slicedToArray__default["default"](_ref25, 2),
1000
+ key = _ref26[0],
1001
+ value = _ref26[1];
1002
1002
  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)]), {}, {
1003
1003
  opt: value.field,
1004
1004
  opv: (_value$field = vd[value.field]) === null || _value$field === void 0 ? void 0 : _value$field.codex,
@@ -1014,11 +1014,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1014
1014
  if (vd.customData) {
1015
1015
  customData = {};
1016
1016
  //convert all customData to objects with value and translations, if they exists
1017
- Object.entries(vd.customData).forEach(function (_ref26) {
1017
+ Object.entries(vd.customData).forEach(function (_ref27) {
1018
1018
  var _vd$customData, _fieldConfiguration$a2;
1019
- var _ref27 = _slicedToArray__default["default"](_ref26, 2),
1020
- key = _ref27[0],
1021
- value = _ref27[1];
1019
+ var _ref28 = _slicedToArray__default["default"](_ref27, 2),
1020
+ key = _ref28[0],
1021
+ value = _ref28[1];
1022
1022
  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);
1023
1023
  });
1024
1024
  }
@@ -1043,6 +1043,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1043
1043
  _id: productId
1044
1044
  };
1045
1045
  }
1046
+ 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;
1046
1047
  product = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, preparedProduct), varinatBase), classData), {}, {
1047
1048
  customData: originProduct ? _objectSpread(_objectSpread({}, (_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.customData), {}, {
1048
1049
  SAP_EINA_LIFNR: {
@@ -1067,6 +1068,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1067
1068
  modelName_locales: vd.modelName_locales,
1068
1069
  shortDescription_locales: vd.shortDescription_locales,
1069
1070
  width: vd.width,
1071
+ configuration: configuration,
1072
+ hqRenderScript: (_configuration$OrderS = configuration === null || configuration === void 0 ? void 0 : configuration.OrderSets[0].HQRenderScript) !== null && _configuration$OrderS !== void 0 ? _configuration$OrderS : vd.hqRenderScript,
1070
1073
  height: vd.height,
1071
1074
  depth: vd.depth,
1072
1075
  calculatedPrice: vd.calculatedPrice,
@@ -1077,7 +1080,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1077
1080
  variantPosition: variantPos,
1078
1081
  image: vd.image,
1079
1082
  image2D: vd.image2D,
1080
- articles: vd.articles,
1081
1083
  affiliate: vd.affiliate,
1082
1084
  originDivaNr: vd.originDivaNr,
1083
1085
  organizationId: baseProduct.organizationId,
@@ -1089,7 +1091,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1089
1091
  uniqueHash: vd.uniqueHash
1090
1092
  });
1091
1093
  if (!vd.media) {
1092
- _context3.next = 27;
1094
+ _context3.next = 28;
1093
1095
  break;
1094
1096
  }
1095
1097
  product.media = [];
@@ -1099,14 +1101,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1099
1101
  dontRenderForm: true
1100
1102
  });
1101
1103
  k = 0;
1102
- case 19:
1104
+ case 20:
1103
1105
  if (!(k < vd.media.length)) {
1104
- _context3.next = 27;
1106
+ _context3.next = 28;
1105
1107
  break;
1106
1108
  }
1107
- _context3.next = 22;
1109
+ _context3.next = 23;
1108
1110
  return _this3.saveProductMedia(vd.media[k], baseProduct.organizationId);
1109
- case 22:
1111
+ case 23:
1110
1112
  _savedMedia = _context3.sent;
1111
1113
  if (_savedMedia) {
1112
1114
  product.media.push(_savedMedia);
@@ -1123,14 +1125,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1123
1125
  "class": vd.media[k]["class"]
1124
1126
  });
1125
1127
  }
1126
- case 24:
1128
+ case 25:
1127
1129
  k++;
1128
- _context3.next = 19;
1130
+ _context3.next = 20;
1129
1131
  break;
1130
- case 27:
1132
+ case 28:
1131
1133
  //add the variant product it the list of products to be saved
1132
1134
  products.push(product);
1133
- case 28:
1135
+ case 29:
1134
1136
  case "end":
1135
1137
  return _context3.stop();
1136
1138
  }
@@ -1179,43 +1181,66 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1179
1181
  }
1180
1182
  }
1181
1183
  }, {
1182
- key: "saveBasketAndProducts",
1184
+ key: "saveProducts",
1183
1185
  value: function () {
1184
- var _saveBasketAndProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref28) {
1185
- var products, removedProducts, basket, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1186
+ var _saveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref29) {
1187
+ var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1186
1188
  return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context5) {
1187
1189
  while (1) switch (_context5.prev = _context5.next) {
1188
1190
  case 0:
1189
- products = _ref28.products, removedProducts = _ref28.removedProducts, basket = _ref28.basket, awaitPDF = _ref28.awaitPDF;
1191
+ products = _ref29.products, removedProducts = _ref29.removedProducts, awaitPDF = _ref29.awaitPDF;
1190
1192
  if (this.jwt) {
1191
1193
  _context5.next = 3;
1192
1194
  break;
1193
1195
  }
1194
1196
  throw new Error('jwt not set');
1195
1197
  case 3:
1196
- _context5.prev = 3;
1197
- _context5.next = 6;
1198
- return this.apiSaveBasketAndProducts(this.catalogService, this.jwt, products, awaitPDF, basket, removedProducts);
1199
- case 6:
1198
+ this.setFirstVariant(products);
1199
+ _context5.prev = 4;
1200
+ _context5.next = 7;
1201
+ return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
1202
+ case 7:
1200
1203
  savedProducts = _context5.sent;
1201
1204
  (_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
1202
1205
  return _context5.abrupt("return", savedProducts);
1203
- case 11:
1204
- _context5.prev = 11;
1205
- _context5.t0 = _context5["catch"](3);
1206
+ case 12:
1207
+ _context5.prev = 12;
1208
+ _context5.t0 = _context5["catch"](4);
1206
1209
  (_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
1207
1210
  throw new Error(_context5.t0.message);
1208
- case 15:
1211
+ case 16:
1209
1212
  case "end":
1210
1213
  return _context5.stop();
1211
1214
  }
1212
- }, _callee4, this, [[3, 11]]);
1215
+ }, _callee4, this, [[4, 12]]);
1213
1216
  }));
1214
- function saveBasketAndProducts(_x4) {
1215
- return _saveBasketAndProducts.apply(this, arguments);
1217
+ function saveProducts(_x4) {
1218
+ return _saveProducts.apply(this, arguments);
1216
1219
  }
1217
- return saveBasketAndProducts;
1218
- }()
1220
+ return saveProducts;
1221
+ }() //variant with lowest variantId gets a flag for filtering purposes
1222
+ }, {
1223
+ key: "setFirstVariant",
1224
+ value: function setFirstVariant(products) {
1225
+ var _variants$;
1226
+ products.map(function (p) {
1227
+ return p.firstVariant = false;
1228
+ });
1229
+ var variants = products.filter(function (p) {
1230
+ return p.variantId !== undefined;
1231
+ });
1232
+ if (!(variants !== null && variants !== void 0 && variants.length)) return;
1233
+ var firstVariant = variants[0];
1234
+ var lowestId = (_variants$ = variants[0]) === null || _variants$ === void 0 ? void 0 : _variants$.variantId;
1235
+ for (var i = 0; i < variants.length; i++) {
1236
+ if (lowestId > variants[i].variantId) {
1237
+ lowestId = variants[i].variantId;
1238
+ firstVariant = variants[i];
1239
+ }
1240
+ }
1241
+ firstVariant.firstVariant = true;
1242
+ }
1243
+
1219
1244
  /**
1220
1245
  * Calculates the inital state of one varinat data entry
1221
1246
  *
@@ -1225,42 +1250,48 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1225
1250
  */
1226
1251
  }, {
1227
1252
  key: "initVariant",
1228
- value: function initVariant(baseData, baseClassification, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1229
- var _cv$VariantDescriptio, _cv$VariantDescriptio2, _baseData$articles, _classificationFields;
1230
- var _this$parseClassifica = this.parseClassificationFields(product),
1253
+ value: function initVariant(baseData, baseClassification, availableLanguages, catalogData, basket, cv, variantProduct, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1254
+ var _basket$OrderSets$0$C3, _ref31, _variantProduct$confi, _classificationFields;
1255
+ var _this$parseClassifica = this.parseClassificationFields(variantProduct),
1231
1256
  parsedProduct = _this$parseClassifica.product;
1232
- var _ref29 = cv || {},
1233
- VariantID = _ref29.VariantID,
1234
- SetImage = _ref29.SetImage,
1235
- Set2DImage = _ref29.Set2DImage,
1236
- SetPrice = _ref29.SetPrice,
1237
- VariantBasketDatas = _ref29.VariantBasketDatas,
1238
- BBox = _ref29.BBox,
1239
- MetaData = _ref29.MetaData,
1240
- MetaData_locales = _ref29.MetaData_locales,
1241
- Variant = _ref29.Variant,
1242
- SetHash = _ref29.SetHash,
1243
- Diva3DProject = _ref29.Diva3DProject;
1257
+ 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) {
1258
+ return vd.VariantID === cv;
1259
+ })) || {
1260
+ 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)
1261
+ },
1262
+ VariantID = _ref30.VariantID,
1263
+ SetImage = _ref30.SetImage,
1264
+ Set2DImage = _ref30.Set2DImage,
1265
+ SetPrice = _ref30.SetPrice,
1266
+ VariantBasketDatas = _ref30.VariantBasketDatas,
1267
+ BBox = _ref30.BBox,
1268
+ MetaData = _ref30.MetaData,
1269
+ MetaData_locales = _ref30.MetaData_locales,
1270
+ Variant = _ref30.Variant,
1271
+ SetHash = _ref30.SetHash,
1272
+ Diva3DProject = _ref30.Diva3DProject,
1273
+ VariantDescription_locales = _ref30.VariantDescription_locales,
1274
+ VariantDescription = _ref30.VariantDescription;
1244
1275
  //total and summary price are currently not avialable per varinat,
1245
1276
  //most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
1246
1277
  //we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
1247
1278
 
1248
- var ismanual = (product === null || product === void 0 ? void 0 : product.calculatedPrice) !== (product === null || product === void 0 ? void 0 : product.addedPrice);
1249
- var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], product === null || product === void 0 ? void 0 : product.calculatedPrice, ismanual);
1279
+ var ismanual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice);
1280
+ var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice, ismanual);
1250
1281
  var addedPrice;
1251
1282
  if (SetPrice == baseData.calculatedPrice) {
1252
1283
  addedPrice = baseData.addedPrice;
1253
1284
  } else {
1254
1285
  addedPrice = price.calculatedPrice;
1255
1286
  }
1256
- var isManual = (product === null || product === void 0 ? void 0 : product.addedPrice) !== (product === null || product === void 0 ? void 0 : product.calculatedPrice);
1287
+ var isManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice);
1257
1288
  if (isManual) {
1258
- addedPrice = product === null || product === void 0 ? void 0 : product.addedPrice;
1289
+ addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1259
1290
  }
1260
- var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, product, classificationConfig, customBaseFields),
1291
+ var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1261
1292
  classificationData = _this$parseMetaDataAn2.classificationData,
1262
1293
  customData = _this$parseMetaDataAn2.customData;
1263
- customData = _objectSpread(_objectSpread({}, product === null || product === void 0 ? void 0 : product.customData), customData);
1294
+ customData = _objectSpread(_objectSpread({}, variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.customData), customData);
1264
1295
  var variant = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseData), {}, {
1265
1296
  media: undefined,
1266
1297
  //set media undefined, just in case "baseData" has media but "parsedProduct" does not have media to overwrite it
@@ -1270,8 +1301,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1270
1301
  width: BBox === null || BBox === void 0 ? void 0 : BBox.X,
1271
1302
  height: BBox === null || BBox === void 0 ? void 0 : BBox.Z,
1272
1303
  depth: BBox === null || BBox === void 0 ? void 0 : BBox.Y,
1273
- technicalDescription: (_cv$VariantDescriptio = cv === null || cv === void 0 ? void 0 : cv.VariantDescription) !== null && _cv$VariantDescriptio !== void 0 ? _cv$VariantDescriptio : baseData.technicalDescription,
1274
- technicalDescription_locales: (_cv$VariantDescriptio2 = cv === null || cv === void 0 ? void 0 : cv.VariantDescription_locales) !== null && _cv$VariantDescriptio2 !== void 0 ? _cv$VariantDescriptio2 : baseData.technicalDescription_locales
1304
+ technicalDescription: VariantDescription !== null && VariantDescription !== void 0 ? VariantDescription : baseData.technicalDescription,
1305
+ technicalDescription_locales: VariantDescription_locales !== null && VariantDescription_locales !== void 0 ? VariantDescription_locales : baseData.technicalDescription_locales
1275
1306
  }, parsedProduct), {}, {
1276
1307
  customData: customData
1277
1308
  }, classificationData), {}, {
@@ -1280,18 +1311,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1280
1311
  //only if cv is not defined fallback to the values in product
1281
1312
  addedPrice: addedPrice,
1282
1313
  calculatedPrice: price.calculatedPrice,
1283
- articles: VariantBasketDatas ? (_baseData$articles = baseData.articles) === null || _baseData$articles === void 0 ? void 0 : _baseData$articles.map(function (art) {
1284
- return _objectSpread(_objectSpread({}, art), {}, {
1285
- variantValues: VariantBasketDatas === null || VariantBasketDatas === void 0 ? void 0 : VariantBasketDatas.filter(function (vb) {
1286
- return !vb.IsDescribingState;
1287
- }).map(function (vb) {
1288
- return {
1289
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
1290
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
1291
- };
1292
- })
1293
- });
1294
- }) : parsedProduct.articles,
1295
1314
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1296
1315
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1297
1316
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1381,10 +1400,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1381
1400
  key: "initOpvMap",
1382
1401
  value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
1383
1402
  var optMap = {};
1384
- Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref30) {
1385
- var _ref31 = _slicedToArray__default["default"](_ref30, 2),
1386
- c = _ref31[0],
1387
- optMapping = _ref31[1].optMapping;
1403
+ Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref32) {
1404
+ var _ref33 = _slicedToArray__default["default"](_ref32, 2),
1405
+ c = _ref33[0],
1406
+ optMapping = _ref33[1].optMapping;
1388
1407
  var optField;
1389
1408
  if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
1390
1409
  optField = optFields.find(function (opt) {
@@ -1445,16 +1464,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1445
1464
  var _classificationConfig;
1446
1465
  //add metadata defined as classification to classificationdata
1447
1466
  var metadataAsClassification = {};
1448
- Object.entries(metaData).filter(function (_ref32) {
1449
- var _ref33 = _slicedToArray__default["default"](_ref32, 1),
1450
- key = _ref33[0];
1467
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref34) {
1468
+ var _ref35 = _slicedToArray__default["default"](_ref34, 1),
1469
+ key = _ref35[0];
1451
1470
  return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
1452
1471
  })
1453
1472
  //if it is defiend as multi field, use full array otherwise only first element of array
1454
- .forEach(function (_ref34) {
1455
- var _ref35 = _slicedToArray__default["default"](_ref34, 2),
1456
- key = _ref35[0],
1457
- value = _ref35[1];
1473
+ .forEach(function (_ref36) {
1474
+ var _ref37 = _slicedToArray__default["default"](_ref36, 2),
1475
+ key = _ref37[0],
1476
+ value = _ref37[1];
1458
1477
  return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
1459
1478
  });
1460
1479
 
@@ -1464,14 +1483,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1464
1483
  optMap = _this$parseClassifica2.optMap;
1465
1484
  var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
1466
1485
  var customData = {};
1467
- Object.entries(metaData).filter(function (_ref36) {
1468
- var _ref37 = _slicedToArray__default["default"](_ref36, 1),
1469
- key = _ref37[0];
1486
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref38) {
1487
+ var _ref39 = _slicedToArray__default["default"](_ref38, 1),
1488
+ key = _ref39[0];
1470
1489
  return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
1471
- }).forEach(function (_ref38) {
1472
- var _ref39 = _slicedToArray__default["default"](_ref38, 2),
1473
- key = _ref39[0],
1474
- value = _ref39[1];
1490
+ }).forEach(function (_ref40) {
1491
+ var _ref41 = _slicedToArray__default["default"](_ref40, 2),
1492
+ key = _ref41[0],
1493
+ value = _ref41[1];
1475
1494
  var langs = {};
1476
1495
  if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
1477
1496
  for (var i = 0; i < metaData_locales[key].length; i++) {
@@ -1503,19 +1522,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1503
1522
 
1504
1523
  //repare customData
1505
1524
  //if it is defiend as multi field, use full array otherwise only first element of array
1506
- Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref40) {
1507
- var _ref41 = _slicedToArray__default["default"](_ref40, 1),
1508
- key = _ref41[0];
1525
+ Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref42) {
1526
+ var _ref43 = _slicedToArray__default["default"](_ref42, 1),
1527
+ key = _ref43[0];
1509
1528
  return customData[key] != undefined;
1510
- }).forEach(function (_ref42) {
1511
- var _ref43 = _slicedToArray__default["default"](_ref42, 2),
1512
- key = _ref43[0],
1513
- value = _ref43[1];
1529
+ }).forEach(function (_ref44) {
1530
+ var _ref45 = _slicedToArray__default["default"](_ref44, 2),
1531
+ key = _ref45[0],
1532
+ value = _ref45[1];
1514
1533
  if (value.multi && !Array.isArray(customData[key])) {
1515
1534
  customData[key] = [customData[key]];
1516
1535
  } else if (!value.multi && Array.isArray(customData[key])) {
1517
- var _key3;
1518
- customData[key] = (_key3 = customData[key]) === null || _key3 === void 0 ? void 0 : _key3[0];
1536
+ var _key2;
1537
+ customData[key] = (_key2 = customData[key]) === null || _key2 === void 0 ? void 0 : _key2[0];
1519
1538
  }
1520
1539
  });
1521
1540
  return {
@@ -1640,52 +1659,200 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1640
1659
  }
1641
1660
  return apiGetProducts;
1642
1661
  }()
1662
+ }, {
1663
+ key: "apiGetCatalogData",
1664
+ value: function () {
1665
+ var _apiGetCatalogData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(catalogCodex, catalogId, language, accountId) {
1666
+ var _response$CollectionG, _response$Properties, _response$Properties2;
1667
+ var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
1668
+ return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context8) {
1669
+ while (1) switch (_context8.prev = _context8.next) {
1670
+ case 0:
1671
+ _context8.next = 2;
1672
+ return this.apiAccountLogin(accountId, catalogId);
1673
+ case 2:
1674
+ currentAccountSessionId = _context8.sent;
1675
+ if (currentAccountSessionId) {
1676
+ _context8.next = 5;
1677
+ break;
1678
+ }
1679
+ return _context8.abrupt("return");
1680
+ case 5:
1681
+ fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
1682
+ _context8.next = 8;
1683
+ return fetch(fullUrl, {
1684
+ headers: {
1685
+ sessionGuid: currentAccountSessionId
1686
+ }
1687
+ }).then(function (res) {
1688
+ if (res.status !== 200) {
1689
+ throw new Error('Collections not loaded.');
1690
+ }
1691
+ return res.json();
1692
+ });
1693
+ case 8:
1694
+ response = _context8.sent;
1695
+ if (!response.Error) {
1696
+ _context8.next = 11;
1697
+ break;
1698
+ }
1699
+ throw new Error(response.Error);
1700
+ case 11:
1701
+ actCatalogInfoData = {
1702
+ lang: language,
1703
+ guid: response.GUID,
1704
+ name: response.Name,
1705
+ name_locales: response.Name_locales,
1706
+ codex: catalogCodex,
1707
+ accountLogo: response.AccountLogo,
1708
+ description: response.LongDescription,
1709
+ description_locales: response.LongDescription_locales,
1710
+ hasPlanner: response.HasIDMPlanner == 'True',
1711
+ brand: response.Brandname,
1712
+ supplierGuid: response.SupplierGUID,
1713
+ retailCatalogNr: response.RetailCatalogNr,
1714
+ accountGuid: (_response$CollectionG = response.CollectionGuid) !== null && _response$CollectionG !== void 0 ? _response$CollectionG : response.AccountGuid,
1715
+ options: response.Options,
1716
+ optionValues: response.Optionvalues,
1717
+ currency: response.currency,
1718
+ has3D: !!((_response$Properties = response.Properties) !== null && _response$Properties !== void 0 && (_response$Properties = _response$Properties.find(function (p) {
1719
+ return p.Codex == 'DIVA3D_RENDERING';
1720
+ })) !== null && _response$Properties !== void 0 && _response$Properties.Value),
1721
+ images: [],
1722
+ documents: [],
1723
+ accountSessionId: response.AccountSessionGuid,
1724
+ arReady: !!((_response$Properties2 = response.Properties) !== null && _response$Properties2 !== void 0 && (_response$Properties2 = _response$Properties2.find(function (p) {
1725
+ return p.Codex == 'DIVA3D_AR_READY';
1726
+ })) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
1727
+ };
1728
+ return _context8.abrupt("return", actCatalogInfoData);
1729
+ case 13:
1730
+ case "end":
1731
+ return _context8.stop();
1732
+ }
1733
+ }, _callee7, this);
1734
+ }));
1735
+ function apiGetCatalogData(_x9, _x10, _x11, _x12) {
1736
+ return _apiGetCatalogData.apply(this, arguments);
1737
+ }
1738
+ return apiGetCatalogData;
1739
+ }()
1740
+ }, {
1741
+ key: "apiAccountLogin",
1742
+ value: function () {
1743
+ var _apiAccountLogin = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(accountId, catalogId) {
1744
+ var fullUrl, response, fallbackUrl, fallbackResponse;
1745
+ return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context9) {
1746
+ while (1) switch (_context9.prev = _context9.next) {
1747
+ case 0:
1748
+ fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
1749
+ _context9.t0 = fetch;
1750
+ _context9.t1 = fullUrl;
1751
+ _context9.next = 5;
1752
+ return this.sessionGuid;
1753
+ case 5:
1754
+ _context9.t2 = _context9.sent;
1755
+ _context9.t3 = {
1756
+ sessionGuid: _context9.t2
1757
+ };
1758
+ _context9.t4 = {
1759
+ headers: _context9.t3
1760
+ };
1761
+ _context9.next = 10;
1762
+ return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
1763
+ if (res.status !== 200) {
1764
+ throw new Error('Collections not loaded.');
1765
+ }
1766
+ return res.json();
1767
+ });
1768
+ case 10:
1769
+ response = _context9.sent;
1770
+ if (!response.SessionGUID) {
1771
+ _context9.next = 13;
1772
+ break;
1773
+ }
1774
+ return _context9.abrupt("return", response.SessionGUID);
1775
+ case 13:
1776
+ fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
1777
+ _context9.t5 = fetch;
1778
+ _context9.t6 = fallbackUrl;
1779
+ _context9.next = 18;
1780
+ return this.sessionGuid;
1781
+ case 18:
1782
+ _context9.t7 = _context9.sent;
1783
+ _context9.t8 = {
1784
+ sessionGuid: _context9.t7
1785
+ };
1786
+ _context9.t9 = {
1787
+ headers: _context9.t8
1788
+ };
1789
+ _context9.next = 23;
1790
+ return (0, _context9.t5)(_context9.t6, _context9.t9).then(function (res) {
1791
+ if (res.status !== 200) {
1792
+ throw new Error('Collections not loaded.');
1793
+ }
1794
+ return res.json();
1795
+ });
1796
+ case 23:
1797
+ fallbackResponse = _context9.sent;
1798
+ return _context9.abrupt("return", fallbackResponse.SessionGUID);
1799
+ case 25:
1800
+ case "end":
1801
+ return _context9.stop();
1802
+ }
1803
+ }, _callee8, this);
1804
+ }));
1805
+ function apiAccountLogin(_x13, _x14) {
1806
+ return _apiAccountLogin.apply(this, arguments);
1807
+ }
1808
+ return apiAccountLogin;
1809
+ }()
1643
1810
  }, {
1644
1811
  key: "apiGetProductVariants",
1645
1812
  value: function () {
1646
- var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(id, full) {
1813
+ var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(id, full) {
1647
1814
  var _res2;
1648
1815
  var fullUrl, res, resData;
1649
- return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context8) {
1650
- while (1) switch (_context8.prev = _context8.next) {
1816
+ return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context10) {
1817
+ while (1) switch (_context10.prev = _context10.next) {
1651
1818
  case 0:
1652
1819
  fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
1653
- _context8.prev = 1;
1654
- _context8.next = 4;
1820
+ _context10.prev = 1;
1821
+ _context10.next = 4;
1655
1822
  return axios__default["default"].get(fullUrl, {
1656
1823
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1657
1824
  'Content-Type': 'application/json'
1658
1825
  })
1659
1826
  });
1660
1827
  case 4:
1661
- res = _context8.sent;
1662
- _context8.next = 7;
1828
+ res = _context10.sent;
1829
+ _context10.next = 7;
1663
1830
  return res.data;
1664
1831
  case 7:
1665
- resData = _context8.sent;
1666
- _context8.next = 13;
1832
+ resData = _context10.sent;
1833
+ _context10.next = 13;
1667
1834
  break;
1668
1835
  case 10:
1669
- _context8.prev = 10;
1670
- _context8.t0 = _context8["catch"](1);
1836
+ _context10.prev = 10;
1837
+ _context10.t0 = _context10["catch"](1);
1671
1838
  throw new Error('Could not get existing products', {
1672
- cause: _context8.t0
1839
+ cause: _context10.t0
1673
1840
  });
1674
1841
  case 13:
1675
1842
  if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
1676
- _context8.next = 15;
1843
+ _context10.next = 15;
1677
1844
  break;
1678
1845
  }
1679
- return _context8.abrupt("return", resData);
1846
+ return _context10.abrupt("return", resData);
1680
1847
  case 15:
1681
1848
  throw new Error(resData.error);
1682
1849
  case 16:
1683
1850
  case "end":
1684
- return _context8.stop();
1851
+ return _context10.stop();
1685
1852
  }
1686
- }, _callee7, this, [[1, 10]]);
1853
+ }, _callee9, this, [[1, 10]]);
1687
1854
  }));
1688
- function apiGetProductVariants(_x9, _x10) {
1855
+ function apiGetProductVariants(_x15, _x16) {
1689
1856
  return _apiGetProductVariants.apply(this, arguments);
1690
1857
  }
1691
1858
  return apiGetProductVariants;
@@ -1693,7 +1860,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1693
1860
  }, {
1694
1861
  key: "apiGetProductByFilter",
1695
1862
  value: function () {
1696
- var _apiGetProductByFilter = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(filter) {
1863
+ var _apiGetProductByFilter = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10(filter) {
1697
1864
  var _res3;
1698
1865
  var limit,
1699
1866
  useFilter,
@@ -1702,39 +1869,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1702
1869
  res,
1703
1870
  resData,
1704
1871
  filterParam,
1705
- _args9 = arguments;
1706
- return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context9) {
1707
- while (1) switch (_context9.prev = _context9.next) {
1872
+ _args11 = arguments;
1873
+ return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context11) {
1874
+ while (1) switch (_context11.prev = _context11.next) {
1708
1875
  case 0:
1709
- limit = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 1;
1710
- useFilter = _args9.length > 2 ? _args9[2] : undefined;
1711
- hierarchy = _args9.length > 3 ? _args9[3] : undefined;
1876
+ limit = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 1;
1877
+ useFilter = _args11.length > 2 ? _args11[2] : undefined;
1878
+ hierarchy = _args11.length > 3 ? _args11[3] : undefined;
1712
1879
  fullUrl = this.catalogService + '/v1/products';
1713
- _context9.prev = 4;
1880
+ _context11.prev = 4;
1714
1881
  filterParam = useFilter ? 'filter' : 'search';
1715
- _context9.next = 8;
1882
+ _context11.next = 8;
1716
1883
  return axios__default["default"].get("".concat(fullUrl, "?organizationIds=").concat(this.organization._id, "&").concat(filterParam, "=").concat(encodeURIComponent(this.parseFilter(filter)), "&limit=").concat(limit, "&hierarchy=").concat(hierarchy !== null && hierarchy !== void 0 ? hierarchy : false), {
1717
1884
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1718
1885
  'Content-Type': 'application/json'
1719
1886
  })
1720
1887
  });
1721
1888
  case 8:
1722
- res = _context9.sent;
1723
- _context9.next = 11;
1889
+ res = _context11.sent;
1890
+ _context11.next = 11;
1724
1891
  return res.data;
1725
1892
  case 11:
1726
- resData = _context9.sent;
1727
- _context9.next = 17;
1893
+ resData = _context11.sent;
1894
+ _context11.next = 17;
1728
1895
  break;
1729
1896
  case 14:
1730
- _context9.prev = 14;
1731
- _context9.t0 = _context9["catch"](4);
1897
+ _context11.prev = 14;
1898
+ _context11.t0 = _context11["catch"](4);
1732
1899
  throw new Error('Could not get existing products', {
1733
- cause: _context9.t0
1900
+ cause: _context11.t0
1734
1901
  });
1735
1902
  case 17:
1736
1903
  if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
1737
- _context9.next = 20;
1904
+ _context11.next = 20;
1738
1905
  break;
1739
1906
  }
1740
1907
  //in order to be backwardscompatible we must transform old products here
@@ -1747,16 +1914,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1747
1914
  }
1748
1915
  return d;
1749
1916
  });
1750
- return _context9.abrupt("return", resData);
1917
+ return _context11.abrupt("return", resData);
1751
1918
  case 20:
1752
1919
  throw new Error(resData.error);
1753
1920
  case 21:
1754
1921
  case "end":
1755
- return _context9.stop();
1922
+ return _context11.stop();
1756
1923
  }
1757
- }, _callee8, this, [[4, 14]]);
1924
+ }, _callee10, this, [[4, 14]]);
1758
1925
  }));
1759
- function apiGetProductByFilter(_x11) {
1926
+ function apiGetProductByFilter(_x17) {
1760
1927
  return _apiGetProductByFilter.apply(this, arguments);
1761
1928
  }
1762
1929
  return apiGetProductByFilter;
@@ -1764,51 +1931,51 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1764
1931
  }, {
1765
1932
  key: "apiSetCustomFlag",
1766
1933
  value: function () {
1767
- var _apiSetCustomFlag = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(id, flagName, organizationId, dependsOn) {
1934
+ var _apiSetCustomFlag = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(id, flagName, organizationId, dependsOn) {
1768
1935
  var _res4;
1769
1936
  var fullUrl, res, resData;
1770
- return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context10) {
1771
- while (1) switch (_context10.prev = _context10.next) {
1937
+ return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context12) {
1938
+ while (1) switch (_context12.prev = _context12.next) {
1772
1939
  case 0:
1773
1940
  fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/' + flagName);
1774
1941
  fullUrl.searchParams.append('organizationId', organizationId);
1775
1942
  if (dependsOn) fullUrl.searchParams.append('dependsOn', dependsOn);
1776
- _context10.prev = 3;
1777
- _context10.next = 6;
1943
+ _context12.prev = 3;
1944
+ _context12.next = 6;
1778
1945
  return axios__default["default"].post(fullUrl.toString(), undefined, {
1779
1946
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1780
1947
  'Content-Type': 'application/json'
1781
1948
  })
1782
1949
  });
1783
1950
  case 6:
1784
- res = _context10.sent;
1785
- _context10.next = 9;
1951
+ res = _context12.sent;
1952
+ _context12.next = 9;
1786
1953
  return res.data;
1787
1954
  case 9:
1788
- resData = _context10.sent;
1789
- _context10.next = 15;
1955
+ resData = _context12.sent;
1956
+ _context12.next = 15;
1790
1957
  break;
1791
1958
  case 12:
1792
- _context10.prev = 12;
1793
- _context10.t0 = _context10["catch"](3);
1959
+ _context12.prev = 12;
1960
+ _context12.t0 = _context12["catch"](3);
1794
1961
  throw new Error('Could not get existing products', {
1795
- cause: _context10.t0
1962
+ cause: _context12.t0
1796
1963
  });
1797
1964
  case 15:
1798
1965
  if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
1799
- _context10.next = 17;
1966
+ _context12.next = 17;
1800
1967
  break;
1801
1968
  }
1802
- return _context10.abrupt("return", resData);
1969
+ return _context12.abrupt("return", resData);
1803
1970
  case 17:
1804
1971
  throw new Error(resData.error);
1805
1972
  case 18:
1806
1973
  case "end":
1807
- return _context10.stop();
1974
+ return _context12.stop();
1808
1975
  }
1809
- }, _callee9, this, [[3, 12]]);
1976
+ }, _callee11, this, [[3, 12]]);
1810
1977
  }));
1811
- function apiSetCustomFlag(_x12, _x13, _x14, _x15) {
1978
+ function apiSetCustomFlag(_x18, _x19, _x20, _x21) {
1812
1979
  return _apiSetCustomFlag.apply(this, arguments);
1813
1980
  }
1814
1981
  return apiSetCustomFlag;
@@ -1816,10 +1983,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1816
1983
  }, {
1817
1984
  key: "apiDeleteProducts",
1818
1985
  value: function () {
1819
- var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10(products) {
1986
+ var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(products) {
1820
1987
  var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
1821
- return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context11) {
1822
- while (1) switch (_context11.prev = _context11.next) {
1988
+ return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context13) {
1989
+ while (1) switch (_context13.prev = _context13.next) {
1823
1990
  case 0:
1824
1991
  fullUrl = this.catalogService + '/products';
1825
1992
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1830,7 +1997,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1830
1997
  i = 0;
1831
1998
  case 5:
1832
1999
  if (!(i < productsInChunks.length)) {
1833
- _context11.next = 13;
2000
+ _context13.next = 13;
1834
2001
  break;
1835
2002
  }
1836
2003
  promises = productsInChunks[i].map(function (p) {
@@ -1852,19 +2019,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1852
2019
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
1853
2020
  dontRenderForm: true
1854
2021
  });
1855
- _context11.next = 10;
2022
+ _context13.next = 10;
1856
2023
  return Promise.all(promises);
1857
2024
  case 10:
1858
2025
  i++;
1859
- _context11.next = 5;
2026
+ _context13.next = 5;
1860
2027
  break;
1861
2028
  case 13:
1862
2029
  case "end":
1863
- return _context11.stop();
2030
+ return _context13.stop();
1864
2031
  }
1865
- }, _callee10, this);
2032
+ }, _callee12, this);
1866
2033
  }));
1867
- function apiDeleteProducts(_x16) {
2034
+ function apiDeleteProducts(_x22) {
1868
2035
  return _apiDeleteProducts.apply(this, arguments);
1869
2036
  }
1870
2037
  return apiDeleteProducts;
@@ -1881,12 +2048,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1881
2048
  }, {
1882
2049
  key: "apiLoadProductVariantsGrouped",
1883
2050
  value: function () {
1884
- var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(_ref44) {
1885
- var limit, skip, fields, _ref44$search, search, sort, abortController, fullUrl, headers, promise;
1886
- return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context12) {
1887
- while (1) switch (_context12.prev = _context12.next) {
2051
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(_ref46) {
2052
+ var limit, skip, fields, _ref46$search, search, sort, abortController, fullUrl, headers, promise;
2053
+ return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context14) {
2054
+ while (1) switch (_context14.prev = _context14.next) {
1888
2055
  case 0:
1889
- 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;
2056
+ 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;
1890
2057
  fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils__default["default"].fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search ? '&search=' + DivaUtils__default["default"].fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils__default["default"].fixedEncodeURIComponent(sort) : '');
1891
2058
  headers = {
1892
2059
  'Content-Type': 'application/json'
@@ -1908,32 +2075,64 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1908
2075
  reject('Error loading products grouped by variants: ' + error.message);
1909
2076
  });
1910
2077
  });
1911
- _context12.next = 7;
2078
+ _context14.next = 7;
1912
2079
  return promise;
1913
2080
  case 7:
1914
- return _context12.abrupt("return", _context12.sent);
2081
+ return _context14.abrupt("return", _context14.sent);
1915
2082
  case 8:
1916
2083
  case "end":
1917
- return _context12.stop();
2084
+ return _context14.stop();
1918
2085
  }
1919
- }, _callee11, this);
2086
+ }, _callee13, this);
1920
2087
  }));
1921
- function apiLoadProductVariantsGrouped(_x17) {
2088
+ function apiLoadProductVariantsGrouped(_x23) {
1922
2089
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
1923
2090
  }
1924
2091
  return apiLoadProductVariantsGrouped;
1925
2092
  }()
1926
2093
  }, {
1927
- key: "apiSaveBasketAndProducts",
2094
+ key: "apiSaveProducts",
1928
2095
  value: function () {
1929
- var _apiSaveBasketAndProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(serverUrl, jwt, products, awaitPDF, basket, removedProductIds) {
1930
- var fullUrl, response, status;
1931
- return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context13) {
1932
- while (1) switch (_context13.prev = _context13.next) {
2096
+ var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2097
+ var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop2, j;
2098
+ return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context16) {
2099
+ while (1) switch (_context16.prev = _context16.next) {
1933
2100
  case 0:
1934
2101
  fullUrl = serverUrl + '/v1/products/groups';
1935
- _context13.prev = 1;
1936
- _context13.next = 4;
2102
+ BATCH_SIZE = 40;
2103
+ productsPackages = [];
2104
+ groupIndex = 0;
2105
+ i = 0;
2106
+ case 5:
2107
+ if (!(i < products.length)) {
2108
+ _context16.next = 15;
2109
+ break;
2110
+ }
2111
+ if (!products[i].baseProduct) {
2112
+ _context16.next = 9;
2113
+ break;
2114
+ }
2115
+ baseProduct = products[i];
2116
+ return _context16.abrupt("continue", 12);
2117
+ case 9:
2118
+ 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++;
2119
+ if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2120
+ productsPackages[groupIndex].push(products[i]);
2121
+ case 12:
2122
+ i++;
2123
+ _context16.next = 5;
2124
+ break;
2125
+ case 15:
2126
+ responseProducts = [];
2127
+ _i2 = 0;
2128
+ case 17:
2129
+ if (!(_i2 < productsPackages.length)) {
2130
+ _context16.next = 40;
2131
+ break;
2132
+ }
2133
+ if (baseProduct) productsPackages[_i2].unshift(baseProduct);
2134
+ _context16.prev = 19;
2135
+ _context16.next = 22;
1937
2136
  return fetch(fullUrl, {
1938
2137
  method: 'PUT',
1939
2138
  headers: {
@@ -1941,8 +2140,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1941
2140
  'Content-Type': 'application/json'
1942
2141
  },
1943
2142
  body: JSON.stringify({
1944
- basket: basket ? basket.getAsJson() : undefined,
1945
- products: products,
2143
+ products: productsPackages[_i2],
1946
2144
  removedProductIds: removedProductIds,
1947
2145
  awaitPDF: awaitPDF
1948
2146
  })
@@ -1953,32 +2151,64 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1953
2151
  }
1954
2152
  return res.json();
1955
2153
  });
1956
- case 4:
1957
- response = _context13.sent;
2154
+ case 22:
2155
+ response = _context16.sent;
1958
2156
  if (!response.Error) {
1959
- _context13.next = 7;
2157
+ _context16.next = 25;
1960
2158
  break;
1961
2159
  }
1962
2160
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
1963
- case 7:
1964
- _context13.next = 12;
2161
+ case 25:
2162
+ _context16.next = 30;
1965
2163
  break;
1966
- case 9:
1967
- _context13.prev = 9;
1968
- _context13.t0 = _context13["catch"](1);
2164
+ case 27:
2165
+ _context16.prev = 27;
2166
+ _context16.t0 = _context16["catch"](19);
1969
2167
  throw Error(status);
1970
- case 12:
1971
- return _context13.abrupt("return", response.products);
1972
- case 13:
2168
+ case 30:
2169
+ _loop2 = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop2(j) {
2170
+ return _regeneratorRuntime__default["default"].wrap(function _loop2$(_context15) {
2171
+ while (1) switch (_context15.prev = _context15.next) {
2172
+ case 0:
2173
+ if (response.products[_i2].baseProduct) baseProduct = response.products[_i2];
2174
+ if (!responseProducts.find(function (p) {
2175
+ return p._id == response.products[j]._id;
2176
+ })) {
2177
+ responseProducts.push(response.products[j]);
2178
+ }
2179
+ case 2:
2180
+ case "end":
2181
+ return _context15.stop();
2182
+ }
2183
+ }, _loop2);
2184
+ });
2185
+ j = 0;
2186
+ case 32:
2187
+ if (!(j < response.products.length)) {
2188
+ _context16.next = 37;
2189
+ break;
2190
+ }
2191
+ return _context16.delegateYield(_loop2(j), "t1", 34);
2192
+ case 34:
2193
+ j++;
2194
+ _context16.next = 32;
2195
+ break;
2196
+ case 37:
2197
+ _i2++;
2198
+ _context16.next = 17;
2199
+ break;
2200
+ case 40:
2201
+ return _context16.abrupt("return", responseProducts);
2202
+ case 41:
1973
2203
  case "end":
1974
- return _context13.stop();
2204
+ return _context16.stop();
1975
2205
  }
1976
- }, _callee12, null, [[1, 9]]);
2206
+ }, _callee14, null, [[19, 27]]);
1977
2207
  }));
1978
- function apiSaveBasketAndProducts(_x18, _x19, _x20, _x21, _x22, _x23) {
1979
- return _apiSaveBasketAndProducts.apply(this, arguments);
2208
+ function apiSaveProducts(_x24, _x25, _x26, _x27, _x28) {
2209
+ return _apiSaveProducts.apply(this, arguments);
1980
2210
  }
1981
- return apiSaveBasketAndProducts;
2211
+ return apiSaveProducts;
1982
2212
  }()
1983
2213
  }, {
1984
2214
  key: "parseFilter",
@@ -2010,54 +2240,54 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2010
2240
  }], [{
2011
2241
  key: "isSameProduct",
2012
2242
  value: function isSameProduct(product, setHash, diva3dProject, orderLines, varinatData, catalogCodex) {
2013
- var _product$articles;
2243
+ var _product$configuratio, _product$configuratio2, _product$configuratio3;
2014
2244
  //For new products we store the setHash and Diva3DProject in order to determine if the product changed.
2015
2245
  if (product.uniqueHash !== undefined) {
2016
2246
  return product.uniqueHash === 'v1' + setHash + (diva3dProject ? DivaUtils.md5(diva3dProject) : '');
2017
2247
  }
2018
2248
 
2019
2249
  //For older products without setHash we use the old comparison logic
2020
- if (((_product$articles = product.articles) === null || _product$articles === void 0 ? void 0 : _product$articles.length) != (orderLines === null || orderLines === void 0 ? void 0 : orderLines.length)) {
2250
+ 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)) {
2021
2251
  return false;
2022
2252
  }
2023
2253
  if (!varinatData) {
2024
2254
  //the old logic was only for variants, not for base products
2025
2255
  return true;
2026
2256
  }
2027
- var _loop2 = function _loop2() {
2028
- var _article$variantValue;
2029
- var article = product.articles[i];
2257
+ 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 : [];
2258
+ var _loop3 = function _loop3() {
2259
+ var article = orderlines[i];
2030
2260
  var orderLine = orderLines.find(function (ol) {
2031
- return ol.ArticleCodex == article.articleCodex && catalogCodex == article.catalogCodex;
2261
+ return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
2032
2262
  });
2033
- 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)) {
2263
+ if (!orderLine) {
2034
2264
  return {
2035
2265
  v: false
2036
2266
  };
2037
2267
  }
2038
- var _loop3 = function _loop3() {
2039
- var varinatValue = article.variantValues[j];
2040
- if (!(varinatData !== null && varinatData !== void 0 && varinatData.find(function (vb) {
2041
- return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2042
- }))) {
2043
- return {
2044
- v: {
2045
- v: false
2046
- }
2047
- };
2048
- }
2049
- },
2050
- _ret2;
2051
- for (var j = 0; j < (((_article$variantValue2 = article.variantValues) === null || _article$variantValue2 === void 0 ? void 0 : _article$variantValue2.length) || 0); j++) {
2052
- var _article$variantValue2;
2053
- _ret2 = _loop3();
2054
- if (_ret2) return _ret2.v;
2268
+ if (article.VariantBasketDatas.length) {
2269
+ var _loop4 = function _loop4() {
2270
+ var varinatValue = article.VariantBasketDatas[j];
2271
+ if (!varinatData.find(function (vb) {
2272
+ return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2273
+ })) {
2274
+ return {
2275
+ v: {
2276
+ v: false
2277
+ }
2278
+ };
2279
+ }
2280
+ },
2281
+ _ret2;
2282
+ for (var j = 0; j < article.VariantBasketDatas.length; j++) {
2283
+ _ret2 = _loop4();
2284
+ if (_ret2) return _ret2.v;
2285
+ }
2055
2286
  }
2056
2287
  },
2057
2288
  _ret;
2058
- 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++) {
2059
- var _product$articles$len, _product$articles2;
2060
- _ret = _loop2();
2289
+ for (var i = 0; i < orderlines.length; i++) {
2290
+ _ret = _loop3();
2061
2291
  if (_ret) return _ret.v;
2062
2292
  }
2063
2293
  return true;
@@ -2135,7 +2365,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2135
2365
  //calculate defaultShortDescription from template string
2136
2366
  var shortDescriptionTemplate = (_configurationData$sh = configurationData === null || configurationData === void 0 ? void 0 : configurationData.shortDescription) !== null && _configurationData$sh !== void 0 ? _configurationData$sh : '${modelName} ${subCategory} ${mainColor}';
2137
2367
  var parts = shortDescriptionTemplate.split(/\${|}/);
2138
- var _loop4 = function _loop4() {
2368
+ var _loop5 = function _loop5() {
2139
2369
  var _classificationConfig2, _classificationConfig4, _value;
2140
2370
  var field = parts[i];
2141
2371
  var value;
@@ -2167,7 +2397,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2167
2397
  shortDescriptionTemplate = shortDescriptionTemplate.replace("${".concat(field, "}"), (_value = value) !== null && _value !== void 0 ? _value : '');
2168
2398
  };
2169
2399
  for (var i = 1; i < parts.length; i = i + 2) {
2170
- _loop4();
2400
+ _loop5();
2171
2401
  }
2172
2402
 
2173
2403
  //as long as shortDescription is not modified by user, autocalc it
@@ -2183,16 +2413,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2183
2413
  }, {
2184
2414
  key: "assign",
2185
2415
  value: function assign(target) {
2186
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
2187
- sources[_key4 - 1] = arguments[_key4];
2416
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
2417
+ sources[_key3 - 1] = arguments[_key3];
2188
2418
  }
2189
2419
  return Object.assign.apply(Object, [target].concat(_toConsumableArray__default["default"](sources.filter(function (s) {
2190
2420
  return s;
2191
2421
  }).map(function (x) {
2192
- return Object.fromEntries(Object.entries(x).filter(function (_ref45) {
2193
- var _ref46 = _slicedToArray__default["default"](_ref45, 2);
2194
- _ref46[0];
2195
- var value = _ref46[1];
2422
+ return Object.fromEntries(Object.entries(x).filter(function (_ref47) {
2423
+ var _ref48 = _slicedToArray__default["default"](_ref47, 2);
2424
+ _ref48[0];
2425
+ var value = _ref48[1];
2196
2426
  return value !== undefined;
2197
2427
  }));
2198
2428
  }))));
@@ -2200,10 +2430,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2200
2430
  }, {
2201
2431
  key: "loadSelectOptions",
2202
2432
  value: function () {
2203
- var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(sessionGuid, dataSource, additionalFilter) {
2433
+ var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2204
2434
  var values, apiUrl, i, apiResult, _i3, value, text;
2205
- return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context14) {
2206
- while (1) switch (_context14.prev = _context14.next) {
2435
+ return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context17) {
2436
+ while (1) switch (_context17.prev = _context17.next) {
2207
2437
  case 0:
2208
2438
  values = [];
2209
2439
  apiUrl = dataSource.url;
@@ -2212,7 +2442,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2212
2442
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2213
2443
  }
2214
2444
  }
2215
- _context14.next = 5;
2445
+ _context17.next = 5;
2216
2446
  return fetch(apiUrl, {
2217
2447
  headers: {
2218
2448
  sessionGuid: sessionGuid
@@ -2224,7 +2454,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2224
2454
  return res.json();
2225
2455
  });
2226
2456
  case 5:
2227
- apiResult = _context14.sent;
2457
+ apiResult = _context17.sent;
2228
2458
  if (dataSource.useKey) {
2229
2459
  apiResult = apiResult[dataSource.useKey];
2230
2460
  }
@@ -2236,14 +2466,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2236
2466
  text: text
2237
2467
  });
2238
2468
  }
2239
- return _context14.abrupt("return", values);
2469
+ return _context17.abrupt("return", values);
2240
2470
  case 9:
2241
2471
  case "end":
2242
- return _context14.stop();
2472
+ return _context17.stop();
2243
2473
  }
2244
- }, _callee13);
2474
+ }, _callee15);
2245
2475
  }));
2246
- function loadSelectOptions(_x24, _x25, _x26) {
2476
+ function loadSelectOptions(_x29, _x30, _x31) {
2247
2477
  return _loadSelectOptions.apply(this, arguments);
2248
2478
  }
2249
2479
  return loadSelectOptions;
@@ -2256,6 +2486,36 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2256
2486
  return rv;
2257
2487
  }, {});
2258
2488
  }
2489
+ }, {
2490
+ key: "getVariantBasketDatasByOrderlines",
2491
+ value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
2492
+ var variantBasketDatas = [];
2493
+ var _loop6 = function _loop6() {
2494
+ var ol = orderLines[i];
2495
+ var catalog = catalogData.find(function (c) {
2496
+ return c.codex === ol.CatalogCodex;
2497
+ });
2498
+ if (!ol.VariantBasketDatas) return 1; // continue
2499
+ for (var j = 0; j < ol.VariantBasketDatas.length; j++) {
2500
+ var v = ol.VariantBasketDatas[j];
2501
+ var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
2502
+ var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
2503
+ {
2504
+ variantBasketDatas.push({
2505
+ BasketID: ol.BasketID,
2506
+ OPT: v.OPT,
2507
+ OPV: v.OPV,
2508
+ OPTName: opt.Name,
2509
+ OPVName: opv.Name
2510
+ });
2511
+ }
2512
+ }
2513
+ };
2514
+ for (var i = 0; i < orderLines.length; i++) {
2515
+ if (_loop6()) continue;
2516
+ }
2517
+ return variantBasketDatas;
2518
+ }
2259
2519
  }]);
2260
2520
  }();
2261
2521
  _ProductHandlerAbstract = ProductHandlerAbstract;