@crystaldesign/product-handler 24.12.0-beta.23 → 24.12.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,9 +26,6 @@ var _excluded = ["value"];
26
26
  var _ProductHandlerAbstract;
27
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
-
30
- //const LOG = initLog('CORE');
31
-
32
29
  var TRANSLATED_FILEDS = ['info', 'modelName', 'technicalDescription', 'shortDescription', 'shortTechnicalDescription'];
33
30
  var ProductHandlerAbstract = /*#__PURE__*/function () {
34
31
  function ProductHandlerAbstract(LOG, t, openModal, closeModal) {
@@ -43,6 +40,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
43
40
  _defineProperty(this, "_apiKey", void 0);
44
41
  _defineProperty(this, "_catalogService", '');
45
42
  _defineProperty(this, "_mediaService", '');
43
+ _defineProperty(this, "_api2", '');
44
+ _defineProperty(this, "_sessionGuid", '');
46
45
  _defineProperty(this, "_organization", {});
47
46
  }
48
47
  return _createClass(ProductHandlerAbstract, [{
@@ -69,6 +68,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
69
68
  set: function set(val) {
70
69
  this._mediaService = val;
71
70
  }
71
+ }, {
72
+ key: "api2",
73
+ get: function get() {
74
+ return this._api2;
75
+ },
76
+ set: function set(val) {
77
+ this._api2 = val;
78
+ }
79
+ }, {
80
+ key: "sessionGuid",
81
+ get: function get() {
82
+ return this._sessionGuid;
83
+ }
72
84
  }, {
73
85
  key: "organization",
74
86
  get: function get() {
@@ -115,7 +127,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
115
127
  value: (function () {
116
128
  var _createAndSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
117
129
  var _basket$ProductSetNam;
118
- var basket, catalogData, availableLanguages, currentLang, createdState, baseData, data;
130
+ var basket, catalogData, availableLanguages, currentLang, createdState, data;
119
131
  return _regeneratorRuntime.wrap(function _callee$(_context) {
120
132
  while (1) switch (_context.prev = _context.next) {
121
133
  case 0:
@@ -123,6 +135,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
123
135
  _context.next = 3;
124
136
  return this.loadProducts({
125
137
  basket: basket,
138
+ divaNr: basket.DivaNr,
126
139
  catalogData: catalogData,
127
140
  productData: [],
128
141
  availableLanguages: availableLanguages,
@@ -132,10 +145,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
132
145
  createdState = _context.sent;
133
146
  createdState.baseData.shortDescription = (_basket$ProductSetNam = basket.ProductSetName) !== null && _basket$ProductSetNam !== void 0 ? _basket$ProductSetNam : basket.SetName;
134
147
  createdState.baseData.shortDescription_locales = basket.SetName_locales;
135
- baseData = _objectSpread({}, createdState.baseData);
148
+ _objectSpread({}, createdState.baseData);
136
149
  _context.next = 9;
137
150
  return this.prepareData({
138
- baseData: baseData,
151
+ basket: basket,
152
+ baseData: createdState.baseData,
139
153
  classificationData: createdState.classificationData,
140
154
  variantData: createdState.variantData,
141
155
  oldClassificationData: createdState.oldClassificationData
@@ -143,9 +157,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
143
157
  case 9:
144
158
  data = _context.sent;
145
159
  _context.next = 12;
146
- return this.saveBasketAndProducts(_objectSpread(_objectSpread({}, data), {}, {
147
- basket: basket
148
- }));
160
+ return this.saveProducts(_objectSpread({}, data));
149
161
  case 12:
150
162
  return _context.abrupt("return", _context.sent);
151
163
  case 13:
@@ -171,82 +183,53 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
171
183
  key: "loadProducts",
172
184
  value: (function () {
173
185
  var _loadProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
174
- var _baseProduct9,
175
- _baseProduct10,
176
- _baseProduct11,
177
- _baseProduct12,
178
- _baseProduct13,
179
- _baseProduct14,
180
- _baseProduct15,
181
- _baseProduct16,
182
- _baseProduct17,
183
- _baseProduct18,
184
- _baseProduct19,
185
- _baseProduct20,
186
- _baseProduct21,
187
- _baseProduct22,
188
- _baseProduct23,
189
- _baseProduct24,
190
- _baseProduct25,
191
- _baseProduct26,
192
- _baseProduct$width,
193
- _baseProduct27,
194
- _basket$SetPlannerInf,
195
- _basket$OrderSets$0$B,
196
- _baseProduct$height,
197
- _baseProduct28,
198
- _basket$SetPlannerInf2,
199
- _basket$OrderSets$0$B2,
200
- _baseProduct$depth,
201
- _baseProduct29,
202
- _basket$SetPlannerInf3,
203
- _basket$OrderSets$0$B3,
204
- _baseProduct$weight,
205
- _baseProduct30,
206
- _price$addedPrice,
207
- _baseProduct31,
208
- _baseProduct32,
209
- _baseProduct33,
210
- _basket$SetPlannerInf4,
211
- _basket$SetPlannerInf5,
212
- _baseProduct34,
213
- _baseProduct35,
214
- _baseProduct36,
215
- _baseProduct37,
216
- _baseProduct38,
217
- _baseProduct39,
218
- _baseProduct$brand,
219
- _baseProduct40,
186
+ var _baseProduct$configur,
187
+ _baseProduct,
188
+ _this = this,
189
+ _baseProduct2,
190
+ _baseProduct3,
191
+ _baseProduct$divaNr,
192
+ _baseProduct4,
193
+ _dataByBasket$price$a,
194
+ _dataByBasket$price,
195
+ _baseProduct5,
196
+ _basket$getProductCon,
197
+ _baseProduct6,
198
+ _dataByBasket$docking,
199
+ _baseProduct7,
220
200
  _baseProduct$organiza,
221
- _baseProduct41,
201
+ _baseProduct8,
222
202
  _this$organization$pa,
223
203
  _this$organization$pa2,
224
- _baseProduct42,
225
204
  _baseProduct$createdB,
226
- _baseProduct43,
205
+ _baseProduct9,
227
206
  _this$user,
228
- _baseProduct44,
229
- _baseProduct45,
230
- _baseProduct46,
231
- _baseProduct47,
232
- _baseProduct48,
233
- _baseProduct49,
234
- _baseProduct50,
235
- _this = this;
236
- var basket, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, editedBasket, products, baseProduct, variantProducts, isSet, dockingPoints, orderDescription, orderDescription_locales, catalogDataName, catalogDataBrand, catalogDataDescription, catalogDataName_locales, catalogDataDescription_locales, i, c, key, _key, articles, delivery, _baseProduct$delivery, _baseProduct, _baseProduct$delivery2, _baseProduct2, _baseProduct$delivery3, _baseProduct3, _baseProduct$delivery4, _baseProduct4, _baseProduct$delivery5, _baseProduct5, _ref3, _baseProduct$delivery6, _baseProduct6, _fieldConfiguration$d, _ref4, _baseProduct$delivery7, _baseProduct7, _fieldConfiguration$d2, _ref5, _baseProduct$delivery8, _baseProduct8, _fieldConfiguration$d3, config, packages, ismanual, price, oldClassificationData, _i, variant, _key2, oldUniqueHash, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, _this$LOG, _basket$OrderSets$0$C3, _basket$OrderSets$0$F, usedConfigVariants, newVariantPosition, variantPositions, currentVariantPos, differingOPTs, _basket$OrderSets$0$C4, opts, _i2, initializedOptMap;
207
+ _baseProduct10,
208
+ _baseProduct11,
209
+ _baseProduct12,
210
+ _baseProduct13,
211
+ _baseProduct14,
212
+ _baseProduct15;
213
+ var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
237
214
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
238
215
  while (1) switch (_context2.prev = _context2.next) {
239
216
  case 0:
240
- basket = _ref2.basket, catalogData = _ref2.catalogData, productData = _ref2.productData, classificationFields = _ref2.classificationFields, fieldConfiguration = _ref2.fieldConfiguration, customBaseFields = _ref2.customBaseFields, classificationConfig = _ref2.classificationConfig, _ref2$availableLangua = _ref2.availableLanguages, availableLanguages = _ref2$availableLangua === void 0 ? ['de', 'fr', 'it', 'en'] : _ref2$availableLangua, _ref2$currentLang = _ref2.currentLang, currentLang = _ref2$currentLang === void 0 ? 'de' : _ref2$currentLang, editedBasket = _ref2.editedBasket;
217
+ 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;
218
+ if (!(!productData && !divaNr)) {
219
+ _context2.next = 3;
220
+ break;
221
+ }
222
+ throw new Error('this should not happen');
223
+ case 3:
241
224
  if (productData) {
242
- _context2.next = 5;
225
+ _context2.next = 7;
243
226
  break;
244
227
  }
245
- _context2.next = 4;
246
- return this.apiGetProducts(basket.DivaNr);
247
- case 4:
228
+ _context2.next = 6;
229
+ return this.apiGetProducts(divaNr);
230
+ case 6:
248
231
  productData = _context2.sent;
249
- case 5:
232
+ case 7:
250
233
  products = {
251
234
  data: productData,
252
235
  total: productData.length
@@ -263,263 +246,59 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
263
246
  return !p.baseProduct;
264
247
  });
265
248
  }
249
+ if (catalogData) {
250
+ _context2.next = 15;
251
+ break;
252
+ }
253
+ _context2.next = 14;
254
+ return Promise.all((_baseProduct$configur = (_baseProduct = baseProduct) === null || _baseProduct === void 0 || (_baseProduct = _baseProduct.configuration) === null || _baseProduct === void 0 ? void 0 : _baseProduct.OrderSets.map(function (os) {
255
+ return _this.apiGetCatalogData(os.CatalogCodex, currentLang, os.AccountGUID);
256
+ })) !== null && _baseProduct$configur !== void 0 ? _baseProduct$configur : []);
257
+ case 14:
258
+ catalogData = _context2.sent;
259
+ case 15:
266
260
  if (!(products.total && !baseProduct)) {
267
- _context2.next = 11;
261
+ _context2.next = 17;
268
262
  break;
269
263
  }
270
264
  throw new Error('If existing products are fetched, there has to be atleast a base product.');
271
- case 11:
272
- isSet = !!basket.SetPlannerInfos;
273
- dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
274
- orderDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
275
- return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
276
- }, '') : basket.OrderSets[0].VariantDescription;
277
- orderDescription_locales = basket.OrderSets[0].VariantDescription_locales;
278
- catalogDataName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
279
- return c.name;
280
- }).filter(function (name) {
281
- return name;
282
- }).join(' - ');
283
- catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
284
- return c.brand;
285
- }).filter(function (brand) {
286
- return brand;
287
- }).join(' - ');
288
- catalogDataDescription = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
289
- return c.description;
290
- }).filter(function (description) {
291
- return description;
292
- }).join('<br/>');
293
- catalogDataName_locales = {};
294
- catalogDataDescription_locales = {};
295
- for (i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
296
- c = catalogData[i];
297
- for (key in c.name_locales) {
298
- if (!catalogDataName_locales[key]) {
299
- catalogDataName_locales[key] = c.name_locales[key];
300
- } else {
301
- catalogDataName_locales[key] = catalogDataName_locales[key] + ' - ' + c.name_locales[key];
302
- }
303
- }
304
- for (_key in c.description_locales) {
305
- if (!catalogDataDescription_locales[_key]) {
306
- catalogDataDescription_locales[_key] = c.description_locales[_key];
307
- } else {
308
- catalogDataDescription_locales[_key] = catalogDataDescription_locales[_key] + ' - ' + c.description_locales[_key];
309
- }
310
- }
311
- }
312
- articles = [];
313
- if (isSet) {
314
- articles = basket.OrderSets.flatMap(function (os) {
315
- return os.OrderLines.map(function (ol) {
316
- var _ol$VariantBasketData;
317
- return {
318
- articleCodex: ol.ArticleCodex,
319
- catalogCodex: os.CatalogCodex,
320
- variantValues: (_ol$VariantBasketData = ol.VariantBasketDatas) === null || _ol$VariantBasketData === void 0 ? void 0 : _ol$VariantBasketData.map(function (vb) {
321
- return {
322
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
323
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
324
- };
325
- })
326
- };
327
- });
328
- });
329
- } else {
330
- articles = basket.OrderSets[0].OrderLines.map(function (ol) {
331
- var _ol$VariantBasketData2;
332
- return {
333
- articleCodex: ol.ArticleCodex,
334
- catalogCodex: basket.OrderSets[0].CatalogCodex,
335
- variantValues: (_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (vb) {
336
- return {
337
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
338
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
339
- };
340
- })
341
- };
342
- });
343
- }
344
- if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
345
- config = {
346
- addedPackageWeight: 0,
347
- addedPackageHeight: 0,
348
- addedPackageWidth: 0,
349
- addedPackageDepth: 0,
350
- defaultDeliveryTime: 0,
351
- defaultDeliveryPrice: 0,
352
- defaultInstallationPrice: 0
353
- };
354
- if (typeof fieldConfiguration.delivery != 'boolean') {
355
- config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
356
- }
357
- packages = [];
358
- basket.OrderSets.flatMap(function (os) {
359
- return os.OrderLines;
360
- }).forEach(function (ol) {
361
- packages.push({
362
- height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
363
- width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
364
- depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
365
- weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
366
- });
367
- });
368
- delivery = {
369
- estPackages: packages,
370
- estMaxPackages: (_baseProduct$delivery = (_baseProduct = baseProduct) === null || _baseProduct === void 0 || (_baseProduct = _baseProduct.delivery) === null || _baseProduct === void 0 ? void 0 : _baseProduct.estMaxPackages) !== null && _baseProduct$delivery !== void 0 ? _baseProduct$delivery : packages.length,
371
- estMaxPackageWeight: (_baseProduct$delivery2 = (_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 || (_baseProduct2 = _baseProduct2.delivery) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2.estMaxPackageWeight) !== null && _baseProduct$delivery2 !== void 0 ? _baseProduct$delivery2 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
372
- return p.weight;
373
- }).filter(function (f) {
374
- return f;
375
- })))),
376
- estMaxPackageHeight: (_baseProduct$delivery3 = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 || (_baseProduct3 = _baseProduct3.delivery) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.estMaxPackageHeight) !== null && _baseProduct$delivery3 !== void 0 ? _baseProduct$delivery3 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
377
- return p.height;
378
- }).filter(function (f) {
379
- return f;
380
- })))),
381
- estMaxPackageWidth: (_baseProduct$delivery4 = (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 || (_baseProduct4 = _baseProduct4.delivery) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.estMaxPackageWidth) !== null && _baseProduct$delivery4 !== void 0 ? _baseProduct$delivery4 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
382
- return p.width;
383
- }).filter(function (f) {
384
- return f;
385
- })))),
386
- estMaxPackageDepth: (_baseProduct$delivery5 = (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 || (_baseProduct5 = _baseProduct5.delivery) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.estMaxPackageDepth) !== null && _baseProduct$delivery5 !== void 0 ? _baseProduct$delivery5 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
387
- return p.depth;
388
- }).filter(function (f) {
389
- return f;
390
- })))),
391
- deliveryTime: (_ref3 = (_baseProduct$delivery6 = (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 || (_baseProduct6 = _baseProduct6.delivery) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.deliveryTime) !== null && _baseProduct$delivery6 !== void 0 ? _baseProduct$delivery6 : (_fieldConfiguration$d = fieldConfiguration.delivery) === null || _fieldConfiguration$d === void 0 ? void 0 : _fieldConfiguration$d.defaultDeliveryTime) !== null && _ref3 !== void 0 ? _ref3 : 0,
392
- deliveryPrice: (_ref4 = (_baseProduct$delivery7 = (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 || (_baseProduct7 = _baseProduct7.delivery) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.deliveryPrice) !== null && _baseProduct$delivery7 !== void 0 ? _baseProduct$delivery7 : (_fieldConfiguration$d2 = fieldConfiguration.delivery) === null || _fieldConfiguration$d2 === void 0 ? void 0 : _fieldConfiguration$d2.defaultDeliveryPrice) !== null && _ref4 !== void 0 ? _ref4 : 0,
393
- installationPrice: (_ref5 = (_baseProduct$delivery8 = (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 || (_baseProduct8 = _baseProduct8.delivery) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.installationPrice) !== null && _baseProduct$delivery8 !== void 0 ? _baseProduct$delivery8 : (_fieldConfiguration$d3 = fieldConfiguration.delivery) === null || _fieldConfiguration$d3 === void 0 ? void 0 : _fieldConfiguration$d3.defaultInstallationPrice) !== null && _ref5 !== void 0 ? _ref5 : 0
394
- };
395
- }
396
- ismanual = ((_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.calculatedPrice) !== ((_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.addedPrice);
397
- price = {
398
- calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
399
- addedPrice: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.addedPrice,
400
- discountPrice: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.discountedPrice
401
- };
402
- if (!((_baseProduct13 = baseProduct) !== null && _baseProduct13 !== void 0 && _baseProduct13.calculatedPrice)) price = ProductHandlerAbstract.calcPrice(basket === null || basket === void 0 ? void 0 : basket.SummaryPrice, basket === null || basket === void 0 ? void 0 : basket.Discounts, (_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.calculatedPrice, ismanual);
403
-
404
- //to remember what for position was previously set for the classification
265
+ case 17:
266
+ dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
405
267
  oldClassificationData = {};
406
- for (_i = 0; _i < products.data.length; _i++) {
407
- variant = products.data[_i];
268
+ for (i = 0; i < products.data.length; i++) {
269
+ variant = products.data[i];
408
270
  oldClassificationData[variant._id] = {};
409
- for (_key2 in variant) {
410
- if (_key2.startsWith('dc_') && variant[_key2].optionPosition !== undefined) {
411
- oldClassificationData[variant._id][_key2] = variant[_key2];
271
+ for (key in variant) {
272
+ if (key.startsWith('dc_') && variant[key].optionPosition !== undefined) {
273
+ oldClassificationData[variant._id][key] = variant[key];
412
274
  }
413
275
  }
414
276
  }
415
- oldUniqueHash = (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.uniqueHash;
416
- baseData = {
417
- _id: ((_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16._id) || nanoid(),
418
- divaNr: basket === null || basket === void 0 ? void 0 : basket.DivaNr,
419
- modelName: ((_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.modelName) || catalogDataName,
420
- info: ((_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.info) || catalogDataDescription,
421
- technicalDescription: ((_baseProduct19 = baseProduct) === null || _baseProduct19 === void 0 ? void 0 : _baseProduct19.technicalDescription) || orderDescription,
422
- shortTechnicalDescription: (_baseProduct20 = baseProduct) === null || _baseProduct20 === void 0 ? void 0 : _baseProduct20.shortTechnicalDescription,
423
- modelName_locales: ((_baseProduct21 = baseProduct) === null || _baseProduct21 === void 0 ? void 0 : _baseProduct21.modelName_locales) || catalogDataName_locales,
424
- info_locales: ((_baseProduct22 = baseProduct) === null || _baseProduct22 === void 0 ? void 0 : _baseProduct22.info_locales) || catalogDataDescription_locales,
425
- technicalDescription_locales: ((_baseProduct23 = baseProduct) === null || _baseProduct23 === void 0 ? void 0 : _baseProduct23.technicalDescription_locales) || orderDescription_locales,
426
- shortTechnicalDescription_locales: (_baseProduct24 = baseProduct) === null || _baseProduct24 === void 0 ? void 0 : _baseProduct24.shortTechnicalDescription_locales,
427
- orderDescription: orderDescription,
428
- shortDescription: (_baseProduct25 = baseProduct) === null || _baseProduct25 === void 0 ? void 0 : _baseProduct25.shortDescription,
429
- shortDescription_locales: (_baseProduct26 = baseProduct) === null || _baseProduct26 === void 0 ? void 0 : _baseProduct26.shortDescription_locales,
430
- width: (_baseProduct$width = (_baseProduct27 = baseProduct) === null || _baseProduct27 === void 0 ? void 0 : _baseProduct27.width) !== null && _baseProduct$width !== void 0 ? _baseProduct$width : isSet ? (_basket$SetPlannerInf = basket.SetPlannerInfos) === null || _basket$SetPlannerInf === void 0 || (_basket$SetPlannerInf = _basket$SetPlannerInf.BBox) === null || _basket$SetPlannerInf === void 0 ? void 0 : _basket$SetPlannerInf.X : (_basket$OrderSets$0$B = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B === void 0 ? void 0 : _basket$OrderSets$0$B.X,
431
- height: (_baseProduct$height = (_baseProduct28 = baseProduct) === null || _baseProduct28 === void 0 ? void 0 : _baseProduct28.height) !== null && _baseProduct$height !== void 0 ? _baseProduct$height : isSet ? (_basket$SetPlannerInf2 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf2 === void 0 || (_basket$SetPlannerInf2 = _basket$SetPlannerInf2.BBox) === null || _basket$SetPlannerInf2 === void 0 ? void 0 : _basket$SetPlannerInf2.Z : (_basket$OrderSets$0$B2 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B2 === void 0 ? void 0 : _basket$OrderSets$0$B2.Z,
432
- depth: (_baseProduct$depth = (_baseProduct29 = baseProduct) === null || _baseProduct29 === void 0 ? void 0 : _baseProduct29.depth) !== null && _baseProduct$depth !== void 0 ? _baseProduct$depth : isSet ? (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 || (_basket$SetPlannerInf3 = _basket$SetPlannerInf3.BBox) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.Y : (_basket$OrderSets$0$B3 = basket.OrderSets[0].BBox) === null || _basket$OrderSets$0$B3 === void 0 ? void 0 : _basket$OrderSets$0$B3.Y,
433
- weight: (_baseProduct$weight = (_baseProduct30 = baseProduct) === null || _baseProduct30 === void 0 ? void 0 : _baseProduct30.weight) !== null && _baseProduct$weight !== void 0 ? _baseProduct$weight : basket.OrderSets.flatMap(function (os) {
434
- return os.OrderLines.map(function (ol) {
435
- return ol.Weight;
436
- }).filter(function (f) {
437
- return f;
438
- });
439
- }).reduce(function (sum, v) {
440
- return sum + v;
441
- }, 0),
442
- calculatedPrice: price.calculatedPrice,
443
- delivery: delivery,
444
- addedPrice: (_price$addedPrice = price.addedPrice) !== null && _price$addedPrice !== void 0 ? _price$addedPrice : (_baseProduct31 = baseProduct) === null || _baseProduct31 === void 0 ? void 0 : _baseProduct31.addedPrice,
445
- discountedPrice: (_baseProduct32 = baseProduct) === null || _baseProduct32 === void 0 ? void 0 : _baseProduct32.discountedPrice,
446
- percentageDiscount: (_baseProduct33 = baseProduct) === null || _baseProduct33 === void 0 ? void 0 : _baseProduct33.percentageDiscount,
447
- articles: articles,
448
- image: isSet ? (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg3D : basket.OrderSets[0].SetImage,
449
- image2D: isSet ? (_basket$SetPlannerInf5 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf5 === void 0 ? void 0 : _basket$SetPlannerInf5.SetPlannerImg2D : basket.OrderSets[0].Set2DImage,
450
- catalogId: isSet ? basket.OrderSets.map(function (os) {
451
- return os.CatalogGUID;
452
- }) : [basket.OrderSets[0].CatalogGUID],
453
- collection: isSet ? basket.OrderSets.map(function (os) {
454
- return os.AccountName;
455
- }) : [basket.OrderSets[0].AccountName],
456
- collectionId: isSet ? basket.OrderSets.map(function (os) {
457
- return os.CollectionGUID;
458
- }) : [basket.OrderSets[0].CollectionGUID],
459
- catCodex: isSet ? basket.OrderSets.map(function (os) {
460
- return os.CatalogCodex;
461
- }) : [basket.OrderSets[0].CatalogCodex],
462
- supplierId: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
463
- return c.supplierGuid;
464
- }).filter(function (c) {
465
- return c;
466
- }),
467
- retailCatalogNr: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
468
- return c.retailCatalogNr;
469
- }).filter(function (c) {
470
- return c;
471
- }),
472
- supplierArticleNr: basket.OrderSets.flatMap(function (os) {
473
- return os.OrderLines.map(function (ol) {
474
- return ol.ConfigArticleCodex;
475
- }).filter(function (f) {
476
- return f;
477
- });
478
- }).filter(function (f) {
479
- return f;
480
- }),
481
- retailCatalogArticleNr: basket.OrderSets.flatMap(function (os) {
482
- return os.OrderLines.map(function (ol) {
483
- return ol.RetailArticleNr;
484
- }).filter(function (f) {
485
- return f;
486
- });
487
- }).filter(function (f) {
488
- return f;
489
- }),
490
- livingArea: (_baseProduct34 = baseProduct) === null || _baseProduct34 === void 0 ? void 0 : _baseProduct34.livingArea,
491
- mainCategory: (_baseProduct35 = baseProduct) === null || _baseProduct35 === void 0 ? void 0 : _baseProduct35.mainCategory,
492
- subCategory: (_baseProduct36 = baseProduct) === null || _baseProduct36 === void 0 ? void 0 : _baseProduct36.subCategory,
493
- retailerArticleNr: (_baseProduct37 = baseProduct) === null || _baseProduct37 === void 0 ? void 0 : _baseProduct37.retailerArticleNr,
494
- dockingPoints: dockingPoints,
495
- media: (_baseProduct38 = baseProduct) === null || _baseProduct38 === void 0 ? void 0 : _baseProduct38.media,
496
- affiliate: (_baseProduct39 = baseProduct) === null || _baseProduct39 === void 0 ? void 0 : _baseProduct39.affiliate,
497
- brand: (_baseProduct$brand = (_baseProduct40 = baseProduct) === null || _baseProduct40 === void 0 ? void 0 : _baseProduct40.brand) !== null && _baseProduct$brand !== void 0 ? _baseProduct$brand : catalogDataBrand,
277
+ oldUniqueHash = (_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2.uniqueHash;
278
+ baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
279
+ _id: ((_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3._id) || nanoid(),
280
+ 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,
281
+ 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,
282
+ configuration: (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.configuration,
283
+ dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.dockingPoints,
498
284
  currency: DivaUtils.defaultPriceFormat.currency,
499
- organizationId: (_baseProduct$organiza = (_baseProduct41 = baseProduct) === null || _baseProduct41 === void 0 ? void 0 : _baseProduct41.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
285
+ organizationId: (_baseProduct$organiza = (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
500
286
  inheritedOrganizations: [].concat(_toConsumableArray((_this$organization$pa = (_this$organization$pa2 = this.organization.parentOrganizations) === null || _this$organization$pa2 === void 0 ? void 0 : _this$organization$pa2.map(function (o) {
501
287
  return o._id;
502
288
  })) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
503
- created: (_baseProduct42 = baseProduct) === null || _baseProduct42 === void 0 ? void 0 : _baseProduct42.created,
504
- createdBy: (_baseProduct$createdB = (_baseProduct43 = baseProduct) === null || _baseProduct43 === void 0 ? void 0 : _baseProduct43.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
505
- createdBy_displayText: (_baseProduct44 = baseProduct) === null || _baseProduct44 === void 0 ? void 0 : _baseProduct44.createdBy_displayText,
506
- archived: (_baseProduct45 = baseProduct) !== null && _baseProduct45 !== void 0 && _baseProduct45.archived ? (_baseProduct46 = baseProduct) === null || _baseProduct46 === void 0 ? void 0 : _baseProduct46.archived : false,
507
- isTopseller: !!((_baseProduct47 = baseProduct) !== null && _baseProduct47 !== void 0 && _baseProduct47.isTopseller),
508
- orderText: basket.getEKText(true),
509
- classificationInfo: (_baseProduct48 = baseProduct) === null || _baseProduct48 === void 0 ? void 0 : _baseProduct48.classificationInfo,
510
- modelInfoPageWeight: (_baseProduct49 = baseProduct) === null || _baseProduct49 === void 0 ? void 0 : _baseProduct49.modelInfoPageWeight,
511
- uniqueHash: isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
512
- return os.SetHash;
513
- }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject)
514
- };
515
- metaData = basket.OrderSets.reduce(function (prev, curr) {
289
+ createdBy: (_baseProduct$createdB = (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
290
+ createdBy_displayText: (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.createdBy_displayText,
291
+ archived: (_baseProduct11 = baseProduct) !== null && _baseProduct11 !== void 0 && _baseProduct11.archived ? (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.archived : false,
292
+ isTopseller: !!((_baseProduct13 = baseProduct) !== null && _baseProduct13 !== void 0 && _baseProduct13.isTopseller)
293
+ });
294
+ metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
516
295
  return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
517
296
  }, {});
518
- metaData_locales = basket.OrderSets.reduce(function (prev, curr) {
297
+ metaData_locales = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
519
298
  return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
520
299
  }, {});
521
300
  _this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
522
- baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct50 = baseProduct) === null || _baseProduct50 === void 0 ? void 0 : _baseProduct50.customData), customData);
301
+ baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.customData), customData);
523
302
 
524
303
  //add livingarea,maincategorie,subcategorie of loaded product if not exists
525
304
  classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
@@ -535,55 +314,56 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
535
314
  removedProducts = [];
536
315
  optFields = [];
537
316
  initialSelectedFields = [];
538
- if (isSet) {
539
- (_this$LOG = this.LOG) === null || _this$LOG === void 0 || _this$LOG.warn('Variants are currently not supported for set products');
540
- } else {
541
- //iterate all existing variant products and add them to the variants
542
- usedConfigVariants = [];
543
- variantProducts.forEach(function (product) {
544
- var cv;
545
- if (editedBasket) {
546
- var _basket$OrderSets$0$C;
547
- cv = (_basket$OrderSets$0$C = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.find(function (cv) {
548
- return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
549
- });
550
- } else {
551
- var _basket$OrderSets$0$C2;
552
- cv = (_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 ? void 0 : _basket$OrderSets$0$C2.find(function (cv) {
553
- return cv.VariantID == product.variantId;
554
- });
555
- }
317
+ if (!dataByBasket.isSet) {
318
+ _context2.next = 37;
319
+ break;
320
+ }
321
+ throw new Error('Variants are currently not supported for set products');
322
+ case 37:
323
+ //iterate all existing variant products and add them to the variants
324
+ usedVariantIds = [];
325
+ variantProducts.forEach(function (product) {
326
+ var cv;
327
+ if (basket) {
328
+ var _basket$OrderSets$0$C;
329
+ 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) {
330
+ return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
331
+ })) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.VariantID;
332
+ } else {
333
+ cv = product.variantId;
334
+ }
556
335
 
557
- //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
558
- if (product.originDivaNr || cv) {
559
- usedConfigVariants.push(cv);
560
- var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
561
- _variant = _this$initVariant.variant,
562
- modified = _this$initVariant.modified;
563
- variantData.push(_variant);
564
- variantDataModified.push(modified);
565
- } else {
566
- var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
567
- _variant2 = _this$initVariant2.variant,
568
- _modified = _this$initVariant2.modified;
569
- variantData.push(_variant2);
570
- variantDataModified.push(_modified);
571
- removedProducts.push(_variant2._id);
572
- }
573
- });
336
+ //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
337
+ if (product.originDivaNr || cv !== undefined) {
338
+ if (cv !== undefined) usedVariantIds.push(cv);
339
+ var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
340
+ _variant = _this$initVariant.variant,
341
+ modified = _this$initVariant.modified;
342
+ variantData.push(_variant);
343
+ variantDataModified.push(modified);
344
+ } else {
345
+ var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
346
+ _variant2 = _this$initVariant2.variant,
347
+ _modified = _this$initVariant2.modified;
348
+ variantData.push(_variant2);
349
+ variantDataModified.push(_modified);
350
+ removedProducts.push(_variant2._id);
351
+ }
352
+ });
574
353
 
575
- //now iterate all configVariants that are left and add them to the variants (new Products)
576
- newVariantPosition = variantData.filter(function (vd) {
577
- return !removedProducts.includes(vd._id);
578
- });
579
- variantPositions = newVariantPosition.map(function (element) {
580
- return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
581
- });
582
- currentVariantPos = Math.max.apply(Math, _toConsumableArray(variantPositions));
583
- (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 || _basket$OrderSets$0$C3.filter(function (cv) {
584
- return !usedConfigVariants.includes(cv);
354
+ //now iterate all configVariants that are left and add them to the variants (new Products)
355
+ newVariantPosition = variantData.filter(function (vd) {
356
+ return !removedProducts.includes(vd._id);
357
+ });
358
+ variantPositions = newVariantPosition.map(function (element) {
359
+ return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
360
+ });
361
+ currentVariantPos = Math.max.apply(Math, _toConsumableArray(variantPositions));
362
+ if (basket) {
363
+ (_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 || _basket$OrderSets$0$C2.filter(function (cv) {
364
+ return !usedVariantIds.includes(cv.VariantID);
585
365
  }).forEach(function (cv) {
586
- var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, cv, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
366
+ var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv.VariantID, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
587
367
  variant = _this$initVariant3.variant,
588
368
  modified = _this$initVariant3.modified;
589
369
  currentVariantPos = currentVariantPos + 1;
@@ -592,60 +372,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
592
372
  variantDataModified.push(modified);
593
373
  addedProducts.push(variant._id);
594
374
  });
375
+ }
595
376
 
596
- //get opt data
597
- differingOPTs = Object.entries(((_basket$OrderSets$0$F = basket.OrderSets[0].Favorites) === null || _basket$OrderSets$0$F === void 0 ? void 0 : _basket$OrderSets$0$F.VariantValues) || []).filter(function (_ref6) {
598
- var _ref7 = _slicedToArray(_ref6, 2);
599
- _ref7[0];
600
- var value = _ref7[1];
601
- return Object.keys(value).length > 1;
602
- }).map(function (_ref8) {
603
- var _ref9 = _slicedToArray(_ref8, 2),
604
- opt = _ref9[0];
605
- _ref9[1];
606
- return opt.replace('OPT', '');
607
- });
608
- if (basket.OrderSets[0].ConfigVariants) {
609
- optFields = ((_basket$OrderSets$0$C4 = basket.OrderSets[0].ConfigVariants[0]) === null || _basket$OrderSets$0$C4 === void 0 ? void 0 : _basket$OrderSets$0$C4.VariantBasketDatas.map(function (vd) {
610
- var _vd$OPTName;
611
- return {
612
- field: vd.OptionOCD ? vd.OptionOCD.substring(3) : vd.OPT,
613
- type: 'string',
614
- title: (_vd$OPTName = vd.OPTName) !== null && _vd$OPTName !== void 0 ? _vd$OPTName : vd.OPT,
615
- readOnly: true,
616
- fieldType: 'OPT'
617
- };
618
- })) || [];
619
- //remove duplicates
620
- opts = {};
621
- for (_i2 = optFields.length - 1; _i2 >= 0; _i2--) {
622
- if (!opts[optFields[_i2].field]) {
623
- opts[optFields[_i2].field] = true;
624
- } else {
625
- optFields.splice(_i2, 1);
626
- }
377
+ //get opt data
378
+ differingOPTs = Object.entries(((_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 || (_baseProduct15 = _baseProduct15.configuration) === null || _baseProduct15 === void 0 || (_baseProduct15 = _baseProduct15.OrderSets[0].Favorites) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.VariantValues) || []).filter(function (_ref3) {
379
+ var _ref4 = _slicedToArray(_ref3, 2);
380
+ _ref4[0];
381
+ var value = _ref4[1];
382
+ return Object.keys(value).length > 1;
383
+ }).map(function (_ref5) {
384
+ var _ref6 = _slicedToArray(_ref5, 2),
385
+ opt = _ref6[0];
386
+ _ref6[1];
387
+ return opt.replace('OPT', '');
388
+ });
389
+ if (variantData) {
390
+ 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) {
391
+ var _catalogData, _vd$OptionOCD, _option$Name;
392
+ 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];
393
+ return {
394
+ field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
395
+ type: 'string',
396
+ title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
397
+ readOnly: true,
398
+ fieldType: 'OPT'
399
+ };
400
+ })) || [];
401
+ //remove duplicates
402
+ opts = {};
403
+ for (_i = optFields.length - 1; _i >= 0; _i--) {
404
+ if (!opts[optFields[_i].field]) {
405
+ opts[optFields[_i].field] = true;
406
+ } else {
407
+ optFields.splice(_i, 1);
627
408
  }
628
409
  }
629
-
630
- //mark all fields where there are differences between the variants as initaly selected
631
- initialSelectedFields = optFields.filter(function (f) {
632
- return differingOPTs.includes(f.field);
633
- });
634
- ProductHandlerAbstract.baseDataFields.forEach(function (field) {
635
- if (variantDataModified.some(function (mod) {
636
- return mod[field.field];
637
- })) {
638
- initialSelectedFields.push(field);
639
- }
640
- });
641
- customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
642
- if (variantDataModified.some(function (mod) {
643
- return mod['customData.' + f.field];
644
- })) {
645
- initialSelectedFields.push(f);
646
- }
647
- });
648
410
  }
411
+
412
+ //mark all fields where there are differences between the variants as initaly selected
413
+ initialSelectedFields = optFields.filter(function (f) {
414
+ return differingOPTs.includes(f.field);
415
+ });
416
+ ProductHandlerAbstract.baseDataFields.forEach(function (field) {
417
+ if (variantDataModified.some(function (mod) {
418
+ return mod[field.field];
419
+ })) {
420
+ initialSelectedFields.push(field);
421
+ }
422
+ });
423
+ customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
424
+ if (variantDataModified.some(function (mod) {
425
+ return mod['customData.' + f.field];
426
+ })) {
427
+ initialSelectedFields.push(f);
428
+ }
429
+ });
649
430
  initializedOptMap = this.initOpvMap(optFields, classificationConfig, optMap);
650
431
  return _context2.abrupt("return", {
651
432
  baseData: baseData,
@@ -653,6 +434,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
653
434
  optFields: optFields,
654
435
  initialSelectedFields: initialSelectedFields,
655
436
  variantData: variantData,
437
+ catalogData: catalogData,
656
438
  optClassMap: initializedOptMap,
657
439
  addedProducts: products.total ? addedProducts : [],
658
440
  removedProducts: products.total ? removedProducts : [],
@@ -666,7 +448,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
666
448
  availableLanguages: availableLanguages,
667
449
  currentLang: currentLang
668
450
  });
669
- case 47:
451
+ case 50:
670
452
  case "end":
671
453
  return _context2.stop();
672
454
  }
@@ -677,6 +459,191 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
677
459
  }
678
460
  return loadProducts;
679
461
  }())
462
+ }, {
463
+ key: "getProductDataByBasket",
464
+ value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
465
+ var dataByBasket = {};
466
+ var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
467
+ dataByBasket.isSet = isSet;
468
+ if (basket) {
469
+ dataByBasket.dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
470
+ dataByBasket.technicalDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
471
+ return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
472
+ }, '') : basket.OrderSets[0].VariantDescription;
473
+ dataByBasket.technicalDescription_locales = basket.OrderSets[0].VariantDescription_locales;
474
+ dataByBasket.modelName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
475
+ return c.name;
476
+ }).filter(function (name) {
477
+ return name;
478
+ }).join(' - ');
479
+ dataByBasket.catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
480
+ return c.brand;
481
+ }).filter(function (brand) {
482
+ return brand;
483
+ }).join(' - ');
484
+ dataByBasket.info = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
485
+ return c.description;
486
+ }).filter(function (description) {
487
+ return description;
488
+ }).join('<br/>');
489
+ dataByBasket.modelName_locales = {};
490
+ for (var i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
491
+ var c = catalogData[i];
492
+ for (var key in c.name_locales) {
493
+ if (!dataByBasket.modelName_locales[key]) {
494
+ dataByBasket.modelName_locales[key] = c.name_locales[key];
495
+ } else {
496
+ dataByBasket.modelName_locales[key] = dataByBasket.modelName_locales[key] + ' - ' + c.name_locales[key];
497
+ }
498
+ }
499
+ dataByBasket.info_locales = {};
500
+ for (var _key in c.description_locales) {
501
+ if (!dataByBasket.info_locales[_key]) {
502
+ dataByBasket.info_locales[_key] = c.description_locales[_key];
503
+ } else {
504
+ dataByBasket.info_locales[_key] = dataByBasket.info_locales[_key] + ' - ' + c.description_locales[_key];
505
+ }
506
+ }
507
+ }
508
+ if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
509
+ var _baseProduct$delivery, _baseProduct$delivery2, _baseProduct$delivery3, _baseProduct$delivery4, _baseProduct$delivery5, _baseProduct$delivery6, _baseProduct$delivery7, _baseProduct$delivery8, _baseProduct$delivery9, _baseProduct$delivery10, _ref7, _baseProduct$delivery11, _baseProduct$delivery12, _fieldConfiguration$d, _ref8, _baseProduct$delivery13, _baseProduct$delivery14, _fieldConfiguration$d2, _ref9, _baseProduct$delivery15, _baseProduct$delivery16, _fieldConfiguration$d3;
510
+ var config = {
511
+ addedPackageWeight: 0,
512
+ addedPackageHeight: 0,
513
+ addedPackageWidth: 0,
514
+ addedPackageDepth: 0,
515
+ defaultDeliveryTime: 0,
516
+ defaultDeliveryPrice: 0,
517
+ defaultInstallationPrice: 0
518
+ };
519
+ if (typeof fieldConfiguration.delivery != 'boolean') {
520
+ config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
521
+ }
522
+ var packages = [];
523
+ basket.OrderSets.flatMap(function (os) {
524
+ return os.OrderLines;
525
+ }).forEach(function (ol) {
526
+ packages.push({
527
+ height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
528
+ width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
529
+ depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
530
+ weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
531
+ });
532
+ });
533
+ dataByBasket.delivery = {
534
+ estPackages: packages,
535
+ 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,
536
+ estMaxPackageWeight: (_baseProduct$delivery3 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery4 = baseProduct.delivery) === null || _baseProduct$delivery4 === void 0 ? void 0 : _baseProduct$delivery4.estMaxPackageWeight) !== null && _baseProduct$delivery3 !== void 0 ? _baseProduct$delivery3 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
537
+ return p.weight;
538
+ }).filter(function (f) {
539
+ return f;
540
+ })))),
541
+ estMaxPackageHeight: (_baseProduct$delivery5 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery6 = baseProduct.delivery) === null || _baseProduct$delivery6 === void 0 ? void 0 : _baseProduct$delivery6.estMaxPackageHeight) !== null && _baseProduct$delivery5 !== void 0 ? _baseProduct$delivery5 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
542
+ return p.height;
543
+ }).filter(function (f) {
544
+ return f;
545
+ })))),
546
+ estMaxPackageWidth: (_baseProduct$delivery7 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery8 = baseProduct.delivery) === null || _baseProduct$delivery8 === void 0 ? void 0 : _baseProduct$delivery8.estMaxPackageWidth) !== null && _baseProduct$delivery7 !== void 0 ? _baseProduct$delivery7 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
547
+ return p.width;
548
+ }).filter(function (f) {
549
+ return f;
550
+ })))),
551
+ estMaxPackageDepth: (_baseProduct$delivery9 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery10 = baseProduct.delivery) === null || _baseProduct$delivery10 === void 0 ? void 0 : _baseProduct$delivery10.estMaxPackageDepth) !== null && _baseProduct$delivery9 !== void 0 ? _baseProduct$delivery9 : Math.max.apply(Math, [0].concat(_toConsumableArray(packages.map(function (p) {
552
+ return p.depth;
553
+ }).filter(function (f) {
554
+ return f;
555
+ })))),
556
+ deliveryTime: (_ref7 = (_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 && _ref7 !== void 0 ? _ref7 : 0,
557
+ deliveryPrice: (_ref8 = (_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 && _ref8 !== void 0 ? _ref8 : 0,
558
+ installationPrice: (_ref9 = (_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 && _ref9 !== void 0 ? _ref9 : 0
559
+ };
560
+ }
561
+ var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
562
+ var price = {
563
+ calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
564
+ addedPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice,
565
+ discountPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.discountedPrice
566
+ };
567
+ if (!(baseProduct !== null && baseProduct !== void 0 && baseProduct.calculatedPrice)) {
568
+ 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);
569
+ }
570
+ dataByBasket.price = price;
571
+ dataByBasket.calculatedPrice = price.calculatedPrice;
572
+ if (isSet) {
573
+ var _basket$SetPlannerInf, _basket$SetPlannerInf2, _basket$OrderSets$0$B, _basket$SetPlannerInf3, _basket$SetPlannerInf4;
574
+ 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;
575
+ 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;
576
+ 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;
577
+ dataByBasket.image = (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.SetPlannerImg3D;
578
+ dataByBasket.image2D = (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg2D;
579
+ dataByBasket.catalogId = basket.OrderSets.map(function (os) {
580
+ return os.CatalogGUID;
581
+ });
582
+ dataByBasket.collection = basket.OrderSets.map(function (os) {
583
+ return os.AccountName;
584
+ });
585
+ dataByBasket.collectionId = basket.OrderSets.map(function (os) {
586
+ return os.CollectionGUID;
587
+ });
588
+ dataByBasket.catCodex = basket.OrderSets.map(function (os) {
589
+ return os.CatalogCodex;
590
+ });
591
+ } else {
592
+ var _basket$OrderSets$0$B2, _basket$OrderSets$0$B3, _basket$OrderSets$0$B4;
593
+ 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;
594
+ 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;
595
+ 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;
596
+ dataByBasket.image = basket.OrderSets[0].SetImage;
597
+ dataByBasket.image2D = basket.OrderSets[0].Set2DImage;
598
+ dataByBasket.catalogId = [basket.OrderSets[0].CatalogGUID];
599
+ dataByBasket.collection = [basket.OrderSets[0].AccountName];
600
+ dataByBasket.collectionId = [basket.OrderSets[0].CollectionGUID];
601
+ dataByBasket.catCodex = [basket.OrderSets[0].CatalogCodex];
602
+ }
603
+ dataByBasket.weight = basket === null || basket === void 0 ? void 0 : basket.OrderSets.flatMap(function (os) {
604
+ return os.OrderLines.map(function (ol) {
605
+ return ol.Weight;
606
+ }).filter(function (f) {
607
+ return f;
608
+ });
609
+ }).reduce(function (sum, v) {
610
+ return sum + v;
611
+ }, 0);
612
+ dataByBasket.supplierId = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
613
+ return c.supplierGuid;
614
+ }).filter(function (c) {
615
+ return c;
616
+ });
617
+ dataByBasket.retailCatalogNr = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
618
+ return c.retailCatalogNr;
619
+ }).filter(function (c) {
620
+ return c;
621
+ });
622
+ dataByBasket.supplierArticleNr = basket.OrderSets.flatMap(function (os) {
623
+ return os.OrderLines.map(function (ol) {
624
+ return ol.ConfigArticleCodex;
625
+ }).filter(function (f) {
626
+ return f;
627
+ });
628
+ }).filter(function (f) {
629
+ return f;
630
+ });
631
+ dataByBasket.retailCatalogArticleNr = basket.OrderSets.flatMap(function (os) {
632
+ return os.OrderLines.map(function (ol) {
633
+ return ol.RetailArticleNr;
634
+ }).filter(function (f) {
635
+ return f;
636
+ });
637
+ }).filter(function (f) {
638
+ return f;
639
+ });
640
+ dataByBasket.orderText = basket.getEKText(true);
641
+ dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
642
+ return os.SetHash;
643
+ }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
644
+ }
645
+ return dataByBasket;
646
+ }
680
647
  }, {
681
648
  key: "checkAndAddClassificationConfigCategories",
682
649
  value: function checkAndAddClassificationConfigCategories(baseProduct, classificationConfig) {
@@ -767,11 +734,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
767
734
  value: function () {
768
735
  var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref11) {
769
736
  var _this3 = this;
770
- var baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref11$oldClassificat, oldClassificationData, originProductId, products, originProduct, sapEinaLifNr, sapEineEkgrp, result, _this$closeModal, _originProduct$percen, _originProduct$discou, _baseData$variantId, _originProduct$create, _originProduct$create2, _originProduct$create3, baseProduct, j, mediaRef, _this$openModal, _this$t, _j, _this$openModal2, _this$t2, savedMedia, _loop, _j2;
737
+ var basket, 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;
771
738
  return _regeneratorRuntime.wrap(function _callee3$(_context4) {
772
739
  while (1) switch (_context4.prev = _context4.next) {
773
740
  case 0:
774
- baseData = _ref11.baseData, classificationData = _ref11.classificationData, variantData = _ref11.variantData, removedProducts = _ref11.removedProducts, removedMedia = _ref11.removedMedia, classificationFields = _ref11.classificationFields, fieldConfiguration = _ref11.fieldConfiguration, optMap = _ref11.optMap, _ref11$oldClassificat = _ref11.oldClassificationData, oldClassificationData = _ref11$oldClassificat === void 0 ? {} : _ref11$oldClassificat, originProductId = _ref11.originProductId;
741
+ basket = _ref11.basket, 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;
775
742
  products = [];
776
743
  originProduct = undefined;
777
744
  if (!originProductId) {
@@ -850,11 +817,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
850
817
  var value = _ref17[1];
851
818
  return value;
852
819
  }).forEach(function (_ref18) {
853
- var _baseProduct51;
820
+ var _baseProduct16;
854
821
  var _ref19 = _slicedToArray(_ref18, 2),
855
822
  key = _ref19[0],
856
823
  value = _ref19[1];
857
- return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct51 = baseProduct["dc_".concat(key)]) !== null && _baseProduct51 !== void 0 ? _baseProduct51 : {}), {}, {
824
+ return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct16 = baseProduct["dc_".concat(key)]) !== null && _baseProduct16 !== void 0 ? _baseProduct16 : {}), {}, {
858
825
  opt: value.field
859
826
  });
860
827
  });
@@ -939,7 +906,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
939
906
  baseProduct.parent = baseProduct._id;
940
907
  }
