@crystaldesign/product-handler 24.12.0-beta.3 → 24.12.0-beta.30

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() {
@@ -97,16 +109,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
97
109
  key: "apiKey",
98
110
  get: function get() {
99
111
  return this._apiKey;
112
+ },
113
+ set: function set(val) {
114
+ this._apiKey = val;
100
115
  }
116
+ }, {
117
+ key: "initProduct",
118
+ value: function initProduct(basket) {}
101
119
 
102
120
  /**
103
121
  * Saves the products in the current state
104
122
  * @param basket the basket data for which products get created/loaded
105
123
  * @param catalogData the catalog data for this basket
106
- */,
107
- set: function set(val) {
108
- this._apiKey = val;
109
- }
124
+ */
110
125
  }, {
111
126
  key: "createAndSave",
112
127
  value: (function () {
@@ -120,6 +135,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
120
135
  _context.next = 3;
121
136
  return this.loadProducts({
122
137
  basket: basket,
138
+ divaNr: basket.DivaNr,
123
139
  catalogData: catalogData,
124
140
  productData: [],
125
141
  availableLanguages: availableLanguages,
@@ -129,22 +145,22 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
129
145
  createdState = _context.sent;
130
146
  createdState.baseData.shortDescription = (_basket$ProductSetNam = basket.ProductSetName) !== null && _basket$ProductSetNam !== void 0 ? _basket$ProductSetNam : basket.SetName;
131
147
  createdState.baseData.shortDescription_locales = basket.SetName_locales;
132
- _context.next = 8;
148
+ _objectSpread({}, createdState.baseData);
149
+ _context.next = 9;
133
150
  return this.prepareData({
151
+ basket: basket,
134
152
  baseData: createdState.baseData,
135
153
  classificationData: createdState.classificationData,
136
154
  variantData: createdState.variantData,
137
155
  oldClassificationData: createdState.oldClassificationData
138
156
  });
139
- case 8:
157
+ case 9:
140
158
  data = _context.sent;
141
- _context.next = 11;
142
- return this.saveBasketAndProducts(_objectSpread(_objectSpread({}, data), {}, {
143
- basket: basket
144
- }));
145
- case 11:
146
- return _context.abrupt("return", _context.sent);
159
+ _context.next = 12;
160
+ return this.saveProducts(_objectSpread({}, data));
147
161
  case 12:
162
+ return _context.abrupt("return", _context.sent);
163
+ case 13:
148
164
  case "end":
149
165
  return _context.stop();
150
166
  }
@@ -167,86 +183,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
167
183
  key: "loadProducts",
168
184
  value: (function () {
169
185
  var _loadProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
170
- var _baseProduct9,
171
- _baseProduct10,
172
- _baseProduct11,
173
- _baseProduct12,
174
- _baseProduct13,
175
- _baseProduct14,
176
- _baseProduct15,
177
- _baseProduct16,
178
- _baseProduct17,
179
- _baseProduct18,
180
- _baseProduct19,
181
- _baseProduct20,
182
- _baseProduct21,
183
- _baseProduct22,
184
- _baseProduct23,
185
- _baseProduct24,
186
- _baseProduct25,
187
- _baseProduct26,
188
- _baseProduct$width,
189
- _baseProduct27,
190
- _basket$SetPlannerInf,
191
- _basket$OrderSets$0$B,
192
- _baseProduct$height,
193
- _baseProduct28,
194
- _basket$SetPlannerInf2,
195
- _basket$OrderSets$0$B2,
196
- _baseProduct$depth,
197
- _baseProduct29,
198
- _basket$SetPlannerInf3,
199
- _basket$OrderSets$0$B3,
200
- _baseProduct$weight,
201
- _baseProduct30,
202
- _price$addedPrice,
203
- _baseProduct31,
204
- _baseProduct32,
205
- _baseProduct33,
206
- _basket$SetPlannerInf4,
207
- _basket$SetPlannerInf5,
208
- _baseProduct34,
209
- _baseProduct35,
210
- _baseProduct36,
211
- _baseProduct37,
212
- _baseProduct38,
213
- _baseProduct39,
214
- _baseProduct$brand,
215
- _baseProduct40,
186
+ var _this = this,
187
+ _baseProduct,
188
+ _baseProduct2,
189
+ _baseProduct$divaNr,
190
+ _baseProduct3,
191
+ _dataByBasket$price$a,
192
+ _dataByBasket$price,
193
+ _baseProduct4,
194
+ _basket$getProductCon,
195
+ _baseProduct5,
196
+ _dataByBasket$docking,
197
+ _baseProduct6,
216
198
  _baseProduct$organiza,
217
- _baseProduct41,
199
+ _baseProduct7,
218
200
  _this$organization$pa,
219
201
  _this$organization$pa2,
220
- _baseProduct42,
221
202
  _baseProduct$createdB,
222
- _baseProduct43,
203
+ _baseProduct8,
223
204
  _this$user,
224
- _baseProduct44,
225
- _baseProduct45,
226
- _baseProduct46,
227
- _baseProduct47,
228
- _baseProduct48,
229
- _baseProduct49,
230
- _baseProduct50,
231
- _this = this;
232
- 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;
205
+ _baseProduct9,
206
+ _baseProduct10,
207
+ _baseProduct11,
208
+ _baseProduct12,
209
+ _baseProduct13,
210
+ _baseProduct14;
211
+ var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, 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;
233
212
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
234
213
  while (1) switch (_context2.prev = _context2.next) {
235
214
  case 0:
236
- 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;
215
+ 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;
216
+ if (!(!productData && !divaNr)) {
217
+ _context2.next = 3;
218
+ break;
219
+ }
220
+ throw new Error('this should not happen');
221
+ case 3:
237
222
  if (productData) {
238
- _context2.next = 5;
223
+ _context2.next = 7;
239
224
  break;
240
225
  }
241
- _context2.next = 4;
242
- return this.apiGetProducts(basket.DivaNr);
243
- case 4:
226
+ _context2.next = 6;
227
+ return this.apiGetProducts(divaNr);
228
+ case 6:
244
229
  productData = _context2.sent;
245
- case 5:
230
+ case 7:
246
231
  products = {
247
232
  data: productData,
248
233
  total: productData.length
249
234
  };
235
+ if (!(!products.data.length && !basket)) {
236
+ _context2.next = 10;
237
+ break;
238
+ }
239
+ throw new Error('If product does not exist yet, basket must be provided');
240
+ case 10:
250
241
  baseProduct = undefined;
251
242
  variantProducts = [];
252
243
  if (products.total == 1) {
@@ -259,263 +250,72 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
259
250
  return !p.baseProduct;
260
251
  });
261
252
  }
262
- if (!(products.total && !baseProduct)) {
263
- _context2.next = 11;
253
+ if (catalogData) {
254
+ _context2.next = 23;
264
255
  break;
265
256
  }
266
- throw new Error('If existing products are fetched, there has to be atleast a base product.');
267
- case 11:
268
- isSet = !!basket.SetPlannerInfos;
269
- dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
270
- orderDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
271
- return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
272
- }, '') : basket.OrderSets[0].VariantDescription;
273
- orderDescription_locales = basket.OrderSets[0].VariantDescription_locales;
274
- catalogDataName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
275
- return c.name;
276
- }).filter(function (name) {
277
- return name;
278
- }).join(' - ');
279
- catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
280
- return c.brand;
281
- }).filter(function (brand) {
282
- return brand;
283
- }).join(' - ');
284
- catalogDataDescription = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
285
- return c.description;
286
- }).filter(function (description) {
287
- return description;
288
- }).join('<br/>');
289
- catalogDataName_locales = {};
290
- catalogDataDescription_locales = {};
291
- for (i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
292
- c = catalogData[i];
293
- for (key in c.name_locales) {
294
- if (!catalogDataName_locales[key]) {
295
- catalogDataName_locales[key] = c.name_locales[key];
296
- } else {
297
- catalogDataName_locales[key] = catalogDataName_locales[key] + ' - ' + c.name_locales[key];
298
- }
299
- }
300
- for (_key in c.description_locales) {
301
- if (!catalogDataDescription_locales[_key]) {
302
- catalogDataDescription_locales[_key] = c.description_locales[_key];
303
- } else {
304
- catalogDataDescription_locales[_key] = catalogDataDescription_locales[_key] + ' - ' + c.description_locales[_key];
305
- }
306
- }
307
- }
308
- articles = [];
309
- if (isSet) {
310
- articles = basket.OrderSets.flatMap(function (os) {
311
- return os.OrderLines.map(function (ol) {
312
- var _ol$VariantBasketData;
313
- return {
314
- articleCodex: ol.ArticleCodex,
315
- catalogCodex: os.CatalogCodex,
316
- variantValues: (_ol$VariantBasketData = ol.VariantBasketDatas) === null || _ol$VariantBasketData === void 0 ? void 0 : _ol$VariantBasketData.map(function (vb) {
317
- return {
318
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
319
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
320
- };
321
- })
322
- };
323
- });
324
- });
325
- } else {
326
- articles = basket.OrderSets[0].OrderLines.map(function (ol) {
327
- var _ol$VariantBasketData2;
328
- return {
329
- articleCodex: ol.ArticleCodex,
330
- catalogCodex: basket.OrderSets[0].CatalogCodex,
331
- variantValues: (_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (vb) {
332
- return {
333
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
334
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
335
- };
336
- })
337
- };
338
- });
257
+ if (!baseProduct) {
258
+ _context2.next = 20;
259
+ break;
339
260
  }
340
- if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
341
- config = {
342
- addedPackageWeight: 0,
343
- addedPackageHeight: 0,
344
- addedPackageWidth: 0,
345
- addedPackageDepth: 0,
346
- defaultDeliveryTime: 0,
347
- defaultDeliveryPrice: 0,
348
- defaultInstallationPrice: 0
349
- };
350
- if (typeof fieldConfiguration.delivery != 'boolean') {
351
- config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
352
- }
353
- packages = [];
354
- basket.OrderSets.flatMap(function (os) {
355
- return os.OrderLines;
356
- }).forEach(function (ol) {
357
- packages.push({
358
- height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
359
- width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
360
- depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
361
- weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
362
- });
363
- });
364
- delivery = {
365
- estPackages: packages,
366
- 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,
367
- 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) {
368
- return p.weight;
369
- }).filter(function (f) {
370
- return f;
371
- })))),
372
- 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) {
373
- return p.height;
374
- }).filter(function (f) {
375
- return f;
376
- })))),
377
- 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) {
378
- return p.width;
379
- }).filter(function (f) {
380
- return f;
381
- })))),
382
- 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) {
383
- return p.depth;
384
- }).filter(function (f) {
385
- return f;
386
- })))),
387
- 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,
388
- 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,
389
- 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
390
- };
261
+ _context2.next = 17;
262
+ return Promise.all((_baseProduct$configur = (_baseProduct$configur2 = baseProduct.configuration) === null || _baseProduct$configur2 === void 0 ? void 0 : _baseProduct$configur2.OrderSets.map(function (os) {
263
+ return _this.apiGetCatalogData(os.CatalogCodex, currentLang, os.AccountGUID);
264
+ })) !== null && _baseProduct$configur !== void 0 ? _baseProduct$configur : []);
265
+ case 17:
266
+ catalogData = _context2.sent;
267
+ _context2.next = 23;
268
+ break;
269
+ case 20:
270
+ _context2.next = 22;
271
+ return Promise.all((_basket$OrderSets$map = basket === null || basket === void 0 ? void 0 : basket.OrderSets.map(function (os) {
272
+ return _this.apiGetCatalogData(os.CatalogCodex, currentLang, os.AccountGUID);
273
+ })) !== null && _basket$OrderSets$map !== void 0 ? _basket$OrderSets$map : []);
274
+ case 22:
275
+ catalogData = _context2.sent;
276
+ case 23:
277
+ if (!(products.total && !baseProduct)) {
278
+ _context2.next = 25;
279
+ break;
391
280
  }
