@crystaldesign/product-handler 24.12.0-beta.3 → 24.12.0-beta.31
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 +815 -609
- package/build/esm/index.js +815 -609
- package/build/types/product-handler/src/index.d.ts +23 -9
- 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 +17 -8
- package/build/types/product-handler/src/types.d.ts.map +1 -1
- package/package.json +5 -8
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() {
|
|
@@ -115,16 +127,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
115
127
|
key: "apiKey",
|
|
116
128
|
get: function get() {
|
|
117
129
|
return this._apiKey;
|
|
130
|
+
},
|
|
131
|
+
set: function set(val) {
|
|
132
|
+
this._apiKey = val;
|
|
118
133
|
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "initProduct",
|
|
136
|
+
value: function initProduct(basket) {}
|
|
119
137
|
|
|
120
138
|
/**
|
|
121
139
|
* Saves the products in the current state
|
|
122
140
|
* @param basket the basket data for which products get created/loaded
|
|
123
141
|
* @param catalogData the catalog data for this basket
|
|
124
|
-
|
|
125
|
-
set: function set(val) {
|
|
126
|
-
this._apiKey = val;
|
|
127
|
-
}
|
|
142
|
+
*/
|
|
128
143
|
}, {
|
|
129
144
|
key: "createAndSave",
|
|
130
145
|
value: (function () {
|
|
@@ -138,6 +153,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
138
153
|
_context.next = 3;
|
|
139
154
|
return this.loadProducts({
|
|
140
155
|
basket: basket,
|
|
156
|
+
divaNr: basket.DivaNr,
|
|
141
157
|
catalogData: catalogData,
|
|
142
158
|
productData: [],
|
|
143
159
|
availableLanguages: availableLanguages,
|
|
@@ -147,22 +163,22 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
147
163
|
createdState = _context.sent;
|
|
148
164
|
createdState.baseData.shortDescription = (_basket$ProductSetNam = basket.ProductSetName) !== null && _basket$ProductSetNam !== void 0 ? _basket$ProductSetNam : basket.SetName;
|
|
149
165
|
createdState.baseData.shortDescription_locales = basket.SetName_locales;
|
|
150
|
-
|
|
166
|
+
_objectSpread({}, createdState.baseData);
|
|
167
|
+
_context.next = 9;
|
|
151
168
|
return this.prepareData({
|
|
169
|
+
basket: basket,
|
|
152
170
|
baseData: createdState.baseData,
|
|
153
171
|
classificationData: createdState.classificationData,
|
|
154
172
|
variantData: createdState.variantData,
|
|
155
173
|
oldClassificationData: createdState.oldClassificationData
|
|
156
174
|
});
|
|
157
|
-
case
|
|
175
|
+
case 9:
|
|
158
176
|
data = _context.sent;
|
|
159
|
-
_context.next =
|
|
160
|
-
return this.
|
|
161
|
-
basket: basket
|
|
162
|
-
}));
|
|
163
|
-
case 11:
|
|
164
|
-
return _context.abrupt("return", _context.sent);
|
|
177
|
+
_context.next = 12;
|
|
178
|
+
return this.saveProducts(_objectSpread({}, data));
|
|
165
179
|
case 12:
|
|
180
|
+
return _context.abrupt("return", _context.sent);
|
|
181
|
+
case 13:
|
|
166
182
|
case "end":
|
|
167
183
|
return _context.stop();
|
|
168
184
|
}
|
|
@@ -185,86 +201,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
185
201
|
key: "loadProducts",
|
|
186
202
|
value: (function () {
|
|
187
203
|
var _loadProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref2) {
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
_baseProduct21,
|
|
201
|
-
_baseProduct22,
|
|
202
|
-
_baseProduct23,
|
|
203
|
-
_baseProduct24,
|
|
204
|
-
_baseProduct25,
|
|
205
|
-
_baseProduct26,
|
|
206
|
-
_baseProduct$width,
|
|
207
|
-
_baseProduct27,
|
|
208
|
-
_basket$SetPlannerInf,
|
|
209
|
-
_basket$OrderSets$0$B,
|
|
210
|
-
_baseProduct$height,
|
|
211
|
-
_baseProduct28,
|
|
212
|
-
_basket$SetPlannerInf2,
|
|
213
|
-
_basket$OrderSets$0$B2,
|
|
214
|
-
_baseProduct$depth,
|
|
215
|
-
_baseProduct29,
|
|
216
|
-
_basket$SetPlannerInf3,
|
|
217
|
-
_basket$OrderSets$0$B3,
|
|
218
|
-
_baseProduct$weight,
|
|
219
|
-
_baseProduct30,
|
|
220
|
-
_price$addedPrice,
|
|
221
|
-
_baseProduct31,
|
|
222
|
-
_baseProduct32,
|
|
223
|
-
_baseProduct33,
|
|
224
|
-
_basket$SetPlannerInf4,
|
|
225
|
-
_basket$SetPlannerInf5,
|
|
226
|
-
_baseProduct34,
|
|
227
|
-
_baseProduct35,
|
|
228
|
-
_baseProduct36,
|
|
229
|
-
_baseProduct37,
|
|
230
|
-
_baseProduct38,
|
|
231
|
-
_baseProduct39,
|
|
232
|
-
_baseProduct$brand,
|
|
233
|
-
_baseProduct40,
|
|
204
|
+
var _this = this,
|
|
205
|
+
_baseProduct,
|
|
206
|
+
_baseProduct2,
|
|
207
|
+
_baseProduct$divaNr,
|
|
208
|
+
_baseProduct3,
|
|
209
|
+
_dataByBasket$price$a,
|
|
210
|
+
_dataByBasket$price,
|
|
211
|
+
_baseProduct4,
|
|
212
|
+
_basket$getProductCon,
|
|
213
|
+
_baseProduct5,
|
|
214
|
+
_dataByBasket$docking,
|
|
215
|
+
_baseProduct6,
|
|
234
216
|
_baseProduct$organiza,
|
|
235
|
-
|
|
217
|
+
_baseProduct7,
|
|
236
218
|
_this$organization$pa,
|
|
237
219
|
_this$organization$pa2,
|
|
238
|
-
_baseProduct42,
|
|
239
220
|
_baseProduct$createdB,
|
|
240
|
-
|
|
221
|
+
_baseProduct8,
|
|
241
222
|
_this$user,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
_this = this;
|
|
250
|
-
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;
|
|
223
|
+
_baseProduct9,
|
|
224
|
+
_baseProduct10,
|
|
225
|
+
_baseProduct11,
|
|
226
|
+
_baseProduct12,
|
|
227
|
+
_baseProduct13,
|
|
228
|
+
_baseProduct14;
|
|
229
|
+
var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
|
|
251
230
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
252
231
|
while (1) switch (_context2.prev = _context2.next) {
|
|
253
232
|
case 0:
|
|
254
|
-
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
|
|
233
|
+
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;
|
|
234
|
+
if (!(!productData && !divaNr)) {
|
|
235
|
+
_context2.next = 3;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
throw new Error('this should not happen');
|
|
239
|
+
case 3:
|
|
255
240
|
if (productData) {
|
|
256
|
-
_context2.next =
|
|
241
|
+
_context2.next = 7;
|
|
257
242
|
break;
|
|
258
243
|
}
|
|
259
|
-
_context2.next =
|
|
260
|
-
return this.apiGetProducts(
|
|
261
|
-
case
|
|
244
|
+
_context2.next = 6;
|
|
245
|
+
return this.apiGetProducts(divaNr);
|
|
246
|
+
case 6:
|
|
262
247
|
productData = _context2.sent;
|
|
263
|
-
case
|
|
248
|
+
case 7:
|
|
264
249
|
products = {
|
|
265
250
|
data: productData,
|
|
266
251
|
total: productData.length
|
|
267
252
|
};
|
|
253
|
+
if (!(!products.data.length && !basket)) {
|
|
254
|
+
_context2.next = 10;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
throw new Error('If product does not exist yet, basket must be provided');
|
|
258
|
+
case 10:
|
|
268
259
|
baseProduct = undefined;
|
|
269
260
|
variantProducts = [];
|
|
270
261
|
if (products.total == 1) {
|
|
@@ -277,263 +268,72 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
277
268
|
return !p.baseProduct;
|
|
278
269
|
});
|
|
279
270
|
}
|
|
280
|
-
if (
|
|
281
|
-
_context2.next =
|
|
271
|
+
if (catalogData) {
|
|
272
|
+
_context2.next = 23;
|
|
282
273
|
break;
|
|
283
274
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
|
|
288
|
-
orderDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
|
|
289
|
-
return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
|
|
290
|
-
}, '') : basket.OrderSets[0].VariantDescription;
|
|
291
|
-
orderDescription_locales = basket.OrderSets[0].VariantDescription_locales;
|
|
292
|
-
catalogDataName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
293
|
-
return c.name;
|
|
294
|
-
}).filter(function (name) {
|
|
295
|
-
return name;
|
|
296
|
-
}).join(' - ');
|
|
297
|
-
catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
298
|
-
return c.brand;
|
|
299
|
-
}).filter(function (brand) {
|
|
300
|
-
return brand;
|
|
301
|
-
}).join(' - ');
|
|
302
|
-
catalogDataDescription = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
303
|
-
return c.description;
|
|
304
|
-
}).filter(function (description) {
|
|
305
|
-
return description;
|
|
306
|
-
}).join('<br/>');
|
|
307
|
-
catalogDataName_locales = {};
|
|
308
|
-
catalogDataDescription_locales = {};
|
|
309
|
-
for (i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
|
|
310
|
-
c = catalogData[i];
|
|
311
|
-
for (key in c.name_locales) {
|
|
312
|
-
if (!catalogDataName_locales[key]) {
|
|
313
|
-
catalogDataName_locales[key] = c.name_locales[key];
|
|
314
|
-
} else {
|
|
315
|
-
catalogDataName_locales[key] = catalogDataName_locales[key] + ' - ' + c.name_locales[key];
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
for (_key in c.description_locales) {
|
|
319
|
-
if (!catalogDataDescription_locales[_key]) {
|
|
320
|
-
catalogDataDescription_locales[_key] = c.description_locales[_key];
|
|
321
|
-
} else {
|
|
322
|
-
catalogDataDescription_locales[_key] = catalogDataDescription_locales[_key] + ' - ' + c.description_locales[_key];
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
articles = [];
|
|
327
|
-
if (isSet) {
|
|
328
|
-
articles = basket.OrderSets.flatMap(function (os) {
|
|
329
|
-
return os.OrderLines.map(function (ol) {
|
|
330
|
-
var _ol$VariantBasketData;
|
|
331
|
-
return {
|
|
332
|
-
articleCodex: ol.ArticleCodex,
|
|
333
|
-
catalogCodex: os.CatalogCodex,
|
|
334
|
-
variantValues: (_ol$VariantBasketData = ol.VariantBasketDatas) === null || _ol$VariantBasketData === void 0 ? void 0 : _ol$VariantBasketData.map(function (vb) {
|
|
335
|
-
return {
|
|
336
|
-
OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
|
|
337
|
-
OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
|
|
338
|
-
};
|
|
339
|
-
})
|
|
340
|
-
};
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
} else {
|
|
344
|
-
articles = basket.OrderSets[0].OrderLines.map(function (ol) {
|
|
345
|
-
var _ol$VariantBasketData2;
|
|
346
|
-
return {
|
|
347
|
-
articleCodex: ol.ArticleCodex,
|
|
348
|
-
catalogCodex: basket.OrderSets[0].CatalogCodex,
|
|
349
|
-
variantValues: (_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (vb) {
|
|
350
|
-
return {
|
|
351
|
-
OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
|
|
352
|
-
OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
|
|
353
|
-
};
|
|
354
|
-
})
|
|
355
|
-
};
|
|
356
|
-
});
|
|
275
|
+
if (!baseProduct) {
|
|
276
|
+
_context2.next = 20;
|
|
277
|
+
break;
|
|
357
278
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
|
|
378
|
-
depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
|
|
379
|
-
weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
delivery = {
|
|
383
|
-
estPackages: packages,
|
|
384
|
-
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,
|
|
385
|
-
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) {
|
|
386
|
-
return p.weight;
|
|
387
|
-
}).filter(function (f) {
|
|
388
|
-
return f;
|
|
389
|
-
})))),
|
|
390
|
-
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) {
|
|
391
|
-
return p.height;
|
|
392
|
-
}).filter(function (f) {
|
|
393
|
-
return f;
|
|
394
|
-
})))),
|
|
395
|
-
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) {
|
|
396
|
-
return p.width;
|
|
397
|
-
}).filter(function (f) {
|
|
398
|
-
return f;
|
|
399
|
-
})))),
|
|
400
|
-
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) {
|
|
401
|
-
return p.depth;
|
|
402
|
-
}).filter(function (f) {
|
|
403
|
-
return f;
|
|
404
|
-
})))),
|
|
405
|
-
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,
|
|
406
|
-
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,
|
|
407
|
-
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
|
|
408
|
-
};
|
|
279
|
+
_context2.next = 17;
|
|
280
|
+
return Promise.all((_baseProduct$configur = (_baseProduct$configur2 = baseProduct.configuration) === null || _baseProduct$configur2 === void 0 ? void 0 : _baseProduct$configur2.OrderSets.map(function (os) {
|
|
281
|
+
return _this.apiGetCatalogData(os.CatalogCodex, currentLang, os.AccountGUID);
|
|
282
|
+
})) !== null && _baseProduct$configur !== void 0 ? _baseProduct$configur : []);
|
|
283
|
+
case 17:
|
|
284
|
+
catalogData = _context2.sent;
|
|
285
|
+
_context2.next = 23;
|
|
286
|
+
break;
|
|
287
|
+
case 20:
|
|
288
|
+
_context2.next = 22;
|
|
289
|
+
return Promise.all((_basket$OrderSets$map = basket === null || basket === void 0 ? void 0 : basket.OrderSets.map(function (os) {
|
|
290
|
+
return _this.apiGetCatalogData(os.CatalogCodex, currentLang, os.AccountGUID);
|
|
291
|
+
})) !== null && _basket$OrderSets$map !== void 0 ? _basket$OrderSets$map : []);
|
|
292
|
+
case 22:
|
|
293
|
+
catalogData = _context2.sent;
|
|
294
|
+
case 23:
|
|
295
|
+
if (!(products.total && !baseProduct)) {
|
|
296
|
+
_context2.next = 25;
|
|
297
|
+
break;
|
|
409
298
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
addedPrice: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.addedPrice,
|
|
414
|
-
discountPrice: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.discountedPrice
|
|
415
|
-
};
|
|
416
|
-
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);
|
|
417
|
-
|
|
418
|
-
//to remember what for position was previously set for the classification
|
|
299
|
+
throw new Error('If existing products are fetched, there has to be atleast a base product.');
|
|
300
|
+
case 25:
|
|
301
|
+
dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
|
|
419
302
|
oldClassificationData = {};
|
|
420
|
-
for (
|
|
421
|
-
variant = products.data[
|
|
303
|
+
for (i = 0; i < products.data.length; i++) {
|
|
304
|
+
variant = products.data[i];
|
|
422
305
|
oldClassificationData[variant._id] = {};
|
|
423
|
-
for (
|
|
424
|
-
if (
|
|
425
|
-
oldClassificationData[variant._id][
|
|
306
|
+
for (key in variant) {
|
|
307
|
+
if (key.startsWith('dc_') && variant[key].optionPosition !== undefined) {
|
|
308
|
+
oldClassificationData[variant._id][key] = variant[key];
|
|
426
309
|
}
|
|
427
310
|
}
|
|
428
311
|
}
|
|
429
|
-
oldUniqueHash = (
|
|
430
|
-
baseData = {
|
|
431
|
-
_id: ((
|
|
432
|
-
divaNr: basket === null || basket === void 0 ? void 0 : basket.DivaNr,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
shortTechnicalDescription: (_baseProduct20 = baseProduct) === null || _baseProduct20 === void 0 ? void 0 : _baseProduct20.shortTechnicalDescription,
|
|
437
|
-
modelName_locales: ((_baseProduct21 = baseProduct) === null || _baseProduct21 === void 0 ? void 0 : _baseProduct21.modelName_locales) || catalogDataName_locales,
|
|
438
|
-
info_locales: ((_baseProduct22 = baseProduct) === null || _baseProduct22 === void 0 ? void 0 : _baseProduct22.info_locales) || catalogDataDescription_locales,
|
|
439
|
-
technicalDescription_locales: ((_baseProduct23 = baseProduct) === null || _baseProduct23 === void 0 ? void 0 : _baseProduct23.technicalDescription_locales) || orderDescription_locales,
|
|
440
|
-
shortTechnicalDescription_locales: (_baseProduct24 = baseProduct) === null || _baseProduct24 === void 0 ? void 0 : _baseProduct24.shortTechnicalDescription_locales,
|
|
441
|
-
orderDescription: orderDescription,
|
|
442
|
-
shortDescription: (_baseProduct25 = baseProduct) === null || _baseProduct25 === void 0 ? void 0 : _baseProduct25.shortDescription,
|
|
443
|
-
shortDescription_locales: (_baseProduct26 = baseProduct) === null || _baseProduct26 === void 0 ? void 0 : _baseProduct26.shortDescription_locales,
|
|
444
|
-
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,
|
|
445
|
-
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,
|
|
446
|
-
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,
|
|
447
|
-
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) {
|
|
448
|
-
return os.OrderLines.map(function (ol) {
|
|
449
|
-
return ol.Weight;
|
|
450
|
-
}).filter(function (f) {
|
|
451
|
-
return f;
|
|
452
|
-
});
|
|
453
|
-
}).reduce(function (sum, v) {
|
|
454
|
-
return sum + v;
|
|
455
|
-
}, 0),
|
|
456
|
-
calculatedPrice: price.calculatedPrice,
|
|
457
|
-
delivery: delivery,
|
|
458
|
-
addedPrice: (_price$addedPrice = price.addedPrice) !== null && _price$addedPrice !== void 0 ? _price$addedPrice : (_baseProduct31 = baseProduct) === null || _baseProduct31 === void 0 ? void 0 : _baseProduct31.addedPrice,
|
|
459
|
-
discountedPrice: (_baseProduct32 = baseProduct) === null || _baseProduct32 === void 0 ? void 0 : _baseProduct32.discountedPrice,
|
|
460
|
-
percentageDiscount: (_baseProduct33 = baseProduct) === null || _baseProduct33 === void 0 ? void 0 : _baseProduct33.percentageDiscount,
|
|
461
|
-
articles: articles,
|
|
462
|
-
image: isSet ? (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg3D : basket.OrderSets[0].SetImage,
|
|
463
|
-
image2D: isSet ? (_basket$SetPlannerInf5 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf5 === void 0 ? void 0 : _basket$SetPlannerInf5.SetPlannerImg2D : basket.OrderSets[0].Set2DImage,
|
|
464
|
-
catalogId: isSet ? basket.OrderSets.map(function (os) {
|
|
465
|
-
return os.CatalogGUID;
|
|
466
|
-
}) : [basket.OrderSets[0].CatalogGUID],
|
|
467
|
-
collection: isSet ? basket.OrderSets.map(function (os) {
|
|
468
|
-
return os.AccountName;
|
|
469
|
-
}) : [basket.OrderSets[0].AccountName],
|
|
470
|
-
collectionId: isSet ? basket.OrderSets.map(function (os) {
|
|
471
|
-
return os.CollectionGUID;
|
|
472
|
-
}) : [basket.OrderSets[0].CollectionGUID],
|
|
473
|
-
catCodex: isSet ? basket.OrderSets.map(function (os) {
|
|
474
|
-
return os.CatalogCodex;
|
|
475
|
-
}) : [basket.OrderSets[0].CatalogCodex],
|
|
476
|
-
supplierId: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
477
|
-
return c.supplierGuid;
|
|
478
|
-
}).filter(function (c) {
|
|
479
|
-
return c;
|
|
480
|
-
}),
|
|
481
|
-
retailCatalogNr: catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
482
|
-
return c.retailCatalogNr;
|
|
483
|
-
}).filter(function (c) {
|
|
484
|
-
return c;
|
|
485
|
-
}),
|
|
486
|
-
supplierArticleNr: basket.OrderSets.flatMap(function (os) {
|
|
487
|
-
return os.OrderLines.map(function (ol) {
|
|
488
|
-
return ol.ConfigArticleCodex;
|
|
489
|
-
}).filter(function (f) {
|
|
490
|
-
return f;
|
|
491
|
-
});
|
|
492
|
-
}).filter(function (f) {
|
|
493
|
-
return f;
|
|
494
|
-
}),
|
|
495
|
-
retailCatalogArticleNr: basket.OrderSets.flatMap(function (os) {
|
|
496
|
-
return os.OrderLines.map(function (ol) {
|
|
497
|
-
return ol.RetailArticleNr;
|
|
498
|
-
}).filter(function (f) {
|
|
499
|
-
return f;
|
|
500
|
-
});
|
|
501
|
-
}).filter(function (f) {
|
|
502
|
-
return f;
|
|
503
|
-
}),
|
|
504
|
-
livingArea: (_baseProduct34 = baseProduct) === null || _baseProduct34 === void 0 ? void 0 : _baseProduct34.livingArea,
|
|
505
|
-
mainCategory: (_baseProduct35 = baseProduct) === null || _baseProduct35 === void 0 ? void 0 : _baseProduct35.mainCategory,
|
|
506
|
-
subCategory: (_baseProduct36 = baseProduct) === null || _baseProduct36 === void 0 ? void 0 : _baseProduct36.subCategory,
|
|
507
|
-
retailerArticleNr: (_baseProduct37 = baseProduct) === null || _baseProduct37 === void 0 ? void 0 : _baseProduct37.retailerArticleNr,
|
|
508
|
-
dockingPoints: dockingPoints,
|
|
509
|
-
media: (_baseProduct38 = baseProduct) === null || _baseProduct38 === void 0 ? void 0 : _baseProduct38.media,
|
|
510
|
-
affiliate: (_baseProduct39 = baseProduct) === null || _baseProduct39 === void 0 ? void 0 : _baseProduct39.affiliate,
|
|
511
|
-
brand: (_baseProduct$brand = (_baseProduct40 = baseProduct) === null || _baseProduct40 === void 0 ? void 0 : _baseProduct40.brand) !== null && _baseProduct$brand !== void 0 ? _baseProduct$brand : catalogDataBrand,
|
|
312
|
+
oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
|
|
313
|
+
baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
|
|
314
|
+
_id: ((_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2._id) || DivaUtils.nanoid(),
|
|
315
|
+
divaNr: (_baseProduct$divaNr = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr,
|
|
316
|
+
addedPrice: (_dataByBasket$price$a = dataByBasket === null || dataByBasket === void 0 || (_dataByBasket$price = dataByBasket.price) === null || _dataByBasket$price === void 0 ? void 0 : _dataByBasket$price.addedPrice) !== null && _dataByBasket$price$a !== void 0 ? _dataByBasket$price$a : (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.addedPrice,
|
|
317
|
+
configuration: (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.configuration,
|
|
318
|
+
dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.dockingPoints,
|
|
512
319
|
currency: DivaUtils__default["default"].defaultPriceFormat.currency,
|
|
513
|
-
organizationId: (_baseProduct$organiza = (
|
|
320
|
+
organizationId: (_baseProduct$organiza = (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
|
|
514
321
|
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) {
|
|
515
322
|
return o._id;
|
|
516
323
|
})) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
classificationInfo: (_baseProduct48 = baseProduct) === null || _baseProduct48 === void 0 ? void 0 : _baseProduct48.classificationInfo,
|
|
524
|
-
modelInfoPageWeight: (_baseProduct49 = baseProduct) === null || _baseProduct49 === void 0 ? void 0 : _baseProduct49.modelInfoPageWeight,
|
|
525
|
-
uniqueHash: isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
|
|
526
|
-
return os.SetHash;
|
|
527
|
-
}).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject)
|
|
528
|
-
};
|
|
529
|
-
metaData = basket.OrderSets.reduce(function (prev, curr) {
|
|
324
|
+
createdBy: (_baseProduct$createdB = (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
|
|
325
|
+
createdBy_displayText: (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.createdBy_displayText,
|
|
326
|
+
archived: (_baseProduct10 = baseProduct) !== null && _baseProduct10 !== void 0 && _baseProduct10.archived ? (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.archived : false,
|
|
327
|
+
isTopseller: !!((_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.isTopseller)
|
|
328
|
+
});
|
|
329
|
+
metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
|
|
530
330
|
return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
|
|
531
331
|
}, {});
|
|
532
|
-
metaData_locales = basket.OrderSets.reduce(function (prev, curr) {
|
|
332
|
+
metaData_locales = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
|
|
533
333
|
return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
|
|
534
334
|
}, {});
|
|
535
335
|
_this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
|
|
536
|
-
baseData.customData = _objectSpread(_objectSpread({}, (
|
|
336
|
+
baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.customData), customData);
|
|
537
337
|
|
|
538
338
|
//add livingarea,maincategorie,subcategorie of loaded product if not exists
|
|
539
339
|
classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
|
|
@@ -549,55 +349,56 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
549
349
|
removedProducts = [];
|
|
550
350
|
optFields = [];
|
|
551
351
|
initialSelectedFields = [];
|
|
552
|
-
if (isSet) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
352
|
+
if (!dataByBasket.isSet) {
|
|
353
|
+
_context2.next = 45;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
throw new Error('Variants are currently not supported for set products');
|
|
357
|
+
case 45:
|
|
358
|
+
//iterate all existing variant products and add them to the variants
|
|
359
|
+
usedVariantIds = [];
|
|
360
|
+
variantProducts.forEach(function (product) {
|
|
361
|
+
var cv;
|
|
362
|
+
if (basket) {
|
|
363
|
+
var _basket$OrderSets$0$C;
|
|
364
|
+
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) {
|
|
365
|
+
return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
|
|
366
|
+
})) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.VariantID;
|
|
367
|
+
} else {
|
|
368
|
+
cv = product.variantId;
|
|
369
|
+
}
|
|
570
370
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
371
|
+
//if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
|
|
372
|
+
if (product.originDivaNr || cv !== undefined) {
|
|
373
|
+
if (cv !== undefined) usedVariantIds.push(cv);
|
|
374
|
+
var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
375
|
+
_variant = _this$initVariant.variant,
|
|
376
|
+
modified = _this$initVariant.modified;
|
|
377
|
+
variantData.push(_variant);
|
|
378
|
+
variantDataModified.push(modified);
|
|
379
|
+
} else {
|
|
380
|
+
var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
381
|
+
_variant2 = _this$initVariant2.variant,
|
|
382
|
+
_modified = _this$initVariant2.modified;
|
|
383
|
+
variantData.push(_variant2);
|
|
384
|
+
variantDataModified.push(_modified);
|
|
385
|
+
removedProducts.push(_variant2._id);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
588
388
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
389
|
+
//now iterate all configVariants that are left and add them to the variants (new Products)
|
|
390
|
+
newVariantPosition = variantData.filter(function (vd) {
|
|
391
|
+
return !removedProducts.includes(vd._id);
|
|
392
|
+
});
|
|
393
|
+
variantPositions = newVariantPosition.map(function (element) {
|
|
394
|
+
return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
|
|
395
|
+
});
|
|
396
|
+
currentVariantPos = Math.max.apply(Math, _toConsumableArray__default["default"](variantPositions));
|
|
397
|
+
if (basket) {
|
|
398
|
+
(_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 || _basket$OrderSets$0$C2.filter(function (cv) {
|
|
399
|
+
return !usedVariantIds.includes(cv.VariantID);
|
|
599
400
|
}).forEach(function (cv) {
|
|
600
|
-
var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, cv, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
401
|
+
var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv.VariantID, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
601
402
|
variant = _this$initVariant3.variant,
|
|
602
403
|
modified = _this$initVariant3.modified;
|
|
603
404
|
currentVariantPos = currentVariantPos + 1;
|
|
@@ -606,60 +407,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
606
407
|
variantDataModified.push(modified);
|
|
607
408
|
addedProducts.push(variant._id);
|
|
608
409
|
});
|
|
410
|
+
}
|
|
609
411
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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
|
-
|
|
412
|
+
//get opt data
|
|
413
|
+
differingOPTs = Object.entries(((_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 || (_baseProduct14 = _baseProduct14.configuration) === null || _baseProduct14 === void 0 || (_baseProduct14 = _baseProduct14.OrderSets[0].Favorites) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.VariantValues) || []).filter(function (_ref3) {
|
|
414
|
+
var _ref4 = _slicedToArray__default["default"](_ref3, 2);
|
|
415
|
+
_ref4[0];
|
|
416
|
+
var value = _ref4[1];
|
|
417
|
+
return Object.keys(value).length > 1;
|
|
418
|
+
}).map(function (_ref5) {
|
|
419
|
+
var _ref6 = _slicedToArray__default["default"](_ref5, 2),
|
|
420
|
+
opt = _ref6[0];
|
|
421
|
+
_ref6[1];
|
|
422
|
+
return opt.replace('OPT', '');
|
|
423
|
+
});
|
|
424
|
+
if (variantData) {
|
|
425
|
+
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) {
|
|
426
|
+
var _catalogData, _vd$OptionOCD, _option$Name;
|
|
427
|
+
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];
|
|
428
|
+
return {
|
|
429
|
+
field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
|
|
430
|
+
type: 'string',
|
|
431
|
+
title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
|
|
432
|
+
readOnly: true,
|
|
433
|
+
fieldType: 'OPT'
|
|
434
|
+
};
|
|
435
|
+
})) || [];
|
|
436
|
+
//remove duplicates
|
|
437
|
+
opts = {};
|
|
438
|
+
for (_i = optFields.length - 1; _i >= 0; _i--) {
|
|
439
|
+
if (!opts[optFields[_i].field]) {
|
|
440
|
+
opts[optFields[_i].field] = true;
|
|
441
|
+
} else {
|
|
442
|
+
optFields.splice(_i, 1);
|
|
641
443
|
}
|
|
642
444
|
}
|
|
643
|
-
|
|
644
|
-
//mark all fields where there are differences between the variants as initaly selected
|
|
645
|
-
initialSelectedFields = optFields.filter(function (f) {
|
|
646
|
-
return differingOPTs.includes(f.field);
|
|
647
|
-
});
|
|
648
|
-
ProductHandlerAbstract.baseDataFields.forEach(function (field) {
|
|
649
|
-
if (variantDataModified.some(function (mod) {
|
|
650
|
-
return mod[field.field];
|
|
651
|
-
})) {
|
|
652
|
-
initialSelectedFields.push(field);
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
|
|
656
|
-
if (variantDataModified.some(function (mod) {
|
|
657
|
-
return mod['customData.' + f.field];
|
|
658
|
-
})) {
|
|
659
|
-
initialSelectedFields.push(f);
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
445
|
}
|
|
446
|
+
|
|
447
|
+
//mark all fields where there are differences between the variants as initaly selected
|
|
448
|
+
initialSelectedFields = optFields.filter(function (f) {
|
|
449
|
+
return differingOPTs.includes(f.field);
|
|
450
|
+
});
|
|
451
|
+
ProductHandlerAbstract.baseDataFields.forEach(function (field) {
|
|
452
|
+
if (variantDataModified.some(function (mod) {
|
|
453
|
+
return mod[field.field];
|
|
454
|
+
})) {
|
|
455
|
+
initialSelectedFields.push(field);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
|
|
459
|
+
if (variantDataModified.some(function (mod) {
|
|
460
|
+
return mod['customData.' + f.field];
|
|
461
|
+
})) {
|
|
462
|
+
initialSelectedFields.push(f);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
663
465
|
initializedOptMap = this.initOpvMap(optFields, classificationConfig, optMap);
|
|
664
466
|
return _context2.abrupt("return", {
|
|
665
467
|
baseData: baseData,
|
|
@@ -667,6 +469,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
667
469
|
optFields: optFields,
|
|
668
470
|
initialSelectedFields: initialSelectedFields,
|
|
669
471
|
variantData: variantData,
|
|
472
|
+
catalogData: catalogData,
|
|
670
473
|
optClassMap: initializedOptMap,
|
|
671
474
|
addedProducts: products.total ? addedProducts : [],
|
|
672
475
|
removedProducts: products.total ? removedProducts : [],
|
|
@@ -680,7 +483,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
680
483
|
availableLanguages: availableLanguages,
|
|
681
484
|
currentLang: currentLang
|
|
682
485
|
});
|
|
683
|
-
case
|
|
486
|
+
case 58:
|
|
684
487
|
case "end":
|
|
685
488
|
return _context2.stop();
|
|
686
489
|
}
|
|
@@ -691,6 +494,191 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
691
494
|
}
|
|
692
495
|
return loadProducts;
|
|
693
496
|
}())
|
|
497
|
+
}, {
|
|
498
|
+
key: "getProductDataByBasket",
|
|
499
|
+
value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
|
|
500
|
+
var dataByBasket = {};
|
|
501
|
+
var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
|
|
502
|
+
dataByBasket.isSet = isSet;
|
|
503
|
+
if (basket) {
|
|
504
|
+
dataByBasket.dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
|
|
505
|
+
dataByBasket.technicalDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
|
|
506
|
+
return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
|
|
507
|
+
}, '') : basket.OrderSets[0].VariantDescription;
|
|
508
|
+
dataByBasket.technicalDescription_locales = basket.OrderSets[0].VariantDescription_locales;
|
|
509
|
+
dataByBasket.modelName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
510
|
+
return c.name;
|
|
511
|
+
}).filter(function (name) {
|
|
512
|
+
return name;
|
|
513
|
+
}).join(' - ');
|
|
514
|
+
dataByBasket.catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
515
|
+
return c.brand;
|
|
516
|
+
}).filter(function (brand) {
|
|
517
|
+
return brand;
|
|
518
|
+
}).join(' - ');
|
|
519
|
+
dataByBasket.info = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
520
|
+
return c.description;
|
|
521
|
+
}).filter(function (description) {
|
|
522
|
+
return description;
|
|
523
|
+
}).join('<br/>');
|
|
524
|
+
dataByBasket.modelName_locales = {};
|
|
525
|
+
for (var i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
|
|
526
|
+
var c = catalogData[i];
|
|
527
|
+
for (var key in c.name_locales) {
|
|
528
|
+
if (!dataByBasket.modelName_locales[key]) {
|
|
529
|
+
dataByBasket.modelName_locales[key] = c.name_locales[key];
|
|
530
|
+
} else {
|
|
531
|
+
dataByBasket.modelName_locales[key] = dataByBasket.modelName_locales[key] + ' - ' + c.name_locales[key];
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
dataByBasket.info_locales = {};
|
|
535
|
+
for (var _key in c.description_locales) {
|
|
536
|
+
if (!dataByBasket.info_locales[_key]) {
|
|
537
|
+
dataByBasket.info_locales[_key] = c.description_locales[_key];
|
|
538
|
+
} else {
|
|
539
|
+
dataByBasket.info_locales[_key] = dataByBasket.info_locales[_key] + ' - ' + c.description_locales[_key];
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
|
|
544
|
+
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;
|
|
545
|
+
var config = {
|
|
546
|
+
addedPackageWeight: 0,
|
|
547
|
+
addedPackageHeight: 0,
|
|
548
|
+
addedPackageWidth: 0,
|
|
549
|
+
addedPackageDepth: 0,
|
|
550
|
+
defaultDeliveryTime: 0,
|
|
551
|
+
defaultDeliveryPrice: 0,
|
|
552
|
+
defaultInstallationPrice: 0
|
|
553
|
+
};
|
|
554
|
+
if (typeof fieldConfiguration.delivery != 'boolean') {
|
|
555
|
+
config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
|
|
556
|
+
}
|
|
557
|
+
var packages = [];
|
|
558
|
+
basket.OrderSets.flatMap(function (os) {
|
|
559
|
+
return os.OrderLines;
|
|
560
|
+
}).forEach(function (ol) {
|
|
561
|
+
packages.push({
|
|
562
|
+
height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
|
|
563
|
+
width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
|
|
564
|
+
depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
|
|
565
|
+
weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
dataByBasket.delivery = {
|
|
569
|
+
estPackages: packages,
|
|
570
|
+
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,
|
|
571
|
+
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) {
|
|
572
|
+
return p.weight;
|
|
573
|
+
}).filter(function (f) {
|
|
574
|
+
return f;
|
|
575
|
+
})))),
|
|
576
|
+
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) {
|
|
577
|
+
return p.height;
|
|
578
|
+
}).filter(function (f) {
|
|
579
|
+
return f;
|
|
580
|
+
})))),
|
|
581
|
+
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) {
|
|
582
|
+
return p.width;
|
|
583
|
+
}).filter(function (f) {
|
|
584
|
+
return f;
|
|
585
|
+
})))),
|
|
586
|
+
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) {
|
|
587
|
+
return p.depth;
|
|
588
|
+
}).filter(function (f) {
|
|
589
|
+
return f;
|
|
590
|
+
})))),
|
|
591
|
+
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,
|
|
592
|
+
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,
|
|
593
|
+
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
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
|
|
597
|
+
var price = {
|
|
598
|
+
calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
|
|
599
|
+
addedPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice,
|
|
600
|
+
discountPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.discountedPrice
|
|
601
|
+
};
|
|
602
|
+
if (!(baseProduct !== null && baseProduct !== void 0 && baseProduct.calculatedPrice)) {
|
|
603
|
+
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);
|
|
604
|
+
}
|
|
605
|
+
dataByBasket.price = price;
|
|
606
|
+
dataByBasket.calculatedPrice = price.calculatedPrice;
|
|
607
|
+
if (isSet) {
|
|
608
|
+
var _basket$SetPlannerInf, _basket$SetPlannerInf2, _basket$OrderSets$0$B, _basket$SetPlannerInf3, _basket$SetPlannerInf4;
|
|
609
|
+
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;
|
|
610
|
+
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;
|
|
611
|
+
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;
|
|
612
|
+
dataByBasket.image = (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.SetPlannerImg3D;
|
|
613
|
+
dataByBasket.image2D = (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg2D;
|
|
614
|
+
dataByBasket.catalogId = basket.OrderSets.map(function (os) {
|
|
615
|
+
return os.CatalogGUID;
|
|
616
|
+
});
|
|
617
|
+
dataByBasket.collection = basket.OrderSets.map(function (os) {
|
|
618
|
+
return os.AccountName;
|
|
619
|
+
});
|
|
620
|
+
dataByBasket.collectionId = basket.OrderSets.map(function (os) {
|
|
621
|
+
return os.CollectionGUID;
|
|
622
|
+
});
|
|
623
|
+
dataByBasket.catCodex = basket.OrderSets.map(function (os) {
|
|
624
|
+
return os.CatalogCodex;
|
|
625
|
+
});
|
|
626
|
+
} else {
|
|
627
|
+
var _basket$OrderSets$0$B2, _basket$OrderSets$0$B3, _basket$OrderSets$0$B4;
|
|
628
|
+
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;
|
|
629
|
+
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;
|
|
630
|
+
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;
|
|
631
|
+
dataByBasket.image = basket.OrderSets[0].SetImage;
|
|
632
|
+
dataByBasket.image2D = basket.OrderSets[0].Set2DImage;
|
|
633
|
+
dataByBasket.catalogId = [basket.OrderSets[0].CatalogGUID];
|
|
634
|
+
dataByBasket.collection = [basket.OrderSets[0].AccountName];
|
|
635
|
+
dataByBasket.collectionId = [basket.OrderSets[0].CollectionGUID];
|
|
636
|
+
dataByBasket.catCodex = [basket.OrderSets[0].CatalogCodex];
|
|
637
|
+
}
|
|
638
|
+
dataByBasket.weight = basket === null || basket === void 0 ? void 0 : basket.OrderSets.flatMap(function (os) {
|
|
639
|
+
return os.OrderLines.map(function (ol) {
|
|
640
|
+
return ol.Weight;
|
|
641
|
+
}).filter(function (f) {
|
|
642
|
+
return f;
|
|
643
|
+
});
|
|
644
|
+
}).reduce(function (sum, v) {
|
|
645
|
+
return sum + v;
|
|
646
|
+
}, 0);
|
|
647
|
+
dataByBasket.supplierId = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
648
|
+
return c.supplierGuid;
|
|
649
|
+
}).filter(function (c) {
|
|
650
|
+
return c;
|
|
651
|
+
});
|
|
652
|
+
dataByBasket.retailCatalogNr = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
653
|
+
return c.retailCatalogNr;
|
|
654
|
+
}).filter(function (c) {
|
|
655
|
+
return c;
|
|
656
|
+
});
|
|
657
|
+
dataByBasket.supplierArticleNr = basket.OrderSets.flatMap(function (os) {
|
|
658
|
+
return os.OrderLines.map(function (ol) {
|
|
659
|
+
return ol.ConfigArticleCodex;
|
|
660
|
+
}).filter(function (f) {
|
|
661
|
+
return f;
|
|
662
|
+
});
|
|
663
|
+
}).filter(function (f) {
|
|
664
|
+
return f;
|
|
665
|
+
});
|
|
666
|
+
dataByBasket.retailCatalogArticleNr = basket.OrderSets.flatMap(function (os) {
|
|
667
|
+
return os.OrderLines.map(function (ol) {
|
|
668
|
+
return ol.RetailArticleNr;
|
|
669
|
+
}).filter(function (f) {
|
|
670
|
+
return f;
|
|
671
|
+
});
|
|
672
|
+
}).filter(function (f) {
|
|
673
|
+
return f;
|
|
674
|
+
});
|
|
675
|
+
dataByBasket.orderText = basket.getEKText(true);
|
|
676
|
+
dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
|
|
677
|
+
return os.SetHash;
|
|
678
|
+
}).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
|
|
679
|
+
}
|
|
680
|
+
return dataByBasket;
|
|
681
|
+
}
|
|
694
682
|
}, {
|
|
695
683
|
key: "checkAndAddClassificationConfigCategories",
|
|
696
684
|
value: function checkAndAddClassificationConfigCategories(baseProduct, classificationConfig) {
|
|
@@ -781,11 +769,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
781
769
|
value: function () {
|
|
782
770
|
var _prepareData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref11) {
|
|
783
771
|
var _this3 = this;
|
|
784
|
-
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;
|
|
772
|
+
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;
|
|
785
773
|
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
|
|
786
774
|
while (1) switch (_context4.prev = _context4.next) {
|
|
787
775
|
case 0:
|
|
788
|
-
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;
|
|
776
|
+
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;
|
|
789
777
|
products = [];
|
|
790
778
|
originProduct = undefined;
|
|
791
779
|
if (!originProductId) {
|
|
@@ -864,11 +852,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
864
852
|
var value = _ref17[1];
|
|
865
853
|
return value;
|
|
866
854
|
}).forEach(function (_ref18) {
|
|
867
|
-
var
|
|
855
|
+
var _baseProduct15;
|
|
868
856
|
var _ref19 = _slicedToArray__default["default"](_ref18, 2),
|
|
869
857
|
key = _ref19[0],
|
|
870
858
|
value = _ref19[1];
|
|
871
|
-
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (
|
|
859
|
+
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct15 = baseProduct["dc_".concat(key)]) !== null && _baseProduct15 !== void 0 ? _baseProduct15 : {}), {}, {
|
|
872
860
|
opt: value.field
|
|
873
861
|
});
|
|
874
862
|
});
|
|
@@ -953,7 +941,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
953
941
|
baseProduct.parent = baseProduct._id;
|
|
954
942
|
}
|
|
955
943
|
_loop = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop() {
|
|
956
|
-
var _originProduct;
|
|
944
|
+
var _originProduct, _basket$getProductCon2;
|
|
957
945
|
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, product, _this3$openModal, _this3$t, k, _savedMedia;
|
|
958
946
|
return _regeneratorRuntime__default["default"].wrap(function _loop$(_context3) {
|
|
959
947
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -1063,6 +1051,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1063
1051
|
modelName_locales: vd.modelName_locales,
|
|
1064
1052
|
shortDescription_locales: vd.shortDescription_locales,
|
|
1065
1053
|
width: vd.width,
|
|
1054
|
+
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,
|
|
1066
1055
|
height: vd.height,
|
|
1067
1056
|
depth: vd.depth,
|
|
1068
1057
|
calculatedPrice: vd.calculatedPrice,
|
|
@@ -1073,7 +1062,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1073
1062
|
variantPosition: variantPos,
|
|
1074
1063
|
image: vd.image,
|
|
1075
1064
|
image2D: vd.image2D,
|
|
1076
|
-
articles: vd.articles,
|
|
1077
1065
|
affiliate: vd.affiliate,
|
|
1078
1066
|
originDivaNr: vd.originDivaNr,
|
|
1079
1067
|
organizationId: baseProduct.organizationId,
|
|
@@ -1175,43 +1163,66 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1175
1163
|
}
|
|
1176
1164
|
}
|
|
1177
1165
|
}, {
|
|
1178
|
-
key: "
|
|
1166
|
+
key: "saveProducts",
|
|
1179
1167
|
value: function () {
|
|
1180
|
-
var
|
|
1181
|
-
var products, removedProducts,
|
|
1168
|
+
var _saveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref28) {
|
|
1169
|
+
var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
|
|
1182
1170
|
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context5) {
|
|
1183
1171
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1184
1172
|
case 0:
|
|
1185
|
-
products = _ref28.products, removedProducts = _ref28.removedProducts,
|
|
1173
|
+
products = _ref28.products, removedProducts = _ref28.removedProducts, awaitPDF = _ref28.awaitPDF;
|
|
1186
1174
|
if (this.jwt) {
|
|
1187
1175
|
_context5.next = 3;
|
|
1188
1176
|
break;
|
|
1189
1177
|
}
|
|
1190
1178
|
throw new Error('jwt not set');
|
|
1191
1179
|
case 3:
|
|
1192
|
-
|
|
1193
|
-
_context5.
|
|
1194
|
-
|
|
1195
|
-
|
|
1180
|
+
this.setFirstVariant(products);
|
|
1181
|
+
_context5.prev = 4;
|
|
1182
|
+
_context5.next = 7;
|
|
1183
|
+
return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
|
|
1184
|
+
case 7:
|
|
1196
1185
|
savedProducts = _context5.sent;
|
|
1197
1186
|
(_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
|
|
1198
1187
|
return _context5.abrupt("return", savedProducts);
|
|
1199
|
-
case
|
|
1200
|
-
_context5.prev =
|
|
1201
|
-
_context5.t0 = _context5["catch"](
|
|
1188
|
+
case 12:
|
|
1189
|
+
_context5.prev = 12;
|
|
1190
|
+
_context5.t0 = _context5["catch"](4);
|
|
1202
1191
|
(_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
|
|
1203
1192
|
throw new Error(_context5.t0.message);
|
|
1204
|
-
case
|
|
1193
|
+
case 16:
|
|
1205
1194
|
case "end":
|
|
1206
1195
|
return _context5.stop();
|
|
1207
1196
|
}
|
|
1208
|
-
}, _callee4, this, [[
|
|
1197
|
+
}, _callee4, this, [[4, 12]]);
|
|
1209
1198
|
}));
|
|
1210
|
-
function
|
|
1211
|
-
return
|
|
1199
|
+
function saveProducts(_x4) {
|
|
1200
|
+
return _saveProducts.apply(this, arguments);
|
|
1212
1201
|
}
|
|
1213
|
-
return
|
|
1214
|
-
}()
|
|
1202
|
+
return saveProducts;
|
|
1203
|
+
}() //variant with lowest variantId gets a flag for filtering purposes
|
|
1204
|
+
}, {
|
|
1205
|
+
key: "setFirstVariant",
|
|
1206
|
+
value: function setFirstVariant(products) {
|
|
1207
|
+
var _variants$;
|
|
1208
|
+
products.map(function (p) {
|
|
1209
|
+
return p.firstVariant = false;
|
|
1210
|
+
});
|
|
1211
|
+
var variants = products.filter(function (p) {
|
|
1212
|
+
return p.variantId !== undefined;
|
|
1213
|
+
});
|
|
1214
|
+
if (!(variants !== null && variants !== void 0 && variants.length)) return;
|
|
1215
|
+
var firstVariant = variants[0];
|
|
1216
|
+
var lowestId = (_variants$ = variants[0]) === null || _variants$ === void 0 ? void 0 : _variants$.variantId;
|
|
1217
|
+
for (var i = 0; i < variants.length; i++) {
|
|
1218
|
+
if (lowestId > variants[i].variantId) {
|
|
1219
|
+
lowestId = variants[i].variantId;
|
|
1220
|
+
firstVariant = variants[i];
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
firstVariant.firstVariant = true;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1215
1226
|
/**
|
|
1216
1227
|
* Calculates the inital state of one varinat data entry
|
|
1217
1228
|
*
|
|
@@ -1221,11 +1232,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1221
1232
|
*/
|
|
1222
1233
|
}, {
|
|
1223
1234
|
key: "initVariant",
|
|
1224
|
-
value: function initVariant(baseData, baseClassification, availableLanguages, cv,
|
|
1225
|
-
var
|
|
1226
|
-
var _this$parseClassifica = this.parseClassificationFields(
|
|
1235
|
+
value: function initVariant(baseData, baseClassification, availableLanguages, catalogData, basket, cv, variantProduct, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
|
|
1236
|
+
var _basket$OrderSets$0$C3, _ref30, _variantProduct$confi, _classificationFields;
|
|
1237
|
+
var _this$parseClassifica = this.parseClassificationFields(variantProduct),
|
|
1227
1238
|
parsedProduct = _this$parseClassifica.product;
|
|
1228
|
-
var _ref29 =
|
|
1239
|
+
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) {
|
|
1240
|
+
return vd.VariantID === cv;
|
|
1241
|
+
})) || {
|
|
1242
|
+
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)
|
|
1243
|
+
},
|
|
1229
1244
|
VariantID = _ref29.VariantID,
|
|
1230
1245
|
SetImage = _ref29.SetImage,
|
|
1231
1246
|
Set2DImage = _ref29.Set2DImage,
|
|
@@ -1236,27 +1251,29 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1236
1251
|
MetaData_locales = _ref29.MetaData_locales,
|
|
1237
1252
|
Variant = _ref29.Variant,
|
|
1238
1253
|
SetHash = _ref29.SetHash,
|
|
1239
|
-
Diva3DProject = _ref29.Diva3DProject
|
|
1254
|
+
Diva3DProject = _ref29.Diva3DProject,
|
|
1255
|
+
VariantDescription_locales = _ref29.VariantDescription_locales,
|
|
1256
|
+
VariantDescription = _ref29.VariantDescription;
|
|
1240
1257
|
//total and summary price are currently not avialable per varinat,
|
|
1241
1258
|
//most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
|
|
1242
1259
|
//we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
|
|
1243
1260
|
|
|
1244
|
-
var ismanual = (
|
|
1245
|
-
var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [],
|
|
1261
|
+
var ismanual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice);
|
|
1262
|
+
var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice, ismanual);
|
|
1246
1263
|
var addedPrice;
|
|
1247
1264
|
if (SetPrice == baseData.calculatedPrice) {
|
|
1248
1265
|
addedPrice = baseData.addedPrice;
|
|
1249
1266
|
} else {
|
|
1250
1267
|
addedPrice = price.calculatedPrice;
|
|
1251
1268
|
}
|
|
1252
|
-
var isManual = (
|
|
1269
|
+
var isManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice);
|
|
1253
1270
|
if (isManual) {
|
|
1254
|
-
addedPrice =
|
|
1271
|
+
addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
|
|
1255
1272
|
}
|
|
1256
|
-
var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales,
|
|
1273
|
+
var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
|
|
1257
1274
|
classificationData = _this$parseMetaDataAn2.classificationData,
|
|
1258
1275
|
customData = _this$parseMetaDataAn2.customData;
|
|
1259
|
-
customData = _objectSpread(_objectSpread({},
|
|
1276
|
+
customData = _objectSpread(_objectSpread({}, variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.customData), customData);
|
|
1260
1277
|
var variant = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseData), {}, {
|
|
1261
1278
|
media: undefined,
|
|
1262
1279
|
//set media undefined, just in case "baseData" has media but "parsedProduct" does not have media to overwrite it
|
|
@@ -1266,8 +1283,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1266
1283
|
width: BBox === null || BBox === void 0 ? void 0 : BBox.X,
|
|
1267
1284
|
height: BBox === null || BBox === void 0 ? void 0 : BBox.Z,
|
|
1268
1285
|
depth: BBox === null || BBox === void 0 ? void 0 : BBox.Y,
|
|
1269
|
-
technicalDescription:
|
|
1270
|
-
technicalDescription_locales:
|
|
1286
|
+
technicalDescription: VariantDescription !== null && VariantDescription !== void 0 ? VariantDescription : baseData.technicalDescription,
|
|
1287
|
+
technicalDescription_locales: VariantDescription_locales !== null && VariantDescription_locales !== void 0 ? VariantDescription_locales : baseData.technicalDescription_locales
|
|
1271
1288
|
}, parsedProduct), {}, {
|
|
1272
1289
|
customData: customData
|
|
1273
1290
|
}, classificationData), {}, {
|
|
@@ -1276,18 +1293,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1276
1293
|
//only if cv is not defined fallback to the values in product
|
|
1277
1294
|
addedPrice: addedPrice,
|
|
1278
1295
|
calculatedPrice: price.calculatedPrice,
|
|
1279
|
-
articles: VariantBasketDatas ? (_baseData$articles = baseData.articles) === null || _baseData$articles === void 0 ? void 0 : _baseData$articles.map(function (art) {
|
|
1280
|
-
return _objectSpread(_objectSpread({}, art), {}, {
|
|
1281
|
-
variantValues: VariantBasketDatas === null || VariantBasketDatas === void 0 ? void 0 : VariantBasketDatas.filter(function (vb) {
|
|
1282
|
-
return !vb.IsDescribingState;
|
|
1283
|
-
}).map(function (vb) {
|
|
1284
|
-
return {
|
|
1285
|
-
OPT: vb.OptionOCD ? vb.OptionOCD.substring(3) : vb.OPT,
|
|
1286
|
-
OPV: vb.OCD ? vb.OCD.substring(3) : vb.OPV
|
|
1287
|
-
};
|
|
1288
|
-
})
|
|
1289
|
-
});
|
|
1290
|
-
}) : parsedProduct.articles,
|
|
1291
1296
|
variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
|
|
1292
1297
|
image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
|
|
1293
1298
|
image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
|
|
@@ -1377,10 +1382,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1377
1382
|
key: "initOpvMap",
|
|
1378
1383
|
value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
|
|
1379
1384
|
var optMap = {};
|
|
1380
|
-
Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (
|
|
1381
|
-
var
|
|
1382
|
-
c =
|
|
1383
|
-
optMapping =
|
|
1385
|
+
Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref31) {
|
|
1386
|
+
var _ref32 = _slicedToArray__default["default"](_ref31, 2),
|
|
1387
|
+
c = _ref32[0],
|
|
1388
|
+
optMapping = _ref32[1].optMapping;
|
|
1384
1389
|
var optField;
|
|
1385
1390
|
if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
|
|
1386
1391
|
optField = optFields.find(function (opt) {
|
|
@@ -1441,16 +1446,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1441
1446
|
var _classificationConfig;
|
|
1442
1447
|
//add metadata defined as classification to classificationdata
|
|
1443
1448
|
var metadataAsClassification = {};
|
|
1444
|
-
Object.entries(metaData).filter(function (
|
|
1445
|
-
var
|
|
1446
|
-
key =
|
|
1449
|
+
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref33) {
|
|
1450
|
+
var _ref34 = _slicedToArray__default["default"](_ref33, 1),
|
|
1451
|
+
key = _ref34[0];
|
|
1447
1452
|
return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
|
|
1448
1453
|
})
|
|
1449
1454
|
//if it is defiend as multi field, use full array otherwise only first element of array
|
|
1450
|
-
.forEach(function (
|
|
1451
|
-
var
|
|
1452
|
-
key =
|
|
1453
|
-
value =
|
|
1455
|
+
.forEach(function (_ref35) {
|
|
1456
|
+
var _ref36 = _slicedToArray__default["default"](_ref35, 2),
|
|
1457
|
+
key = _ref36[0],
|
|
1458
|
+
value = _ref36[1];
|
|
1454
1459
|
return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
|
|
1455
1460
|
});
|
|
1456
1461
|
|
|
@@ -1460,14 +1465,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1460
1465
|
optMap = _this$parseClassifica2.optMap;
|
|
1461
1466
|
var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
|
|
1462
1467
|
var customData = {};
|
|
1463
|
-
Object.entries(metaData).filter(function (
|
|
1464
|
-
var
|
|
1465
|
-
key =
|
|
1468
|
+
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref37) {
|
|
1469
|
+
var _ref38 = _slicedToArray__default["default"](_ref37, 1),
|
|
1470
|
+
key = _ref38[0];
|
|
1466
1471
|
return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
|
|
1467
|
-
}).forEach(function (
|
|
1468
|
-
var
|
|
1469
|
-
key =
|
|
1470
|
-
value =
|
|
1472
|
+
}).forEach(function (_ref39) {
|
|
1473
|
+
var _ref40 = _slicedToArray__default["default"](_ref39, 2),
|
|
1474
|
+
key = _ref40[0],
|
|
1475
|
+
value = _ref40[1];
|
|
1471
1476
|
var langs = {};
|
|
1472
1477
|
if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
|
|
1473
1478
|
for (var i = 0; i < metaData_locales[key].length; i++) {
|
|
@@ -1499,19 +1504,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1499
1504
|
|
|
1500
1505
|
//repare customData
|
|
1501
1506
|
//if it is defiend as multi field, use full array otherwise only first element of array
|
|
1502
|
-
Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (
|
|
1503
|
-
var
|
|
1504
|
-
key =
|
|
1507
|
+
Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref41) {
|
|
1508
|
+
var _ref42 = _slicedToArray__default["default"](_ref41, 1),
|
|
1509
|
+
key = _ref42[0];
|
|
1505
1510
|
return customData[key] != undefined;
|
|
1506
|
-
}).forEach(function (
|
|
1507
|
-
var
|
|
1508
|
-
key =
|
|
1509
|
-
value =
|
|
1511
|
+
}).forEach(function (_ref43) {
|
|
1512
|
+
var _ref44 = _slicedToArray__default["default"](_ref43, 2),
|
|
1513
|
+
key = _ref44[0],
|
|
1514
|
+
value = _ref44[1];
|
|
1510
1515
|
if (value.multi && !Array.isArray(customData[key])) {
|
|
1511
1516
|
customData[key] = [customData[key]];
|
|
1512
1517
|
} else if (!value.multi && Array.isArray(customData[key])) {
|
|
1513
|
-
var
|
|
1514
|
-
customData[key] = (
|
|
1518
|
+
var _key2;
|
|
1519
|
+
customData[key] = (_key2 = customData[key]) === null || _key2 === void 0 ? void 0 : _key2[0];
|
|
1515
1520
|
}
|
|
1516
1521
|
});
|
|
1517
1522
|
return {
|
|
@@ -1636,52 +1641,172 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1636
1641
|
}
|
|
1637
1642
|
return apiGetProducts;
|
|
1638
1643
|
}()
|
|
1644
|
+
}, {
|
|
1645
|
+
key: "apiGetCatalogData",
|
|
1646
|
+
value: function () {
|
|
1647
|
+
var _apiGetCatalogData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(catalogCodex, language, accountId) {
|
|
1648
|
+
var _response$CollectionG, _response$Properties, _response$Properties2;
|
|
1649
|
+
var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
|
|
1650
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context8) {
|
|
1651
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1652
|
+
case 0:
|
|
1653
|
+
_context8.next = 2;
|
|
1654
|
+
return this.apiAccountLogin(accountId);
|
|
1655
|
+
case 2:
|
|
1656
|
+
currentAccountSessionId = _context8.sent;
|
|
1657
|
+
if (currentAccountSessionId) {
|
|
1658
|
+
_context8.next = 5;
|
|
1659
|
+
break;
|
|
1660
|
+
}
|
|
1661
|
+
return _context8.abrupt("return");
|
|
1662
|
+
case 5:
|
|
1663
|
+
fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
|
|
1664
|
+
_context8.next = 8;
|
|
1665
|
+
return fetch(fullUrl, {
|
|
1666
|
+
headers: {
|
|
1667
|
+
sessionGuid: currentAccountSessionId
|
|
1668
|
+
}
|
|
1669
|
+
}).then(function (res) {
|
|
1670
|
+
if (res.status !== 200) {
|
|
1671
|
+
throw new Error('Collections not loaded.');
|
|
1672
|
+
}
|
|
1673
|
+
return res.json();
|
|
1674
|
+
});
|
|
1675
|
+
case 8:
|
|
1676
|
+
response = _context8.sent;
|
|
1677
|
+
if (!response.Error) {
|
|
1678
|
+
_context8.next = 11;
|
|
1679
|
+
break;
|
|
1680
|
+
}
|
|
1681
|
+
throw new Error(response.Error);
|
|
1682
|
+
case 11:
|
|
1683
|
+
actCatalogInfoData = {
|
|
1684
|
+
lang: language,
|
|
1685
|
+
guid: response.GUID,
|
|
1686
|
+
name: response.Name,
|
|
1687
|
+
name_locales: response.Name_locales,
|
|
1688
|
+
codex: catalogCodex,
|
|
1689
|
+
accountLogo: response.AccountLogo,
|
|
1690
|
+
description: response.LongDescription,
|
|
1691
|
+
description_locales: response.LongDescription_locales,
|
|
1692
|
+
hasPlanner: response.HasIDMPlanner == 'True',
|
|
1693
|
+
brand: response.Brandname,
|
|
1694
|
+
supplierGuid: response.SupplierGUID,
|
|
1695
|
+
retailCatalogNr: response.RetailCatalogNr,
|
|
1696
|
+
accountGuid: (_response$CollectionG = response.CollectionGuid) !== null && _response$CollectionG !== void 0 ? _response$CollectionG : response.AccountGuid,
|
|
1697
|
+
options: response.Options,
|
|
1698
|
+
optionValues: response.Optionvalues,
|
|
1699
|
+
currency: response.currency,
|
|
1700
|
+
has3D: !!((_response$Properties = response.Properties) !== null && _response$Properties !== void 0 && (_response$Properties = _response$Properties.find(function (p) {
|
|
1701
|
+
return p.Codex == 'DIVA3D_RENDERING';
|
|
1702
|
+
})) !== null && _response$Properties !== void 0 && _response$Properties.Value),
|
|
1703
|
+
images: [],
|
|
1704
|
+
documents: [],
|
|
1705
|
+
accountSessionId: response.AccountSessionGuid,
|
|
1706
|
+
arReady: !!((_response$Properties2 = response.Properties) !== null && _response$Properties2 !== void 0 && (_response$Properties2 = _response$Properties2.find(function (p) {
|
|
1707
|
+
return p.Codex == 'DIVA3D_AR_READY';
|
|
1708
|
+
})) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
|
|
1709
|
+
};
|
|
1710
|
+
return _context8.abrupt("return", actCatalogInfoData);
|
|
1711
|
+
case 13:
|
|
1712
|
+
case "end":
|
|
1713
|
+
return _context8.stop();
|
|
1714
|
+
}
|
|
1715
|
+
}, _callee7, this);
|
|
1716
|
+
}));
|
|
1717
|
+
function apiGetCatalogData(_x9, _x10, _x11) {
|
|
1718
|
+
return _apiGetCatalogData.apply(this, arguments);
|
|
1719
|
+
}
|
|
1720
|
+
return apiGetCatalogData;
|
|
1721
|
+
}()
|
|
1722
|
+
}, {
|
|
1723
|
+
key: "apiAccountLogin",
|
|
1724
|
+
value: function () {
|
|
1725
|
+
var _apiAccountLogin = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(accountId) {
|
|
1726
|
+
var fullUrl, response;
|
|
1727
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context9) {
|
|
1728
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1729
|
+
case 0:
|
|
1730
|
+
fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
|
|
1731
|
+
_context9.t0 = fetch;
|
|
1732
|
+
_context9.t1 = fullUrl;
|
|
1733
|
+
_context9.next = 5;
|
|
1734
|
+
return this.sessionGuid;
|
|
1735
|
+
case 5:
|
|
1736
|
+
_context9.t2 = _context9.sent;
|
|
1737
|
+
_context9.t3 = {
|
|
1738
|
+
sessionGuid: _context9.t2
|
|
1739
|
+
};
|
|
1740
|
+
_context9.t4 = {
|
|
1741
|
+
headers: _context9.t3
|
|
1742
|
+
};
|
|
1743
|
+
_context9.next = 10;
|
|
1744
|
+
return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
|
|
1745
|
+
if (res.status !== 200) {
|
|
1746
|
+
throw new Error('Collections not loaded.');
|
|
1747
|
+
}
|
|
1748
|
+
return res.json();
|
|
1749
|
+
});
|
|
1750
|
+
case 10:
|
|
1751
|
+
response = _context9.sent;
|
|
1752
|
+
return _context9.abrupt("return", response.SessionGUID);
|
|
1753
|
+
case 12:
|
|
1754
|
+
case "end":
|
|
1755
|
+
return _context9.stop();
|
|
1756
|
+
}
|
|
1757
|
+
}, _callee8, this);
|
|
1758
|
+
}));
|
|
1759
|
+
function apiAccountLogin(_x12) {
|
|
1760
|
+
return _apiAccountLogin.apply(this, arguments);
|
|
1761
|
+
}
|
|
1762
|
+
return apiAccountLogin;
|
|
1763
|
+
}()
|
|
1639
1764
|
}, {
|
|
1640
1765
|
key: "apiGetProductVariants",
|
|
1641
1766
|
value: function () {
|
|
1642
|
-
var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1767
|
+
var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(id, full) {
|
|
1643
1768
|
var _res2;
|
|
1644
1769
|
var fullUrl, res, resData;
|
|
1645
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1646
|
-
while (1) switch (
|
|
1770
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context10) {
|
|
1771
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1647
1772
|
case 0:
|
|
1648
1773
|
fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
|
|
1649
|
-
|
|
1650
|
-
|
|
1774
|
+
_context10.prev = 1;
|
|
1775
|
+
_context10.next = 4;
|
|
1651
1776
|
return axios__default["default"].get(fullUrl, {
|
|
1652
1777
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1653
1778
|
'Content-Type': 'application/json'
|
|
1654
1779
|
})
|
|
1655
1780
|
});
|
|
1656
1781
|
case 4:
|
|
1657
|
-
res =
|
|
1658
|
-
|
|
1782
|
+
res = _context10.sent;
|
|
1783
|
+
_context10.next = 7;
|
|
1659
1784
|
return res.data;
|
|
1660
1785
|
case 7:
|
|
1661
|
-
resData =
|
|
1662
|
-
|
|
1786
|
+
resData = _context10.sent;
|
|
1787
|
+
_context10.next = 13;
|
|
1663
1788
|
break;
|
|
1664
1789
|
case 10:
|
|
1665
|
-
|
|
1666
|
-
|
|
1790
|
+
_context10.prev = 10;
|
|
1791
|
+
_context10.t0 = _context10["catch"](1);
|
|
1667
1792
|
throw new Error('Could not get existing products', {
|
|
1668
|
-
cause:
|
|
1793
|
+
cause: _context10.t0
|
|
1669
1794
|
});
|
|
1670
1795
|
case 13:
|
|
1671
1796
|
if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
|
|
1672
|
-
|
|
1797
|
+
_context10.next = 15;
|
|
1673
1798
|
break;
|
|
1674
1799
|
}
|
|
1675
|
-
return
|
|
1800
|
+
return _context10.abrupt("return", resData);
|
|
1676
1801
|
case 15:
|
|
1677
1802
|
throw new Error(resData.error);
|
|
1678
1803
|
case 16:
|
|
1679
1804
|
case "end":
|
|
1680
|
-
return
|
|
1805
|
+
return _context10.stop();
|
|
1681
1806
|
}
|
|
1682
|
-
},
|
|
1807
|
+
}, _callee9, this, [[1, 10]]);
|
|
1683
1808
|
}));
|
|
1684
|
-
function apiGetProductVariants(
|
|
1809
|
+
function apiGetProductVariants(_x13, _x14) {
|
|
1685
1810
|
return _apiGetProductVariants.apply(this, arguments);
|
|
1686
1811
|
}
|
|
1687
1812
|
return apiGetProductVariants;
|
|
@@ -1689,7 +1814,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1689
1814
|
}, {
|
|
1690
1815
|
key: "apiGetProductByFilter",
|
|
1691
1816
|
value: function () {
|
|
1692
|
-
var _apiGetProductByFilter = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1817
|
+
var _apiGetProductByFilter = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10(filter) {
|
|
1693
1818
|
var _res3;
|
|
1694
1819
|
var limit,
|
|
1695
1820
|
useFilter,
|
|
@@ -1698,39 +1823,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1698
1823
|
res,
|
|
1699
1824
|
resData,
|
|
1700
1825
|
filterParam,
|
|
1701
|
-
|
|
1702
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1703
|
-
while (1) switch (
|
|
1826
|
+
_args11 = arguments;
|
|
1827
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context11) {
|
|
1828
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1704
1829
|
case 0:
|
|
1705
|
-
limit =
|
|
1706
|
-
useFilter =
|
|
1707
|
-
hierarchy =
|
|
1830
|
+
limit = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 1;
|
|
1831
|
+
useFilter = _args11.length > 2 ? _args11[2] : undefined;
|
|
1832
|
+
hierarchy = _args11.length > 3 ? _args11[3] : undefined;
|
|
1708
1833
|
fullUrl = this.catalogService + '/v1/products';
|
|
1709
|
-
|
|
1834
|
+
_context11.prev = 4;
|
|
1710
1835
|
filterParam = useFilter ? 'filter' : 'search';
|
|
1711
|
-
|
|
1836
|
+
_context11.next = 8;
|
|
1712
1837
|
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), {
|
|
1713
1838
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1714
1839
|
'Content-Type': 'application/json'
|
|
1715
1840
|
})
|
|
1716
1841
|
});
|
|
1717
1842
|
case 8:
|
|
1718
|
-
res =
|
|
1719
|
-
|
|
1843
|
+
res = _context11.sent;
|
|
1844
|
+
_context11.next = 11;
|
|
1720
1845
|
return res.data;
|
|
1721
1846
|
case 11:
|
|
1722
|
-
resData =
|
|
1723
|
-
|
|
1847
|
+
resData = _context11.sent;
|
|
1848
|
+
_context11.next = 17;
|
|
1724
1849
|
break;
|
|
1725
1850
|
case 14:
|
|
1726
|
-
|
|
1727
|
-
|
|
1851
|
+
_context11.prev = 14;
|
|
1852
|
+
_context11.t0 = _context11["catch"](4);
|
|
1728
1853
|
throw new Error('Could not get existing products', {
|
|
1729
|
-
cause:
|
|
1854
|
+
cause: _context11.t0
|
|
1730
1855
|
});
|
|
1731
1856
|
case 17:
|
|
1732
1857
|
if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
|
|
1733
|
-
|
|
1858
|
+
_context11.next = 20;
|
|
1734
1859
|
break;
|
|
1735
1860
|
}
|
|
1736
1861
|
//in order to be backwardscompatible we must transform old products here
|
|
@@ -1743,27 +1868,79 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1743
1868
|
}
|
|
1744
1869
|
return d;
|
|
1745
1870
|
});
|
|
1746
|
-
return
|
|
1871
|
+
return _context11.abrupt("return", resData);
|
|
1747
1872
|
case 20:
|
|
1748
1873
|
throw new Error(resData.error);
|
|
1749
1874
|
case 21:
|
|
1750
1875
|
case "end":
|
|
1751
|
-
return
|
|
1876
|
+
return _context11.stop();
|
|
1752
1877
|
}
|
|
1753
|
-
},
|
|
1878
|
+
}, _callee10, this, [[4, 14]]);
|
|
1754
1879
|
}));
|
|
1755
|
-
function apiGetProductByFilter(
|
|
1880
|
+
function apiGetProductByFilter(_x15) {
|
|
1756
1881
|
return _apiGetProductByFilter.apply(this, arguments);
|
|
1757
1882
|
}
|
|
1758
1883
|
return apiGetProductByFilter;
|
|
1759
1884
|
}()
|
|
1885
|
+
}, {
|
|
1886
|
+
key: "apiSetCustomFlag",
|
|
1887
|
+
value: function () {
|
|
1888
|
+
var _apiSetCustomFlag = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(id, flagName, organizationId, dependsOn) {
|
|
1889
|
+
var _res4;
|
|
1890
|
+
var fullUrl, res, resData;
|
|
1891
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context12) {
|
|
1892
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1893
|
+
case 0:
|
|
1894
|
+
fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/' + flagName);
|
|
1895
|
+
fullUrl.searchParams.append('organizationId', organizationId);
|
|
1896
|
+
if (dependsOn) fullUrl.searchParams.append('dependsOn', dependsOn);
|
|
1897
|
+
_context12.prev = 3;
|
|
1898
|
+
_context12.next = 6;
|
|
1899
|
+
return axios__default["default"].post(fullUrl.toString(), undefined, {
|
|
1900
|
+
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1901
|
+
'Content-Type': 'application/json'
|
|
1902
|
+
})
|
|
1903
|
+
});
|
|
1904
|
+
case 6:
|
|
1905
|
+
res = _context12.sent;
|
|
1906
|
+
_context12.next = 9;
|
|
1907
|
+
return res.data;
|
|
1908
|
+
case 9:
|
|
1909
|
+
resData = _context12.sent;
|
|
1910
|
+
_context12.next = 15;
|
|
1911
|
+
break;
|
|
1912
|
+
case 12:
|
|
1913
|
+
_context12.prev = 12;
|
|
1914
|
+
_context12.t0 = _context12["catch"](3);
|
|
1915
|
+
throw new Error('Could not get existing products', {
|
|
1916
|
+
cause: _context12.t0
|
|
1917
|
+
});
|
|
1918
|
+
case 15:
|
|
1919
|
+
if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
|
|
1920
|
+
_context12.next = 17;
|
|
1921
|
+
break;
|
|
1922
|
+
}
|
|
1923
|
+
return _context12.abrupt("return", resData);
|
|
1924
|
+
case 17:
|
|
1925
|
+
throw new Error(resData.error);
|
|
1926
|
+
case 18:
|
|
1927
|
+
case "end":
|
|
1928
|
+
return _context12.stop();
|
|
1929
|
+
}
|
|
1930
|
+
}, _callee11, this, [[3, 12]]);
|
|
1931
|
+
}));
|
|
1932
|
+
function apiSetCustomFlag(_x16, _x17, _x18, _x19) {
|
|
1933
|
+
return _apiSetCustomFlag.apply(this, arguments);
|
|
1934
|
+
}
|
|
1935
|
+
return apiSetCustomFlag;
|
|
1936
|
+
}()
|
|
1760
1937
|
}, {
|
|
1761
1938
|
key: "apiDeleteProducts",
|
|
1762
1939
|
value: function () {
|
|
1763
|
-
var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1940
|
+
var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(products) {
|
|
1764
1941
|
var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
|
|
1765
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1766
|
-
while (1) switch (
|
|
1942
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context13) {
|
|
1943
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1767
1944
|
case 0:
|
|
1768
1945
|
fullUrl = this.catalogService + '/products';
|
|
1769
1946
|
fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
|
|
@@ -1774,7 +1951,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1774
1951
|
i = 0;
|
|
1775
1952
|
case 5:
|
|
1776
1953
|
if (!(i < productsInChunks.length)) {
|
|
1777
|
-
|
|
1954
|
+
_context13.next = 13;
|
|
1778
1955
|
break;
|
|
1779
1956
|
}
|
|
1780
1957
|
promises = productsInChunks[i].map(function (p) {
|
|
@@ -1796,19 +1973,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1796
1973
|
title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
|
|
1797
1974
|
dontRenderForm: true
|
|
1798
1975
|
});
|
|
1799
|
-
|
|
1976
|
+
_context13.next = 10;
|
|
1800
1977
|
return Promise.all(promises);
|
|
1801
1978
|
case 10:
|
|
1802
1979
|
i++;
|
|
1803
|
-
|
|
1980
|
+
_context13.next = 5;
|
|
1804
1981
|
break;
|
|
1805
1982
|
case 13:
|
|
1806
1983
|
case "end":
|
|
1807
|
-
return
|
|
1984
|
+
return _context13.stop();
|
|
1808
1985
|
}
|
|
1809
|
-
},
|
|
1986
|
+
}, _callee12, this);
|
|
1810
1987
|
}));
|
|
1811
|
-
function apiDeleteProducts(
|
|
1988
|
+
function apiDeleteProducts(_x20) {
|
|
1812
1989
|
return _apiDeleteProducts.apply(this, arguments);
|
|
1813
1990
|
}
|
|
1814
1991
|
return apiDeleteProducts;
|
|
@@ -1825,12 +2002,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1825
2002
|
}, {
|
|
1826
2003
|
key: "apiLoadProductVariantsGrouped",
|
|
1827
2004
|
value: function () {
|
|
1828
|
-
var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1829
|
-
var limit, skip, fields,
|
|
1830
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1831
|
-
while (1) switch (
|
|
2005
|
+
var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(_ref45) {
|
|
2006
|
+
var limit, skip, fields, _ref45$search, search, sort, abortController, fullUrl, headers, promise;
|
|
2007
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context14) {
|
|
2008
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1832
2009
|
case 0:
|
|
1833
|
-
limit =
|
|
2010
|
+
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;
|
|
1834
2011
|
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) : '');
|
|
1835
2012
|
headers = {
|
|
1836
2013
|
'Content-Type': 'application/json'
|
|
@@ -1852,32 +2029,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1852
2029
|
reject('Error loading products grouped by variants: ' + error.message);
|
|
1853
2030
|
});
|
|
1854
2031
|
});
|
|
1855
|
-
|
|
2032
|
+
_context14.next = 7;
|
|
1856
2033
|
return promise;
|
|
1857
2034
|
case 7:
|
|
1858
|
-
return
|
|
2035
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1859
2036
|
case 8:
|
|
1860
2037
|
case "end":
|
|
1861
|
-
return
|
|
2038
|
+
return _context14.stop();
|
|
1862
2039
|
}
|
|
1863
|
-
},
|
|
2040
|
+
}, _callee13, this);
|
|
1864
2041
|
}));
|
|
1865
|
-
function apiLoadProductVariantsGrouped(
|
|
2042
|
+
function apiLoadProductVariantsGrouped(_x21) {
|
|
1866
2043
|
return _apiLoadProductVariantsGrouped.apply(this, arguments);
|
|
1867
2044
|
}
|
|
1868
2045
|
return apiLoadProductVariantsGrouped;
|
|
1869
2046
|
}()
|
|
1870
2047
|
}, {
|
|
1871
|
-
key: "
|
|
2048
|
+
key: "apiSaveProducts",
|
|
1872
2049
|
value: function () {
|
|
1873
|
-
var
|
|
2050
|
+
var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
|
|
1874
2051
|
var fullUrl, response, status;
|
|
1875
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1876
|
-
while (1) switch (
|
|
2052
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context15) {
|
|
2053
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1877
2054
|
case 0:
|
|
1878
2055
|
fullUrl = serverUrl + '/v1/products/groups';
|
|
1879
|
-
|
|
1880
|
-
|
|
2056
|
+
_context15.prev = 1;
|
|
2057
|
+
_context15.next = 4;
|
|
1881
2058
|
return fetch(fullUrl, {
|
|
1882
2059
|
method: 'PUT',
|
|
1883
2060
|
headers: {
|
|
@@ -1885,7 +2062,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1885
2062
|
'Content-Type': 'application/json'
|
|
1886
2063
|
},
|
|
1887
2064
|
body: JSON.stringify({
|
|
1888
|
-
basket: basket ? basket.getAsJson() : undefined,
|
|
1889
2065
|
products: products,
|
|
1890
2066
|
removedProductIds: removedProductIds,
|
|
1891
2067
|
awaitPDF: awaitPDF
|
|
@@ -1898,31 +2074,31 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1898
2074
|
return res.json();
|
|
1899
2075
|
});
|
|
1900
2076
|
case 4:
|
|
1901
|
-
response =
|
|
2077
|
+
response = _context15.sent;
|
|
1902
2078
|
if (!response.Error) {
|
|
1903
|
-
|
|
2079
|
+
_context15.next = 7;
|
|
1904
2080
|
break;
|
|
1905
2081
|
}
|
|
1906
2082
|
throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
|
|
1907
2083
|
case 7:
|
|
1908
|
-
|
|
2084
|
+
_context15.next = 12;
|
|
1909
2085
|
break;
|
|
1910
2086
|
case 9:
|
|
1911
|
-
|
|
1912
|
-
|
|
2087
|
+
_context15.prev = 9;
|
|
2088
|
+
_context15.t0 = _context15["catch"](1);
|
|
1913
2089
|
throw Error(status);
|
|
1914
2090
|
case 12:
|
|
1915
|
-
return
|
|
2091
|
+
return _context15.abrupt("return", response.products);
|
|
1916
2092
|
case 13:
|
|
1917
2093
|
case "end":
|
|
1918
|
-
return
|
|
2094
|
+
return _context15.stop();
|
|
1919
2095
|
}
|
|
1920
|
-
},
|
|
2096
|
+
}, _callee14, null, [[1, 9]]);
|
|
1921
2097
|
}));
|
|
1922
|
-
function
|
|
1923
|
-
return
|
|
2098
|
+
function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
|
|
2099
|
+
return _apiSaveProducts.apply(this, arguments);
|
|
1924
2100
|
}
|
|
1925
|
-
return
|
|
2101
|
+
return apiSaveProducts;
|
|
1926
2102
|
}()
|
|
1927
2103
|
}, {
|
|
1928
2104
|
key: "parseFilter",
|
|
@@ -1954,53 +2130,53 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1954
2130
|
}], [{
|
|
1955
2131
|
key: "isSameProduct",
|
|
1956
2132
|
value: function isSameProduct(product, setHash, diva3dProject, orderLines, varinatData, catalogCodex) {
|
|
1957
|
-
var _product$
|
|
2133
|
+
var _product$configuratio, _product$configuratio2, _product$configuratio3;
|
|
1958
2134
|
//For new products we store the setHash and Diva3DProject in order to determine if the product changed.
|
|
1959
2135
|
if (product.uniqueHash !== undefined) {
|
|
1960
2136
|
return product.uniqueHash === 'v1' + setHash + (diva3dProject ? DivaUtils.md5(diva3dProject) : '');
|
|
1961
2137
|
}
|
|
1962
2138
|
|
|
1963
2139
|
//For older products without setHash we use the old comparison logic
|
|
1964
|
-
if (((_product$
|
|
2140
|
+
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)) {
|
|
1965
2141
|
return false;
|
|
1966
2142
|
}
|
|
1967
2143
|
if (!varinatData) {
|
|
1968
2144
|
//the old logic was only for variants, not for base products
|
|
1969
2145
|
return true;
|
|
1970
2146
|
}
|
|
2147
|
+
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 : [];
|
|
1971
2148
|
var _loop2 = function _loop2() {
|
|
1972
|
-
var
|
|
1973
|
-
var article = product.articles[i];
|
|
2149
|
+
var article = orderlines[i];
|
|
1974
2150
|
var orderLine = orderLines.find(function (ol) {
|
|
1975
|
-
return ol.ArticleCodex == article.
|
|
2151
|
+
return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
|
|
1976
2152
|
});
|
|
1977
|
-
if (!orderLine
|
|
2153
|
+
if (!orderLine) {
|
|
1978
2154
|
return {
|
|
1979
2155
|
v: false
|
|
1980
2156
|
};
|
|
1981
2157
|
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
v:
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
var
|
|
1997
|
-
|
|
1998
|
-
|
|
2158
|
+
if (article.VariantBasketDatas.length) {
|
|
2159
|
+
var _loop3 = function _loop3() {
|
|
2160
|
+
var varinatValue = article.VariantBasketDatas[j];
|
|
2161
|
+
if (!varinatData.find(function (vb) {
|
|
2162
|
+
return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
|
|
2163
|
+
})) {
|
|
2164
|
+
return {
|
|
2165
|
+
v: {
|
|
2166
|
+
v: false
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
},
|
|
2171
|
+
_ret2;
|
|
2172
|
+
for (var j = 0; j < article.VariantBasketDatas.length; j++) {
|
|
2173
|
+
_ret2 = _loop3();
|
|
2174
|
+
if (_ret2) return _ret2.v;
|
|
2175
|
+
}
|
|
1999
2176
|
}
|
|
2000
2177
|
},
|
|
2001
2178
|
_ret;
|
|
2002
|
-
for (var i = 0; i <
|
|
2003
|
-
var _product$articles$len, _product$articles2;
|
|
2179
|
+
for (var i = 0; i < orderlines.length; i++) {
|
|
2004
2180
|
_ret = _loop2();
|
|
2005
2181
|
if (_ret) return _ret.v;
|
|
2006
2182
|
}
|
|
@@ -2127,16 +2303,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2127
2303
|
}, {
|
|
2128
2304
|
key: "assign",
|
|
2129
2305
|
value: function assign(target) {
|
|
2130
|
-
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0),
|
|
2131
|
-
sources[
|
|
2306
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
|
|
2307
|
+
sources[_key3 - 1] = arguments[_key3];
|
|
2132
2308
|
}
|
|
2133
2309
|
return Object.assign.apply(Object, [target].concat(_toConsumableArray__default["default"](sources.filter(function (s) {
|
|
2134
2310
|
return s;
|
|
2135
2311
|
}).map(function (x) {
|
|
2136
|
-
return Object.fromEntries(Object.entries(x).filter(function (
|
|
2137
|
-
var
|
|
2138
|
-
|
|
2139
|
-
var value =
|
|
2312
|
+
return Object.fromEntries(Object.entries(x).filter(function (_ref46) {
|
|
2313
|
+
var _ref47 = _slicedToArray__default["default"](_ref46, 2);
|
|
2314
|
+
_ref47[0];
|
|
2315
|
+
var value = _ref47[1];
|
|
2140
2316
|
return value !== undefined;
|
|
2141
2317
|
}));
|
|
2142
2318
|
}))));
|
|
@@ -2144,10 +2320,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2144
2320
|
}, {
|
|
2145
2321
|
key: "loadSelectOptions",
|
|
2146
2322
|
value: function () {
|
|
2147
|
-
var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
2148
|
-
var values, apiUrl, i, apiResult,
|
|
2149
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
2150
|
-
while (1) switch (
|
|
2323
|
+
var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
|
|
2324
|
+
var values, apiUrl, i, apiResult, _i2, value, text;
|
|
2325
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context16) {
|
|
2326
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2151
2327
|
case 0:
|
|
2152
2328
|
values = [];
|
|
2153
2329
|
apiUrl = dataSource.url;
|
|
@@ -2156,7 +2332,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2156
2332
|
apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
|
|
2157
2333
|
}
|
|
2158
2334
|
}
|
|
2159
|
-
|
|
2335
|
+
_context16.next = 5;
|
|
2160
2336
|
return fetch(apiUrl, {
|
|
2161
2337
|
headers: {
|
|
2162
2338
|
sessionGuid: sessionGuid
|
|
@@ -2168,26 +2344,26 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2168
2344
|
return res.json();
|
|
2169
2345
|
});
|
|
2170
2346
|
case 5:
|
|
2171
|
-
apiResult =
|
|
2347
|
+
apiResult = _context16.sent;
|
|
2172
2348
|
if (dataSource.useKey) {
|
|
2173
2349
|
apiResult = apiResult[dataSource.useKey];
|
|
2174
2350
|
}
|
|
2175
|
-
for (
|
|
2176
|
-
value = apiResult[
|
|
2177
|
-
text = apiResult[
|
|
2351
|
+
for (_i2 = 0; _i2 < apiResult.length; _i2++) {
|
|
2352
|
+
value = apiResult[_i2][dataSource.fieldValueMapping];
|
|
2353
|
+
text = apiResult[_i2][dataSource.fieldDescriptionMapping];
|
|
2178
2354
|
values.push({
|
|
2179
2355
|
value: value,
|
|
2180
2356
|
text: text
|
|
2181
2357
|
});
|
|
2182
2358
|
}
|
|
2183
|
-
return
|
|
2359
|
+
return _context16.abrupt("return", values);
|
|
2184
2360
|
case 9:
|
|
2185
2361
|
case "end":
|
|
2186
|
-
return
|
|
2362
|
+
return _context16.stop();
|
|
2187
2363
|
}
|
|
2188
|
-
},
|
|
2364
|
+
}, _callee15);
|
|
2189
2365
|
}));
|
|
2190
|
-
function loadSelectOptions(
|
|
2366
|
+
function loadSelectOptions(_x27, _x28, _x29) {
|
|
2191
2367
|
return _loadSelectOptions.apply(this, arguments);
|
|
2192
2368
|
}
|
|
2193
2369
|
return loadSelectOptions;
|
|
@@ -2200,6 +2376,36 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2200
2376
|
return rv;
|
|
2201
2377
|
}, {});
|
|
2202
2378
|
}
|
|
2379
|
+
}, {
|
|
2380
|
+
key: "getVariantBasketDatasByOrderlines",
|
|
2381
|
+
value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
|
|
2382
|
+
var variantBasketDatas = [];
|
|
2383
|
+
var _loop5 = function _loop5() {
|
|
2384
|
+
var ol = orderLines[i];
|
|
2385
|
+
var catalog = catalogData.find(function (c) {
|
|
2386
|
+
return c.codex === ol.CatalogCodex;
|
|
2387
|
+
});
|
|
2388
|
+
if (!ol.VariantBasketDatas) return 1; // continue
|
|
2389
|
+
for (var j = 0; j < ol.VariantBasketDatas.length; j++) {
|
|
2390
|
+
var v = ol.VariantBasketDatas[j];
|
|
2391
|
+
var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
|
|
2392
|
+
var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
|
|
2393
|
+
{
|
|
2394
|
+
variantBasketDatas.push({
|
|
2395
|
+
BasketID: ol.BasketID,
|
|
2396
|
+
OPT: v.OPT,
|
|
2397
|
+
OPV: v.OPV,
|
|
2398
|
+
OPTName: opt.Name,
|
|
2399
|
+
OPVName: opv.Name
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
for (var i = 0; i < orderLines.length; i++) {
|
|
2405
|
+
if (_loop5()) continue;
|
|
2406
|
+
}
|
|
2407
|
+
return variantBasketDatas;
|
|
2408
|
+
}
|
|
2203
2409
|
}]);
|
|
2204
2410
|
}();
|
|
2205
2411
|
_ProductHandlerAbstract = ProductHandlerAbstract;
|