941
908
  _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
942
- var _originProduct;
909
+ var _originProduct, _basket$getProductCon2;
943
910
  var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, product, _this3$openModal, _this3$t, k, _savedMedia;
944
911
  return _regeneratorRuntime.wrap(function _loop$(_context3) {
945
912
  while (1) switch (_context3.prev = _context3.next) {
@@ -1049,6 +1016,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1049
1016
  modelName_locales: vd.modelName_locales,
1050
1017
  shortDescription_locales: vd.shortDescription_locales,
1051
1018
  width: vd.width,
1019
+ 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,
1052
1020
  height: vd.height,
1053
1021
  depth: vd.depth,
1054
1022
  calculatedPrice: vd.calculatedPrice,
@@ -1059,7 +1027,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1059
1027
  variantPosition: variantPos,
1060
1028
  image: vd.image,
1061
1029
  image2D: vd.image2D,
1062
- articles: vd.articles,
1063
1030
  affiliate: vd.affiliate,
1064
1031
  originDivaNr: vd.originDivaNr,
1065
1032
  organizationId: baseProduct.organizationId,
@@ -1161,43 +1128,66 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1161
1128
  }
1162
1129
  }
1163
1130
  }, {
1164
- key: "saveBasketAndProducts",
1131
+ key: "saveProducts",
1165
1132
  value: function () {
1166
- var _saveBasketAndProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref28) {
1167
- var products, removedProducts, basket, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1133
+ var _saveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref28) {
1134
+ var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1168
1135
  return _regeneratorRuntime.wrap(function _callee4$(_context5) {
1169
1136
  while (1) switch (_context5.prev = _context5.next) {
1170
1137
  case 0:
1171
- products = _ref28.products, removedProducts = _ref28.removedProducts, basket = _ref28.basket, awaitPDF = _ref28.awaitPDF;
1138
+ products = _ref28.products, removedProducts = _ref28.removedProducts, awaitPDF = _ref28.awaitPDF;
1172
1139
  if (this.jwt) {
1173
1140
  _context5.next = 3;
1174
1141
  break;
1175
1142
  }
1176
1143
  throw new Error('jwt not set');
1177
1144
  case 3:
1178
- _context5.prev = 3;
1179
- _context5.next = 6;
1180
- return this.apiSaveBasketAndProducts(this.catalogService, this.jwt, products, awaitPDF, basket, removedProducts);
1181
- case 6:
1145
+ this.setFirstVariant(products);
1146
+ _context5.prev = 4;
1147
+ _context5.next = 7;
1148
+ return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
1149
+ case 7:
1182
1150
  savedProducts = _context5.sent;
1183
1151
  (_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
1184
1152
  return _context5.abrupt("return", savedProducts);
1185
- case 11:
1186
- _context5.prev = 11;
1187
- _context5.t0 = _context5["catch"](3);
1153
+ case 12:
1154
+ _context5.prev = 12;
1155
+ _context5.t0 = _context5["catch"](4);
1188
1156
  (_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
1189
1157
  throw new Error(_context5.t0.message);
1190
- case 15:
1158
+ case 16:
1191
1159
  case "end":
1192
1160
  return _context5.stop();
1193
1161
  }
1194
- }, _callee4, this, [[3, 11]]);
1162
+ }, _callee4, this, [[4, 12]]);
1195
1163
  }));