392
- ismanual = ((_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.calculatedPrice) !== ((_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.addedPrice);
393
- price = {
394
- calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
395
- addedPrice: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.addedPrice,
396
- discountPrice: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.discountedPrice
397
- };
398
- 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);
399
-
400
- //to remember what for position was previously set for the classification
281
+ throw new Error('If existing products are fetched, there has to be atleast a base product.');
282
+ case 25:
283
+ dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
401
284
  oldClassificationData = {};
402
- for (_i = 0; _i < products.data.length; _i++) {
403
- variant = products.data[_i];
285
+ for (i = 0; i < products.data.length; i++) {
286
+ variant = products.data[i];
404
287
  oldClassificationData[variant._id] = {};
405
- for (_key2 in variant) {
406
- if (_key2.startsWith('dc_') && variant[_key2].optionPosition !== undefined) {
407
- oldClassificationData[variant._id][_key2] = variant[_key2];
288
+ for (key in variant) {
289
+ if (key.startsWith('dc_') && variant[key].optionPosition !== undefined) {
290
+ oldClassificationData[variant._id][key] = variant[key];
408
291
  }
409
292
  }
410
293
  }
411
- oldUniqueHash = (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.uniqueHash;
412
- baseData = {
413
- _id: ((_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16._id) || nanoid(),
414
- divaNr: basket === null || basket === void 0 ? void 0 : basket.DivaNr,
415
- modelName: ((_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.modelName) || catalogDataName,
416
- info: ((_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.info) || catalogDataDescription,
417
- technicalDescription: ((_baseProduct19 = baseProduct) === null || _baseProduct19 === void 0 ? void 0 : _baseProduct19.technicalDescription) || orderDescription,
418
- shortTechnicalDescription: (_baseProduct20 = baseProduct) === null || _baseProduct20 === void 0 ? void 0 : _baseProduct20.shortTechnicalDescription,
419
- modelName_locales: ((_baseProduct21 = baseProduct) === null || _baseProduct21 === void 0 ? void 0 : _baseProduct21.modelName_locales) || catalogDataName_locales,
420
- info_locales: ((_baseProduct22 = baseProduct) === null || _baseProduct22 === void 0 ? void 0 : _baseProduct22.info_locales) || catalogDataDescription_locales,
421
- technicalDescription_locales: ((_baseProduct23 = baseProduct) === null || _baseProduct23 === void 0 ? void 0 : _baseProduct23.technicalDescription_locales) || orderDescription_locales,
422
- shortTechnicalDescription_locales: (_baseProduct24 = baseProduct) === null || _baseProduct24 === void 0 ? void 0 : _baseProduct24.shortTechnicalDescription_locales,
423
- orderDescription: orderDescription,
424
- shortDescription: (_baseProduct25 = baseProduct) === null || _baseProduct25 === void 0 ? void 0 : _baseProduct25.shortDescription,
425
- shortDescription_locales: (_baseProduct26 = baseProduct) === null || _baseProduct26 === void 0 ? void 0 : _baseProduct26.shortDescription_locales,
426
- 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,
427
- 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,
428
- 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,
429
- 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) {
430
- return os.OrderLines.map(function (ol) {
431
- return ol.Weight;
432
- }).filter(function (f) {
433
- return f;
434
- });
435
- }).reduce(function (sum, v) {
436
- return sum + v;
437
- }, 0),
438
- calculatedPrice: price.calculatedPrice,
439
- delivery: delivery,
440
- addedPrice: (_price$addedPrice = price.addedPrice) !== null && _price$addedPrice !== void 0 ? _price$addedPrice : (_baseProduct31 = baseProduct) === null || _baseProduct31 === void 0 ? void 0 : _baseProduct31.addedPrice,
441
- discountedPrice: (_baseProduct32 = baseProduct) === null || _baseProduct32 === void 0 ? void 0 : _baseProduct32.discountedPrice,
442
- percentageDiscount: (_baseProduct33 = baseProduct) === null || _baseProduct33 === void 0 ? void 0 : _baseProduct33.percentageDiscount,
443
- articles: articles,
444
- image: isSet ? (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg3D : basket.OrderSets[0].SetImage,
445
- image2D: isSet ? (_basket$SetPlannerInf5 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf5 === void 0 ? void 0 : _basket$SetPlannerInf5.SetPlannerImg2D : basket.OrderSets[0].Set2DImage,
446
- catalogId: isSet ? basket.OrderSets.map(function (os) {
447
- return os.CatalogGUID;
448
- }) : [basket.OrderSets[0].CatalogGUID],
449
- collection: isSet ? basket.OrderSets.map(function (os) {
450
- return os.AccountName;
451
- }) : [basket.OrderSets[0].AccountName],
452
- collectionId: isSet ? basket.OrderSets.map(function (os) {
453
- return os.CollectionGUID;
454
- }) : [basket.OrderSets[0].CollectionGUID],
455
- catCodex: isSet ? basket.OrderSets.map(function (os) {
456
- return os.CatalogCodex;
457
- }) : [basket.OrderSets[0].CatalogCodex],
458
- supplierId: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
459
- return c.supplierGuid;
460
- }).filter(function (c) {
461
- return c;
462
- }),
463
- retailCatalogNr: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
464
- return c.retailCatalogNr;
465
- }).filter(function (c) {
466
- return c;
467
- }),
468
- supplierArticleNr: basket.OrderSets.flatMap(function (os) {
469
- return os.OrderLines.map(function (ol) {
470
- return ol.ConfigArticleCodex;
471
- }).filter(function (f) {
472
- return f;
473
- });
474
- }).filter(function (f) {
475
- return f;
476
- }),
477
- retailCatalogArticleNr: basket.OrderSets.flatMap(function (os) {
478
- return os.OrderLines.map(function (ol) {
479
- return ol.RetailArticleNr;
480
- }).filter(function (f) {
481
- return f;
482
- });
483
- }).filter(function (f) {
484
- return f;
485
- }),
486
- livingArea: (_baseProduct34 = baseProduct) === null || _baseProduct34 === void 0 ? void 0 : _baseProduct34.livingArea,
487
- mainCategory: (_baseProduct35 = baseProduct) === null || _baseProduct35 === void 0 ? void 0 : _baseProduct35.mainCategory,
488
- subCategory: (_baseProduct36 = baseProduct) === null || _baseProduct36 === void 0 ? void 0 : _baseProduct36.subCategory,
489
- retailerArticleNr: (_baseProduct37 = baseProduct) === null || _baseProduct37 === void 0 ? void 0 : _baseProduct37.retailerArticleNr,
490
- dockingPoints: dockingPoints,
491
- media: (_baseProduct38 = baseProduct) === null || _baseProduct38 === void 0 ? void 0 : _baseProduct38.media,
492
- affiliate: (_baseProduct39 = baseProduct) === null || _baseProduct39 === void 0 ? void 0 : _baseProduct39.affiliate,
493
- brand: (_baseProduct$brand = (_baseProduct40 = baseProduct) === null || _baseProduct40 === void 0 ? void 0 : _baseProduct40.brand) !== null && _baseProduct$brand !== void 0 ? _baseProduct$brand : catalogDataBrand,
294
+ oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
295
+ baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
296
+ _id: ((_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2._id) || nanoid(),
297
+ divaNr: (_baseProduct$divaNr = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr,
298
+ 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 : (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.addedPrice,
299
+ configuration: (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.configuration,
300
+ dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.dockingPoints,
494
301
  currency: DivaUtils.defaultPriceFormat.currency,
495
- organizationId: (_baseProduct$organiza = (_baseProduct41 = baseProduct) === null || _baseProduct41 === void 0 ? void 0 : _baseProduct41.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
302
+ organizationId: (_baseProduct$organiza = (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
496
303
  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) {
497
304
  return o._id;
498
305
  })) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
499
- created: (_baseProduct42 = baseProduct) === null || _baseProduct42 === void 0 ? void 0 : _baseProduct42.created,
500
- 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,
501
- createdBy_displayText: (_baseProduct44 = baseProduct) === null || _baseProduct44 === void 0 ? void 0 : _baseProduct44.createdBy_displayText,
502
- archived: (_baseProduct45 = baseProduct) !== null && _baseProduct45 !== void 0 && _baseProduct45.archived ? (_baseProduct46 = baseProduct) === null || _baseProduct46 === void 0 ? void 0 : _baseProduct46.archived : false,
503
- isTopseller: !!((_baseProduct47 = baseProduct) !== null && _baseProduct47 !== void 0 && _baseProduct47.isTopseller),
504
- orderText: basket.getEKText(true),
505
- classificationInfo: (_baseProduct48 = baseProduct) === null || _baseProduct48 === void 0 ? void 0 : _baseProduct48.classificationInfo,
506
- modelInfoPageWeight: (_baseProduct49 = baseProduct) === null || _baseProduct49 === void 0 ? void 0 : _baseProduct49.modelInfoPageWeight,
507
- uniqueHash: isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
508
- return os.SetHash;
509
- }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject)
510
- };
511
- metaData = basket.OrderSets.reduce(function (prev, curr) {
306
+ createdBy: (_baseProduct$createdB = (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
307
+ createdBy_displayText: (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.createdBy_displayText,
308
+ archived: (_baseProduct10 = baseProduct) !== null && _baseProduct10 !== void 0 && _baseProduct10.archived ? (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.archived : false,
309
+ isTopseller: !!((_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.isTopseller)
310
+ });
311
+ metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
512
312
  return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
513
313
  }, {});
514
- metaData_locales = basket.OrderSets.reduce(function (prev, curr) {
314
+ metaData_locales = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
515
315
  return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
516
316
  }, {});
517
317
  _this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
518
- baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct50 = baseProduct) === null || _baseProduct50 === void 0 ? void 0 : _baseProduct50.customData), customData);
318
+ baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.customData), customData);
519
319
 
520
320
  //add livingarea,maincategorie,subcategorie of loaded product if not exists
521
321
  classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
@@ -531,55 +331,56 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
531
331
  removedProducts = [];
532
332
  optFields = [];
533
333
  initialSelectedFields = [];
534
- if (isSet) {
535
- (_this$LOG = this.LOG) === null || _this$LOG === void 0 || _this$LOG.warn('Variants are currently not supported for set products');
536
- } else {
537
- //iterate all existing variant products and add them to the variants
538
- usedConfigVariants = [];
539
- variantProducts.forEach(function (product) {
540
- var cv;
541
- if (editedBasket) {
542
- var _basket$OrderSets$0$C;
543
- 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) {
544
- return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
545
- });
546
- } else {
547
- var _basket$OrderSets$0$C2;
548
- 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) {
549
- return cv.VariantID == product.variantId;
550
- });
551
- }
334
+ if (!dataByBasket.isSet) {
335
+ _context2.next = 45;
336
+ break;
337
+ }
338
+ throw new Error('Variants are currently not supported for set products');
339
+ case 45:
340
+ //iterate all existing variant products and add them to the variants
341
+ usedVariantIds = [];
342
+ variantProducts.forEach(function (product) {
343
+ var cv;
344
+ if (basket) {
345
+ var _basket$OrderSets$0$C;
346
+ 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) {
347
+ return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
348
+ })) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.VariantID;
349
+ } else {
350
+ cv = product.variantId;
351
+ }
552
352
 
553
- //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
554
- if (product.originDivaNr || cv) {
555
- usedConfigVariants.push(cv);
556
- var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
557
- _variant = _this$initVariant.variant,
558
- modified = _this$initVariant.modified;
559
- variantData.push(_variant);
560
- variantDataModified.push(modified);
561
- } else {
562
- var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
563
- _variant2 = _this$initVariant2.variant,
564
- _modified = _this$initVariant2.modified;
565
- variantData.push(_variant2);
566
- variantDataModified.push(_modified);
567
- removedProducts.push(_variant2._id);
568
- }
569
- });
353
+ //if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
354
+ if (product.originDivaNr || cv !== undefined) {
355
+ if (cv !== undefined) usedVariantIds.push(cv);
356
+ var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
357
+ _variant = _this$initVariant.variant,
358
+ modified = _this$initVariant.modified;
359
+ variantData.push(_variant);
360
+ variantDataModified.push(modified);
361
+ } else {
362
+ var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
363
+ _variant2 = _this$initVariant2.variant,
364
+ _modified = _this$initVariant2.modified;
365
+ variantData.push(_variant2);
366
+ variantDataModified.push(_modified);
367
+ removedProducts.push(_variant2._id);
368
+ }
369
+ });
570
370
 
