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