1196
- function saveBasketAndProducts(_x4) {
1197
- return _saveBasketAndProducts.apply(this, arguments);
1164
+ function saveProducts(_x4) {
1165
+ return _saveProducts.apply(this, arguments);
1198
1166
  }
1199
- return saveBasketAndProducts;
1200
- }()
1167
+ return saveProducts;
1168
+ }() //variant with lowest variantId gets a flag for filtering purposes
1169
+ }, {
1170
+ key: "setFirstVariant",
1171
+ value: function setFirstVariant(products) {
1172
+ var _variants$;
1173
+ products.map(function (p) {
1174
+ return p.firstVariant = false;
1175
+ });
1176
+ var variants = products.filter(function (p) {
1177
+ return p.variantId !== undefined;
1178
+ });
1179
+ if (!(variants !== null && variants !== void 0 && variants.length)) return;
1180
+ var firstVariant = variants[0];
1181
+ var lowestId = (_variants$ = variants[0]) === null || _variants$ === void 0 ? void 0 : _variants$.variantId;
1182
+ for (var i = 0; i < variants.length; i++) {
1183
+ if (lowestId > variants[i].variantId) {
1184
+ lowestId = variants[i].variantId;
1185
+ firstVariant = variants[i];
1186
+ }
1187
+ }
1188
+ firstVariant.firstVariant = true;
1189
+ }
1190
+
1201
1191
  /**
1202
1192
  * Calculates the inital state of one varinat data entry
1203
1193
  *
@@ -1207,11 +1197,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1207
1197
  */
1208
1198
  }, {
1209
1199
  key: "initVariant",
1210
- value: function initVariant(baseData, baseClassification, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1211
- var _cv$VariantDescriptio, _cv$VariantDescriptio2, _baseData$articles, _classificationFields;
1212
- var _this$parseClassifica = this.parseClassificationFields(product),
1200
+ value: function initVariant(baseData, baseClassification, availableLanguages, catalogData, basket, cv, variantProduct, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1201
+ var _basket$OrderSets$0$C3, _ref30, _variantProduct$confi, _classificationFields;
1202
+ var _this$parseClassifica = this.parseClassificationFields(variantProduct),
1213
1203
  parsedProduct = _this$parseClassifica.product;
1214
- var _ref29 = cv || {},
1204
+ var _ref29 = (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) {
1205
+ return vd.VariantID === cv;
1206
+ })) || {
1207
+ VariantBasketDatas: ProductHandlerAbstract.getVariantBasketDatasByOrderlines((_ref30 = variantProduct === null || variantProduct === void 0 || (_variantProduct$confi = variantProduct.configuration) === null || _variantProduct$confi === void 0 ? void 0 : _variantProduct$confi.OrderSets[0].OrderLines) !== null && _ref30 !== void 0 ? _ref30 : [], catalogData)
1208
+ },
1215
1209
  VariantID = _ref29.VariantID,
1216
1210
  SetImage = _ref29.SetImage,
1217
1211
  Set2DImage = _ref29.Set2DImage,
@@ -1222,27 +1216,29 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1222
1216
  MetaData_locales = _ref29.MetaData_locales,
1223
1217
  Variant = _ref29.Variant,
1224
1218
  SetHash = _ref29.SetHash,
1225
- Diva3DProject = _ref29.Diva3DProject;
1219
+ Diva3DProject = _ref29.Diva3DProject,
1220
+ VariantDescription_locales = _ref29.VariantDescription_locales,
1221
+ VariantDescription = _ref29.VariantDescription;
1226
1222
  //total and summary price are currently not avialable per varinat,
1227
1223
  //most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
1228
1224
  //we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
1229
1225
 
1230
- var ismanual = (product === null || product === void 0 ? void 0 : product.calculatedPrice) !== (product === null || product === void 0 ? void 0 : product.addedPrice);
1231
- var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], product === null || product === void 0 ? void 0 : product.calculatedPrice, ismanual);
1226
+ var ismanual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice);
1227
+ var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice, ismanual);
1232
1228
  var addedPrice;