571
- //now iterate all configVariants that are left and add them to the variants (new Products)
572
- newVariantPosition = variantData.filter(function (vd) {
573
- return !removedProducts.includes(vd._id);
574
- });
575
- variantPositions = newVariantPosition.map(function (element) {
576
- return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
577
- });
578
- currentVariantPos = Math.max.apply(Math, _toConsumableArray(variantPositions));
579
- (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 || _basket$OrderSets$0$C3.filter(function (cv) {
580
- return !usedConfigVariants.includes(cv);
371
+ //now iterate all configVariants that are left and add them to the variants (new Products)
372
+ newVariantPosition = variantData.filter(function (vd) {
373
+ return !removedProducts.includes(vd._id);
374
+ });
375
+ variantPositions = newVariantPosition.map(function (element) {
376
+ return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
377
+ });
378
+ currentVariantPos = Math.max.apply(Math, _toConsumableArray(variantPositions));
379
+ if (basket) {
380
+ (_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 || _basket$OrderSets$0$C2.filter(function (cv) {
381
+ return !usedVariantIds.includes(cv.VariantID);
581
382
  }).forEach(function (cv) {
582
- var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, cv, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
383
+ var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv.VariantID, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
583
384
  variant = _this$initVariant3.variant,
584
385
  modified = _this$initVariant3.modified;
585
386
  currentVariantPos = currentVariantPos + 1;
@@ -588,60 +389,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
588
389
  variantDataModified.push(modified);
589
390
  addedProducts.push(variant._id);
590
391
  });
392
+ }
591
393
 
592
- //get opt data
593
- 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) {
594
- var _ref7 = _slicedToArray(_ref6, 2);
595
- _ref7[0];
596
- var value = _ref7[1];
597
- return Object.keys(value).length > 1;
598
- }).map(function (_ref8) {
599
- var _ref9 = _slicedToArray(_ref8, 2),
600
- opt = _ref9[0];
601
- _ref9[1];
602
- return opt.replace('OPT', '');
603
- });
604
- if (basket.OrderSets[0].ConfigVariants) {
605
- 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) {
606
- var _vd$OPTName;
607
- return {
608
- field: vd.OptionOCD ? vd.OptionOCD.substring(3) : vd.OPT,
609
- type: 'string',
610
- title: (_vd$OPTName = vd.OPTName) !== null && _vd$OPTName !== void 0 ? _vd$OPTName : vd.OPT,
611
- readOnly: true,
612
- fieldType: 'OPT'
613
- };
614
- })) || [];
615
- //remove duplicates
616
- opts = {};
617
- for (_i2 = optFields.length - 1; _i2 >= 0; _i2--) {
618
- if (!opts[optFields[_i2].field]) {
619
- opts[optFields[_i2].field] = true;
620
- } else {
621
- optFields.splice(_i2, 1);
622
- }
394
+ //get opt data
395
+ differingOPTs = Object.entries(((_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 || (_baseProduct14 = _baseProduct14.configuration) === null || _baseProduct14 === void 0 || (_baseProduct14 = _baseProduct14.OrderSets[0].Favorites) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.VariantValues) || []).filter(function (_ref3) {
396
+ var _ref4 = _slicedToArray(_ref3, 2);
397
+ _ref4[0];
398
+ var value = _ref4[1];
399
+ return Object.keys(value).length > 1;
400
+ }).map(function (_ref5) {
401
+ var _ref6 = _slicedToArray(_ref5, 2),
402
+ opt = _ref6[0];
403
+ _ref6[1];
404
+ return opt.replace('OPT', '');
405
+ });
406
+ if (variantData) {
407
+ 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) {
408
+ var _catalogData, _vd$OptionOCD, _option$Name;
409
+ 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];
410
+ return {
411
+ field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
412
+ type: 'string',
413
+ title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
414
+ readOnly: true,
415
+ fieldType: 'OPT'
416
+ };
417
+ })) || [];
418
+ //remove duplicates
419
+ opts = {};
420
+ for (_i = optFields.length - 1; _i >= 0; _i--) {
421
+ if (!opts[optFields[_i].field]) {
422
+ opts[optFields[_i].field] = true;
423
+ } else {
424
+ optFields.splice(_i, 1);
623
425
  }
624
426
  }
625
-
626
- //mark all fields where there are differences between the variants as initaly selected
627
- initialSelectedFields = optFields.filter(function (f) {
628
- return differingOPTs.includes(f.field);
629
- });
630
- ProductHandlerAbstract.baseDataFields.forEach(function (field) {
631
- if (variantDataModified.some(function (mod) {
632
- return mod[field.field];
633
- })) {
634
- initialSelectedFields.push(field);
635
- }
636
- });
637
- customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
638
- if (variantDataModified.some(function (mod) {
639
- return mod['customData.' + f.field];
640
- })) {
641
- initialSelectedFields.push(f);
642
- }
643
- });
644
427
  }
428
+
429
+ //mark all fields where there are differences between the variants as initaly selected
430
+ initialSelectedFields = optFields.filter(function (f) {
431
+ return differingOPTs.includes(f.field);
432
+ });
433
+ ProductHandlerAbstract.baseDataFields.forEach(function (field) {
434
+ if (variantDataModified.some(function (mod) {
435
+ return mod[field.field];
436
+ })) {
437
+ initialSelectedFields.push(field);
438
+ }
439
+ });
440
+ customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
441
+ if (variantDataModified.some(function (mod) {
442
+ return mod['customData.' + f.field];
443
+ })) {
444
+ initialSelectedFields.push(f);
445
+ }
446
+ });
645
447
  initializedOptMap = this.initOpvMap(optFields, classificationConfig, optMap);
646
448
  return _context2.abrupt("return", {
647
449
  baseData: baseData,
@@ -649,6 +451,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
649
451
  optFields: optFields,
650
452
  initialSelectedFields: initialSelectedFields,
651
453
  variantData: variantData,
454
+ catalogData: catalogData,
652
455
  optClassMap: initializedOptMap,
653
456
  addedProducts: products.total ? addedProducts : [],
654
457
  removedProducts: products.total ? removedProducts : [],
@@ -662,7 +465,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
662
465
  availableLanguages: availableLanguages,
663
466
  currentLang: currentLang
664
467
  });
665
- case 47:
468
+ case 58:
666
469
  case "end":
