@crystaldesign/product-handler 24.15.0-beta.8 → 24.15.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +179 -96
- package/build/esm/index.js +179 -96
- package/build/types/product-handler/src/index.d.ts +7 -2
- package/build/types/product-handler/src/index.d.ts.map +1 -1
- package/build/types/product-handler/src/types.d.ts +2 -1
- package/build/types/product-handler/src/types.d.ts.map +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
40
40
|
_defineProperty(this, "_apiKey", void 0);
|
|
41
41
|
_defineProperty(this, "_catalogService", '');
|
|
42
42
|
_defineProperty(this, "_mediaService", '');
|
|
43
|
+
_defineProperty(this, "_basketService", '');
|
|
43
44
|
_defineProperty(this, "_api2", '');
|
|
44
45
|
_defineProperty(this, "_sessionGuid", '');
|
|
45
46
|
_defineProperty(this, "_organization", {});
|
|
@@ -60,6 +61,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
60
61
|
set: function set(val) {
|
|
61
62
|
this._catalogService = val;
|
|
62
63
|
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "basketService",
|
|
66
|
+
get: function get() {
|
|
67
|
+
return this._basketService;
|
|
68
|
+
},
|
|
69
|
+
set: function set(val) {
|
|
70
|
+
this._basketService = val;
|
|
71
|
+
}
|
|
63
72
|
}, {
|
|
64
73
|
key: "mediaService",
|
|
65
74
|
get: function get() {
|
|
@@ -184,46 +193,47 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
184
193
|
value: (function () {
|
|
185
194
|
var _loadProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
186
195
|
var _this = this,
|
|
196
|
+
_baseProduct$divaNr,
|
|
187
197
|
_baseProduct,
|
|
188
|
-
_basket$getProductCon,
|
|
189
198
|
_baseProduct2,
|
|
190
199
|
_baseProduct3,
|
|
191
|
-
|
|
200
|
+
_basket$getProductCon,
|
|
192
201
|
_baseProduct4,
|
|
202
|
+
_baseProduct5,
|
|
193
203
|
_dataByBasket$price$a,
|
|
194
204
|
_dataByBasket$price,
|
|
195
|
-
_baseProduct5,
|
|
196
|
-
_dataByBasket$image,
|
|
197
205
|
_baseProduct6,
|
|
198
|
-
_dataByBasket$
|
|
206
|
+
_dataByBasket$image,
|
|
199
207
|
_baseProduct7,
|
|
200
|
-
_dataByBasket$
|
|
208
|
+
_dataByBasket$image2D,
|
|
201
209
|
_baseProduct8,
|
|
202
|
-
|
|
210
|
+
_dataByBasket$docking,
|
|
203
211
|
_baseProduct9,
|
|
212
|
+
_baseProduct$organiza,
|
|
213
|
+
_baseProduct10,
|
|
204
214
|
_this$organization$pa,
|
|
205
215
|
_this$organization$pa2,
|
|
206
216
|
_baseProduct$createdB,
|
|
207
|
-
_baseProduct10,
|
|
208
|
-
_this$user,
|
|
209
217
|
_baseProduct11,
|
|
218
|
+
_this$user,
|
|
210
219
|
_baseProduct12,
|
|
211
220
|
_baseProduct13,
|
|
212
221
|
_baseProduct14,
|
|
213
|
-
_dataByBasket$orderTe,
|
|
214
222
|
_baseProduct15,
|
|
215
|
-
_dataByBasket$
|
|
223
|
+
_dataByBasket$orderTe,
|
|
216
224
|
_baseProduct16,
|
|
225
|
+
_dataByBasket$technic,
|
|
217
226
|
_baseProduct17,
|
|
227
|
+
_baseProduct18,
|
|
218
228
|
_ref3,
|
|
219
229
|
_baseProduct$configur3,
|
|
220
|
-
|
|
221
|
-
var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
|
|
230
|
+
_baseProduct19;
|
|
231
|
+
var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, getUniqueNewDivaNr, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, myDivaNr, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
|
|
222
232
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
223
233
|
while (1) switch (_context2.prev = _context2.next) {
|
|
224
234
|
case 0:
|
|
225
|
-
basket = _ref2.basket, divaNr = _ref2.divaNr, catalogData = _ref2.catalogData, productData = _ref2.productData, classificationFields = _ref2.classificationFields, fieldConfiguration = _ref2.fieldConfiguration, customBaseFields = _ref2.customBaseFields, classificationConfig = _ref2.classificationConfig, _ref2$availableLangua = _ref2.availableLanguages, availableLanguages = _ref2$availableLangua === void 0 ? ['de', 'fr', 'it', 'en'] : _ref2$availableLangua, _ref2$currentLang = _ref2.currentLang, currentLang = _ref2$currentLang === void 0 ? 'de' : _ref2$currentLang;
|
|
226
|
-
if (!(!productData && !divaNr)) {
|
|
235
|
+
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, getUniqueNewDivaNr = _ref2.getUniqueNewDivaNr;
|
|
236
|
+
if (!(!productData && !divaNr && !getUniqueNewDivaNr)) {
|
|
227
237
|
_context2.next = 3;
|
|
228
238
|
break;
|
|
229
239
|
}
|
|
@@ -290,7 +300,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
290
300
|
}
|
|
291
301
|
throw new Error('If existing products are fetched, there has to be atleast a base product.');
|
|
292
302
|
case 25:
|
|
293
|
-
|
|
303
|
+
myDivaNr = (_baseProduct$divaNr = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr;
|
|
304
|
+
if (!(!((_baseProduct2 = baseProduct) !== null && _baseProduct2 !== void 0 && _baseProduct2.divaNr) && getUniqueNewDivaNr)) {
|
|
305
|
+
_context2.next = 30;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
_context2.next = 29;
|
|
309
|
+
return this.apiGetUniqueDivaNr();
|
|
310
|
+
case 29:
|
|
311
|
+
myDivaNr = _context2.sent;
|
|
312
|
+
case 30:
|
|
313
|
+
dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct, getUniqueNewDivaNr ? myDivaNr : undefined); //to remember what for position was previously set for the classification
|
|
294
314
|
oldClassificationData = {};
|
|
295
315
|
for (i = 0; i < products.data.length; i++) {
|
|
296
316
|
variant = products.data[i];
|
|
@@ -301,27 +321,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
301
321
|
}
|
|
302
322
|
}
|
|
303
323
|
}
|
|
304
|
-
oldUniqueHash = (
|
|
305
|
-
configuration = (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (
|
|
324
|
+
oldUniqueHash = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.uniqueHash;
|
|
325
|
+
configuration = (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.configuration;
|
|
326
|
+
if (getUniqueNewDivaNr && myDivaNr) {
|
|
327
|
+
configuration = _objectSpread(_objectSpread({}, configuration), {}, {
|
|
328
|
+
DivaNr: myDivaNr
|
|
329
|
+
});
|
|
330
|
+
}
|
|
306
331
|
baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
|
|
307
|
-
_id: ((
|
|
308
|
-
divaNr:
|
|
309
|
-
addedPrice: (_dataByBasket$price$a = dataByBasket === null || dataByBasket === void 0 || (_dataByBasket$price = dataByBasket.price) === null || _dataByBasket$price === void 0 ? void 0 : _dataByBasket$price.addedPrice) !== null && _dataByBasket$price$a !== void 0 ? _dataByBasket$price$a : (
|
|
310
|
-
image: (_dataByBasket$image = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image) !== null && _dataByBasket$image !== void 0 ? _dataByBasket$image : (
|
|
311
|
-
image2D: (_dataByBasket$image2D = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image2D) !== null && _dataByBasket$image2D !== void 0 ? _dataByBasket$image2D : (
|
|
332
|
+
_id: ((_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5._id) || nanoid(),
|
|
333
|
+
divaNr: myDivaNr,
|
|
334
|
+
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 : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.addedPrice,
|
|
335
|
+
image: (_dataByBasket$image = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image) !== null && _dataByBasket$image !== void 0 ? _dataByBasket$image : (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.image,
|
|
336
|
+
image2D: (_dataByBasket$image2D = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image2D) !== null && _dataByBasket$image2D !== void 0 ? _dataByBasket$image2D : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.image2D,
|
|
312
337
|
configuration: configuration,
|
|
313
|
-
dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (
|
|
338
|
+
dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.dockingPoints,
|
|
314
339
|
currency: DivaUtils.defaultPriceFormat.currency,
|
|
315
|
-
organizationId: (_baseProduct$organiza = (
|
|
340
|
+
organizationId: (_baseProduct$organiza = (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
|
|
316
341
|
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) {
|
|
317
342
|
return o._id;
|
|
318
343
|
})) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
|
|
319
|
-
createdBy: (_baseProduct$createdB = (
|
|
320
|
-
createdBy_displayText: (
|
|
321
|
-
archived: (
|
|
322
|
-
isTopseller: !!((
|
|
323
|
-
orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (
|
|
324
|
-
technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (
|
|
344
|
+
createdBy: (_baseProduct$createdB = (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
|
|
345
|
+
createdBy_displayText: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.createdBy_displayText,
|
|
346
|
+
archived: (_baseProduct13 = baseProduct) !== null && _baseProduct13 !== void 0 && _baseProduct13.archived ? (_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.archived : false,
|
|
347
|
+
isTopseller: !!((_baseProduct15 = baseProduct) !== null && _baseProduct15 !== void 0 && _baseProduct15.isTopseller),
|
|
348
|
+
orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.orderText,
|
|
349
|
+
technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.technicalDescription
|
|
325
350
|
});
|
|
326
351
|
metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
|
|
327
352
|
return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
|
|
@@ -330,7 +355,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
330
355
|
return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
|
|
331
356
|
}, {});
|
|
332
357
|
_this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
|
|
333
|
-
baseData.customData = _objectSpread(_objectSpread({}, (
|
|
358
|
+
baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.customData), customData);
|
|
334
359
|
|
|
335
360
|
//add livingarea,maincategorie,subcategorie of loaded product if not exists
|
|
336
361
|
classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
|
|
@@ -347,11 +372,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
347
372
|
optFields = [];
|
|
348
373
|
initialSelectedFields = [];
|
|
349
374
|
if (!dataByBasket.isSet) {
|
|
350
|
-
_context2.next =
|
|
375
|
+
_context2.next = 52;
|
|
351
376
|
break;
|
|
352
377
|
}
|
|
353
378
|
throw new Error('Variants are currently not supported for set products');
|
|
354
|
-
case
|
|
379
|
+
case 52:
|
|
355
380
|
//iterate all existing variant products and add them to the variants
|
|
356
381
|
usedVariantIds = [];
|
|
357
382
|
variantProducts.forEach(function (product) {
|
|
@@ -407,7 +432,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
407
432
|
}
|
|
408
433
|
|
|
409
434
|
//get opt data
|
|
410
|
-
differingOPTs = Object.entries(((_ref3 = (_baseProduct$configur3 = (
|
|
435
|
+
differingOPTs = Object.entries(((_ref3 = (_baseProduct$configur3 = (_baseProduct19 = baseProduct) === null || _baseProduct19 === void 0 ? void 0 : _baseProduct19.configuration) !== null && _baseProduct$configur3 !== void 0 ? _baseProduct$configur3 : basket) === null || _ref3 === void 0 || (_ref3 = _ref3.OrderSets[0].Favorites) === null || _ref3 === void 0 ? void 0 : _ref3.VariantValues) || []).filter(function (_ref4) {
|
|
411
436
|
var _ref5 = _slicedToArray(_ref4, 2);
|
|
412
437
|
_ref5[0];
|
|
413
438
|
var value = _ref5[1];
|
|
@@ -482,7 +507,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
482
507
|
availableLanguages: availableLanguages,
|
|
483
508
|
currentLang: currentLang
|
|
484
509
|
});
|
|
485
|
-
case
|
|
510
|
+
case 65:
|
|
486
511
|
case "end":
|
|
487
512
|
return _context2.stop();
|
|
488
513
|
}
|
|
@@ -495,7 +520,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
495
520
|
}())
|
|
496
521
|
}, {
|
|
497
522
|
key: "getProductDataByBasket",
|
|
498
|
-
value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
|
|
523
|
+
value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct, customDivaNr) {
|
|
499
524
|
var dataByBasket = {};
|
|
500
525
|
var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
|
|
501
526
|
dataByBasket.isSet = isSet;
|
|
@@ -671,7 +696,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
671
696
|
}).filter(function (f) {
|
|
672
697
|
return f;
|
|
673
698
|
});
|
|
674
|
-
dataByBasket.orderText = basket.getEKText(true);
|
|
699
|
+
dataByBasket.orderText = basket.getEKText(true, customDivaNr);
|
|
675
700
|
dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
|
|
676
701
|
return os.SetHash;
|
|
677
702
|
}).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
|
|
@@ -825,10 +850,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
825
850
|
this.trimStrings(baseData);
|
|
826
851
|
//the base product is constructed, based on baseData and classification data
|
|
827
852
|
baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref13) {
|
|
853
|
+
var _fieldConfiguration$c;
|
|
828
854
|
var _ref14 = _slicedToArray(_ref13, 2),
|
|
829
855
|
key = _ref14[0],
|
|
830
856
|
value = _ref14[1];
|
|
831
|
-
prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0
|
|
857
|
+
prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$c = fieldConfiguration.classMap[key]) === null || _fieldConfiguration$c === void 0 ? void 0 : _fieldConfiguration$c.values);
|
|
832
858
|
return prev;
|
|
833
859
|
}, {})), {}, {
|
|
834
860
|
_id: originProductId && !(variantData !== null && variantData !== void 0 && variantData.length) ? originProductId : baseData._id,
|
|
@@ -858,11 +884,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
858
884
|
var value = _ref18[1];
|
|
859
885
|
return value;
|
|
860
886
|
}).forEach(function (_ref19) {
|
|
861
|
-
var
|
|
887
|
+
var _baseProduct20;
|
|
862
888
|
var _ref20 = _slicedToArray(_ref19, 2),
|
|
863
889
|
key = _ref20[0],
|
|
864
890
|
value = _ref20[1];
|
|
865
|
-
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (
|
|
891
|
+
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct20 = baseProduct["dc_".concat(key)]) !== null && _baseProduct20 !== void 0 ? _baseProduct20 : {}), {}, {
|
|
866
892
|
opt: value.field
|
|
867
893
|
});
|
|
868
894
|
});
|
|
@@ -1005,7 +1031,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1005
1031
|
preparedProduct = {
|
|
1006
1032
|
parent: baseProduct._id,
|
|
1007
1033
|
baseProduct: false,
|
|
1008
|
-
_id: productId
|
|
1034
|
+
_id: productId,
|
|
1035
|
+
organizationId: baseProduct.organizationId
|
|
1009
1036
|
};
|
|
1010
1037
|
}
|
|
1011
1038
|
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;
|
|
@@ -1264,6 +1291,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1264
1291
|
if (isManual) {
|
|
1265
1292
|
addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
|
|
1266
1293
|
}
|
|
1294
|
+
var discountedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice;
|
|
1295
|
+
var noDiscountManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice) === undefined && (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.percentageDiscount) === 0;
|
|
1296
|
+
if (noDiscountManual) {
|
|
1297
|
+
discountedPrice = undefined;
|
|
1298
|
+
}
|
|
1267
1299
|
var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
|
|
1268
1300
|
classificationData = _this$parseMetaDataAn2.classificationData,
|
|
1269
1301
|
customData = _this$parseMetaDataAn2.customData;
|
|
@@ -1287,6 +1319,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1287
1319
|
//only if cv is not defined fallback to the values in product
|
|
1288
1320
|
addedPrice: addedPrice,
|
|
1289
1321
|
calculatedPrice: price.calculatedPrice,
|
|
1322
|
+
discountedPrice: discountedPrice,
|
|
1290
1323
|
variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
|
|
1291
1324
|
image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
|
|
1292
1325
|
image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
|
|
@@ -1957,12 +1990,62 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1957
1990
|
return apiMarkAsFavorite;
|
|
1958
1991
|
}()
|
|
1959
1992
|
}, {
|
|
1960
|
-
key: "
|
|
1993
|
+
key: "apiGetUniqueDivaNr",
|
|
1961
1994
|
value: function () {
|
|
1962
|
-
var
|
|
1963
|
-
var
|
|
1995
|
+
var _apiGetUniqueDivaNr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
1996
|
+
var _res5;
|
|
1997
|
+
var fullUrl, res, resData;
|
|
1964
1998
|
return _regeneratorRuntime.wrap(function _callee12$(_context14) {
|
|
1965
1999
|
while (1) switch (_context14.prev = _context14.next) {
|
|
2000
|
+
case 0:
|
|
2001
|
+
fullUrl = new URL(this.basketService + '/baskets/uniqueDivaNr');
|
|
2002
|
+
_context14.prev = 1;
|
|
2003
|
+
_context14.next = 4;
|
|
2004
|
+
return axios.get(fullUrl.toString(), {
|
|
2005
|
+
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
2006
|
+
'Content-Type': 'application/json'
|
|
2007
|
+
})
|
|
2008
|
+
});
|
|
2009
|
+
case 4:
|
|
2010
|
+
res = _context14.sent;
|
|
2011
|
+
_context14.next = 7;
|
|
2012
|
+
return res.data;
|
|
2013
|
+
case 7:
|
|
2014
|
+
resData = _context14.sent;
|
|
2015
|
+
_context14.next = 13;
|
|
2016
|
+
break;
|
|
2017
|
+
case 10:
|
|
2018
|
+
_context14.prev = 10;
|
|
2019
|
+
_context14.t0 = _context14["catch"](1);
|
|
2020
|
+
throw new Error('Error on activate product', {
|
|
2021
|
+
cause: _context14.t0
|
|
2022
|
+
});
|
|
2023
|
+
case 13:
|
|
2024
|
+
if (!(((_res5 = res) === null || _res5 === void 0 ? void 0 : _res5.status) == 200)) {
|
|
2025
|
+
_context14.next = 15;
|
|
2026
|
+
break;
|
|
2027
|
+
}
|
|
2028
|
+
return _context14.abrupt("return", resData.divaNr);
|
|
2029
|
+
case 15:
|
|
2030
|
+
throw new Error(resData.error);
|
|
2031
|
+
case 16:
|
|
2032
|
+
case "end":
|
|
2033
|
+
return _context14.stop();
|
|
2034
|
+
}
|
|
2035
|
+
}, _callee12, this, [[1, 10]]);
|
|
2036
|
+
}));
|
|
2037
|
+
function apiGetUniqueDivaNr() {
|
|
2038
|
+
return _apiGetUniqueDivaNr.apply(this, arguments);
|
|
2039
|
+
}
|
|
2040
|
+
return apiGetUniqueDivaNr;
|
|
2041
|
+
}()
|
|
2042
|
+
}, {
|
|
2043
|
+
key: "apiDeleteProducts",
|
|
2044
|
+
value: function () {
|
|
2045
|
+
var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(products) {
|
|
2046
|
+
var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
|
|
2047
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context15) {
|
|
2048
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1966
2049
|
case 0:
|
|
1967
2050
|
fullUrl = this.catalogService + '/products';
|
|
1968
2051
|
fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
|
|
@@ -1973,7 +2056,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1973
2056
|
i = 0;
|
|
1974
2057
|
case 5:
|
|
1975
2058
|
if (!(i < productsInChunks.length)) {
|
|
1976
|
-
|
|
2059
|
+
_context15.next = 13;
|
|
1977
2060
|
break;
|
|
1978
2061
|
}
|
|
1979
2062
|
promises = productsInChunks[i].map(function (p) {
|
|
@@ -1995,17 +2078,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1995
2078
|
title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
|
|
1996
2079
|
dontRenderForm: true
|
|
1997
2080
|
});
|
|
1998
|
-
|
|
2081
|
+
_context15.next = 10;
|
|
1999
2082
|
return Promise.all(promises);
|
|
2000
2083
|
case 10:
|
|
2001
2084
|
i++;
|
|
2002
|
-
|
|
2085
|
+
_context15.next = 5;
|
|
2003
2086
|
break;
|
|
2004
2087
|
case 13:
|
|
2005
2088
|
case "end":
|
|
2006
|
-
return
|
|
2089
|
+
return _context15.stop();
|
|
2007
2090
|
}
|
|
2008
|
-
},
|
|
2091
|
+
}, _callee13, this);
|
|
2009
2092
|
}));
|
|
2010
2093
|
function apiDeleteProducts(_x20) {
|
|
2011
2094
|
return _apiDeleteProducts.apply(this, arguments);
|
|
@@ -2024,13 +2107,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2024
2107
|
}, {
|
|
2025
2108
|
key: "apiLoadProductVariantsGrouped",
|
|
2026
2109
|
value: function () {
|
|
2027
|
-
var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2110
|
+
var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref45) {
|
|
2028
2111
|
var limit, skip, fields, _ref45$search, search, sort, favorites, abortController, fullUrl, headers, promise;
|
|
2029
|
-
return _regeneratorRuntime.wrap(function
|
|
2030
|
-
while (1) switch (
|
|
2112
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context16) {
|
|
2113
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2031
2114
|
case 0:
|
|
2032
2115
|
limit = _ref45.limit, skip = _ref45.skip, fields = _ref45.fields, _ref45$search = _ref45.search, search = _ref45$search === void 0 ? [] : _ref45$search, sort = _ref45.sort, favorites = _ref45.favorites, abortController = _ref45.abortController;
|
|
2033
|
-
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) : '') + (favorites ? '&favorites=true' : '');
|
|
2116
|
+
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.length ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
|
|
2034
2117
|
headers = {
|
|
2035
2118
|
'Content-Type': 'application/json'
|
|
2036
2119
|
};
|
|
@@ -2051,15 +2134,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2051
2134
|
reject('Error loading products grouped by variants: ' + error.message);
|
|
2052
2135
|
});
|
|
2053
2136
|
});
|
|
2054
|
-
|
|
2137
|
+
_context16.next = 7;
|
|
2055
2138
|
return promise;
|
|
2056
2139
|
case 7:
|
|
2057
|
-
return
|
|
2140
|
+
return _context16.abrupt("return", _context16.sent);
|
|
2058
2141
|
case 8:
|
|
2059
2142
|
case "end":
|
|
2060
|
-
return
|
|
2143
|
+
return _context16.stop();
|
|
2061
2144
|
}
|
|
2062
|
-
},
|
|
2145
|
+
}, _callee14, this);
|
|
2063
2146
|
}));
|
|
2064
2147
|
function apiLoadProductVariantsGrouped(_x21) {
|
|
2065
2148
|
return _apiLoadProductVariantsGrouped.apply(this, arguments);
|
|
@@ -2069,46 +2152,46 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2069
2152
|
}, {
|
|
2070
2153
|
key: "apiSaveProducts",
|
|
2071
2154
|
value: function () {
|
|
2072
|
-
var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2155
|
+
var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(serverUrl, jwt, products, awaitPDF, removedProductIds) {
|
|
2073
2156
|
var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop3, j;
|
|
2074
|
-
return _regeneratorRuntime.wrap(function
|
|
2075
|
-
while (1) switch (
|
|
2157
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context18) {
|
|
2158
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2076
2159
|
case 0:
|
|
2077
2160
|
fullUrl = serverUrl + '/v1/products/groups';
|
|
2078
|
-
BATCH_SIZE =
|
|
2161
|
+
BATCH_SIZE = 10;
|
|
2079
2162
|
productsPackages = [];
|
|
2080
2163
|
groupIndex = 0;
|
|
2081
2164
|
i = 0;
|
|
2082
2165
|
case 5:
|
|
2083
2166
|
if (!(i < products.length)) {
|
|
2084
|
-
|
|
2167
|
+
_context18.next = 15;
|
|
2085
2168
|
break;
|
|
2086
2169
|
}
|
|
2087
2170
|
if (!products[i].baseProduct) {
|
|
2088
|
-
|
|
2171
|
+
_context18.next = 9;
|
|
2089
2172
|
break;
|
|
2090
2173
|
}
|
|
2091
2174
|
baseProduct = products[i];
|
|
2092
|
-
return
|
|
2175
|
+
return _context18.abrupt("continue", 12);
|
|
2093
2176
|
case 9:
|
|
2094
2177
|
if (BATCH_SIZE < ((_productsPackages$gro = (_productsPackages$gro2 = productsPackages[groupIndex]) === null || _productsPackages$gro2 === void 0 ? void 0 : _productsPackages$gro2.length) !== null && _productsPackages$gro !== void 0 ? _productsPackages$gro : 0)) groupIndex++;
|
|
2095
2178
|
if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
|
|
2096
2179
|
productsPackages[groupIndex].push(products[i]);
|
|
2097
2180
|
case 12:
|
|
2098
2181
|
i++;
|
|
2099
|
-
|
|
2182
|
+
_context18.next = 5;
|
|
2100
2183
|
break;
|
|
2101
2184
|
case 15:
|
|
2102
2185
|
responseProducts = [];
|
|
2103
2186
|
_i2 = 0;
|
|
2104
2187
|
case 17:
|
|
2105
2188
|
if (!(_i2 < productsPackages.length)) {
|
|
2106
|
-
|
|
2189
|
+
_context18.next = 40;
|
|
2107
2190
|
break;
|
|
2108
2191
|
}
|
|
2109
|
-
if (baseProduct) productsPackages[_i2].unshift(baseProduct);
|
|
2110
|
-
|
|
2111
|
-
|
|
2192
|
+
if (baseProduct && _i2 == 0) productsPackages[_i2].unshift(baseProduct);
|
|
2193
|
+
_context18.prev = 19;
|
|
2194
|
+
_context18.next = 22;
|
|
2112
2195
|
return fetch(fullUrl, {
|
|
2113
2196
|
method: 'PUT',
|
|
2114
2197
|
headers: {
|
|
@@ -2128,23 +2211,23 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2128
2211
|
return res.json();
|
|
2129
2212
|
});
|
|
2130
2213
|
case 22:
|
|
2131
|
-
response =
|
|
2214
|
+
response = _context18.sent;
|
|
2132
2215
|
if (!response.Error) {
|
|
2133
|
-
|
|
2216
|
+
_context18.next = 25;
|
|
2134
2217
|
break;
|
|
2135
2218
|
}
|
|
2136
2219
|
throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
|
|
2137
2220
|
case 25:
|
|
2138
|
-
|
|
2221
|
+
_context18.next = 30;
|
|
2139
2222
|
break;
|
|
2140
2223
|
case 27:
|
|
2141
|
-
|
|
2142
|
-
|
|
2224
|
+
_context18.prev = 27;
|
|
2225
|
+
_context18.t0 = _context18["catch"](19);
|
|
2143
2226
|
throw Error(status);
|
|
2144
2227
|
case 30:
|
|
2145
2228
|
_loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3(j) {
|
|
2146
|
-
return _regeneratorRuntime.wrap(function _loop3$(
|
|
2147
|
-
while (1) switch (
|
|
2229
|
+
return _regeneratorRuntime.wrap(function _loop3$(_context17) {
|
|
2230
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2148
2231
|
case 0:
|
|
2149
2232
|
if (response.products[j].baseProduct) baseProduct = response.products[j];
|
|
2150
2233
|
if (!responseProducts.find(function (p) {
|
|
@@ -2154,32 +2237,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2154
2237
|
}
|
|
2155
2238
|
case 2:
|
|
2156
2239
|
case "end":
|
|
2157
|
-
return
|
|
2240
|
+
return _context17.stop();
|
|
2158
2241
|
}
|
|
2159
2242
|
}, _loop3);
|
|
2160
2243
|
});
|
|
2161
2244
|
j = 0;
|
|
2162
2245
|
case 32:
|
|
2163
2246
|
if (!(j < response.products.length)) {
|
|
2164
|
-
|
|
2247
|
+
_context18.next = 37;
|
|
2165
2248
|
break;
|
|
2166
2249
|
}
|
|
2167
|
-
return
|
|
2250
|
+
return _context18.delegateYield(_loop3(j), "t1", 34);
|
|
2168
2251
|
case 34:
|
|
2169
2252
|
j++;
|
|
2170
|
-
|
|
2253
|
+
_context18.next = 32;
|
|
2171
2254
|
break;
|
|
2172
2255
|
case 37:
|
|
2173
2256
|
_i2++;
|
|
2174
|
-
|
|
2257
|
+
_context18.next = 17;
|
|
2175
2258
|
break;
|
|
2176
2259
|
case 40:
|
|
2177
|
-
return
|
|
2260
|
+
return _context18.abrupt("return", responseProducts);
|
|
2178
2261
|
case 41:
|
|
2179
2262
|
case "end":
|
|
2180
|
-
return
|
|
2263
|
+
return _context18.stop();
|
|
2181
2264
|
}
|
|
2182
|
-
},
|
|
2265
|
+
}, _callee15, null, [[19, 27]]);
|
|
2183
2266
|
}));
|
|
2184
2267
|
function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
|
|
2185
2268
|
return _apiSaveProducts.apply(this, arguments);
|
|
@@ -2201,14 +2284,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2201
2284
|
filter.push("+[".concat(groups[key].filter(function (f) {
|
|
2202
2285
|
return f.or;
|
|
2203
2286
|
}).map(function (f) {
|
|
2204
|
-
return "{".concat(f.id, ",").concat(f.op, ",").concat(f.value, "}");
|
|
2287
|
+
return "{".concat(f.id, ",").concat(f.op, ",").concat(typeof f.value == 'string' ? "\"".concat(f.value, "\"") : f.value, "}");
|
|
2205
2288
|
}).join(), "]"));
|
|
2206
2289
|
}
|
|
2207
2290
|
}
|
|
2208
2291
|
filters.filter(function (f) {
|
|
2209
2292
|
return !f.or;
|
|
2210
2293
|
}).forEach(function (f) {
|
|
2211
|
-
return filter.push("{".concat(f.id, ",").concat(f.op, ",").concat(f.value, "}"));
|
|
2294
|
+
return filter.push("{".concat(f.id, ",").concat(f.op, ",").concat(typeof f.value == 'string' ? "\"".concat(f.value, "\"") : f.value, "}"));
|
|
2212
2295
|
});
|
|
2213
2296
|
}
|
|
2214
2297
|
return "[".concat(filter.join(), "]");
|
|
@@ -2406,10 +2489,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2406
2489
|
}, {
|
|
2407
2490
|
key: "loadSelectOptions",
|
|
2408
2491
|
value: function () {
|
|
2409
|
-
var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2492
|
+
var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16(sessionGuid, dataSource, additionalFilter) {
|
|
2410
2493
|
var values, apiUrl, i, apiResult, _i3, value, text;
|
|
2411
|
-
return _regeneratorRuntime.wrap(function
|
|
2412
|
-
while (1) switch (
|
|
2494
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context19) {
|
|
2495
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2413
2496
|
case 0:
|
|
2414
2497
|
values = [];
|
|
2415
2498
|
apiUrl = dataSource.url;
|
|
@@ -2418,7 +2501,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2418
2501
|
apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
|
|
2419
2502
|
}
|
|
2420
2503
|
}
|
|
2421
|
-
|
|
2504
|
+
_context19.next = 5;
|
|
2422
2505
|
return fetch(apiUrl, {
|
|
2423
2506
|
headers: {
|
|
2424
2507
|
sessionGuid: sessionGuid
|
|
@@ -2430,7 +2513,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2430
2513
|
return res.json();
|
|
2431
2514
|
});
|
|
2432
2515
|
case 5:
|
|
2433
|
-
apiResult =
|
|
2516
|
+
apiResult = _context19.sent;
|
|
2434
2517
|
if (dataSource.useKey) {
|
|
2435
2518
|
apiResult = apiResult[dataSource.useKey];
|
|
2436
2519
|
}
|
|
@@ -2442,12 +2525,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2442
2525
|
text: text
|
|
2443
2526
|
});
|
|
2444
2527
|
}
|
|
2445
|
-
return
|
|
2528
|
+
return _context19.abrupt("return", values);
|
|
2446
2529
|
case 9:
|
|
2447
2530
|
case "end":
|
|
2448
|
-
return
|
|
2531
|
+
return _context19.stop();
|
|
2449
2532
|
}
|
|
2450
|
-
},
|
|
2533
|
+
}, _callee16);
|
|
2451
2534
|
}));
|
|
2452
2535
|
function loadSelectOptions(_x27, _x28, _x29) {
|
|
2453
2536
|
return _loadSelectOptions.apply(this, arguments);
|
|
@@ -2483,7 +2566,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2483
2566
|
OPV: v.OPV,
|
|
2484
2567
|
OPTName: opt.Name,
|
|
2485
2568
|
OPVName: opv.Name,
|
|
2486
|
-
OPVImage: catalog.mediaUrl + opv.Image
|
|
2569
|
+
OPVImage: opv.Image ? catalog.mediaUrl + opv.Image : undefined
|
|
2487
2570
|
});
|
|
2488
2571
|
}
|
|
2489
2572
|
}
|