1233
1229
  if (SetPrice == baseData.calculatedPrice) {
1234
1230
  addedPrice = baseData.addedPrice;
1235
1231
  } else {
1236
1232
  addedPrice = price.calculatedPrice;
1237
1233
  }
1238
- var isManual = (product === null || product === void 0 ? void 0 : product.addedPrice) !== (product === null || product === void 0 ? void 0 : product.calculatedPrice);
1234
+ var isManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice);
1239
1235
  if (isManual) {
1240
- addedPrice = product === null || product === void 0 ? void 0 : product.addedPrice;
1236
+ addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1241
1237
  }
1242
- var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, product, classificationConfig, customBaseFields),
1238
+ var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1243
1239
  classificationData = _this$parseMetaDataAn2.classificationData,
1244
1240
  customData = _this$parseMetaDataAn2.customData;
1245
- customData = _objectSpread(_objectSpread({}, product === null || product === void 0 ? void 0 : product.customData), customData);
1241
+ customData = _objectSpread(_objectSpread({}, variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.customData), customData);
1246
1242
  var variant = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseData), {}, {
1247
1243
  media: undefined,
1248
1244
  //set media undefined, just in case "baseData" has media but "parsedProduct" does not have media to overwrite it
@@ -1252,8 +1248,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1252
1248
  width: BBox === null || BBox === void 0 ? void 0 : BBox.X,
1253
1249
  height: BBox === null || BBox === void 0 ? void 0 : BBox.Z,
1254
1250
  depth: BBox === null || BBox === void 0 ? void 0 : BBox.Y,
1255
- technicalDescription: (_cv$VariantDescriptio = cv === null || cv === void 0 ? void 0 : cv.VariantDescription) !== null && _cv$VariantDescriptio !== void 0 ? _cv$VariantDescriptio : baseData.technicalDescription,
1256
- technicalDescription_locales: (_cv$VariantDescriptio2 = cv === null || cv === void 0 ? void 0 : cv.VariantDescription_locales) !== null && _cv$VariantDescriptio2 !== void 0 ? _cv$VariantDescriptio2 : baseData.technicalDescription_locales
1251
+ technicalDescription: VariantDescription !== null && VariantDescription !== void 0 ? VariantDescription : baseData.technicalDescription,
1252
+ technicalDescription_locales: VariantDescription_locales !== null && VariantDescription_locales !== void 0 ? VariantDescription_locales : baseData.technicalDescription_locales
1257
1253
  }, parsedProduct), {}, {
1258
1254
  customData: customData
1259
1255
  }, classificationData), {}, {
@@ -1262,18 +1258,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1262
1258
  //only if cv is not defined fallback to the values in product
1263
1259
  addedPrice: addedPrice,
1264
1260
  calculatedPrice: price.calculatedPrice,
1265
- articles: VariantBasketDatas ? (_baseData$articles = baseData.articles) === null || _baseData$articles === void 0 ? void 0 : _baseData$articles.map(function (art) {
1266
- return _objectSpread(_objectSpread({}, art), {}, {
1267
- variantValues: VariantBasketDatas === null || VariantBasketDatas === void 0 ? void 0 : VariantBasketDatas.filter(function (vb) {
1268
- return !vb.IsDescribingState;
1269
- }).map(function (vb) {
1270
- return {
1271
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
1272
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
1273
- };
1274
- })
1275
- });
1276
- }) : parsedProduct.articles,
1277
1261
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1278
1262
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1279
1263
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1363,10 +1347,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1363
1347
  key: "initOpvMap",
1364
1348
  value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
1365
1349
  var optMap = {};
1366
- Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref30) {
1367
- var _ref31 = _slicedToArray(_ref30, 2),
1368
- c = _ref31[0],
1369
- optMapping = _ref31[1].optMapping;
1350
+ Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref31) {
1351
+ var _ref32 = _slicedToArray(_ref31, 2),
1352
+ c = _ref32[0],
1353
+ optMapping = _ref32[1].optMapping;
1370
1354
  var optField;
1371
1355
  if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
1372
1356
  optField = optFields.find(function (opt) {
@@ -1427,16 +1411,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1427
1411
  var _classificationConfig;
1428
1412
  //add metadata defined as classification to classificationdata
1429
1413
  var metadataAsClassification = {};
1430
- Object.entries(metaData).filter(function (_ref32) {
1431
- var _ref33 = _slicedToArray(_ref32, 1),
1432
- key = _ref33[0];
1414
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref33) {
1415
+ var _ref34 = _slicedToArray(_ref33, 1),
1416
+ key = _ref34[0];
1433
1417
  return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
1434
1418
  })
1435
1419
  //if it is defiend as multi field, use full array otherwise only first element of array
1436
- .forEach(function (_ref34) {
1437
- var _ref35 = _slicedToArray(_ref34, 2),
1438
- key = _ref35[0],
1439
- value = _ref35[1];
1420
+ .forEach(function (_ref35) {
1421
+ var _ref36 = _slicedToArray(_ref35, 2),
1422
+ key = _ref36[0],
1423
+ value = _ref36[1];
1440
1424
  return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
1441
1425
  });
1442
1426
 
@@ -1446,14 +1430,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1446
1430
  optMap = _this$parseClassifica2.optMap;
1447
1431
  var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
1448
1432
  var customData = {};
1449
- Object.entries(metaData).filter(function (_ref36) {
1450
- var _ref37 = _slicedToArray(_ref36, 1),
1451
- key = _ref37[0];
1433
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref37) {
1434
+ var _ref38 = _slicedToArray(_ref37, 1),
1435
+ key = _ref38[0];
1452
1436
  return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
1453
- }).forEach(function (_ref38) {
1454
- var _ref39 = _slicedToArray(_ref38, 2),
1455
- key = _ref39[0],
1456
- value = _ref39[1];
1437
+ }).forEach(function (_ref39) {
1438
+ var _ref40 = _slicedToArray(_ref39, 2),
1439
+ key = _ref40[0],
1440
+ value = _ref40[1];
1457
1441
  var langs = {};
1458
1442
  if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
1459
1443
  for (var i = 0; i < metaData_locales[key].length; i++) {
@@ -1485,19 +1469,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1485
1469
 
1486
1470
  //repare customData
1487
1471
  //if it is defiend as multi field, use full array otherwise only first element of array
1488
- Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref40) {
1489
- var _ref41 = _slicedToArray(_ref40, 1),
1490
- key = _ref41[0];
1472
+ Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref41) {
1473
+ var _ref42 = _slicedToArray(_ref41, 1),
1474
+ key = _ref42[0];
1491
1475
  return customData[key] != undefined;
1492
- }).forEach(function (_ref42) {
1493
- var _ref43 = _slicedToArray(_ref42, 2),
1494
- key = _ref43[0],
1495
- value = _ref43[1];
1476
+ }).forEach(function (_ref43) {
1477
+ var _ref44 = _slicedToArray(_ref43, 2),
1478
+ key = _ref44[0],
1479
+ value = _ref44[1];
1496
1480
  if (value.multi && !Array.isArray(customData[key])) {
1497
1481
  customData[key] = [customData[key]];
1498
1482
  } else if (!value.multi && Array.isArray(customData[key])) {
1499
- var _key3;
1500
- customData[key] = (_key3 = customData[key]) === null || _key3 === void 0 ? void 0 : _key3[0];
1483
+ var _key2;
1484
+ customData[key] = (_key2 = customData[key]) === null || _key2 === void 0 ? void 0 : _key2[0];
1501
1485
  }
1502
1486
  });
1503
1487
  return {
@@ -1622,52 +1606,172 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1622
1606
  }
1623
1607
  return apiGetProducts;
1624
1608
  }()
1609
+ }, {
1610
+ key: "apiGetCatalogData",
1611
+ value: function () {
1612
+ var _apiGetCatalogData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(catalogCodex, language, accountId) {
1613
+ var _response$CollectionG, _response$Properties, _response$Properties2;
1614
+ var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
1615
+ return _regeneratorRuntime.wrap(function _callee7$(_context8) {
1616
+ while (1) switch (_context8.prev = _context8.next) {
1617
+ case 0:
1618
+ _context8.next = 2;
1619
+ return this.apiAccountLogin(accountId);
1620
+ case 2:
1621
+ currentAccountSessionId = _context8.sent;
1622
+ if (currentAccountSessionId) {
1623
+ _context8.next = 5;
1624
+ break;
1625
+ }
1626
+ return _context8.abrupt("return");
1627
+ case 5:
1628
+ fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
1629
+ _context8.next = 8;
1630
+ return fetch(fullUrl, {
1631
+ headers: {
1632
+ sessionGuid: currentAccountSessionId
1633
+ }
1634
+ }).then(function (res) {
1635
+ if (res.status !== 200) {
1636
+ throw new Error('Collections not loaded.');
1637
+ }
1638
+ return res.json();
1639
+ });
1640
+ case 8:
1641
+ response = _context8.sent;
1642
+ if (!response.Error) {
1643
+ _context8.next = 11;
1644
+ break;
1645
+ }
1646
+ throw new Error(response.Error);
1647
+ case 11:
1648
+ actCatalogInfoData = {
1649
+ lang: language,
1650
+ guid: response.GUID,
1651
+ name: response.Name,
1652
+ name_locales: response.Name_locales,
1653
+ codex: catalogCodex,
1654
+ accountLogo: response.AccountLogo,
1655
+ description: response.LongDescription,
1656
+ description_locales: response.LongDescription_locales,
1657
+ hasPlanner: response.HasIDMPlanner == 'True',
1658
+ brand: response.Brandname,
1659
+ supplierGuid: response.SupplierGUID,
1660
+ retailCatalogNr: response.RetailCatalogNr,
1661
+ accountGuid: (_response$CollectionG = response.CollectionGuid) !== null && _response$CollectionG !== void 0 ? _response$CollectionG : response.AccountGuid,
1662
+ options: response.Options,
1663
+ optionValues: response.Optionvalues,
1664
+ currency: response.currency,
1665
+ has3D: !!((_response$Properties = response.Properties) !== null && _response$Properties !== void 0 && (_response$Properties = _response$Properties.find(function (p) {
1666
+ return p.Codex == 'DIVA3D_RENDERING';
1667
+ })) !== null && _response$Properties !== void 0 && _response$Properties.Value),
1668
+ images: [],
1669
+ documents: [],
1670
+ accountSessionId: response.AccountSessionGuid,
1671
+ arReady: !!((_response$Properties2 = response.Properties) !== null && _response$Properties2 !== void 0 && (_response$Properties2 = _response$Properties2.find(function (p) {
1672
+ return p.Codex == 'DIVA3D_AR_READY';
1673
+ })) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
1674
+ };
1675
+ return _context8.abrupt("return", actCatalogInfoData);
1676
+ case 13:
1677
+ case "end":
1678
+ return _context8.stop();
1679
+ }
1680
+ }, _callee7, this);
1681
+ }));
1682
+ function apiGetCatalogData(_x9, _x10, _x11) {
1683
+ return _apiGetCatalogData.apply(this, arguments);
1684
+ }
1685
+ return apiGetCatalogData;
1686
+ }()
1687
+ }, {
1688
+ key: "apiAccountLogin",
1689
+ value: function () {
1690
+ var _apiAccountLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(accountId) {
1691
+ var fullUrl, response;
1692
+ return _regeneratorRuntime.wrap(function _callee8$(_context9) {
1693
+ while (1) switch (_context9.prev = _context9.next) {
1694
+ case 0:
1695
+ fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
1696
+ _context9.t0 = fetch;
1697
+ _context9.t1 = fullUrl;
1698
+ _context9.next = 5;
1699
+ return this.sessionGuid;
1700
+ case 5:
1701
+ _context9.t2 = _context9.sent;
1702
+ _context9.t3 = {
1703
+ sessionGuid: _context9.t2
1704
+ };
1705
+ _context9.t4 = {
1706
+ headers: _context9.t3
1707
+ };
1708
+ _context9.next = 10;
1709
+ return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
1710
+ if (res.status !== 200) {
1711
+ throw new Error('Collections not loaded.');
1712
+ }
1713
+ return res.json();
1714
+ });
1715
+ case 10:
1716
+ response = _context9.sent;
1717
+ return _context9.abrupt("return", response.SessionGUID);
1718
+ case 12:
1719
+ case "end":
1720
+ return _context9.stop();
1721
+ }
1722
+ }, _callee8, this);
1723
+ }));
1724
+ function apiAccountLogin(_x12) {
1725
+ return _apiAccountLogin.apply(this, arguments);
1726
+ }
1727
+ return apiAccountLogin;
1728
+ }()
1625
1729
  }, {
1626
1730
  key: "apiGetProductVariants",
1627
1731
  value: function () {
1628
- var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, full) {
1732
+ var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, full) {
1629
1733
  var _res2;
1630
1734
  var fullUrl, res, resData;
1631
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
1632
- while (1) switch (_context8.prev = _context8.next) {
1735
+ return _regeneratorRuntime.wrap(function _callee9$(_context10) {
1736
+ while (1) switch (_context10.prev = _context10.next) {
1633
1737
  case 0:
1634
1738
  fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
1635
- _context8.prev = 1;
1636
- _context8.next = 4;
1739
+ _context10.prev = 1;
1740
+ _context10.next = 4;
1637
1741
  return axios.get(fullUrl, {
1638
1742
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1639
1743
  'Content-Type': 'application/json'
1640
1744
  })
1641
1745
  });
1642
1746
  case 4:
1643
- res = _context8.sent;
1644
- _context8.next = 7;
1747
+ res = _context10.sent;
1748
+ _context10.next = 7;
1645
1749
  return res.data;
1646
1750
  case 7:
1647
- resData = _context8.sent;
1648
- _context8.next = 13;
1751
+ resData = _context10.sent;
1752
+ _context10.next = 13;
1649
1753
  break;
1650
1754
  case 10:
1651
- _context8.prev = 10;
1652
- _context8.t0 = _context8["catch"](1);
1755
+ _context10.prev = 10;
1756
+ _context10.t0 = _context10["catch"](1);
1653
1757
  throw new Error('Could not get existing products', {
1654
- cause: _context8.t0
1758
+ cause: _context10.t0
1655
1759
  });
1656
1760
  case 13:
1657
1761
  if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
1658
- _context8.next = 15;
1762
+ _context10.next = 15;
1659
1763
  break;
1660
1764
  }
1661
- return _context8.abrupt("return", resData);
1765
+ return _context10.abrupt("return", resData);
1662
1766
  case 15:
1663
1767
  throw new Error(resData.error);
1664
1768
  case 16:
1665
1769
  case "end":
1666
- return _context8.stop();
1770
+ return _context10.stop();
1667
1771
  }
1668
- }, _callee7, this, [[1, 10]]);
1772
+ }, _callee9, this, [[1, 10]]);
1669
1773
  }));