667
470
  return _context2.stop();
668
471
  }
@@ -673,6 +476,191 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
673
476
  }
674
477
  return loadProducts;
675
478
  }())
479
+ }, {
480
+ key: "getProductDataByBasket",
481
+ value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
482
+ var dataByBasket = {};
483
+ var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
484
+ dataByBasket.isSet = isSet;
485
+ if (basket) {
486
+ dataByBasket.dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
487
+ dataByBasket.technicalDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
488
+ return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
489
+ }, '') : basket.OrderSets[0].VariantDescription;
490
+ dataByBasket.technicalDescription_locales = basket.OrderSets[0].VariantDescription_locales;
491
+ dataByBasket.modelName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
492
+ return c.name;
493
+ }).filter(function (name) {
494
+ return name;
495
+ }).join(' - ');
496
+ dataByBasket.catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
497
+ return c.brand;
498
+ }).filter(function (brand) {
499
+ return brand;
500
+ }).join(' - ');
501
+ dataByBasket.info = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
502
+ return c.description;
503
+ }).filter(function (description) {
504
+ return description;
505
+ }).join('<br/>');
506
+ dataByBasket.modelName_locales = {};
507
+ for (var i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
508
+ var c = catalogData[i];
509
+ for (var key in c.name_locales) {
510
+ if (!dataByBasket.modelName_locales[key]) {
511
+ dataByBasket.modelName_locales[key] = c.name_locales[key];
512
+ } else {
513
+ dataByBasket.modelName_locales[key] = dataByBasket.modelName_locales[key] + ' - ' + c.name_locales[key];
514
+ }
515
+ }
516
+ dataByBasket.info_locales = {};
517
+ for (var _key in c.description_locales) {
518
+ if (!dataByBasket.info_locales[_key]) {
519
+ dataByBasket.info_locales[_key] = c.description_locales[_key];
520
+ } else {
521
+ dataByBasket.info_locales[_key] = dataByBasket.info_locales[_key] + ' - ' + c.description_locales[_key];
522
+ }
523
+ }
524
+ }
525
+ if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
526
+ 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;
527
+ var config = {
528
+ addedPackageWeight: 0,
529
+ addedPackageHeight: 0,
530
+ addedPackageWidth: 0,
531
+ addedPackageDepth: 0,
532
+ defaultDeliveryTime: 0,
533
+ defaultDeliveryPrice: 0,
534
+ defaultInstallationPrice: 0
535
+ };
536
+ if (typeof fieldConfiguration.delivery != 'boolean') {
537
+ config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
538
+ }
539
+ var packages = [];
540
+ basket.OrderSets.flatMap(function (os) {
541
+ return os.OrderLines;
542
+ }).forEach(function (ol) {
543
+ packages.push({
544
+ height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
545
+ width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
546
+ depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
547
+ weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
548
+ });
549
+ });
550
+ dataByBasket.delivery = {
551
+ estPackages: packages,
552
+ 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,
553
+ 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) {
554
+ return p.weight;
555
+ }).filter(function (f) {
556
+ return f;
557
+ })))),
558
+ 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) {
559
+ return p.height;
560
+ }).filter(function (f) {
561
+ return f;
562
+ })))),
563
+ 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) {
564
+ return p.width;
565
+ }).filter(function (f) {
566
+ return f;
567
+ })))),
568
+ 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) {
569
+ return p.depth;
570
+ }).filter(function (f) {
571
+ return f;
572
+ })))),
573
+ 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,
574
+ 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,
575
+ 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
576
+ };
577
+ }
578
+ var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
579
+ var price = {
580
+ calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
581
+ addedPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice,
582
+ discountPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.discountedPrice
583
+ };
584
+ if (!(baseProduct !== null && baseProduct !== void 0 && baseProduct.calculatedPrice)) {
585
+ 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);
586
+ }
587
+ dataByBasket.price = price;
588
+ dataByBasket.calculatedPrice = price.calculatedPrice;
589
+ if (isSet) {
590
+ var _basket$SetPlannerInf, _basket$SetPlannerInf2, _basket$OrderSets$0$B, _basket$SetPlannerInf3, _basket$SetPlannerInf4;
591
+ 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;
592
+ 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;
593
+ 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;
594
+ dataByBasket.image = (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.SetPlannerImg3D;
595
+ dataByBasket.image2D = (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg2D;
596
+ dataByBasket.catalogId = basket.OrderSets.map(function (os) {
597
+ return os.CatalogGUID;
598
+ });
599
+ dataByBasket.collection = basket.OrderSets.map(function (os) {
600
+ return os.AccountName;
601
+ });
602
+ dataByBasket.collectionId = basket.OrderSets.map(function (os) {
603
+ return os.CollectionGUID;
604
+ });
605
+ dataByBasket.catCodex = basket.OrderSets.map(function (os) {
606
+ return os.CatalogCodex;
607
+ });
608
+ } else {
609
+ var _basket$OrderSets$0$B2, _basket$OrderSets$0$B3, _basket$OrderSets$0$B4;
610
+ 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;
611
+ 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;
612
+ 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;
613
+ dataByBasket.image = basket.OrderSets[0].SetImage;
614
+ dataByBasket.image2D = basket.OrderSets[0].Set2DImage;
615
+ dataByBasket.catalogId = [basket.OrderSets[0].CatalogGUID];
616
+ dataByBasket.collection = [basket.OrderSets[0].AccountName];
617
+ dataByBasket.collectionId = [basket.OrderSets[0].CollectionGUID];
618
+ dataByBasket.catCodex = [basket.OrderSets[0].CatalogCodex];
619
+ }
620
+ dataByBasket.weight = basket === null || basket === void 0 ? void 0 : basket.OrderSets.flatMap(function (os) {
621
+ return os.OrderLines.map(function (ol) {
622
+ return ol.Weight;
623
+ }).filter(function (f) {
624
+ return f;
625
+ });
626
+ }).reduce(function (sum, v) {
627
+ return sum + v;
628
+ }, 0);
629
+ dataByBasket.supplierId = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
630
+ return c.supplierGuid;
631
+ }).filter(function (c) {
632
+ return c;
633
+ });
634
+ dataByBasket.retailCatalogNr = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
635
+ return c.retailCatalogNr;
636
+ }).filter(function (c) {
637
+ return c;
638
+ });
639
+ dataByBasket.supplierArticleNr = basket.OrderSets.flatMap(function (os) {
640
+ return os.OrderLines.map(function (ol) {
641
+ return ol.ConfigArticleCodex;
642
+ }).filter(function (f) {
643
+ return f;
644
+ });
645
+ }).filter(function (f) {
646
+ return f;
647
+ });
648
+ dataByBasket.retailCatalogArticleNr = basket.OrderSets.flatMap(function (os) {
649
+ return os.OrderLines.map(function (ol) {
650
+ return ol.RetailArticleNr;
651
+ }).filter(function (f) {
652
+ return f;
653
+ });
654
+ }).filter(function (f) {
655
+ return f;
656
+ });
657
+ dataByBasket.orderText = basket.getEKText(true);
658
+ dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
659
+ return os.SetHash;
660
+ }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
661
+ }
662
+ return dataByBasket;
663
+ }
676
664
  }, {
677
665
  key: "checkAndAddClassificationConfigCategories",
678
666
  value: function checkAndAddClassificationConfigCategories(baseProduct, classificationConfig) {
@@ -763,11 +751,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
763
751
  value: function () {
764
752
  var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref11) {
765
753
  var _this3 = this;
766
- 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;
754
+ 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;
767
755
  return _regeneratorRuntime.wrap(function _callee3$(_context4) {
768
756
  while (1) switch (_context4.prev = _context4.next) {
769
757
  case 0:
770
- 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;
758
+ 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;
771
759
  products = [];
772
760
  originProduct = undefined;
773
761
  if (!originProductId) {
@@ -846,11 +834,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
846
834
  var value = _ref17[1];
847
835
  return value;
848
836
  }).forEach(function (_ref18) {
849
- var _baseProduct51;
837
+ var _baseProduct15;
850
838
  var _ref19 = _slicedToArray(_ref18, 2),
851
839
  key = _ref19[0],
852
840
  value = _ref19[1];
853
- return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct51 = baseProduct["dc_".concat(key)]) !== null && _baseProduct51 !== void 0 ? _baseProduct51 : {}), {}, {
841
+ return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct15 = baseProduct["dc_".concat(key)]) !== null && _baseProduct15 !== void 0 ? _baseProduct15 : {}), {}, {
854
842
  opt: value.field
855
843
  });
856
844
  });
@@ -935,7 +923,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
935
923
  baseProduct.parent = baseProduct._id;
936
924
  }
937
925
  _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
938
- var _originProduct;
926
+ var _originProduct, _basket$getProductCon2;
939
927
  var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, product, _this3$openModal, _this3$t, k, _savedMedia;
