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