1670
- function apiGetProductVariants(_x9, _x10) {
1774
+ function apiGetProductVariants(_x13, _x14) {
1671
1775
  return _apiGetProductVariants.apply(this, arguments);
1672
1776
  }
1673
1777
  return apiGetProductVariants;
@@ -1675,7 +1779,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1675
1779
  }, {
1676
1780
  key: "apiGetProductByFilter",
1677
1781
  value: function () {
1678
- var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(filter) {
1782
+ var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(filter) {
1679
1783
  var _res3;
1680
1784
  var limit,
1681
1785
  useFilter,
@@ -1684,39 +1788,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1684
1788
  res,
1685
1789
  resData,
1686
1790
  filterParam,
1687
- _args9 = arguments;
1688
- return _regeneratorRuntime.wrap(function _callee8$(_context9) {
1689
- while (1) switch (_context9.prev = _context9.next) {
1791
+ _args11 = arguments;
1792
+ return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1793
+ while (1) switch (_context11.prev = _context11.next) {
1690
1794
  case 0:
1691
- limit = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 1;
1692
- useFilter = _args9.length > 2 ? _args9[2] : undefined;
1693
- hierarchy = _args9.length > 3 ? _args9[3] : undefined;
1795
+ limit = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 1;
1796
+ useFilter = _args11.length > 2 ? _args11[2] : undefined;
1797
+ hierarchy = _args11.length > 3 ? _args11[3] : undefined;
1694
1798
  fullUrl = this.catalogService + '/v1/products';
1695
- _context9.prev = 4;
1799
+ _context11.prev = 4;
1696
1800
  filterParam = useFilter ? 'filter' : 'search';
1697
- _context9.next = 8;
1801
+ _context11.next = 8;
1698
1802
  return axios.get("".concat(fullUrl, "?organizationIds=").concat(this.organization._id, "&").concat(filterParam, "=").concat(encodeURIComponent(this.parseFilter(filter)), "&limit=").concat(limit, "&hierarchy=").concat(hierarchy !== null && hierarchy !== void 0 ? hierarchy : false), {
1699
1803
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1700
1804
  'Content-Type': 'application/json'
1701
1805
  })
1702
1806
  });
1703
1807
  case 8:
1704
- res = _context9.sent;
1705
- _context9.next = 11;
1808
+ res = _context11.sent;
1809
+ _context11.next = 11;
1706
1810
  return res.data;
1707
1811
  case 11:
1708
- resData = _context9.sent;
1709
- _context9.next = 17;
1812
+ resData = _context11.sent;
1813
+ _context11.next = 17;
1710
1814
  break;
1711
1815
  case 14:
1712
- _context9.prev = 14;
1713
- _context9.t0 = _context9["catch"](4);
1816
+ _context11.prev = 14;
1817
+ _context11.t0 = _context11["catch"](4);
1714
1818
  throw new Error('Could not get existing products', {
1715
- cause: _context9.t0
1819
+ cause: _context11.t0
1716
1820
  });
1717
1821
  case 17:
1718
1822
  if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
1719
- _context9.next = 20;
1823
+ _context11.next = 20;
1720
1824
  break;
1721
1825
  }
1722
1826
  //in order to be backwardscompatible we must transform old products here
@@ -1729,16 +1833,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1729
1833
  }
1730
1834
  return d;
1731
1835
  });
1732
- return _context9.abrupt("return", resData);
1836
+ return _context11.abrupt("return", resData);
1733
1837
  case 20:
1734
1838
  throw new Error(resData.error);
1735
1839
  case 21:
1736
1840
  case "end":
1737
- return _context9.stop();
1841
+ return _context11.stop();
1738
1842
  }
1739
- }, _callee8, this, [[4, 14]]);
1843
+ }, _callee10, this, [[4, 14]]);
1740
1844
  }));