940
928
  return _regeneratorRuntime.wrap(function _loop$(_context3) {
941
929
  while (1) switch (_context3.prev = _context3.next) {
@@ -1045,6 +1033,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1045
1033
  modelName_locales: vd.modelName_locales,
1046
1034
  shortDescription_locales: vd.shortDescription_locales,
1047
1035
  width: vd.width,
1036
+ 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,
1048
1037
  height: vd.height,
1049
1038
  depth: vd.depth,
1050
1039
  calculatedPrice: vd.calculatedPrice,
@@ -1055,7 +1044,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1055
1044
  variantPosition: variantPos,
1056
1045
  image: vd.image,
1057
1046
  image2D: vd.image2D,
1058
- articles: vd.articles,
1059
1047
  affiliate: vd.affiliate,
1060
1048
  originDivaNr: vd.originDivaNr,
1061
1049
  organizationId: baseProduct.organizationId,
@@ -1157,43 +1145,66 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1157
1145
  }
1158
1146
  }
1159
1147
  }, {
1160
- key: "saveBasketAndProducts",
1148
+ key: "saveProducts",
1161
1149
  value: function () {
1162
- var _saveBasketAndProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref28) {
1163
- var products, removedProducts, basket, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1150
+ var _saveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref28) {
1151
+ var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
1164
1152
  return _regeneratorRuntime.wrap(function _callee4$(_context5) {
1165
1153
  while (1) switch (_context5.prev = _context5.next) {
1166
1154
  case 0:
1167
- products = _ref28.products, removedProducts = _ref28.removedProducts, basket = _ref28.basket, awaitPDF = _ref28.awaitPDF;
1155
+ products = _ref28.products, removedProducts = _ref28.removedProducts, awaitPDF = _ref28.awaitPDF;
1168
1156
  if (this.jwt) {
1169
1157
  _context5.next = 3;
1170
1158
  break;
1171
1159
  }
1172
1160
  throw new Error('jwt not set');
1173
1161
  case 3:
1174
- _context5.prev = 3;
1175
- _context5.next = 6;
1176
- return this.apiSaveBasketAndProducts(this.catalogService, this.jwt, products, awaitPDF, basket, removedProducts);
1177
- case 6:
1162
+ this.setFirstVariant(products);
1163
+ _context5.prev = 4;
1164
+ _context5.next = 7;
1165
+ return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
1166
+ case 7:
1178
1167
  savedProducts = _context5.sent;
1179
1168
  (_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
1180
1169
  return _context5.abrupt("return", savedProducts);
1181
- case 11:
1182
- _context5.prev = 11;
1183
- _context5.t0 = _context5["catch"](3);
1170
+ case 12:
1171
+ _context5.prev = 12;
1172
+ _context5.t0 = _context5["catch"](4);
1184
1173
  (_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
1185
1174
  throw new Error(_context5.t0.message);
1186
- case 15:
1175
+ case 16:
1187
1176
  case "end":
1188
1177
  return _context5.stop();
1189
1178
  }
1190
- }, _callee4, this, [[3, 11]]);
1179
+ }, _callee4, this, [[4, 12]]);
1191
1180
  }));
1192
- function saveBasketAndProducts(_x4) {
1193
- return _saveBasketAndProducts.apply(this, arguments);
1181
+ function saveProducts(_x4) {
1182
+ return _saveProducts.apply(this, arguments);
1194
1183
  }
1195
- return saveBasketAndProducts;
1196
- }()
1184
+ return saveProducts;
1185
+ }() //variant with lowest variantId gets a flag for filtering purposes
1186
+ }, {
1187
+ key: "setFirstVariant",
1188
+ value: function setFirstVariant(products) {
1189
+ var _variants$;
1190
+ products.map(function (p) {
1191
+ return p.firstVariant = false;
1192
+ });
1193
+ var variants = products.filter(function (p) {
1194
+ return p.variantId !== undefined;
1195
+ });
1196
+ if (!(variants !== null && variants !== void 0 && variants.length)) return;
1197
+ var firstVariant = variants[0];
1198
+ var lowestId = (_variants$ = variants[0]) === null || _variants$ === void 0 ? void 0 : _variants$.variantId;
1199
+ for (var i = 0; i < variants.length; i++) {
1200
+ if (lowestId > variants[i].variantId) {
1201
+ lowestId = variants[i].variantId;
1202
+ firstVariant = variants[i];
1203
+ }
1204
+ }
1205
+ firstVariant.firstVariant = true;
1206
+ }
1207
+
1197
1208
  /**
1198
1209
  * Calculates the inital state of one varinat data entry
1199
1210
  *
@@ -1203,11 +1214,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1203
1214
  */
1204
1215
  }, {
1205
1216
  key: "initVariant",
1206
- value: function initVariant(baseData, baseClassification, availableLanguages, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1207
- var _cv$VariantDescriptio, _cv$VariantDescriptio2, _baseData$articles, _classificationFields;
1208
- var _this$parseClassifica = this.parseClassificationFields(product),
1217
+ value: function initVariant(baseData, baseClassification, availableLanguages, catalogData, basket, cv, variantProduct, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
1218
+ var _basket$OrderSets$0$C3, _ref30, _variantProduct$confi, _classificationFields;
1219
+ var _this$parseClassifica = this.parseClassificationFields(variantProduct),
1209
1220
  parsedProduct = _this$parseClassifica.product;
1210
- var _ref29 = cv || {},
1221
+ 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) {
1222
+ return vd.VariantID === cv;
1223
+ })) || {
1224
+ 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)
1225
+ },
1211
1226
  VariantID = _ref29.VariantID,
1212
1227
  SetImage = _ref29.SetImage,
1213
1228
  Set2DImage = _ref29.Set2DImage,
@@ -1218,27 +1233,29 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1218
1233
  MetaData_locales = _ref29.MetaData_locales,
1219
1234
  Variant = _ref29.Variant,
1220
1235
  SetHash = _ref29.SetHash,
1221
- Diva3DProject = _ref29.Diva3DProject;
1236
+ Diva3DProject = _ref29.Diva3DProject,
1237
+ VariantDescription_locales = _ref29.VariantDescription_locales,
1238
+ VariantDescription = _ref29.VariantDescription;
1222
1239
  //total and summary price are currently not avialable per varinat,
1223
1240
  //most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
1224
1241
  //we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
1225
1242
 
1226
- var ismanual = (product === null || product === void 0 ? void 0 : product.calculatedPrice) !== (product === null || product === void 0 ? void 0 : product.addedPrice);
1227
- var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], product === null || product === void 0 ? void 0 : product.calculatedPrice, ismanual);
1243
+ var ismanual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice);
1244
+ var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice, ismanual);
1228
1245
  var addedPrice;
1229
1246
  if (SetPrice == baseData.calculatedPrice) {
1230
1247
  addedPrice = baseData.addedPrice;
1231
1248
  } else {
1232
1249
  addedPrice = price.calculatedPrice;
1233
1250
  }
1234
- var isManual = (product === null || product === void 0 ? void 0 : product.addedPrice) !== (product === null || product === void 0 ? void 0 : product.calculatedPrice);
1251
+ var isManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice);
1235
1252
  if (isManual) {
1236
- addedPrice = product === null || product === void 0 ? void 0 : product.addedPrice;
1253
+ addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1237
1254
  }
1238
- var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, product, classificationConfig, customBaseFields),
1255
+ var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1239
1256
  classificationData = _this$parseMetaDataAn2.classificationData,
1240
1257
  customData = _this$parseMetaDataAn2.customData;