1741
- function apiGetProductByFilter(_x11) {
1845
+ function apiGetProductByFilter(_x15) {
1742
1846
  return _apiGetProductByFilter.apply(this, arguments);
1743
1847
  }
1744
1848
  return apiGetProductByFilter;
@@ -1746,51 +1850,51 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1746
1850
  }, {
1747
1851
  key: "apiSetCustomFlag",
1748
1852
  value: function () {
1749
- var _apiSetCustomFlag = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, flagName, organizationId, dependsOn) {
1853
+ var _apiSetCustomFlag = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(id, flagName, organizationId, dependsOn) {
1750
1854
  var _res4;
1751
1855
  var fullUrl, res, resData;
1752
- return _regeneratorRuntime.wrap(function _callee9$(_context10) {
1753
- while (1) switch (_context10.prev = _context10.next) {
1856
+ return _regeneratorRuntime.wrap(function _callee11$(_context12) {
1857
+ while (1) switch (_context12.prev = _context12.next) {
1754
1858
  case 0:
1755
1859
  fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/' + flagName);
1756
1860
  fullUrl.searchParams.append('organizationId', organizationId);
1757
1861
  if (dependsOn) fullUrl.searchParams.append('dependsOn', dependsOn);
1758
- _context10.prev = 3;
1759
- _context10.next = 6;
1862
+ _context12.prev = 3;
1863
+ _context12.next = 6;
1760
1864
  return axios.post(fullUrl.toString(), undefined, {
1761
1865
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1762
1866
  'Content-Type': 'application/json'
1763
1867
  })
1764
1868
  });
1765
1869
  case 6:
1766
- res = _context10.sent;
1767
- _context10.next = 9;
1870
+ res = _context12.sent;
1871
+ _context12.next = 9;
1768
1872
  return res.data;
1769
1873
  case 9:
1770
- resData = _context10.sent;
1771
- _context10.next = 15;
1874
+ resData = _context12.sent;
1875
+ _context12.next = 15;
1772
1876
  break;
1773
1877
  case 12:
1774
- _context10.prev = 12;
1775
- _context10.t0 = _context10["catch"](3);
1878
+ _context12.prev = 12;
1879
+ _context12.t0 = _context12["catch"](3);
1776
1880
  throw new Error('Could not get existing products', {
1777
- cause: _context10.t0
1881
+ cause: _context12.t0
1778
1882
  });
1779
1883
  case 15:
1780
1884
  if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
1781
- _context10.next = 17;
1885
+ _context12.next = 17;
1782
1886
  break;
1783
1887
  }
1784
- return _context10.abrupt("return", resData);
1888
+ return _context12.abrupt("return", resData);
1785
1889
  case 17:
1786
1890
  throw new Error(resData.error);
1787
1891
  case 18:
1788
1892
  case "end":
1789
- return _context10.stop();
1893
+ return _context12.stop();
1790
1894
  }
1791
- }, _callee9, this, [[3, 12]]);
1895
+ }, _callee11, this, [[3, 12]]);
1792
1896
  }));
1793
- function apiSetCustomFlag(_x12, _x13, _x14, _x15) {
1897
+ function apiSetCustomFlag(_x16, _x17, _x18, _x19) {
1794
1898
  return _apiSetCustomFlag.apply(this, arguments);
1795
1899
  }
1796
1900
  return apiSetCustomFlag;
@@ -1798,10 +1902,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1798
1902
  }, {
1799
1903
  key: "apiDeleteProducts",
1800
1904
  value: function () {
1801
- var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(products) {
1905
+ var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(products) {
1802
1906
  var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
1803
- return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1804
- while (1) switch (_context11.prev = _context11.next) {
1907
+ return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1908
+ while (1) switch (_context13.prev = _context13.next) {
1805
1909
  case 0:
1806
1910
  fullUrl = this.catalogService + '/products';
1807
1911
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1812,7 +1916,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1812
1916
  i = 0;
1813
1917
  case 5:
1814
1918
  if (!(i < productsInChunks.length)) {
1815
- _context11.next = 13;
1919
+ _context13.next = 13;
1816
1920
  break;
1817
1921
  }
1818
1922
  promises = productsInChunks[i].map(function (p) {
@@ -1834,19 +1938,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1834
1938
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
1835
1939
  dontRenderForm: true
1836
1940
  });
1837
- _context11.next = 10;
1941
+ _context13.next = 10;
1838
1942
  return Promise.all(promises);
1839
1943
  case 10:
1840
1944
  i++;
1841
- _context11.next = 5;
1945
+ _context13.next = 5;
1842
1946
  break;
1843
1947
  case 13:
1844
1948
  case "end":
1845
- return _context11.stop();
1949
+ return _context13.stop();
1846
1950
  }
1847
- }, _callee10, this);
1951
+ }, _callee12, this);
1848
1952
  }));
1849
- function apiDeleteProducts(_x16) {
1953
+ function apiDeleteProducts(_x20) {
1850
1954
  return _apiDeleteProducts.apply(this, arguments);
1851
1955
  }
1852
1956
  return apiDeleteProducts;
@@ -1863,12 +1967,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1863
1967
  }, {
1864
1968
  key: "apiLoadProductVariantsGrouped",
1865
1969
  value: function () {
1866
- var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref44) {
1867
- var limit, skip, fields, _ref44$search, search, sort, abortController, fullUrl, headers, promise;
1868
- return _regeneratorRuntime.wrap(function _callee11$(_context12) {
1869
- while (1) switch (_context12.prev = _context12.next) {
1970
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref45) {
1971
+ var limit, skip, fields, _ref45$search, search, sort, abortController, fullUrl, headers, promise;
1972
+ return _regeneratorRuntime.wrap(function _callee13$(_context14) {
1973
+ while (1) switch (_context14.prev = _context14.next) {
1870
1974
  case 0:
1871
- limit = _ref44.limit, skip = _ref44.skip, fields = _ref44.fields, _ref44$search = _ref44.search, search = _ref44$search === void 0 ? [] : _ref44$search, sort = _ref44.sort, _ref44.showAllProducts, abortController = _ref44.abortController;
1975
+ limit = _ref45.limit, skip = _ref45.skip, fields = _ref45.fields, _ref45$search = _ref45.search, search = _ref45$search === void 0 ? [] : _ref45$search, sort = _ref45.sort, _ref45.showAllProducts, abortController = _ref45.abortController;
1872
1976
  fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils.fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '');
1873
1977
  headers = {
1874
1978
  'Content-Type': 'application/json'
@@ -1890,32 +1994,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1890
1994
  reject('Error loading products grouped by variants: ' + error.message);
1891
1995
  });
1892
1996
  });
1893
- _context12.next = 7;
1997
+ _context14.next = 7;
1894
1998
  return promise;
1895
1999
  case 7:
1896
- return _context12.abrupt("return", _context12.sent);
2000
+ return _context14.abrupt("return", _context14.sent);
1897
2001
  case 8:
1898
2002
  case "end":
1899
- return _context12.stop();
2003
+ return _context14.stop();
1900
2004
  }
1901
- }, _callee11, this);
2005
+ }, _callee13, this);
1902
2006
  }));
1903
- function apiLoadProductVariantsGrouped(_x17) {
2007
+ function apiLoadProductVariantsGrouped(_x21) {
1904
2008
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
1905
2009
  }
1906
2010
  return apiLoadProductVariantsGrouped;
1907
2011
  }()