1241
- customData = _objectSpread(_objectSpread({}, product === null || product === void 0 ? void 0 : product.customData), customData);
1258
+ customData = _objectSpread(_objectSpread({}, variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.customData), customData);
1242
1259
  var variant = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseData), {}, {
1243
1260
  media: undefined,
1244
1261
  //set media undefined, just in case "baseData" has media but "parsedProduct" does not have media to overwrite it
@@ -1248,8 +1265,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1248
1265
  width: BBox === null || BBox === void 0 ? void 0 : BBox.X,
1249
1266
  height: BBox === null || BBox === void 0 ? void 0 : BBox.Z,
1250
1267
  depth: BBox === null || BBox === void 0 ? void 0 : BBox.Y,
1251
- technicalDescription: (_cv$VariantDescriptio = cv === null || cv === void 0 ? void 0 : cv.VariantDescription) !== null && _cv$VariantDescriptio !== void 0 ? _cv$VariantDescriptio : baseData.technicalDescription,
1252
- technicalDescription_locales: (_cv$VariantDescriptio2 = cv === null || cv === void 0 ? void 0 : cv.VariantDescription_locales) !== null && _cv$VariantDescriptio2 !== void 0 ? _cv$VariantDescriptio2 : baseData.technicalDescription_locales
1268
+ technicalDescription: VariantDescription !== null && VariantDescription !== void 0 ? VariantDescription : baseData.technicalDescription,
1269
+ technicalDescription_locales: VariantDescription_locales !== null && VariantDescription_locales !== void 0 ? VariantDescription_locales : baseData.technicalDescription_locales
1253
1270
  }, parsedProduct), {}, {
1254
1271
  customData: customData
1255
1272
  }, classificationData), {}, {
@@ -1258,18 +1275,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1258
1275
  //only if cv is not defined fallback to the values in product
1259
1276
  addedPrice: addedPrice,
1260
1277
  calculatedPrice: price.calculatedPrice,
1261
- articles: VariantBasketDatas ? (_baseData$articles = baseData.articles) === null || _baseData$articles === void 0 ? void 0 : _baseData$articles.map(function (art) {
1262
- return _objectSpread(_objectSpread({}, art), {}, {
1263
- variantValues: VariantBasketDatas === null || VariantBasketDatas === void 0 ? void 0 : VariantBasketDatas.filter(function (vb) {
1264
- return !vb.IsDescribingState;
1265
- }).map(function (vb) {
1266
- return {
1267
- OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
1268
- OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
1269
- };
1270
- })
1271
- });
1272
- }) : parsedProduct.articles,
1273
1278
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1274
1279
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1275
1280
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1359,10 +1364,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1359
1364
  key: "initOpvMap",
1360
1365
  value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
1361
1366
  var optMap = {};
1362
- Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref30) {
1363
- var _ref31 = _slicedToArray(_ref30, 2),
1364
- c = _ref31[0],
1365
- optMapping = _ref31[1].optMapping;
1367
+ Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref31) {
1368
+ var _ref32 = _slicedToArray(_ref31, 2),
1369
+ c = _ref32[0],
1370
+ optMapping = _ref32[1].optMapping;
1366
1371
  var optField;
1367
1372
  if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
1368
1373
  optField = optFields.find(function (opt) {
@@ -1423,16 +1428,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1423
1428
  var _classificationConfig;
1424
1429
  //add metadata defined as classification to classificationdata
1425
1430
  var metadataAsClassification = {};
1426
- Object.entries(metaData).filter(function (_ref32) {
1427
- var _ref33 = _slicedToArray(_ref32, 1),
1428
- key = _ref33[0];
1431
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref33) {
1432
+ var _ref34 = _slicedToArray(_ref33, 1),
1433
+ key = _ref34[0];
1429
1434
  return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
1430
1435
  })
1431
1436
  //if it is defiend as multi field, use full array otherwise only first element of array
1432
- .forEach(function (_ref34) {
1433
- var _ref35 = _slicedToArray(_ref34, 2),
1434
- key = _ref35[0],
1435
- value = _ref35[1];
1437
+ .forEach(function (_ref35) {
1438
+ var _ref36 = _slicedToArray(_ref35, 2),
1439
+ key = _ref36[0],
1440
+ value = _ref36[1];
1436
1441
  return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
1437
1442
  });
1438
1443
 
@@ -1442,14 +1447,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1442
1447
  optMap = _this$parseClassifica2.optMap;
1443
1448
  var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
1444
1449
  var customData = {};
1445
- Object.entries(metaData).filter(function (_ref36) {
1446
- var _ref37 = _slicedToArray(_ref36, 1),
1447
- key = _ref37[0];
1450
+ Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref37) {
1451
+ var _ref38 = _slicedToArray(_ref37, 1),
1452
+ key = _ref38[0];
1448
1453
  return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
1449
- }).forEach(function (_ref38) {
1450
- var _ref39 = _slicedToArray(_ref38, 2),
1451
- key = _ref39[0],
1452
- value = _ref39[1];
1454
+ }).forEach(function (_ref39) {
1455
+ var _ref40 = _slicedToArray(_ref39, 2),
1456
+ key = _ref40[0],
1457
+ value = _ref40[1];
1453
1458
  var langs = {};
1454
1459
  if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
1455
1460
  for (var i = 0; i < metaData_locales[key].length; i++) {
@@ -1481,19 +1486,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1481
1486
 
1482
1487
  //repare customData
1483
1488
  //if it is defiend as multi field, use full array otherwise only first element of array
1484
- Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref40) {
1485
- var _ref41 = _slicedToArray(_ref40, 1),
1486
- key = _ref41[0];
1489
+ Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref41) {
1490
+ var _ref42 = _slicedToArray(_ref41, 1),
1491
+ key = _ref42[0];
1487
1492
  return customData[key] != undefined;
1488
- }).forEach(function (_ref42) {
1489
- var _ref43 = _slicedToArray(_ref42, 2),
1490
- key = _ref43[0],
1491
- value = _ref43[1];
1493
+ }).forEach(function (_ref43) {
1494
+ var _ref44 = _slicedToArray(_ref43, 2),
1495
+ key = _ref44[0],
1496
+ value = _ref44[1];
1492
1497
  if (value.multi && !Array.isArray(customData[key])) {
1493
1498
  customData[key] = [customData[key]];
1494
1499
  } else if (!value.multi && Array.isArray(customData[key])) {
1495
- var _key3;
1496
- customData[key] = (_key3 = customData[key]) === null || _key3 === void 0 ? void 0 : _key3[0];
1500
+ var _key2;
1501
+ customData[key] = (_key2 = customData[key]) === null || _key2 === void 0 ? void 0 : _key2[0];
1497
1502
  }
1498
1503
  });
1499
1504
  return {
@@ -1618,52 +1623,172 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1618
1623
  }
1619
1624
  return apiGetProducts;
1620
1625
  }()
1626
+ }, {
1627
+ key: "apiGetCatalogData",
1628
+ value: function () {
1629
+ var _apiGetCatalogData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(catalogCodex, language, accountId) {
1630
+ var _response$CollectionG, _response$Properties, _response$Properties2;
1631
+ var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
1632
+ return _regeneratorRuntime.wrap(function _callee7$(_context8) {
1633
+ while (1) switch (_context8.prev = _context8.next) {
1634
+ case 0:
1635
+ _context8.next = 2;
1636
+ return this.apiAccountLogin(accountId);
1637
+ case 2:
1638
+ currentAccountSessionId = _context8.sent;
1639
+ if (currentAccountSessionId) {
1640
+ _context8.next = 5;
1641
+ break;
1642
+ }
1643
+ return _context8.abrupt("return");
1644
+ case 5:
1645
+ fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
1646
+ _context8.next = 8;
1647
+ return fetch(fullUrl, {
1648
+ headers: {
1649
+ sessionGuid: currentAccountSessionId
1650
+ }
1651
+ }).then(function (res) {
1652
+ if (res.status !== 200) {
1653
+ throw new Error('Collections not loaded.');
1654
+ }
1655
+ return res.json();
1656
+ });
1657
+ case 8:
1658
+ response = _context8.sent;
1659
+ if (!response.Error) {
1660
+ _context8.next = 11;
1661
+ break;
1662
+ }
1663
+ throw new Error(response.Error);
1664
+ case 11:
1665
+ actCatalogInfoData = {
1666
+ lang: language,
1667
+ guid: response.GUID,
1668
+ name: response.Name,
1669
+ name_locales: response.Name_locales,
1670
+ codex: catalogCodex,
1671
+ accountLogo: response.AccountLogo,
1672
+ description: response.LongDescription,
1673
+ description_locales: response.LongDescription_locales,
1674
+ hasPlanner: response.HasIDMPlanner == 'True',
1675
+ brand: response.Brandname,
1676
+ supplierGuid: response.SupplierGUID,
1677
+ retailCatalogNr: response.RetailCatalogNr,
1678
+ accountGuid: (_response$CollectionG = response.CollectionGuid) !== null && _response$CollectionG !== void 0 ? _response$CollectionG : response.AccountGuid,
1679
+ options: response.Options,
1680
+ optionValues: response.Optionvalues,
1681
+ currency: response.currency,
1682
+ has3D: !!((_response$Properties = response.Properties) !== null && _response$Properties !== void 0 && (_response$Properties = _response$Properties.find(function (p) {
1683
+ return p.Codex == 'DIVA3D_RENDERING';
1684
+ })) !== null && _response$Properties !== void 0 && _response$Properties.Value),
1685
+ images: [],
1686
+ documents: [],
1687
+ accountSessionId: response.AccountSessionGuid,
1688
+ arReady: !!((_response$Properties2 = response.Properties) !== null && _response$Properties2 !== void 0 && (_response$Properties2 = _response$Properties2.find(function (p) {
1689
+ return p.Codex == 'DIVA3D_AR_READY';
1690
+ })) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
1691
+ };
1692
+ return _context8.abrupt("return", actCatalogInfoData);
1693
+ case 13:
1694
+ case "end":
1695
+ return _context8.stop();
1696
+ }
1697
+ }, _callee7, this);
1698
+ }));
1699
+ function apiGetCatalogData(_x9, _x10, _x11) {
1700
+ return _apiGetCatalogData.apply(this, arguments);
1701
+ }
1702
+ return apiGetCatalogData;
1703
+ }()
1704
+ }, {
1705
+ key: "apiAccountLogin",
1706
+ value: function () {
1707
+ var _apiAccountLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(accountId) {
1708
+ var fullUrl, response;
1709
+ return _regeneratorRuntime.wrap(function _callee8$(_context9) {
1710
+ while (1) switch (_context9.prev = _context9.next) {
1711
+ case 0:
1712
+ fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
1713
+ _context9.t0 = fetch;
1714
+ _context9.t1 = fullUrl;
1715
+ _context9.next = 5;
1716
+ return this.sessionGuid;
1717
+ case 5:
1718
+ _context9.t2 = _context9.sent;
1719
+ _context9.t3 = {
1720
+ sessionGuid: _context9.t2
1721
+ };
1722
+ _context9.t4 = {
1723
+ headers: _context9.t3
1724
+ };
1725
+ _context9.next = 10;
1726
+ return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
1727
+ if (res.status !== 200) {
1728
+ throw new Error('Collections not loaded.');
1729
+ }
1730
+ return res.json();
1731
+ });
1732
+ case 10:
1733
+ response = _context9.sent;
1734
+ return _context9.abrupt("return", response.SessionGUID);
1735
+ case 12:
1736
+ case "end":
1737
+ return _context9.stop();
1738
+ }
1739
+ }, _callee8, this);
1740
+ }));
1741
+ function apiAccountLogin(_x12) {
1742
+ return _apiAccountLogin.apply(this, arguments);
1743
+ }
1744
+ return apiAccountLogin;
1745
+ }()
1621
1746
  }, {
1622
1747
  key: "apiGetProductVariants",
1623
1748
  value: function () {
1624
- var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, full) {
1749
+ var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, full) {
1625
1750
  var _res2;
1626
1751
  var fullUrl, res, resData;
1627
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
1628
- while (1) switch (_context8.prev = _context8.next) {
1752
+ return _regeneratorRuntime.wrap(function _callee9$(_context10) {
1753
+ while (1) switch (_context10.prev = _context10.next) {
1629
1754
  case 0:
1630
1755
  fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
1631
- _context8.prev = 1;
1632
- _context8.next = 4;
1756
+ _context10.prev = 1;
1757
+ _context10.next = 4;
1633
1758
  return axios.get(fullUrl, {
1634
1759
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1635
1760
  'Content-Type': 'application/json'
1636
1761
  })
1637
1762
  });
1638
1763
  case 4:
1639
- res = _context8.sent;
1640
- _context8.next = 7;
1764
+ res = _context10.sent;
1765
+ _context10.next = 7;
1641
1766
  return res.data;
1642
1767
  case 7:
1643
- resData = _context8.sent;
1644
- _context8.next = 13;
1768
+ resData = _context10.sent;
1769
+ _context10.next = 13;
1645
1770
  break;
1646
1771
  case 10:
1647
- _context8.prev = 10;
1648
- _context8.t0 = _context8["catch"](1);
1772
+ _context10.prev = 10;
1773
+ _context10.t0 = _context10["catch"](1);
1649
1774
  throw new Error('Could not get existing products', {
1650
- cause: _context8.t0
1775
+ cause: _context10.t0
1651
1776
  });
1652
1777
  case 13:
1653
1778
  if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
1654
- _context8.next = 15;
1779
+ _context10.next = 15;
1655
1780
  break;
1656
1781
  }
1657
- return _context8.abrupt("return", resData);
1782
+ return _context10.abrupt("return", resData);
1658
1783
  case 15:
1659
1784
  throw new Error(resData.error);
1660
1785
  case 16:
1661
1786
  case "end":
1662
- return _context8.stop();
1787
+ return _context10.stop();
1663
1788
  }
1664
- }, _callee7, this, [[1, 10]]);
1789
+ }, _callee9, this, [[1, 10]]);
1665
1790
  }));