1908
2012
  }, {
1909
- key: "apiSaveBasketAndProducts",
2013
+ key: "apiSaveProducts",
1910
2014
  value: function () {
1911
- var _apiSaveBasketAndProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(serverUrl, jwt, products, awaitPDF, basket, removedProductIds) {
2015
+ var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
1912
2016
  var fullUrl, response, status;
1913
- return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1914
- while (1) switch (_context13.prev = _context13.next) {
2017
+ return _regeneratorRuntime.wrap(function _callee14$(_context15) {
2018
+ while (1) switch (_context15.prev = _context15.next) {
1915
2019
  case 0:
1916
2020
  fullUrl = serverUrl + '/v1/products/groups';
1917
- _context13.prev = 1;
1918
- _context13.next = 4;
2021
+ _context15.prev = 1;
2022
+ _context15.next = 4;
1919
2023
  return fetch(fullUrl, {
1920
2024
  method: 'PUT',
1921
2025
  headers: {
@@ -1923,7 +2027,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1923
2027
  'Content-Type': 'application/json'
1924
2028
  },
1925
2029
  body: JSON.stringify({
1926
- basket: basket ? basket.getAsJson() : undefined,
1927
2030
  products: products,
1928
2031
  removedProductIds: removedProductIds,
1929
2032
  awaitPDF: awaitPDF
@@ -1936,31 +2039,31 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1936
2039
  return res.json();
1937
2040
  });
1938
2041
  case 4:
1939
- response = _context13.sent;
2042
+ response = _context15.sent;
1940
2043
  if (!response.Error) {
1941
- _context13.next = 7;
2044
+ _context15.next = 7;
1942
2045
  break;
1943
2046
  }
1944
2047
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
1945
2048
  case 7:
1946
- _context13.next = 12;
2049
+ _context15.next = 12;
1947
2050
  break;
1948
2051
  case 9:
1949
- _context13.prev = 9;
1950
- _context13.t0 = _context13["catch"](1);
2052
+ _context15.prev = 9;
2053
+ _context15.t0 = _context15["catch"](1);
1951
2054
  throw Error(status);
1952
2055
  case 12:
1953
- return _context13.abrupt("return", response.products);
2056
+ return _context15.abrupt("return", response.products);
1954
2057
  case 13:
1955
2058
  case "end":
1956
- return _context13.stop();
2059
+ return _context15.stop();
1957
2060
  }
1958
- }, _callee12, null, [[1, 9]]);
2061
+ }, _callee14, null, [[1, 9]]);
1959
2062
  }));
1960
- function apiSaveBasketAndProducts(_x18, _x19, _x20, _x21, _x22, _x23) {
1961
- return _apiSaveBasketAndProducts.apply(this, arguments);
2063
+ function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
2064
+ return _apiSaveProducts.apply(this, arguments);
1962
2065
  }
1963
- return apiSaveBasketAndProducts;
2066
+ return apiSaveProducts;
1964
2067
  }()
1965
2068
  }, {
1966
2069
  key: "parseFilter",
@@ -1992,53 +2095,53 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1992
2095
  }], [{
1993
2096
  key: "isSameProduct",
1994
2097
  value: function isSameProduct(product, setHash, diva3dProject, orderLines, varinatData, catalogCodex) {
1995
- var _product$articles;
2098
+ var _product$configuratio, _product$configuratio2, _product$configuratio3;
1996
2099
  //For new products we store the setHash and Diva3DProject in order to determine if the product changed.
1997
2100
  if (product.uniqueHash !== undefined) {
1998
2101
  return product.uniqueHash === 'v1' + setHash + (diva3dProject ? md5(diva3dProject) : '');
1999
2102
  }
2000
2103
 
2001
2104
  //For older products without setHash we use the old comparison logic
2002
- if (((_product$articles = product.articles) === null || _product$articles === void 0 ? void 0 : _product$articles.length) != (orderLines === null || orderLines === void 0 ? void 0 : orderLines.length)) {
2105
+ if (((_product$configuratio = product.configuration) === null || _product$configuratio === void 0 || (_product$configuratio = _product$configuratio.OrderSets[0].OrderLines) === null || _product$configuratio === void 0 ? void 0 : _product$configuratio.length) != (orderLines === null || orderLines === void 0 ? void 0 : orderLines.length)) {
2003
2106
  return false;
2004
2107
  }
2005
2108
  if (!varinatData) {
2006
2109
  //the old logic was only for variants, not for base products
2007
2110
  return true;
2008
2111
  }
2112
+ 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 : [];
2009
2113
  var _loop2 = function _loop2() {
2010
- var _article$variantValue;
2011
- var article = product.articles[i];
2114
+ var article = orderlines[i];
2012
2115
  var orderLine = orderLines.find(function (ol) {
2013
- return ol.ArticleCodex == article.articleCodex && catalogCodex == article.catalogCodex;
2116
+ return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
2014
2117
  });
2015
- if (!orderLine || ((_article$variantValue = article.variantValues) === null || _article$variantValue === void 0 ? void 0 : _article$variantValue.length) != (varinatData === null || varinatData === void 0 ? void 0 : varinatData.length)) {
2118
+ if (!orderLine) {
2016
2119
  return {
2017
2120
  v: false
2018
2121
  };
2019
2122
  }
2020
- var _loop3 = function _loop3() {
2021
- var varinatValue = article.variantValues[j];
2022
- if (!(varinatData !== null && varinatData !== void 0 && varinatData.find(function (vb) {
2023
- return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2024
- }))) {
2025
- return {
2026
- v: {
2027
- v: false
2028
- }
2029
- };
2030
- }
2031
- },
2032
- _ret2;
2033
- for (var j = 0; j < (((_article$variantValue2 = article.variantValues) === null || _article$variantValue2 === void 0 ? void 0 : _article$variantValue2.length) || 0); j++) {
2034
- var _article$variantValue2;
2035
- _ret2 = _loop3();
2036
- if (_ret2) return _ret2.v;
2123
+ if (article.VariantBasketDatas.length) {
2124
+ var _loop3 = function _loop3() {
2125
+ var varinatValue = article.VariantBasketDatas[j];
2126
+ if (!varinatData.find(function (vb) {
2127
+ return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2128
+ })) {
2129
+ return {
2130
+ v: {
2131
+ v: false
2132
+ }
2133
+ };
2134
+ }
2135
+ },
2136
+ _ret2;
2137
+ for (var j = 0; j < article.VariantBasketDatas.length; j++) {
2138
+ _ret2 = _loop3();
2139
+ if (_ret2) return _ret2.v;
2140
+ }
2037
2141
  }
2038
2142
  },
2039
2143
  _ret;
2040
- for (var i = 0; i < ((_product$articles$len = (_product$articles2 = product.articles) === null || _product$articles2 === void 0 ? void 0 : _product$articles2.length) !== null && _product$articles$len !== void 0 ? _product$articles$len : 0); i++) {
2041
- var _product$articles$len, _product$articles2;
2144
+ for (var i = 0; i < orderlines.length; i++) {
2042
2145
  _ret = _loop2();
2043
2146
  if (_ret) return _ret.v;
2044
2147
  }
@@ -2165,16 +2268,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2165
2268
  }, {
2166
2269
  key: "assign",
2167
2270
  value: function assign(target) {
2168
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
2169
- sources[_key4 - 1] = arguments[_key4];
2271
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
2272
+ sources[_key3 - 1] = arguments[_key3];
2170
2273
  }
2171
2274
  return Object.assign.apply(Object, [target].concat(_toConsumableArray(sources.filter(function (s) {
2172
2275
  return s;
2173
2276
  }).map(function (x) {
2174
- return Object.fromEntries(Object.entries(x).filter(function (_ref45) {
2175
- var _ref46 = _slicedToArray(_ref45, 2);
2176
- _ref46[0];
2177
- var value = _ref46[1];
2277
+ return Object.fromEntries(Object.entries(x).filter(function (_ref46) {
2278
+ var _ref47 = _slicedToArray(_ref46, 2);
2279
+ _ref47[0];
2280
+ var value = _ref47[1];
2178
2281
  return value !== undefined;
2179
2282
  }));
2180
2283
  }))));
@@ -2182,10 +2285,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2182
2285
  }, {
2183
2286
  key: "loadSelectOptions",
2184
2287
  value: function () {
2185
- var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(sessionGuid, dataSource, additionalFilter) {
2186
- var values, apiUrl, i, apiResult, _i3, value, text;
2187
- return _regeneratorRuntime.wrap(function _callee13$(_context14) {
2188
- while (1) switch (_context14.prev = _context14.next) {
2288
+ var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2289
+ var values, apiUrl, i, apiResult, _i2, value, text;
2290
+ return _regeneratorRuntime.wrap(function _callee15$(_context16) {
2291
+ while (1) switch (_context16.prev = _context16.next) {
2189
2292
  case 0:
2190
2293
  values = [];
2191
2294
  apiUrl = dataSource.url;
@@ -2194,7 +2297,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2194
2297
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2195
2298
  }
2196
2299
  }
2197
- _context14.next = 5;
2300
+ _context16.next = 5;
2198
2301
  return fetch(apiUrl, {
2199
2302
  headers: {
2200
2303
  sessionGuid: sessionGuid
@@ -2206,26 +2309,26 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2206
2309
  return res.json();
2207
2310
  });
2208
2311
  case 5:
2209
- apiResult = _context14.sent;
2312
+ apiResult = _context16.sent;
2210
2313
  if (dataSource.useKey) {
2211
2314
  apiResult = apiResult[dataSource.useKey];
2212
2315
  }
2213
- for (_i3 = 0; _i3 < apiResult.length; _i3++) {
2214
- value = apiResult[_i3][dataSource.fieldValueMapping];
2215
- text = apiResult[_i3][dataSource.fieldDescriptionMapping];
2316
+ for (_i2 = 0; _i2 < apiResult.length; _i2++) {
2317
+ value = apiResult[_i2][dataSource.fieldValueMapping];
2318
+ text = apiResult[_i2][dataSource.fieldDescriptionMapping];
2216
2319
  values.push({
2217
2320
  value: value,
2218
2321
  text: text
2219
2322
  });
2220
2323
  }
2221
- return _context14.abrupt("return", values);
2324
+ return _context16.abrupt("return", values);
2222
2325
  case 9:
2223
2326
  case "end":
2224
- return _context14.stop();
2327
+ return _context16.stop();
2225
2328
  }
2226
- }, _callee13);
2329
+ }, _callee15);
2227
2330
  }));
2228
- function loadSelectOptions(_x24, _x25, _x26) {
2331
+ function loadSelectOptions(_x27, _x28, _x29) {
2229
2332
  return _loadSelectOptions.apply(this, arguments);
2230
2333
  }
2231
2334
  return loadSelectOptions;
@@ -2238,6 +2341,36 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2238
2341
  return rv;
2239
2342
  }, {});
2240
2343
  }
2344
+ }, {
2345
+ key: "getVariantBasketDatasByOrderlines",
2346
+ value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
2347
+ var variantBasketDatas = [];
2348
+ var _loop5 = function _loop5() {
2349
+ var ol = orderLines[i];
2350
+ var catalog = catalogData.find(function (c) {
2351
+ return c.codex === ol.CatalogCodex;
2352
+ });
2353
+ if (!ol.VariantBasketDatas) return 1; // continue
2354
+ for (var j = 0; j < ol.VariantBasketDatas.length; j++) {
2355
+ var v = ol.VariantBasketDatas[j];
2356
+ var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
2357
+ var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
2358
+ {
2359
+ variantBasketDatas.push({
2360
+ BasketID: ol.BasketID,
2361
+ OPT: v.OPT,
2362
+ OPV: v.OPV,
2363
+ OPTName: opt.Name,
2364
+ OPVName: opv.Name
2365
+ });
2366
+ }
2367
+ }
2368
+ };
2369
+ for (var i = 0; i < orderLines.length; i++) {
2370
+ if (_loop5()) continue;
2371
+ }
2372
+ return variantBasketDatas;
2373
+ }
2241
2374
  }]);
2242
2375
  }();
2243
2376
  _ProductHandlerAbstract = ProductHandlerAbstract;