1666
- function apiGetProductVariants(_x9, _x10) {
1791
+ function apiGetProductVariants(_x13, _x14) {
1667
1792
  return _apiGetProductVariants.apply(this, arguments);
1668
1793
  }
1669
1794
  return apiGetProductVariants;
@@ -1671,7 +1796,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1671
1796
  }, {
1672
1797
  key: "apiGetProductByFilter",
1673
1798
  value: function () {
1674
- var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(filter) {
1799
+ var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(filter) {
1675
1800
  var _res3;
1676
1801
  var limit,
1677
1802
  useFilter,
@@ -1680,39 +1805,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1680
1805
  res,
1681
1806
  resData,
1682
1807
  filterParam,
1683
- _args9 = arguments;
1684
- return _regeneratorRuntime.wrap(function _callee8$(_context9) {
1685
- while (1) switch (_context9.prev = _context9.next) {
1808
+ _args11 = arguments;
1809
+ return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1810
+ while (1) switch (_context11.prev = _context11.next) {
1686
1811
  case 0:
1687
- limit = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 1;
1688
- useFilter = _args9.length > 2 ? _args9[2] : undefined;
1689
- hierarchy = _args9.length > 3 ? _args9[3] : undefined;
1812
+ limit = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 1;
1813
+ useFilter = _args11.length > 2 ? _args11[2] : undefined;
1814
+ hierarchy = _args11.length > 3 ? _args11[3] : undefined;
1690
1815
  fullUrl = this.catalogService + '/v1/products';
1691
- _context9.prev = 4;
1816
+ _context11.prev = 4;
1692
1817
  filterParam = useFilter ? 'filter' : 'search';
1693
- _context9.next = 8;
1818
+ _context11.next = 8;
1694
1819
  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), {
1695
1820
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1696
1821
  'Content-Type': 'application/json'
1697
1822
  })
1698
1823
  });
1699
1824
  case 8:
1700
- res = _context9.sent;
1701
- _context9.next = 11;
1825
+ res = _context11.sent;
1826
+ _context11.next = 11;
1702
1827
  return res.data;
1703
1828
  case 11:
1704
- resData = _context9.sent;
1705
- _context9.next = 17;
1829
+ resData = _context11.sent;
1830
+ _context11.next = 17;
1706
1831
  break;
1707
1832
  case 14:
1708
- _context9.prev = 14;
1709
- _context9.t0 = _context9["catch"](4);
1833
+ _context11.prev = 14;
1834
+ _context11.t0 = _context11["catch"](4);
1710
1835
  throw new Error('Could not get existing products', {
1711
- cause: _context9.t0
1836
+ cause: _context11.t0
1712
1837
  });
1713
1838
  case 17:
1714
1839
  if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
1715
- _context9.next = 20;
1840
+ _context11.next = 20;
1716
1841
  break;
1717
1842
  }
1718
1843
  //in order to be backwardscompatible we must transform old products here
@@ -1725,27 +1850,79 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1725
1850
  }
1726
1851
  return d;
1727
1852
  });
1728
- return _context9.abrupt("return", resData);
1853
+ return _context11.abrupt("return", resData);
1729
1854
  case 20:
1730
1855
  throw new Error(resData.error);
1731
1856
  case 21:
1732
1857
  case "end":
1733
- return _context9.stop();
1858
+ return _context11.stop();
1734
1859
  }
1735
- }, _callee8, this, [[4, 14]]);
1860
+ }, _callee10, this, [[4, 14]]);
1736
1861
  }));
1737
- function apiGetProductByFilter(_x11) {
1862
+ function apiGetProductByFilter(_x15) {
1738
1863
  return _apiGetProductByFilter.apply(this, arguments);
1739
1864
  }
1740
1865
  return apiGetProductByFilter;
1741
1866
  }()
1867
+ }, {
1868
+ key: "apiSetCustomFlag",
1869
+ value: function () {
1870
+ var _apiSetCustomFlag = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(id, flagName, organizationId, dependsOn) {
1871
+ var _res4;
1872
+ var fullUrl, res, resData;
1873
+ return _regeneratorRuntime.wrap(function _callee11$(_context12) {
1874
+ while (1) switch (_context12.prev = _context12.next) {
1875
+ case 0:
1876
+ fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/' + flagName);
1877
+ fullUrl.searchParams.append('organizationId', organizationId);
1878
+ if (dependsOn) fullUrl.searchParams.append('dependsOn', dependsOn);
1879
+ _context12.prev = 3;
1880
+ _context12.next = 6;
1881
+ return axios.post(fullUrl.toString(), undefined, {
1882
+ headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1883
+ 'Content-Type': 'application/json'
1884
+ })
1885
+ });
1886
+ case 6:
1887
+ res = _context12.sent;
1888
+ _context12.next = 9;
1889
+ return res.data;
1890
+ case 9:
1891
+ resData = _context12.sent;
1892
+ _context12.next = 15;
1893
+ break;
1894
+ case 12:
1895
+ _context12.prev = 12;
1896
+ _context12.t0 = _context12["catch"](3);
1897
+ throw new Error('Could not get existing products', {
1898
+ cause: _context12.t0
1899
+ });
1900
+ case 15:
1901
+ if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
1902
+ _context12.next = 17;
1903
+ break;
1904
+ }
1905
+ return _context12.abrupt("return", resData);
1906
+ case 17:
1907
+ throw new Error(resData.error);
1908
+ case 18:
1909
+ case "end":
1910
+ return _context12.stop();
1911
+ }
1912
+ }, _callee11, this, [[3, 12]]);
1913
+ }));
1914
+ function apiSetCustomFlag(_x16, _x17, _x18, _x19) {
1915
+ return _apiSetCustomFlag.apply(this, arguments);
1916
+ }
1917
+ return apiSetCustomFlag;
1918
+ }()
1742
1919
  }, {
1743
1920
  key: "apiDeleteProducts",
1744
1921
  value: function () {
1745
- var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(products) {
1922
+ var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(products) {
1746
1923
  var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
1747
- return _regeneratorRuntime.wrap(function _callee9$(_context10) {
1748
- while (1) switch (_context10.prev = _context10.next) {
1924
+ return _regeneratorRuntime.wrap(function _callee12$(_context13) {
1925
+ while (1) switch (_context13.prev = _context13.next) {
1749
1926
  case 0:
1750
1927
  fullUrl = this.catalogService + '/products';
1751
1928
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1756,7 +1933,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1756
1933
  i = 0;
1757
1934
  case 5:
1758
1935
  if (!(i < productsInChunks.length)) {
1759
- _context10.next = 13;
1936
+ _context13.next = 13;
1760
1937
  break;
1761
1938
  }
1762
1939
  promises = productsInChunks[i].map(function (p) {
@@ -1778,19 +1955,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1778
1955
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
1779
1956
  dontRenderForm: true
1780
1957
  });
1781
- _context10.next = 10;
1958
+ _context13.next = 10;
1782
1959
  return Promise.all(promises);
1783
1960
  case 10:
1784
1961
  i++;
1785
- _context10.next = 5;
1962
+ _context13.next = 5;
1786
1963
  break;
1787
1964
  case 13:
1788
1965
  case "end":
1789
- return _context10.stop();
1966
+ return _context13.stop();
1790
1967
  }
1791
- }, _callee9, this);
1968
+ }, _callee12, this);
1792
1969
  }));
1793
- function apiDeleteProducts(_x12) {
1970
+ function apiDeleteProducts(_x20) {
1794
1971
  return _apiDeleteProducts.apply(this, arguments);
1795
1972
  }
1796
1973
  return apiDeleteProducts;
@@ -1807,12 +1984,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1807
1984
  }, {
1808
1985
  key: "apiLoadProductVariantsGrouped",
1809
1986
  value: function () {
1810
- var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref44) {
1811
- var limit, skip, fields, _ref44$search, search, sort, abortController, fullUrl, headers, promise;
1812
- return _regeneratorRuntime.wrap(function _callee10$(_context11) {
1813
- while (1) switch (_context11.prev = _context11.next) {
1987
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref45) {
1988
+ var limit, skip, fields, _ref45$search, search, sort, abortController, fullUrl, headers, promise;
1989
+ return _regeneratorRuntime.wrap(function _callee13$(_context14) {
1990
+ while (1) switch (_context14.prev = _context14.next) {
1814
1991
  case 0:
1815
- 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;
1992
+ 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;
1816
1993
  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) : '');
1817
1994
  headers = {
1818
1995
  'Content-Type': 'application/json'
@@ -1834,32 +2011,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1834
2011
  reject('Error loading products grouped by variants: ' + error.message);
1835
2012
  });
1836
2013
  });
1837
- _context11.next = 7;
2014
+ _context14.next = 7;
1838
2015
  return promise;
1839
2016
  case 7:
1840
- return _context11.abrupt("return", _context11.sent);
2017
+ return _context14.abrupt("return", _context14.sent);
1841
2018
  case 8:
1842
2019
  case "end":
1843
- return _context11.stop();
2020
+ return _context14.stop();
1844
2021
  }
1845
- }, _callee10, this);
2022
+ }, _callee13, this);
1846
2023
  }));
1847
- function apiLoadProductVariantsGrouped(_x13) {
2024
+ function apiLoadProductVariantsGrouped(_x21) {
1848
2025
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
1849
2026
  }
1850
2027
  return apiLoadProductVariantsGrouped;
1851
2028
  }()
1852
2029
  }, {
1853
- key: "apiSaveBasketAndProducts",
2030
+ key: "apiSaveProducts",
1854
2031
  value: function () {
1855
- var _apiSaveBasketAndProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(serverUrl, jwt, products, awaitPDF, basket, removedProductIds) {
2032
+ var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
1856
2033
  var fullUrl, response, status;
1857
- return _regeneratorRuntime.wrap(function _callee11$(_context12) {
1858
- while (1) switch (_context12.prev = _context12.next) {
2034
+ return _regeneratorRuntime.wrap(function _callee14$(_context15) {
2035
+ while (1) switch (_context15.prev = _context15.next) {
1859
2036
  case 0:
1860
2037
  fullUrl = serverUrl + '/v1/products/groups';
1861
- _context12.prev = 1;
1862
- _context12.next = 4;
2038
+ _context15.prev = 1;
2039
+ _context15.next = 4;
1863
2040
  return fetch(fullUrl, {
1864
2041
  method: 'PUT',
1865
2042
  headers: {
@@ -1867,7 +2044,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1867
2044
  'Content-Type': 'application/json'
1868
2045
  },
1869
2046
  body: JSON.stringify({
1870
- basket: basket ? basket.getAsJson() : undefined,
1871
2047
  products: products,
1872
2048
  removedProductIds: removedProductIds,
1873
2049
  awaitPDF: awaitPDF
@@ -1880,31 +2056,31 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1880
2056
  return res.json();
1881
2057
  });
1882
2058
  case 4:
1883
- response = _context12.sent;
2059
+ response = _context15.sent;
1884
2060
  if (!response.Error) {
1885
- _context12.next = 7;
2061
+ _context15.next = 7;
1886
2062
  break;
1887
2063
  }
1888
2064
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
1889
2065
  case 7:
1890
- _context12.next = 12;
2066
+ _context15.next = 12;
1891
2067
  break;
1892
2068
  case 9:
1893
- _context12.prev = 9;
1894
- _context12.t0 = _context12["catch"](1);
2069
+ _context15.prev = 9;
2070
+ _context15.t0 = _context15["catch"](1);
1895
2071
  throw Error(status);
1896
2072
  case 12:
1897
- return _context12.abrupt("return", response.products);
2073
+ return _context15.abrupt("return", response.products);
1898
2074
  case 13:
1899
2075
  case "end":
1900
- return _context12.stop();
2076
+ return _context15.stop();
1901
2077
  }
1902
- }, _callee11, null, [[1, 9]]);
2078
+ }, _callee14, null, [[1, 9]]);
1903
2079
  }));
1904
- function apiSaveBasketAndProducts(_x14, _x15, _x16, _x17, _x18, _x19) {
1905
- return _apiSaveBasketAndProducts.apply(this, arguments);
2080
+ function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
2081
+ return _apiSaveProducts.apply(this, arguments);
1906
2082
  }
1907
- return apiSaveBasketAndProducts;
2083
+ return apiSaveProducts;
1908
2084
  }()
1909
2085
  }, {
1910
2086
  key: "parseFilter",
@@ -1936,53 +2112,53 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1936
2112
  }], [{
1937
2113
  key: "isSameProduct",
1938
2114
  value: function isSameProduct(product, setHash, diva3dProject, orderLines, varinatData, catalogCodex) {
1939
- var _product$articles;
2115
+ var _product$configuratio, _product$configuratio2, _product$configuratio3;
1940
2116
  //For new products we store the setHash and Diva3DProject in order to determine if the product changed.
1941
2117
  if (product.uniqueHash !== undefined) {
1942
2118
  return product.uniqueHash === 'v1' + setHash + (diva3dProject ? md5(diva3dProject) : '');
1943
2119
  }
1944
2120
 
1945
2121
  //For older products without setHash we use the old comparison logic
1946
- if (((_product$articles = product.articles) === null || _product$articles === void 0 ? void 0 : _product$articles.length) != (orderLines === null || orderLines === void 0 ? void 0 : orderLines.length)) {
2122
+ 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)) {
1947
2123
  return false;
1948
2124
  }
1949
2125
  if (!varinatData) {
1950
2126
  //the old logic was only for variants, not for base products
1951
2127
  return true;
1952
2128
  }
2129
+ 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 : [];
1953
2130
  var _loop2 = function _loop2() {
1954
- var _article$variantValue;
1955
- var article = product.articles[i];
2131
+ var article = orderlines[i];
1956
2132
  var orderLine = orderLines.find(function (ol) {
1957
- return ol.ArticleCodex == article.articleCodex && catalogCodex == article.catalogCodex;
2133
+ return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
1958
2134
  });
1959
- 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)) {
2135
+ if (!orderLine) {
1960
2136
  return {
1961
2137
  v: false
1962
2138
  };
1963
2139
  }
1964
- var _loop3 = function _loop3() {
1965
- var varinatValue = article.variantValues[j];
1966
- if (!(varinatData !== null && varinatData !== void 0 && varinatData.find(function (vb) {
1967
- return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
1968
- }))) {
1969
- return {
1970
- v: {
1971
- v: false
1972
- }
1973
- };
1974
- }
1975
- },
1976
- _ret2;
1977
- for (var j = 0; j < (((_article$variantValue2 = article.variantValues) === null || _article$variantValue2 === void 0 ? void 0 : _article$variantValue2.length) || 0); j++) {
1978
- var _article$variantValue2;
1979
- _ret2 = _loop3();
1980
- if (_ret2) return _ret2.v;
2140
+ if (article.VariantBasketDatas.length) {
2141
+ var _loop3 = function _loop3() {
2142
+ var varinatValue = article.VariantBasketDatas[j];
2143
+ if (!varinatData.find(function (vb) {
2144
+ return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
2145
+ })) {
2146
+ return {
2147
+ v: {
2148
+ v: false
2149
+ }
2150
+ };
2151
+ }
2152
+ },
2153
+ _ret2;
2154
+ for (var j = 0; j < article.VariantBasketDatas.length; j++) {
2155
+ _ret2 = _loop3();
2156
+ if (_ret2) return _ret2.v;
2157
+ }
1981
2158
  }
1982
2159
  },
1983
2160
  _ret;
1984
- 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++) {
1985
- var _product$articles$len, _product$articles2;
2161
+ for (var i = 0; i < orderlines.length; i++) {
1986
2162
  _ret = _loop2();
1987
2163
  if (_ret) return _ret.v;
1988
2164
  }
@@ -2109,16 +2285,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2109
2285
  }, {
2110
2286
  key: "assign",
2111
2287
  value: function assign(target) {
2112
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
2113
- sources[_key4 - 1] = arguments[_key4];
2288
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
2289
+ sources[_key3 - 1] = arguments[_key3];
2114
2290
  }
2115
2291
  return Object.assign.apply(Object, [target].concat(_toConsumableArray(sources.filter(function (s) {
2116
2292
  return s;
2117
2293
  }).map(function (x) {
2118
- return Object.fromEntries(Object.entries(x).filter(function (_ref45) {
2119
- var _ref46 = _slicedToArray(_ref45, 2);
2120
- _ref46[0];
2121
- var value = _ref46[1];
2294
+ return Object.fromEntries(Object.entries(x).filter(function (_ref46) {
2295
+ var _ref47 = _slicedToArray(_ref46, 2);
2296
+ _ref47[0];
2297
+ var value = _ref47[1];
2122
2298
  return value !== undefined;
2123
2299
  }));
2124
2300
  }))));
@@ -2126,10 +2302,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2126
2302
  }, {
2127
2303
  key: "loadSelectOptions",
2128
2304
  value: function () {
2129
- var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(sessionGuid, dataSource, additionalFilter) {
2130
- var values, apiUrl, i, apiResult, _i3, value, text;
2131
- return _regeneratorRuntime.wrap(function _callee12$(_context13) {
2132
- while (1) switch (_context13.prev = _context13.next) {
2305
+ var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2306
+ var values, apiUrl, i, apiResult, _i2, value, text;
2307
+ return _regeneratorRuntime.wrap(function _callee15$(_context16) {
2308
+ while (1) switch (_context16.prev = _context16.next) {
2133
2309
  case 0:
2134
2310
  values = [];
2135
2311
  apiUrl = dataSource.url;
@@ -2138,7 +2314,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2138
2314
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2139
2315
  }
2140
2316
  }
2141
- _context13.next = 5;
2317
+ _context16.next = 5;
2142
2318
  return fetch(apiUrl, {
2143
2319
  headers: {
2144
2320
  sessionGuid: sessionGuid
@@ -2150,26 +2326,26 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2150
2326
  return res.json();
2151
2327
  });
2152
2328
  case 5:
2153
- apiResult = _context13.sent;
2329
+ apiResult = _context16.sent;
2154
2330
  if (dataSource.useKey) {
2155
2331
  apiResult = apiResult[dataSource.useKey];
2156
2332
  }
2157
- for (_i3 = 0; _i3 < apiResult.length; _i3++) {
2158
- value = apiResult[_i3][dataSource.fieldValueMapping];
2159
- text = apiResult[_i3][dataSource.fieldDescriptionMapping];
2333
+ for (_i2 = 0; _i2 < apiResult.length; _i2++) {
2334
+ value = apiResult[_i2][dataSource.fieldValueMapping];
2335
+ text = apiResult[_i2][dataSource.fieldDescriptionMapping];
2160
2336
  values.push({
2161
2337
  value: value,
2162
2338
  text: text
2163
2339
  });
2164
2340
  }
2165
- return _context13.abrupt("return", values);
2341
+ return _context16.abrupt("return", values);
2166
2342
  case 9:
2167
2343
  case "end":
2168
- return _context13.stop();
2344
+ return _context16.stop();
2169
2345
  }
2170
- }, _callee12);
2346
+ }, _callee15);
2171
2347
  }));
2172
- function loadSelectOptions(_x20, _x21, _x22) {
2348
+ function loadSelectOptions(_x27, _x28, _x29) {
2173
2349
  return _loadSelectOptions.apply(this, arguments);
2174
2350
  }
2175
2351
  return loadSelectOptions;
@@ -2182,6 +2358,36 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2182
2358
  return rv;
2183
2359
  }, {});
2184
2360
  }
2361
+ }, {
2362
+ key: "getVariantBasketDatasByOrderlines",
2363
+ value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
2364
+ var variantBasketDatas = [];
2365
+ var _loop5 = function _loop5() {
2366
+ var ol = orderLines[i];
2367
+ var catalog = catalogData.find(function (c) {
2368
+ return c.codex === ol.CatalogCodex;
2369
+ });
2370
+ if (!ol.VariantBasketDatas) return 1; // continue
2371
+ for (var j = 0; j < ol.VariantBasketDatas.length; j++) {
2372
+ var v = ol.VariantBasketDatas[j];
2373
+ var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
2374
+ var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
2375
+ {
2376
+ variantBasketDatas.push({
2377
+ BasketID: ol.BasketID,
2378
+ OPT: v.OPT,
2379
+ OPV: v.OPV,
2380
+ OPTName: opt.Name,
2381
+ OPVName: opv.Name
2382
+ });
2383
+ }
2384
+ }
2385
+ };
2386
+ for (var i = 0; i < orderLines.length; i++) {
2387
+ if (_loop5()) continue;
2388
+ }
2389
+ return variantBasketDatas;
2390
+ }
2185
2391
  }]);
2186
2392
  }();
2187
2393
  _ProductHandlerAbstract = ProductHandlerAbstract;