@crystaldesign/product-handler 24.12.0-beta.8 → 24.12.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +985 -669
- package/build/esm/index.js +985 -669
- package/build/types/product-handler/src/index.d.ts +24 -10
- package/build/types/product-handler/src/index.d.ts.map +1 -1
- package/build/types/product-handler/src/types.d.ts +17 -8
- package/build/types/product-handler/src/types.d.ts.map +1 -1
- package/package.json +5 -8
package/build/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,71 @@ 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
|
|
204
|
+
var _this = this,
|
|
205
|
+
_baseProduct,
|
|
206
|
+
_basket$getProductCon,
|
|
207
|
+
_baseProduct2,
|
|
208
|
+
_baseProduct3,
|
|
209
|
+
_baseProduct$divaNr,
|
|
210
|
+
_baseProduct4,
|
|
211
|
+
_dataByBasket$price$a,
|
|
212
|
+
_dataByBasket$price,
|
|
213
|
+
_baseProduct5,
|
|
214
|
+
_dataByBasket$image,
|
|
215
|
+
_baseProduct6,
|
|
216
|
+
_dataByBasket$image2D,
|
|
217
|
+
_baseProduct7,
|
|
218
|
+
_dataByBasket$docking,
|
|
219
|
+
_baseProduct8,
|
|
220
|
+
_baseProduct$organiza,
|
|
221
|
+
_baseProduct9,
|
|
222
|
+
_this$organization$pa,
|
|
223
|
+
_this$organization$pa2,
|
|
224
|
+
_baseProduct$createdB,
|
|
189
225
|
_baseProduct10,
|
|
226
|
+
_this$user,
|
|
190
227
|
_baseProduct11,
|
|
191
228
|
_baseProduct12,
|
|
192
229
|
_baseProduct13,
|
|
193
230
|
_baseProduct14,
|
|
231
|
+
_dataByBasket$orderTe,
|
|
194
232
|
_baseProduct15,
|
|
233
|
+
_dataByBasket$technic,
|
|
195
234
|
_baseProduct16,
|
|
196
235
|
_baseProduct17,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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,
|
|
234
|
-
_baseProduct$organiza,
|
|
235
|
-
_baseProduct41,
|
|
236
|
-
_this$organization$pa,
|
|
237
|
-
_this$organization$pa2,
|
|
238
|
-
_baseProduct42,
|
|
239
|
-
_baseProduct$createdB,
|
|
240
|
-
_baseProduct43,
|
|
241
|
-
_this$user,
|
|
242
|
-
_baseProduct44,
|
|
243
|
-
_baseProduct45,
|
|
244
|
-
_baseProduct46,
|
|
245
|
-
_baseProduct47,
|
|
246
|
-
_baseProduct48,
|
|
247
|
-
_baseProduct49,
|
|
248
|
-
_baseProduct50,
|
|
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;
|
|
236
|
+
_ref3,
|
|
237
|
+
_baseProduct$configur3,
|
|
238
|
+
_baseProduct18;
|
|
239
|
+
var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
|
|
251
240
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
252
241
|
while (1) switch (_context2.prev = _context2.next) {
|
|
253
242
|
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
|
|
243
|
+
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;
|
|
244
|
+
if (!(!productData && !divaNr)) {
|
|
245
|
+
_context2.next = 3;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
throw new Error('this should not happen');
|
|
249
|
+
case 3:
|
|
255
250
|
if (productData) {
|
|
256
|
-
_context2.next =
|
|
251
|
+
_context2.next = 7;
|
|
257
252
|
break;
|
|
258
253
|
}
|
|
259
|
-
_context2.next =
|
|
260
|
-
return this.apiGetProducts(
|
|
261
|
-
case
|
|
254
|
+
_context2.next = 6;
|
|
255
|
+
return this.apiGetProducts(divaNr);
|
|
256
|
+
case 6:
|
|
262
257
|
productData = _context2.sent;
|
|
263
|
-
case
|
|
258
|
+
case 7:
|
|
264
259
|
products = {
|
|
265
260
|
data: productData,
|
|
266
261
|
total: productData.length
|
|
267
262
|
};
|
|
263
|
+
if (!(!products.data.length && !basket)) {
|
|
264
|
+
_context2.next = 10;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
throw new Error('If product does not exist yet, basket must be provided');
|
|
268
|
+
case 10:
|
|
268
269
|
baseProduct = undefined;
|
|
269
270
|
variantProducts = [];
|
|
270
271
|
if (products.total == 1) {
|
|
@@ -277,263 +278,77 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
277
278
|
return !p.baseProduct;
|
|
278
279
|
});
|
|
279
280
|
}
|
|
280
|
-
if (
|
|
281
|
-
_context2.next =
|
|
281
|
+
if (catalogData) {
|
|
282
|
+
_context2.next = 23;
|
|
282
283
|
break;
|
|
283
284
|
}
|
|
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
|
-
});
|
|
285
|
+
if (!baseProduct) {
|
|
286
|
+
_context2.next = 20;
|
|
287
|
+
break;
|
|
357
288
|
}
|
|
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
|
-
};
|
|
289
|
+
_context2.next = 17;
|
|
290
|
+
return Promise.all((_baseProduct$configur = (_baseProduct$configur2 = baseProduct.configuration) === null || _baseProduct$configur2 === void 0 ? void 0 : _baseProduct$configur2.OrderSets.map(function (os) {
|
|
291
|
+
return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
|
|
292
|
+
})) !== null && _baseProduct$configur !== void 0 ? _baseProduct$configur : []);
|
|
293
|
+
case 17:
|
|
294
|
+
catalogData = _context2.sent;
|
|
295
|
+
_context2.next = 23;
|
|
296
|
+
break;
|
|
297
|
+
case 20:
|
|
298
|
+
_context2.next = 22;
|
|
299
|
+
return Promise.all((_basket$OrderSets$map = basket === null || basket === void 0 ? void 0 : basket.OrderSets.map(function (os) {
|
|
300
|
+
return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
|
|
301
|
+
})) !== null && _basket$OrderSets$map !== void 0 ? _basket$OrderSets$map : []);
|
|
302
|
+
case 22:
|
|
303
|
+
catalogData = _context2.sent;
|
|
304
|
+
case 23:
|
|
305
|
+
if (!(products.total && !baseProduct)) {
|
|
306
|
+
_context2.next = 25;
|
|
307
|
+
break;
|
|
409
308
|
}
|
|
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
|
|
309
|
+
throw new Error('If existing products are fetched, there has to be atleast a base product.');
|
|
310
|
+
case 25:
|
|
311
|
+
dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
|
|
419
312
|
oldClassificationData = {};
|
|
420
|
-
for (
|
|
421
|
-
variant = products.data[
|
|
313
|
+
for (i = 0; i < products.data.length; i++) {
|
|
314
|
+
variant = products.data[i];
|
|
422
315
|
oldClassificationData[variant._id] = {};
|
|
423
|
-
for (
|
|
424
|
-
if (
|
|
425
|
-
oldClassificationData[variant._id][
|
|
316
|
+
for (key in variant) {
|
|
317
|
+
if (key.startsWith('dc_') && variant[key].optionPosition !== undefined) {
|
|
318
|
+
oldClassificationData[variant._id][key] = variant[key];
|
|
426
319
|
}
|
|
427
320
|
}
|
|
428
321
|
}
|
|
429
|
-
oldUniqueHash = (
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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,
|
|
322
|
+
oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
|
|
323
|
+
configuration = (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2.configuration;
|
|
324
|
+
baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
|
|
325
|
+
_id: ((_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3._id) || DivaUtils.nanoid(),
|
|
326
|
+
divaNr: (_baseProduct$divaNr = (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr,
|
|
327
|
+
addedPrice: (_dataByBasket$price$a = dataByBasket === null || dataByBasket === void 0 || (_dataByBasket$price = dataByBasket.price) === null || _dataByBasket$price === void 0 ? void 0 : _dataByBasket$price.addedPrice) !== null && _dataByBasket$price$a !== void 0 ? _dataByBasket$price$a : (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.addedPrice,
|
|
328
|
+
image: (_dataByBasket$image = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image) !== null && _dataByBasket$image !== void 0 ? _dataByBasket$image : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.image,
|
|
329
|
+
image2D: (_dataByBasket$image2D = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image2D) !== null && _dataByBasket$image2D !== void 0 ? _dataByBasket$image2D : (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.image2D,
|
|
330
|
+
configuration: configuration,
|
|
331
|
+
dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.dockingPoints,
|
|
512
332
|
currency: DivaUtils__default["default"].defaultPriceFormat.currency,
|
|
513
|
-
organizationId: (_baseProduct$organiza = (
|
|
333
|
+
organizationId: (_baseProduct$organiza = (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
|
|
514
334
|
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
335
|
return o._id;
|
|
516
336
|
})) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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) {
|
|
337
|
+
createdBy: (_baseProduct$createdB = (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
|
|
338
|
+
createdBy_displayText: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy_displayText,
|
|
339
|
+
archived: (_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.archived ? (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.archived : false,
|
|
340
|
+
isTopseller: !!((_baseProduct14 = baseProduct) !== null && _baseProduct14 !== void 0 && _baseProduct14.isTopseller),
|
|
341
|
+
orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.orderText,
|
|
342
|
+
technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.technicalDescription
|
|
343
|
+
});
|
|
344
|
+
metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
|
|
530
345
|
return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
|
|
531
346
|
}, {});
|
|
532
|
-
metaData_locales = basket.OrderSets.reduce(function (prev, curr) {
|
|
347
|
+
metaData_locales = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
|
|
533
348
|
return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
|
|
534
349
|
}, {});
|
|
535
350
|
_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({}, (
|
|
351
|
+
baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.customData), customData);
|
|
537
352
|
|
|
538
353
|
//add livingarea,maincategorie,subcategorie of loaded product if not exists
|
|
539
354
|
classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
|
|
@@ -549,55 +364,56 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
549
364
|
removedProducts = [];
|
|
550
365
|
optFields = [];
|
|
551
366
|
initialSelectedFields = [];
|
|
552
|
-
if (isSet) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
367
|
+
if (!dataByBasket.isSet) {
|
|
368
|
+
_context2.next = 46;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
throw new Error('Variants are currently not supported for set products');
|
|
372
|
+
case 46:
|
|
373
|
+
//iterate all existing variant products and add them to the variants
|
|
374
|
+
usedVariantIds = [];
|
|
375
|
+
variantProducts.forEach(function (product) {
|
|
376
|
+
var cv;
|
|
377
|
+
if (basket) {
|
|
378
|
+
var _basket$OrderSets$0$C;
|
|
379
|
+
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) {
|
|
380
|
+
return ProductHandlerAbstract.isSameProduct(product, cv.SetHash, cv.Diva3DProject, basket.OrderSets[0].OrderLines, cv.VariantBasketDatas, basket.OrderSets[0].CatalogCodex);
|
|
381
|
+
})) === null || _basket$OrderSets$0$C === void 0 ? void 0 : _basket$OrderSets$0$C.VariantID;
|
|
382
|
+
} else {
|
|
383
|
+
cv = product.variantId;
|
|
384
|
+
}
|
|
570
385
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
386
|
+
//if the product is originating from a different divaNr it is not included in the configVariant of this divaNr
|
|
387
|
+
if (product.originDivaNr || cv !== undefined) {
|
|
388
|
+
if (cv !== undefined) usedVariantIds.push(cv);
|
|
389
|
+
var _this$initVariant = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
390
|
+
_variant = _this$initVariant.variant,
|
|
391
|
+
modified = _this$initVariant.modified;
|
|
392
|
+
variantData.push(_variant);
|
|
393
|
+
variantDataModified.push(modified);
|
|
394
|
+
} else {
|
|
395
|
+
var _this$initVariant2 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv, product, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
396
|
+
_variant2 = _this$initVariant2.variant,
|
|
397
|
+
_modified = _this$initVariant2.modified;
|
|
398
|
+
variantData.push(_variant2);
|
|
399
|
+
variantDataModified.push(_modified);
|
|
400
|
+
removedProducts.push(_variant2._id);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
588
403
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
404
|
+
//now iterate all configVariants that are left and add them to the variants (new Products)
|
|
405
|
+
newVariantPosition = variantData.filter(function (vd) {
|
|
406
|
+
return !removedProducts.includes(vd._id);
|
|
407
|
+
});
|
|
408
|
+
variantPositions = newVariantPosition.map(function (element) {
|
|
409
|
+
return element.variantPosition || element.variantPosition === 0 ? element.variantPosition : -1;
|
|
410
|
+
});
|
|
411
|
+
currentVariantPos = Math.max.apply(Math, _toConsumableArray__default["default"](variantPositions));
|
|
412
|
+
if (basket) {
|
|
413
|
+
(_basket$OrderSets$0$C2 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C2 === void 0 || _basket$OrderSets$0$C2.filter(function (cv) {
|
|
414
|
+
return !usedVariantIds.includes(cv.VariantID);
|
|
599
415
|
}).forEach(function (cv) {
|
|
600
|
-
var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, cv, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
416
|
+
var _this$initVariant3 = _this.initVariant(baseData, classificationData, availableLanguages, catalogData, basket, cv.VariantID, undefined, classificationFields, fieldConfiguration, customBaseFields, classificationConfig),
|
|
601
417
|
variant = _this$initVariant3.variant,
|
|
602
418
|
modified = _this$initVariant3.modified;
|
|
603
419
|
currentVariantPos = currentVariantPos + 1;
|
|
@@ -606,60 +422,61 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
606
422
|
variantDataModified.push(modified);
|
|
607
423
|
addedProducts.push(variant._id);
|
|
608
424
|
});
|
|
425
|
+
}
|
|
609
426
|
|
|
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
|
-
|
|
427
|
+
//get opt data
|
|
428
|
+
differingOPTs = Object.entries(((_ref3 = (_baseProduct$configur3 = (_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.configuration) !== null && _baseProduct$configur3 !== void 0 ? _baseProduct$configur3 : basket) === null || _ref3 === void 0 || (_ref3 = _ref3.OrderSets[0].Favorites) === null || _ref3 === void 0 ? void 0 : _ref3.VariantValues) || []).filter(function (_ref4) {
|
|
429
|
+
var _ref5 = _slicedToArray__default["default"](_ref4, 2);
|
|
430
|
+
_ref5[0];
|
|
431
|
+
var value = _ref5[1];
|
|
432
|
+
return Object.keys(value).length > 1;
|
|
433
|
+
}).map(function (_ref6) {
|
|
434
|
+
var _ref7 = _slicedToArray__default["default"](_ref6, 2),
|
|
435
|
+
opt = _ref7[0];
|
|
436
|
+
_ref7[1];
|
|
437
|
+
return opt.replace('OPT', '');
|
|
438
|
+
});
|
|
439
|
+
if (variantData) {
|
|
440
|
+
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) {
|
|
441
|
+
var _catalogData, _vd$OptionOCD, _option$Name;
|
|
442
|
+
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];
|
|
443
|
+
return {
|
|
444
|
+
field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
|
|
445
|
+
type: 'string',
|
|
446
|
+
title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
|
|
447
|
+
readOnly: true,
|
|
448
|
+
fieldType: 'OPT'
|
|
449
|
+
};
|
|
450
|
+
})) || [];
|
|
451
|
+
//remove duplicates
|
|
452
|
+
opts = {};
|
|
453
|
+
for (_i = optFields.length - 1; _i >= 0; _i--) {
|
|
454
|
+
if (!opts[optFields[_i].field]) {
|
|
455
|
+
opts[optFields[_i].field] = true;
|
|
456
|
+
} else {
|
|
457
|
+
optFields.splice(_i, 1);
|
|
641
458
|
}
|
|
642
459
|
}
|
|
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
460
|
}
|
|
461
|
+
|
|
462
|
+
//mark all fields where there are differences between the variants as initaly selected
|
|
463
|
+
initialSelectedFields = optFields.filter(function (f) {
|
|
464
|
+
return differingOPTs.includes(f.field);
|
|
465
|
+
});
|
|
466
|
+
ProductHandlerAbstract.baseDataFields.forEach(function (field) {
|
|
467
|
+
if (variantDataModified.some(function (mod) {
|
|
468
|
+
return mod[field.field];
|
|
469
|
+
})) {
|
|
470
|
+
initialSelectedFields.push(field);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
customBaseFields === null || customBaseFields === void 0 || customBaseFields.forEach(function (f) {
|
|
474
|
+
if (variantDataModified.some(function (mod) {
|
|
475
|
+
return mod['customData.' + f.field];
|
|
476
|
+
})) {
|
|
477
|
+
initialSelectedFields.push(f);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
663
480
|
initializedOptMap = this.initOpvMap(optFields, classificationConfig, optMap);
|
|
664
481
|
return _context2.abrupt("return", {
|
|
665
482
|
baseData: baseData,
|
|
@@ -667,6 +484,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
667
484
|
optFields: optFields,
|
|
668
485
|
initialSelectedFields: initialSelectedFields,
|
|
669
486
|
variantData: variantData,
|
|
487
|
+
catalogData: catalogData,
|
|
670
488
|
optClassMap: initializedOptMap,
|
|
671
489
|
addedProducts: products.total ? addedProducts : [],
|
|
672
490
|
removedProducts: products.total ? removedProducts : [],
|
|
@@ -680,7 +498,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
680
498
|
availableLanguages: availableLanguages,
|
|
681
499
|
currentLang: currentLang
|
|
682
500
|
});
|
|
683
|
-
case
|
|
501
|
+
case 59:
|
|
684
502
|
case "end":
|
|
685
503
|
return _context2.stop();
|
|
686
504
|
}
|
|
@@ -691,6 +509,192 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
691
509
|
}
|
|
692
510
|
return loadProducts;
|
|
693
511
|
}())
|
|
512
|
+
}, {
|
|
513
|
+
key: "getProductDataByBasket",
|
|
514
|
+
value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
|
|
515
|
+
var dataByBasket = {};
|
|
516
|
+
var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
|
|
517
|
+
dataByBasket.isSet = isSet;
|
|
518
|
+
if (basket) {
|
|
519
|
+
dataByBasket.hqRenderScript = basket === null || basket === void 0 ? void 0 : basket.OrderSets[0].HQRenderScript;
|
|
520
|
+
dataByBasket.dockingPoints = isSet ? undefined : basket.OrderSets[0].getDockingPointInfo();
|
|
521
|
+
dataByBasket.technicalDescription = isSet ? basket.OrderSets.reduce(function (total, os) {
|
|
522
|
+
return total + os.SetName + '\n' + os.VariantDescription + '\n\n';
|
|
523
|
+
}, '') : basket.OrderSets[0].VariantDescription;
|
|
524
|
+
dataByBasket.technicalDescription_locales = basket.OrderSets[0].VariantDescription_locales;
|
|
525
|
+
dataByBasket.modelName = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
526
|
+
return c.name;
|
|
527
|
+
}).filter(function (name) {
|
|
528
|
+
return name;
|
|
529
|
+
}).join(' - ');
|
|
530
|
+
dataByBasket.catalogDataBrand = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
531
|
+
return c.brand;
|
|
532
|
+
}).filter(function (brand) {
|
|
533
|
+
return brand;
|
|
534
|
+
}).join(' - ');
|
|
535
|
+
dataByBasket.info = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
536
|
+
return c.description;
|
|
537
|
+
}).filter(function (description) {
|
|
538
|
+
return description;
|
|
539
|
+
}).join('<br/>');
|
|
540
|
+
dataByBasket.modelName_locales = {};
|
|
541
|
+
for (var i = 0; i < (catalogData !== null && catalogData !== void 0 ? catalogData : []).length; i++) {
|
|
542
|
+
var c = catalogData[i];
|
|
543
|
+
for (var key in c.name_locales) {
|
|
544
|
+
if (!dataByBasket.modelName_locales[key]) {
|
|
545
|
+
dataByBasket.modelName_locales[key] = c.name_locales[key];
|
|
546
|
+
} else {
|
|
547
|
+
dataByBasket.modelName_locales[key] = dataByBasket.modelName_locales[key] + ' - ' + c.name_locales[key];
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
dataByBasket.info_locales = {};
|
|
551
|
+
for (var _key in c.description_locales) {
|
|
552
|
+
if (!dataByBasket.info_locales[_key]) {
|
|
553
|
+
dataByBasket.info_locales[_key] = c.description_locales[_key];
|
|
554
|
+
} else {
|
|
555
|
+
dataByBasket.info_locales[_key] = dataByBasket.info_locales[_key] + ' - ' + c.description_locales[_key];
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
|
|
560
|
+
var _baseProduct$delivery, _baseProduct$delivery2, _baseProduct$delivery3, _baseProduct$delivery4, _baseProduct$delivery5, _baseProduct$delivery6, _baseProduct$delivery7, _baseProduct$delivery8, _baseProduct$delivery9, _baseProduct$delivery10, _ref8, _baseProduct$delivery11, _baseProduct$delivery12, _fieldConfiguration$d, _ref9, _baseProduct$delivery13, _baseProduct$delivery14, _fieldConfiguration$d2, _ref10, _baseProduct$delivery15, _baseProduct$delivery16, _fieldConfiguration$d3;
|
|
561
|
+
var config = {
|
|
562
|
+
addedPackageWeight: 0,
|
|
563
|
+
addedPackageHeight: 0,
|
|
564
|
+
addedPackageWidth: 0,
|
|
565
|
+
addedPackageDepth: 0,
|
|
566
|
+
defaultDeliveryTime: 0,
|
|
567
|
+
defaultDeliveryPrice: 0,
|
|
568
|
+
defaultInstallationPrice: 0
|
|
569
|
+
};
|
|
570
|
+
if (typeof fieldConfiguration.delivery != 'boolean') {
|
|
571
|
+
config = _objectSpread(_objectSpread({}, config), fieldConfiguration.delivery);
|
|
572
|
+
}
|
|
573
|
+
var packages = [];
|
|
574
|
+
basket.OrderSets.flatMap(function (os) {
|
|
575
|
+
return os.OrderLines;
|
|
576
|
+
}).forEach(function (ol) {
|
|
577
|
+
packages.push({
|
|
578
|
+
height: ol.Height ? ol.Height + config.addedPackageHeight : 0,
|
|
579
|
+
width: ol.Width ? ol.Width + config.addedPackageWidth : 0,
|
|
580
|
+
depth: ol.Depth ? ol.Depth + config.addedPackageDepth : 0,
|
|
581
|
+
weight: ol.Weight ? ol.Weight + config.addedPackageWeight : 0
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
dataByBasket.delivery = {
|
|
585
|
+
estPackages: packages,
|
|
586
|
+
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,
|
|
587
|
+
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) {
|
|
588
|
+
return p.weight;
|
|
589
|
+
}).filter(function (f) {
|
|
590
|
+
return f;
|
|
591
|
+
})))),
|
|
592
|
+
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) {
|
|
593
|
+
return p.height;
|
|
594
|
+
}).filter(function (f) {
|
|
595
|
+
return f;
|
|
596
|
+
})))),
|
|
597
|
+
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) {
|
|
598
|
+
return p.width;
|
|
599
|
+
}).filter(function (f) {
|
|
600
|
+
return f;
|
|
601
|
+
})))),
|
|
602
|
+
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) {
|
|
603
|
+
return p.depth;
|
|
604
|
+
}).filter(function (f) {
|
|
605
|
+
return f;
|
|
606
|
+
})))),
|
|
607
|
+
deliveryTime: (_ref8 = (_baseProduct$delivery11 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery12 = baseProduct.delivery) === null || _baseProduct$delivery12 === void 0 ? void 0 : _baseProduct$delivery12.deliveryTime) !== null && _baseProduct$delivery11 !== void 0 ? _baseProduct$delivery11 : (_fieldConfiguration$d = fieldConfiguration.delivery) === null || _fieldConfiguration$d === void 0 ? void 0 : _fieldConfiguration$d.defaultDeliveryTime) !== null && _ref8 !== void 0 ? _ref8 : 0,
|
|
608
|
+
deliveryPrice: (_ref9 = (_baseProduct$delivery13 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery14 = baseProduct.delivery) === null || _baseProduct$delivery14 === void 0 ? void 0 : _baseProduct$delivery14.deliveryPrice) !== null && _baseProduct$delivery13 !== void 0 ? _baseProduct$delivery13 : (_fieldConfiguration$d2 = fieldConfiguration.delivery) === null || _fieldConfiguration$d2 === void 0 ? void 0 : _fieldConfiguration$d2.defaultDeliveryPrice) !== null && _ref9 !== void 0 ? _ref9 : 0,
|
|
609
|
+
installationPrice: (_ref10 = (_baseProduct$delivery15 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery16 = baseProduct.delivery) === null || _baseProduct$delivery16 === void 0 ? void 0 : _baseProduct$delivery16.installationPrice) !== null && _baseProduct$delivery15 !== void 0 ? _baseProduct$delivery15 : (_fieldConfiguration$d3 = fieldConfiguration.delivery) === null || _fieldConfiguration$d3 === void 0 ? void 0 : _fieldConfiguration$d3.defaultInstallationPrice) !== null && _ref10 !== void 0 ? _ref10 : 0
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
|
|
613
|
+
var price = {
|
|
614
|
+
calculatedPrice: basket === null || basket === void 0 ? void 0 : basket.SummaryPrice,
|
|
615
|
+
addedPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice,
|
|
616
|
+
discountPrice: baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.discountedPrice
|
|
617
|
+
};
|
|
618
|
+
if (!(baseProduct !== null && baseProduct !== void 0 && baseProduct.calculatedPrice)) {
|
|
619
|
+
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);
|
|
620
|
+
}
|
|
621
|
+
dataByBasket.price = price;
|
|
622
|
+
dataByBasket.calculatedPrice = price.calculatedPrice;
|
|
623
|
+
if (isSet) {
|
|
624
|
+
var _basket$SetPlannerInf, _basket$SetPlannerInf2, _basket$OrderSets$0$B, _basket$SetPlannerInf3, _basket$SetPlannerInf4;
|
|
625
|
+
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;
|
|
626
|
+
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;
|
|
627
|
+
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;
|
|
628
|
+
dataByBasket.image = (_basket$SetPlannerInf3 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf3 === void 0 ? void 0 : _basket$SetPlannerInf3.SetPlannerImg3D;
|
|
629
|
+
dataByBasket.image2D = (_basket$SetPlannerInf4 = basket.SetPlannerInfos) === null || _basket$SetPlannerInf4 === void 0 ? void 0 : _basket$SetPlannerInf4.SetPlannerImg2D;
|
|
630
|
+
dataByBasket.catalogId = basket.OrderSets.map(function (os) {
|
|
631
|
+
return os.CatalogGUID;
|
|
632
|
+
});
|
|
633
|
+
dataByBasket.collection = basket.OrderSets.map(function (os) {
|
|
634
|
+
return os.AccountName;
|
|
635
|
+
});
|
|
636
|
+
dataByBasket.collectionId = basket.OrderSets.map(function (os) {
|
|
637
|
+
return os.CollectionGUID;
|
|
638
|
+
});
|
|
639
|
+
dataByBasket.catCodex = basket.OrderSets.map(function (os) {
|
|
640
|
+
return os.CatalogCodex;
|
|
641
|
+
});
|
|
642
|
+
} else {
|
|
643
|
+
var _basket$OrderSets$0$B2, _basket$OrderSets$0$B3, _basket$OrderSets$0$B4;
|
|
644
|
+
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;
|
|
645
|
+
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;
|
|
646
|
+
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;
|
|
647
|
+
dataByBasket.image = basket.OrderSets[0].SetImage;
|
|
648
|
+
dataByBasket.image2D = basket.OrderSets[0].Set2DImage;
|
|
649
|
+
dataByBasket.catalogId = [basket.OrderSets[0].CatalogGUID];
|
|
650
|
+
dataByBasket.collection = [basket.OrderSets[0].AccountName];
|
|
651
|
+
dataByBasket.collectionId = [basket.OrderSets[0].CollectionGUID];
|
|
652
|
+
dataByBasket.catCodex = [basket.OrderSets[0].CatalogCodex];
|
|
653
|
+
}
|
|
654
|
+
dataByBasket.weight = basket === null || basket === void 0 ? void 0 : basket.OrderSets.flatMap(function (os) {
|
|
655
|
+
return os.OrderLines.map(function (ol) {
|
|
656
|
+
return ol.Weight;
|
|
657
|
+
}).filter(function (f) {
|
|
658
|
+
return f;
|
|
659
|
+
});
|
|
660
|
+
}).reduce(function (sum, v) {
|
|
661
|
+
return sum + v;
|
|
662
|
+
}, 0);
|
|
663
|
+
dataByBasket.supplierId = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
664
|
+
return c.supplierGuid;
|
|
665
|
+
}).filter(function (c) {
|
|
666
|
+
return c;
|
|
667
|
+
});
|
|
668
|
+
dataByBasket.retailCatalogNr = catalogData === null || catalogData === void 0 ? void 0 : catalogData.map(function (c) {
|
|
669
|
+
return c.retailCatalogNr;
|
|
670
|
+
}).filter(function (c) {
|
|
671
|
+
return c;
|
|
672
|
+
});
|
|
673
|
+
dataByBasket.supplierArticleNr = basket.OrderSets.flatMap(function (os) {
|
|
674
|
+
return os.OrderLines.map(function (ol) {
|
|
675
|
+
return ol.ConfigArticleCodex;
|
|
676
|
+
}).filter(function (f) {
|
|
677
|
+
return f;
|
|
678
|
+
});
|
|
679
|
+
}).filter(function (f) {
|
|
680
|
+
return f;
|
|
681
|
+
});
|
|
682
|
+
dataByBasket.retailCatalogArticleNr = basket.OrderSets.flatMap(function (os) {
|
|
683
|
+
return os.OrderLines.map(function (ol) {
|
|
684
|
+
return ol.RetailArticleNr;
|
|
685
|
+
}).filter(function (f) {
|
|
686
|
+
return f;
|
|
687
|
+
});
|
|
688
|
+
}).filter(function (f) {
|
|
689
|
+
return f;
|
|
690
|
+
});
|
|
691
|
+
dataByBasket.orderText = basket.getEKText(true);
|
|
692
|
+
dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
|
|
693
|
+
return os.SetHash;
|
|
694
|
+
}).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
|
|
695
|
+
}
|
|
696
|
+
return dataByBasket;
|
|
697
|
+
}
|
|
694
698
|
}, {
|
|
695
699
|
key: "checkAndAddClassificationConfigCategories",
|
|
696
700
|
value: function checkAndAddClassificationConfigCategories(baseProduct, classificationConfig) {
|
|
@@ -751,11 +755,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
751
755
|
key: "mapCategory",
|
|
752
756
|
value: function mapCategory(value, translations) {
|
|
753
757
|
var _translations$find2;
|
|
754
|
-
var
|
|
758
|
+
var _ref11 = (_translations$find2 = translations === null || translations === void 0 ? void 0 : translations.find(function (t) {
|
|
755
759
|
return t.value == value;
|
|
756
760
|
})) !== null && _translations$find2 !== void 0 ? _translations$find2 : {};
|
|
757
|
-
|
|
758
|
-
var translation = _objectWithoutProperties__default["default"](
|
|
761
|
+
_ref11.value;
|
|
762
|
+
var translation = _objectWithoutProperties__default["default"](_ref11, _excluded);
|
|
759
763
|
if (Object.keys(translation).length) {
|
|
760
764
|
return translation;
|
|
761
765
|
}
|
|
@@ -779,13 +783,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
779
783
|
}, {
|
|
780
784
|
key: "prepareData",
|
|
781
785
|
value: function () {
|
|
782
|
-
var _prepareData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(
|
|
786
|
+
var _prepareData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref12) {
|
|
783
787
|
var _this3 = this;
|
|
784
|
-
var baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap,
|
|
788
|
+
var basket, baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref12$oldClassificat, oldClassificationData, originProductId, products, originProduct, sapEinaLifNr, sapEineEkgrp, result, _this$closeModal, _originProduct$percen, _originProduct$discou, _baseData$variantId, _originProduct$create, _originProduct$create2, _originProduct$create3, baseProduct, j, mediaRef, _this$openModal, _this$t, _j, _this$openModal2, _this$t2, savedMedia, _loop, _j2;
|
|
785
789
|
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
|
|
786
790
|
while (1) switch (_context4.prev = _context4.next) {
|
|
787
791
|
case 0:
|
|
788
|
-
baseData =
|
|
792
|
+
basket = _ref12.basket, baseData = _ref12.baseData, classificationData = _ref12.classificationData, variantData = _ref12.variantData, removedProducts = _ref12.removedProducts, removedMedia = _ref12.removedMedia, classificationFields = _ref12.classificationFields, fieldConfiguration = _ref12.fieldConfiguration, optMap = _ref12.optMap, _ref12$oldClassificat = _ref12.oldClassificationData, oldClassificationData = _ref12$oldClassificat === void 0 ? {} : _ref12$oldClassificat, originProductId = _ref12.originProductId;
|
|
789
793
|
products = [];
|
|
790
794
|
originProduct = undefined;
|
|
791
795
|
if (!originProductId) {
|
|
@@ -830,10 +834,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
830
834
|
}
|
|
831
835
|
this.trimStrings(baseData);
|
|
832
836
|
//the base product is constructed, based on baseData and classification data
|
|
833
|
-
baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev,
|
|
834
|
-
var
|
|
835
|
-
key =
|
|
836
|
-
value =
|
|
837
|
+
baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref13) {
|
|
838
|
+
var _ref14 = _slicedToArray__default["default"](_ref13, 2),
|
|
839
|
+
key = _ref14[0],
|
|
840
|
+
value = _ref14[1];
|
|
837
841
|
prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
|
|
838
842
|
return prev;
|
|
839
843
|
}, {})), {}, {
|
|
@@ -845,11 +849,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
845
849
|
});
|
|
846
850
|
if (!originProduct && baseData.customData) {
|
|
847
851
|
//convert all customData to objects with value and translations, if they exists
|
|
848
|
-
Object.entries(baseData.customData).forEach(function (
|
|
852
|
+
Object.entries(baseData.customData).forEach(function (_ref15) {
|
|
849
853
|
var _baseProduct$customDa;
|
|
850
|
-
var
|
|
851
|
-
key =
|
|
852
|
-
value =
|
|
854
|
+
var _ref16 = _slicedToArray__default["default"](_ref15, 2),
|
|
855
|
+
key = _ref16[0],
|
|
856
|
+
value = _ref16[1];
|
|
853
857
|
if (!((_baseProduct$customDa = baseProduct.customData[key]) !== null && _baseProduct$customDa !== void 0 && _baseProduct$customDa.value)) {
|
|
854
858
|
var _fieldConfiguration$a;
|
|
855
859
|
baseProduct.customData[key] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$a = fieldConfiguration.additional) === null || _fieldConfiguration$a === void 0 || (_fieldConfiguration$a = _fieldConfiguration$a[key]) === null || _fieldConfiguration$a === void 0 ? void 0 : _fieldConfiguration$a.values);
|
|
@@ -858,17 +862,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
858
862
|
}
|
|
859
863
|
if (optMap) {
|
|
860
864
|
//save to class fields the information to which opt it maps
|
|
861
|
-
Object.entries(optMap).filter(function (
|
|
862
|
-
var
|
|
863
|
-
|
|
864
|
-
var value =
|
|
865
|
+
Object.entries(optMap).filter(function (_ref17) {
|
|
866
|
+
var _ref18 = _slicedToArray__default["default"](_ref17, 2);
|
|
867
|
+
_ref18[0];
|
|
868
|
+
var value = _ref18[1];
|
|
865
869
|
return value;
|
|
866
|
-
}).forEach(function (
|
|
867
|
-
var
|
|
868
|
-
var
|
|
869
|
-
key =
|
|
870
|
-
value =
|
|
871
|
-
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (
|
|
870
|
+
}).forEach(function (_ref19) {
|
|
871
|
+
var _baseProduct19;
|
|
872
|
+
var _ref20 = _slicedToArray__default["default"](_ref19, 2),
|
|
873
|
+
key = _ref20[0],
|
|
874
|
+
value = _ref20[1];
|
|
875
|
+
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct19 = baseProduct["dc_".concat(key)]) !== null && _baseProduct19 !== void 0 ? _baseProduct19 : {}), {}, {
|
|
872
876
|
opt: value.field
|
|
873
877
|
});
|
|
874
878
|
});
|
|
@@ -953,8 +957,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
953
957
|
baseProduct.parent = baseProduct._id;
|
|
954
958
|
}
|
|
955
959
|
_loop = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop() {
|
|
956
|
-
var _originProduct;
|
|
957
|
-
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, product, _this3$openModal, _this3$t, k, _savedMedia;
|
|
960
|
+
var _basket$getProductCon2, _originProduct, _configuration$OrderS;
|
|
961
|
+
var vd, varinatBase, classData, customData, variantPos, productId, preparedProduct, configuration, product, _this3$openModal, _this3$t, k, _savedMedia;
|
|
958
962
|
return _regeneratorRuntime__default["default"].wrap(function _loop$(_context3) {
|
|
959
963
|
while (1) switch (_context3.prev = _context3.next) {
|
|
960
964
|
case 0:
|
|
@@ -967,11 +971,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
967
971
|
case 3:
|
|
968
972
|
varinatBase = {};
|
|
969
973
|
classData = {};
|
|
970
|
-
Object.entries(vd).forEach(function (
|
|
974
|
+
Object.entries(vd).forEach(function (_ref21) {
|
|
971
975
|
var _optMap$key;
|
|
972
|
-
var
|
|
973
|
-
key =
|
|
974
|
-
value =
|
|
976
|
+
var _ref22 = _slicedToArray__default["default"](_ref21, 2),
|
|
977
|
+
key = _ref22[0],
|
|
978
|
+
value = _ref22[1];
|
|
975
979
|
//save those fields that are specified as class fields
|
|
976
980
|
if (classificationFields !== null && classificationFields !== void 0 && classificationFields.includes(key) && (value || optMap !== null && optMap !== void 0 && (_optMap$key = optMap[key]) !== null && _optMap$key !== void 0 && _optMap$key.field)) {
|
|
977
981
|
classData["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
|
|
@@ -985,16 +989,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
985
989
|
});
|
|
986
990
|
if (optMap) {
|
|
987
991
|
//save to class fields the information to which opt it maps
|
|
988
|
-
Object.entries(optMap).filter(function (
|
|
989
|
-
var
|
|
990
|
-
|
|
991
|
-
var value =
|
|
992
|
+
Object.entries(optMap).filter(function (_ref23) {
|
|
993
|
+
var _ref24 = _slicedToArray__default["default"](_ref23, 2);
|
|
994
|
+
_ref24[0];
|
|
995
|
+
var value = _ref24[1];
|
|
992
996
|
return value;
|
|
993
|
-
}).forEach(function (
|
|
997
|
+
}).forEach(function (_ref25) {
|
|
994
998
|
var _oldClassificationDat, _oldClassificationDat2, _value$field, _value$field2, _value$field3, _value$field4;
|
|
995
|
-
var
|
|
996
|
-
key =
|
|
997
|
-
value =
|
|
999
|
+
var _ref26 = _slicedToArray__default["default"](_ref25, 2),
|
|
1000
|
+
key = _ref26[0],
|
|
1001
|
+
value = _ref26[1];
|
|
998
1002
|
return classData["dc_".concat(key)] = _objectSpread(_objectSpread(_objectSpread({}, (_oldClassificationDat = (_oldClassificationDat2 = oldClassificationData[vd._id]) === null || _oldClassificationDat2 === void 0 ? void 0 : _oldClassificationDat2["dc_".concat(key)]) !== null && _oldClassificationDat !== void 0 ? _oldClassificationDat : {}), classData["dc_".concat(key)]), {}, {
|
|
999
1003
|
opt: value.field,
|
|
1000
1004
|
opv: (_value$field = vd[value.field]) === null || _value$field === void 0 ? void 0 : _value$field.codex,
|
|
@@ -1010,11 +1014,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1010
1014
|
if (vd.customData) {
|
|
1011
1015
|
customData = {};
|
|
1012
1016
|
//convert all customData to objects with value and translations, if they exists
|
|
1013
|
-
Object.entries(vd.customData).forEach(function (
|
|
1017
|
+
Object.entries(vd.customData).forEach(function (_ref27) {
|
|
1014
1018
|
var _vd$customData, _fieldConfiguration$a2;
|
|
1015
|
-
var
|
|
1016
|
-
key =
|
|
1017
|
-
value =
|
|
1019
|
+
var _ref28 = _slicedToArray__default["default"](_ref27, 2),
|
|
1020
|
+
key = _ref28[0],
|
|
1021
|
+
value = _ref28[1];
|
|
1018
1022
|
if (!((_vd$customData = vd.customData) !== null && _vd$customData !== void 0 && (_vd$customData = _vd$customData[key]) !== null && _vd$customData !== void 0 && _vd$customData.value)) customData[key] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$a2 = fieldConfiguration.additional) === null || _fieldConfiguration$a2 === void 0 || (_fieldConfiguration$a2 = _fieldConfiguration$a2[key]) === null || _fieldConfiguration$a2 === void 0 ? void 0 : _fieldConfiguration$a2.values);
|
|
1019
1023
|
});
|
|
1020
1024
|
}
|
|
@@ -1039,6 +1043,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1039
1043
|
_id: productId
|
|
1040
1044
|
};
|
|
1041
1045
|
}
|
|
1046
|
+
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;
|
|
1042
1047
|
product = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, preparedProduct), varinatBase), classData), {}, {
|
|
1043
1048
|
customData: originProduct ? _objectSpread(_objectSpread({}, (_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.customData), {}, {
|
|
1044
1049
|
SAP_EINA_LIFNR: {
|
|
@@ -1063,6 +1068,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1063
1068
|
modelName_locales: vd.modelName_locales,
|
|
1064
1069
|
shortDescription_locales: vd.shortDescription_locales,
|
|
1065
1070
|
width: vd.width,
|
|
1071
|
+
configuration: configuration,
|
|
1072
|
+
hqRenderScript: (_configuration$OrderS = configuration === null || configuration === void 0 ? void 0 : configuration.OrderSets[0].HQRenderScript) !== null && _configuration$OrderS !== void 0 ? _configuration$OrderS : vd.hqRenderScript,
|
|
1066
1073
|
height: vd.height,
|
|
1067
1074
|
depth: vd.depth,
|
|
1068
1075
|
calculatedPrice: vd.calculatedPrice,
|
|
@@ -1073,7 +1080,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1073
1080
|
variantPosition: variantPos,
|
|
1074
1081
|
image: vd.image,
|
|
1075
1082
|
image2D: vd.image2D,
|
|
1076
|
-
articles: vd.articles,
|
|
1077
1083
|
affiliate: vd.affiliate,
|
|
1078
1084
|
originDivaNr: vd.originDivaNr,
|
|
1079
1085
|
organizationId: baseProduct.organizationId,
|
|
@@ -1085,7 +1091,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1085
1091
|
uniqueHash: vd.uniqueHash
|
|
1086
1092
|
});
|
|
1087
1093
|
if (!vd.media) {
|
|
1088
|
-
_context3.next =
|
|
1094
|
+
_context3.next = 28;
|
|
1089
1095
|
break;
|
|
1090
1096
|
}
|
|
1091
1097
|
product.media = [];
|
|
@@ -1095,14 +1101,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1095
1101
|
dontRenderForm: true
|
|
1096
1102
|
});
|
|
1097
1103
|
k = 0;
|
|
1098
|
-
case
|
|
1104
|
+
case 20:
|
|
1099
1105
|
if (!(k < vd.media.length)) {
|
|
1100
|
-
_context3.next =
|
|
1106
|
+
_context3.next = 28;
|
|
1101
1107
|
break;
|
|
1102
1108
|
}
|
|
1103
|
-
_context3.next =
|
|
1109
|
+
_context3.next = 23;
|
|
1104
1110
|
return _this3.saveProductMedia(vd.media[k], baseProduct.organizationId);
|
|
1105
|
-
case
|
|
1111
|
+
case 23:
|
|
1106
1112
|
_savedMedia = _context3.sent;
|
|
1107
1113
|
if (_savedMedia) {
|
|
1108
1114
|
product.media.push(_savedMedia);
|
|
@@ -1119,14 +1125,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1119
1125
|
"class": vd.media[k]["class"]
|
|
1120
1126
|
});
|
|
1121
1127
|
}
|
|
1122
|
-
case
|
|
1128
|
+
case 25:
|
|
1123
1129
|
k++;
|
|
1124
|
-
_context3.next =
|
|
1130
|
+
_context3.next = 20;
|
|
1125
1131
|
break;
|
|
1126
|
-
case
|
|
1132
|
+
case 28:
|
|
1127
1133
|
//add the variant product it the list of products to be saved
|
|
1128
1134
|
products.push(product);
|
|
1129
|
-
case
|
|
1135
|
+
case 29:
|
|
1130
1136
|
case "end":
|
|
1131
1137
|
return _context3.stop();
|
|
1132
1138
|
}
|
|
@@ -1175,43 +1181,66 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1175
1181
|
}
|
|
1176
1182
|
}
|
|
1177
1183
|
}, {
|
|
1178
|
-
key: "
|
|
1184
|
+
key: "saveProducts",
|
|
1179
1185
|
value: function () {
|
|
1180
|
-
var
|
|
1181
|
-
var products, removedProducts,
|
|
1186
|
+
var _saveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref29) {
|
|
1187
|
+
var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
|
|
1182
1188
|
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context5) {
|
|
1183
1189
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1184
1190
|
case 0:
|
|
1185
|
-
products =
|
|
1191
|
+
products = _ref29.products, removedProducts = _ref29.removedProducts, awaitPDF = _ref29.awaitPDF;
|
|
1186
1192
|
if (this.jwt) {
|
|
1187
1193
|
_context5.next = 3;
|
|
1188
1194
|
break;
|
|
1189
1195
|
}
|
|
1190
1196
|
throw new Error('jwt not set');
|
|
1191
1197
|
case 3:
|
|
1192
|
-
|
|
1193
|
-
_context5.
|
|
1194
|
-
|
|
1195
|
-
|
|
1198
|
+
this.setFirstVariant(products);
|
|
1199
|
+
_context5.prev = 4;
|
|
1200
|
+
_context5.next = 7;
|
|
1201
|
+
return this.apiSaveProducts(this.catalogService, this.jwt, products, awaitPDF, removedProducts);
|
|
1202
|
+
case 7:
|
|
1196
1203
|
savedProducts = _context5.sent;
|
|
1197
1204
|
(_this$closeModal2 = this.closeModal) === null || _this$closeModal2 === void 0 || _this$closeModal2.call(this);
|
|
1198
1205
|
return _context5.abrupt("return", savedProducts);
|
|
1199
|
-
case
|
|
1200
|
-
_context5.prev =
|
|
1201
|
-
_context5.t0 = _context5["catch"](
|
|
1206
|
+
case 12:
|
|
1207
|
+
_context5.prev = 12;
|
|
1208
|
+
_context5.t0 = _context5["catch"](4);
|
|
1202
1209
|
(_this$closeModal3 = this.closeModal) === null || _this$closeModal3 === void 0 || _this$closeModal3.call(this);
|
|
1203
1210
|
throw new Error(_context5.t0.message);
|
|
1204
|
-
case
|
|
1211
|
+
case 16:
|
|
1205
1212
|
case "end":
|
|
1206
1213
|
return _context5.stop();
|
|
1207
1214
|
}
|
|
1208
|
-
}, _callee4, this, [[
|
|
1215
|
+
}, _callee4, this, [[4, 12]]);
|
|
1209
1216
|
}));
|
|
1210
|
-
function
|
|
1211
|
-
return
|
|
1217
|
+
function saveProducts(_x4) {
|
|
1218
|
+
return _saveProducts.apply(this, arguments);
|
|
1212
1219
|
}
|
|
1213
|
-
return
|
|
1214
|
-
}()
|
|
1220
|
+
return saveProducts;
|
|
1221
|
+
}() //variant with lowest variantId gets a flag for filtering purposes
|
|
1222
|
+
}, {
|
|
1223
|
+
key: "setFirstVariant",
|
|
1224
|
+
value: function setFirstVariant(products) {
|
|
1225
|
+
var _variants$;
|
|
1226
|
+
products.map(function (p) {
|
|
1227
|
+
return p.firstVariant = false;
|
|
1228
|
+
});
|
|
1229
|
+
var variants = products.filter(function (p) {
|
|
1230
|
+
return p.variantId !== undefined;
|
|
1231
|
+
});
|
|
1232
|
+
if (!(variants !== null && variants !== void 0 && variants.length)) return;
|
|
1233
|
+
var firstVariant = variants[0];
|
|
1234
|
+
var lowestId = (_variants$ = variants[0]) === null || _variants$ === void 0 ? void 0 : _variants$.variantId;
|
|
1235
|
+
for (var i = 0; i < variants.length; i++) {
|
|
1236
|
+
if (lowestId > variants[i].variantId) {
|
|
1237
|
+
lowestId = variants[i].variantId;
|
|
1238
|
+
firstVariant = variants[i];
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
firstVariant.firstVariant = true;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1215
1244
|
/**
|
|
1216
1245
|
* Calculates the inital state of one varinat data entry
|
|
1217
1246
|
*
|
|
@@ -1221,42 +1250,48 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1221
1250
|
*/
|
|
1222
1251
|
}, {
|
|
1223
1252
|
key: "initVariant",
|
|
1224
|
-
value: function initVariant(baseData, baseClassification, availableLanguages, cv,
|
|
1225
|
-
var
|
|
1226
|
-
var _this$parseClassifica = this.parseClassificationFields(
|
|
1253
|
+
value: function initVariant(baseData, baseClassification, availableLanguages, catalogData, basket, cv, variantProduct, classificationFields, fieldConfiguration, customBaseFields, classificationConfig) {
|
|
1254
|
+
var _basket$OrderSets$0$C3, _ref31, _variantProduct$confi, _classificationFields;
|
|
1255
|
+
var _this$parseClassifica = this.parseClassificationFields(variantProduct),
|
|
1227
1256
|
parsedProduct = _this$parseClassifica.product;
|
|
1228
|
-
var
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1257
|
+
var _ref30 = (basket === null || basket === void 0 || (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 ? void 0 : _basket$OrderSets$0$C3.find(function (vd) {
|
|
1258
|
+
return vd.VariantID === cv;
|
|
1259
|
+
})) || {
|
|
1260
|
+
VariantBasketDatas: ProductHandlerAbstract.getVariantBasketDatasByOrderlines((_ref31 = variantProduct === null || variantProduct === void 0 || (_variantProduct$confi = variantProduct.configuration) === null || _variantProduct$confi === void 0 ? void 0 : _variantProduct$confi.OrderSets[0].OrderLines) !== null && _ref31 !== void 0 ? _ref31 : [], catalogData)
|
|
1261
|
+
},
|
|
1262
|
+
VariantID = _ref30.VariantID,
|
|
1263
|
+
SetImage = _ref30.SetImage,
|
|
1264
|
+
Set2DImage = _ref30.Set2DImage,
|
|
1265
|
+
SetPrice = _ref30.SetPrice,
|
|
1266
|
+
VariantBasketDatas = _ref30.VariantBasketDatas,
|
|
1267
|
+
BBox = _ref30.BBox,
|
|
1268
|
+
MetaData = _ref30.MetaData,
|
|
1269
|
+
MetaData_locales = _ref30.MetaData_locales,
|
|
1270
|
+
Variant = _ref30.Variant,
|
|
1271
|
+
SetHash = _ref30.SetHash,
|
|
1272
|
+
Diva3DProject = _ref30.Diva3DProject,
|
|
1273
|
+
VariantDescription_locales = _ref30.VariantDescription_locales,
|
|
1274
|
+
VariantDescription = _ref30.VariantDescription;
|
|
1240
1275
|
//total and summary price are currently not avialable per varinat,
|
|
1241
1276
|
//most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
|
|
1242
1277
|
//we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
|
|
1243
1278
|
|
|
1244
|
-
var ismanual = (
|
|
1245
|
-
var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [],
|
|
1279
|
+
var ismanual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice);
|
|
1280
|
+
var price = ProductHandlerAbstract.calcPrice(SetPrice !== null && SetPrice !== void 0 ? SetPrice : 0, [], variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice, ismanual);
|
|
1246
1281
|
var addedPrice;
|
|
1247
1282
|
if (SetPrice == baseData.calculatedPrice) {
|
|
1248
1283
|
addedPrice = baseData.addedPrice;
|
|
1249
1284
|
} else {
|
|
1250
1285
|
addedPrice = price.calculatedPrice;
|
|
1251
1286
|
}
|
|
1252
|
-
var isManual = (
|
|
1287
|
+
var isManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice) !== (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.calculatedPrice);
|
|
1253
1288
|
if (isManual) {
|
|
1254
|
-
addedPrice =
|
|
1289
|
+
addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
|
|
1255
1290
|
}
|
|
1256
|
-
var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales,
|
|
1291
|
+
var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
|
|
1257
1292
|
classificationData = _this$parseMetaDataAn2.classificationData,
|
|
1258
1293
|
customData = _this$parseMetaDataAn2.customData;
|
|
1259
|
-
customData = _objectSpread(_objectSpread({},
|
|
1294
|
+
customData = _objectSpread(_objectSpread({}, variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.customData), customData);
|
|
1260
1295
|
var variant = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseData), {}, {
|
|
1261
1296
|
media: undefined,
|
|
1262
1297
|
//set media undefined, just in case "baseData" has media but "parsedProduct" does not have media to overwrite it
|
|
@@ -1266,8 +1301,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1266
1301
|
width: BBox === null || BBox === void 0 ? void 0 : BBox.X,
|
|
1267
1302
|
height: BBox === null || BBox === void 0 ? void 0 : BBox.Z,
|
|
1268
1303
|
depth: BBox === null || BBox === void 0 ? void 0 : BBox.Y,
|
|
1269
|
-
technicalDescription:
|
|
1270
|
-
technicalDescription_locales:
|
|
1304
|
+
technicalDescription: VariantDescription !== null && VariantDescription !== void 0 ? VariantDescription : baseData.technicalDescription,
|
|
1305
|
+
technicalDescription_locales: VariantDescription_locales !== null && VariantDescription_locales !== void 0 ? VariantDescription_locales : baseData.technicalDescription_locales
|
|
1271
1306
|
}, parsedProduct), {}, {
|
|
1272
1307
|
customData: customData
|
|
1273
1308
|
}, classificationData), {}, {
|
|
@@ -1276,18 +1311,6 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1276
1311
|
//only if cv is not defined fallback to the values in product
|
|
1277
1312
|
addedPrice: addedPrice,
|
|
1278
1313
|
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
1314
|
variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
|
|
1292
1315
|
image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
|
|
1293
1316
|
image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
|
|
@@ -1377,10 +1400,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1377
1400
|
key: "initOpvMap",
|
|
1378
1401
|
value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
|
|
1379
1402
|
var optMap = {};
|
|
1380
|
-
Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (
|
|
1381
|
-
var
|
|
1382
|
-
c =
|
|
1383
|
-
optMapping =
|
|
1403
|
+
Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref32) {
|
|
1404
|
+
var _ref33 = _slicedToArray__default["default"](_ref32, 2),
|
|
1405
|
+
c = _ref33[0],
|
|
1406
|
+
optMapping = _ref33[1].optMapping;
|
|
1384
1407
|
var optField;
|
|
1385
1408
|
if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
|
|
1386
1409
|
optField = optFields.find(function (opt) {
|
|
@@ -1441,16 +1464,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1441
1464
|
var _classificationConfig;
|
|
1442
1465
|
//add metadata defined as classification to classificationdata
|
|
1443
1466
|
var metadataAsClassification = {};
|
|
1444
|
-
Object.entries(metaData).filter(function (
|
|
1445
|
-
var
|
|
1446
|
-
key =
|
|
1467
|
+
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref34) {
|
|
1468
|
+
var _ref35 = _slicedToArray__default["default"](_ref34, 1),
|
|
1469
|
+
key = _ref35[0];
|
|
1447
1470
|
return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
|
|
1448
1471
|
})
|
|
1449
1472
|
//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 =
|
|
1473
|
+
.forEach(function (_ref36) {
|
|
1474
|
+
var _ref37 = _slicedToArray__default["default"](_ref36, 2),
|
|
1475
|
+
key = _ref37[0],
|
|
1476
|
+
value = _ref37[1];
|
|
1454
1477
|
return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
|
|
1455
1478
|
});
|
|
1456
1479
|
|
|
@@ -1460,14 +1483,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1460
1483
|
optMap = _this$parseClassifica2.optMap;
|
|
1461
1484
|
var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
|
|
1462
1485
|
var customData = {};
|
|
1463
|
-
Object.entries(metaData).filter(function (
|
|
1464
|
-
var
|
|
1465
|
-
key =
|
|
1486
|
+
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref38) {
|
|
1487
|
+
var _ref39 = _slicedToArray__default["default"](_ref38, 1),
|
|
1488
|
+
key = _ref39[0];
|
|
1466
1489
|
return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
|
|
1467
|
-
}).forEach(function (
|
|
1468
|
-
var
|
|
1469
|
-
key =
|
|
1470
|
-
value =
|
|
1490
|
+
}).forEach(function (_ref40) {
|
|
1491
|
+
var _ref41 = _slicedToArray__default["default"](_ref40, 2),
|
|
1492
|
+
key = _ref41[0],
|
|
1493
|
+
value = _ref41[1];
|
|
1471
1494
|
var langs = {};
|
|
1472
1495
|
if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
|
|
1473
1496
|
for (var i = 0; i < metaData_locales[key].length; i++) {
|
|
@@ -1499,19 +1522,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1499
1522
|
|
|
1500
1523
|
//repare customData
|
|
1501
1524
|
//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 =
|
|
1525
|
+
Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref42) {
|
|
1526
|
+
var _ref43 = _slicedToArray__default["default"](_ref42, 1),
|
|
1527
|
+
key = _ref43[0];
|
|
1505
1528
|
return customData[key] != undefined;
|
|
1506
|
-
}).forEach(function (
|
|
1507
|
-
var
|
|
1508
|
-
key =
|
|
1509
|
-
value =
|
|
1529
|
+
}).forEach(function (_ref44) {
|
|
1530
|
+
var _ref45 = _slicedToArray__default["default"](_ref44, 2),
|
|
1531
|
+
key = _ref45[0],
|
|
1532
|
+
value = _ref45[1];
|
|
1510
1533
|
if (value.multi && !Array.isArray(customData[key])) {
|
|
1511
1534
|
customData[key] = [customData[key]];
|
|
1512
1535
|
} else if (!value.multi && Array.isArray(customData[key])) {
|
|
1513
|
-
var
|
|
1514
|
-
customData[key] = (
|
|
1536
|
+
var _key2;
|
|
1537
|
+
customData[key] = (_key2 = customData[key]) === null || _key2 === void 0 ? void 0 : _key2[0];
|
|
1515
1538
|
}
|
|
1516
1539
|
});
|
|
1517
1540
|
return {
|
|
@@ -1636,52 +1659,200 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1636
1659
|
}
|
|
1637
1660
|
return apiGetProducts;
|
|
1638
1661
|
}()
|
|
1662
|
+
}, {
|
|
1663
|
+
key: "apiGetCatalogData",
|
|
1664
|
+
value: function () {
|
|
1665
|
+
var _apiGetCatalogData = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(catalogCodex, catalogId, language, accountId) {
|
|
1666
|
+
var _response$CollectionG, _response$Properties, _response$Properties2;
|
|
1667
|
+
var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
|
|
1668
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context8) {
|
|
1669
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1670
|
+
case 0:
|
|
1671
|
+
_context8.next = 2;
|
|
1672
|
+
return this.apiAccountLogin(accountId, catalogId);
|
|
1673
|
+
case 2:
|
|
1674
|
+
currentAccountSessionId = _context8.sent;
|
|
1675
|
+
if (currentAccountSessionId) {
|
|
1676
|
+
_context8.next = 5;
|
|
1677
|
+
break;
|
|
1678
|
+
}
|
|
1679
|
+
return _context8.abrupt("return");
|
|
1680
|
+
case 5:
|
|
1681
|
+
fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
|
|
1682
|
+
_context8.next = 8;
|
|
1683
|
+
return fetch(fullUrl, {
|
|
1684
|
+
headers: {
|
|
1685
|
+
sessionGuid: currentAccountSessionId
|
|
1686
|
+
}
|
|
1687
|
+
}).then(function (res) {
|
|
1688
|
+
if (res.status !== 200) {
|
|
1689
|
+
throw new Error('Collections not loaded.');
|
|
1690
|
+
}
|
|
1691
|
+
return res.json();
|
|
1692
|
+
});
|
|
1693
|
+
case 8:
|
|
1694
|
+
response = _context8.sent;
|
|
1695
|
+
if (!response.Error) {
|
|
1696
|
+
_context8.next = 11;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
throw new Error(response.Error);
|
|
1700
|
+
case 11:
|
|
1701
|
+
actCatalogInfoData = {
|
|
1702
|
+
lang: language,
|
|
1703
|
+
guid: response.GUID,
|
|
1704
|
+
name: response.Name,
|
|
1705
|
+
name_locales: response.Name_locales,
|
|
1706
|
+
codex: catalogCodex,
|
|
1707
|
+
accountLogo: response.AccountLogo,
|
|
1708
|
+
description: response.LongDescription,
|
|
1709
|
+
description_locales: response.LongDescription_locales,
|
|
1710
|
+
hasPlanner: response.HasIDMPlanner == 'True',
|
|
1711
|
+
brand: response.Brandname,
|
|
1712
|
+
supplierGuid: response.SupplierGUID,
|
|
1713
|
+
retailCatalogNr: response.RetailCatalogNr,
|
|
1714
|
+
accountGuid: (_response$CollectionG = response.CollectionGuid) !== null && _response$CollectionG !== void 0 ? _response$CollectionG : response.AccountGuid,
|
|
1715
|
+
options: response.Options,
|
|
1716
|
+
optionValues: response.Optionvalues,
|
|
1717
|
+
currency: response.currency,
|
|
1718
|
+
has3D: !!((_response$Properties = response.Properties) !== null && _response$Properties !== void 0 && (_response$Properties = _response$Properties.find(function (p) {
|
|
1719
|
+
return p.Codex == 'DIVA3D_RENDERING';
|
|
1720
|
+
})) !== null && _response$Properties !== void 0 && _response$Properties.Value),
|
|
1721
|
+
images: [],
|
|
1722
|
+
documents: [],
|
|
1723
|
+
accountSessionId: response.AccountSessionGuid,
|
|
1724
|
+
arReady: !!((_response$Properties2 = response.Properties) !== null && _response$Properties2 !== void 0 && (_response$Properties2 = _response$Properties2.find(function (p) {
|
|
1725
|
+
return p.Codex == 'DIVA3D_AR_READY';
|
|
1726
|
+
})) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
|
|
1727
|
+
};
|
|
1728
|
+
return _context8.abrupt("return", actCatalogInfoData);
|
|
1729
|
+
case 13:
|
|
1730
|
+
case "end":
|
|
1731
|
+
return _context8.stop();
|
|
1732
|
+
}
|
|
1733
|
+
}, _callee7, this);
|
|
1734
|
+
}));
|
|
1735
|
+
function apiGetCatalogData(_x9, _x10, _x11, _x12) {
|
|
1736
|
+
return _apiGetCatalogData.apply(this, arguments);
|
|
1737
|
+
}
|
|
1738
|
+
return apiGetCatalogData;
|
|
1739
|
+
}()
|
|
1740
|
+
}, {
|
|
1741
|
+
key: "apiAccountLogin",
|
|
1742
|
+
value: function () {
|
|
1743
|
+
var _apiAccountLogin = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(accountId, catalogId) {
|
|
1744
|
+
var fullUrl, response, fallbackUrl, fallbackResponse;
|
|
1745
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context9) {
|
|
1746
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1747
|
+
case 0:
|
|
1748
|
+
fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
|
|
1749
|
+
_context9.t0 = fetch;
|
|
1750
|
+
_context9.t1 = fullUrl;
|
|
1751
|
+
_context9.next = 5;
|
|
1752
|
+
return this.sessionGuid;
|
|
1753
|
+
case 5:
|
|
1754
|
+
_context9.t2 = _context9.sent;
|
|
1755
|
+
_context9.t3 = {
|
|
1756
|
+
sessionGuid: _context9.t2
|
|
1757
|
+
};
|
|
1758
|
+
_context9.t4 = {
|
|
1759
|
+
headers: _context9.t3
|
|
1760
|
+
};
|
|
1761
|
+
_context9.next = 10;
|
|
1762
|
+
return (0, _context9.t0)(_context9.t1, _context9.t4).then(function (res) {
|
|
1763
|
+
if (res.status !== 200) {
|
|
1764
|
+
throw new Error('Collections not loaded.');
|
|
1765
|
+
}
|
|
1766
|
+
return res.json();
|
|
1767
|
+
});
|
|
1768
|
+
case 10:
|
|
1769
|
+
response = _context9.sent;
|
|
1770
|
+
if (!response.SessionGUID) {
|
|
1771
|
+
_context9.next = 13;
|
|
1772
|
+
break;
|
|
1773
|
+
}
|
|
1774
|
+
return _context9.abrupt("return", response.SessionGUID);
|
|
1775
|
+
case 13:
|
|
1776
|
+
fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
|
|
1777
|
+
_context9.t5 = fetch;
|
|
1778
|
+
_context9.t6 = fallbackUrl;
|
|
1779
|
+
_context9.next = 18;
|
|
1780
|
+
return this.sessionGuid;
|
|
1781
|
+
case 18:
|
|
1782
|
+
_context9.t7 = _context9.sent;
|
|
1783
|
+
_context9.t8 = {
|
|
1784
|
+
sessionGuid: _context9.t7
|
|
1785
|
+
};
|
|
1786
|
+
_context9.t9 = {
|
|
1787
|
+
headers: _context9.t8
|
|
1788
|
+
};
|
|
1789
|
+
_context9.next = 23;
|
|
1790
|
+
return (0, _context9.t5)(_context9.t6, _context9.t9).then(function (res) {
|
|
1791
|
+
if (res.status !== 200) {
|
|
1792
|
+
throw new Error('Collections not loaded.');
|
|
1793
|
+
}
|
|
1794
|
+
return res.json();
|
|
1795
|
+
});
|
|
1796
|
+
case 23:
|
|
1797
|
+
fallbackResponse = _context9.sent;
|
|
1798
|
+
return _context9.abrupt("return", fallbackResponse.SessionGUID);
|
|
1799
|
+
case 25:
|
|
1800
|
+
case "end":
|
|
1801
|
+
return _context9.stop();
|
|
1802
|
+
}
|
|
1803
|
+
}, _callee8, this);
|
|
1804
|
+
}));
|
|
1805
|
+
function apiAccountLogin(_x13, _x14) {
|
|
1806
|
+
return _apiAccountLogin.apply(this, arguments);
|
|
1807
|
+
}
|
|
1808
|
+
return apiAccountLogin;
|
|
1809
|
+
}()
|
|
1639
1810
|
}, {
|
|
1640
1811
|
key: "apiGetProductVariants",
|
|
1641
1812
|
value: function () {
|
|
1642
|
-
var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1813
|
+
var _apiGetProductVariants = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(id, full) {
|
|
1643
1814
|
var _res2;
|
|
1644
1815
|
var fullUrl, res, resData;
|
|
1645
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1646
|
-
while (1) switch (
|
|
1816
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context10) {
|
|
1817
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1647
1818
|
case 0:
|
|
1648
1819
|
fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
|
|
1649
|
-
|
|
1650
|
-
|
|
1820
|
+
_context10.prev = 1;
|
|
1821
|
+
_context10.next = 4;
|
|
1651
1822
|
return axios__default["default"].get(fullUrl, {
|
|
1652
1823
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1653
1824
|
'Content-Type': 'application/json'
|
|
1654
1825
|
})
|
|
1655
1826
|
});
|
|
1656
1827
|
case 4:
|
|
1657
|
-
res =
|
|
1658
|
-
|
|
1828
|
+
res = _context10.sent;
|
|
1829
|
+
_context10.next = 7;
|
|
1659
1830
|
return res.data;
|
|
1660
1831
|
case 7:
|
|
1661
|
-
resData =
|
|
1662
|
-
|
|
1832
|
+
resData = _context10.sent;
|
|
1833
|
+
_context10.next = 13;
|
|
1663
1834
|
break;
|
|
1664
1835
|
case 10:
|
|
1665
|
-
|
|
1666
|
-
|
|
1836
|
+
_context10.prev = 10;
|
|
1837
|
+
_context10.t0 = _context10["catch"](1);
|
|
1667
1838
|
throw new Error('Could not get existing products', {
|
|
1668
|
-
cause:
|
|
1839
|
+
cause: _context10.t0
|
|
1669
1840
|
});
|
|
1670
1841
|
case 13:
|
|
1671
1842
|
if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
|
|
1672
|
-
|
|
1843
|
+
_context10.next = 15;
|
|
1673
1844
|
break;
|
|
1674
1845
|
}
|
|
1675
|
-
return
|
|
1846
|
+
return _context10.abrupt("return", resData);
|
|
1676
1847
|
case 15:
|
|
1677
1848
|
throw new Error(resData.error);
|
|
1678
1849
|
case 16:
|
|
1679
1850
|
case "end":
|
|
1680
|
-
return
|
|
1851
|
+
return _context10.stop();
|
|
1681
1852
|
}
|
|
1682
|
-
},
|
|
1853
|
+
}, _callee9, this, [[1, 10]]);
|
|
1683
1854
|
}));
|
|
1684
|
-
function apiGetProductVariants(
|
|
1855
|
+
function apiGetProductVariants(_x15, _x16) {
|
|
1685
1856
|
return _apiGetProductVariants.apply(this, arguments);
|
|
1686
1857
|
}
|
|
1687
1858
|
return apiGetProductVariants;
|
|
@@ -1689,7 +1860,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1689
1860
|
}, {
|
|
1690
1861
|
key: "apiGetProductByFilter",
|
|
1691
1862
|
value: function () {
|
|
1692
|
-
var _apiGetProductByFilter = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1863
|
+
var _apiGetProductByFilter = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10(filter) {
|
|
1693
1864
|
var _res3;
|
|
1694
1865
|
var limit,
|
|
1695
1866
|
useFilter,
|
|
@@ -1698,39 +1869,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1698
1869
|
res,
|
|
1699
1870
|
resData,
|
|
1700
1871
|
filterParam,
|
|
1701
|
-
|
|
1702
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1703
|
-
while (1) switch (
|
|
1872
|
+
_args11 = arguments;
|
|
1873
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context11) {
|
|
1874
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1704
1875
|
case 0:
|
|
1705
|
-
limit =
|
|
1706
|
-
useFilter =
|
|
1707
|
-
hierarchy =
|
|
1876
|
+
limit = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 1;
|
|
1877
|
+
useFilter = _args11.length > 2 ? _args11[2] : undefined;
|
|
1878
|
+
hierarchy = _args11.length > 3 ? _args11[3] : undefined;
|
|
1708
1879
|
fullUrl = this.catalogService + '/v1/products';
|
|
1709
|
-
|
|
1880
|
+
_context11.prev = 4;
|
|
1710
1881
|
filterParam = useFilter ? 'filter' : 'search';
|
|
1711
|
-
|
|
1882
|
+
_context11.next = 8;
|
|
1712
1883
|
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
1884
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1714
1885
|
'Content-Type': 'application/json'
|
|
1715
1886
|
})
|
|
1716
1887
|
});
|
|
1717
1888
|
case 8:
|
|
1718
|
-
res =
|
|
1719
|
-
|
|
1889
|
+
res = _context11.sent;
|
|
1890
|
+
_context11.next = 11;
|
|
1720
1891
|
return res.data;
|
|
1721
1892
|
case 11:
|
|
1722
|
-
resData =
|
|
1723
|
-
|
|
1893
|
+
resData = _context11.sent;
|
|
1894
|
+
_context11.next = 17;
|
|
1724
1895
|
break;
|
|
1725
1896
|
case 14:
|
|
1726
|
-
|
|
1727
|
-
|
|
1897
|
+
_context11.prev = 14;
|
|
1898
|
+
_context11.t0 = _context11["catch"](4);
|
|
1728
1899
|
throw new Error('Could not get existing products', {
|
|
1729
|
-
cause:
|
|
1900
|
+
cause: _context11.t0
|
|
1730
1901
|
});
|
|
1731
1902
|
case 17:
|
|
1732
1903
|
if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
|
|
1733
|
-
|
|
1904
|
+
_context11.next = 20;
|
|
1734
1905
|
break;
|
|
1735
1906
|
}
|
|
1736
1907
|
//in order to be backwardscompatible we must transform old products here
|
|
@@ -1743,27 +1914,79 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1743
1914
|
}
|
|
1744
1915
|
return d;
|
|
1745
1916
|
});
|
|
1746
|
-
return
|
|
1917
|
+
return _context11.abrupt("return", resData);
|
|
1747
1918
|
case 20:
|
|
1748
1919
|
throw new Error(resData.error);
|
|
1749
1920
|
case 21:
|
|
1750
1921
|
case "end":
|
|
1751
|
-
return
|
|
1922
|
+
return _context11.stop();
|
|
1752
1923
|
}
|
|
1753
|
-
},
|
|
1924
|
+
}, _callee10, this, [[4, 14]]);
|
|
1754
1925
|
}));
|
|
1755
|
-
function apiGetProductByFilter(
|
|
1926
|
+
function apiGetProductByFilter(_x17) {
|
|
1756
1927
|
return _apiGetProductByFilter.apply(this, arguments);
|
|
1757
1928
|
}
|
|
1758
1929
|
return apiGetProductByFilter;
|
|
1759
1930
|
}()
|
|
1931
|
+
}, {
|
|
1932
|
+
key: "apiSetCustomFlag",
|
|
1933
|
+
value: function () {
|
|
1934
|
+
var _apiSetCustomFlag = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(id, flagName, organizationId, dependsOn) {
|
|
1935
|
+
var _res4;
|
|
1936
|
+
var fullUrl, res, resData;
|
|
1937
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context12) {
|
|
1938
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1939
|
+
case 0:
|
|
1940
|
+
fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/' + flagName);
|
|
1941
|
+
fullUrl.searchParams.append('organizationId', organizationId);
|
|
1942
|
+
if (dependsOn) fullUrl.searchParams.append('dependsOn', dependsOn);
|
|
1943
|
+
_context12.prev = 3;
|
|
1944
|
+
_context12.next = 6;
|
|
1945
|
+
return axios__default["default"].post(fullUrl.toString(), undefined, {
|
|
1946
|
+
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1947
|
+
'Content-Type': 'application/json'
|
|
1948
|
+
})
|
|
1949
|
+
});
|
|
1950
|
+
case 6:
|
|
1951
|
+
res = _context12.sent;
|
|
1952
|
+
_context12.next = 9;
|
|
1953
|
+
return res.data;
|
|
1954
|
+
case 9:
|
|
1955
|
+
resData = _context12.sent;
|
|
1956
|
+
_context12.next = 15;
|
|
1957
|
+
break;
|
|
1958
|
+
case 12:
|
|
1959
|
+
_context12.prev = 12;
|
|
1960
|
+
_context12.t0 = _context12["catch"](3);
|
|
1961
|
+
throw new Error('Could not get existing products', {
|
|
1962
|
+
cause: _context12.t0
|
|
1963
|
+
});
|
|
1964
|
+
case 15:
|
|
1965
|
+
if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
|
|
1966
|
+
_context12.next = 17;
|
|
1967
|
+
break;
|
|
1968
|
+
}
|
|
1969
|
+
return _context12.abrupt("return", resData);
|
|
1970
|
+
case 17:
|
|
1971
|
+
throw new Error(resData.error);
|
|
1972
|
+
case 18:
|
|
1973
|
+
case "end":
|
|
1974
|
+
return _context12.stop();
|
|
1975
|
+
}
|
|
1976
|
+
}, _callee11, this, [[3, 12]]);
|
|
1977
|
+
}));
|
|
1978
|
+
function apiSetCustomFlag(_x18, _x19, _x20, _x21) {
|
|
1979
|
+
return _apiSetCustomFlag.apply(this, arguments);
|
|
1980
|
+
}
|
|
1981
|
+
return apiSetCustomFlag;
|
|
1982
|
+
}()
|
|
1760
1983
|
}, {
|
|
1761
1984
|
key: "apiDeleteProducts",
|
|
1762
1985
|
value: function () {
|
|
1763
|
-
var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1986
|
+
var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(products) {
|
|
1764
1987
|
var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
|
|
1765
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1766
|
-
while (1) switch (
|
|
1988
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context13) {
|
|
1989
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1767
1990
|
case 0:
|
|
1768
1991
|
fullUrl = this.catalogService + '/products';
|
|
1769
1992
|
fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
|
|
@@ -1774,7 +1997,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1774
1997
|
i = 0;
|
|
1775
1998
|
case 5:
|
|
1776
1999
|
if (!(i < productsInChunks.length)) {
|
|
1777
|
-
|
|
2000
|
+
_context13.next = 13;
|
|
1778
2001
|
break;
|
|
1779
2002
|
}
|
|
1780
2003
|
promises = productsInChunks[i].map(function (p) {
|
|
@@ -1796,19 +2019,19 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1796
2019
|
title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
|
|
1797
2020
|
dontRenderForm: true
|
|
1798
2021
|
});
|
|
1799
|
-
|
|
2022
|
+
_context13.next = 10;
|
|
1800
2023
|
return Promise.all(promises);
|
|
1801
2024
|
case 10:
|
|
1802
2025
|
i++;
|
|
1803
|
-
|
|
2026
|
+
_context13.next = 5;
|
|
1804
2027
|
break;
|
|
1805
2028
|
case 13:
|
|
1806
2029
|
case "end":
|
|
1807
|
-
return
|
|
2030
|
+
return _context13.stop();
|
|
1808
2031
|
}
|
|
1809
|
-
},
|
|
2032
|
+
}, _callee12, this);
|
|
1810
2033
|
}));
|
|
1811
|
-
function apiDeleteProducts(
|
|
2034
|
+
function apiDeleteProducts(_x22) {
|
|
1812
2035
|
return _apiDeleteProducts.apply(this, arguments);
|
|
1813
2036
|
}
|
|
1814
2037
|
return apiDeleteProducts;
|
|
@@ -1825,12 +2048,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1825
2048
|
}, {
|
|
1826
2049
|
key: "apiLoadProductVariantsGrouped",
|
|
1827
2050
|
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 (
|
|
2051
|
+
var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(_ref46) {
|
|
2052
|
+
var limit, skip, fields, _ref46$search, search, sort, abortController, fullUrl, headers, promise;
|
|
2053
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context14) {
|
|
2054
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1832
2055
|
case 0:
|
|
1833
|
-
limit =
|
|
2056
|
+
limit = _ref46.limit, skip = _ref46.skip, fields = _ref46.fields, _ref46$search = _ref46.search, search = _ref46$search === void 0 ? [] : _ref46$search, sort = _ref46.sort, _ref46.showAllProducts, abortController = _ref46.abortController;
|
|
1834
2057
|
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
2058
|
headers = {
|
|
1836
2059
|
'Content-Type': 'application/json'
|
|
@@ -1852,32 +2075,64 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1852
2075
|
reject('Error loading products grouped by variants: ' + error.message);
|
|
1853
2076
|
});
|
|
1854
2077
|
});
|
|
1855
|
-
|
|
2078
|
+
_context14.next = 7;
|
|
1856
2079
|
return promise;
|
|
1857
2080
|
case 7:
|
|
1858
|
-
return
|
|
2081
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1859
2082
|
case 8:
|
|
1860
2083
|
case "end":
|
|
1861
|
-
return
|
|
2084
|
+
return _context14.stop();
|
|
1862
2085
|
}
|
|
1863
|
-
},
|
|
2086
|
+
}, _callee13, this);
|
|
1864
2087
|
}));
|
|
1865
|
-
function apiLoadProductVariantsGrouped(
|
|
2088
|
+
function apiLoadProductVariantsGrouped(_x23) {
|
|
1866
2089
|
return _apiLoadProductVariantsGrouped.apply(this, arguments);
|
|
1867
2090
|
}
|
|
1868
2091
|
return apiLoadProductVariantsGrouped;
|
|
1869
2092
|
}()
|
|
1870
2093
|
}, {
|
|
1871
|
-
key: "
|
|
2094
|
+
key: "apiSaveProducts",
|
|
1872
2095
|
value: function () {
|
|
1873
|
-
var
|
|
1874
|
-
var fullUrl, response, status;
|
|
1875
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
1876
|
-
while (1) switch (
|
|
2096
|
+
var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
|
|
2097
|
+
var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop2, j;
|
|
2098
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context16) {
|
|
2099
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1877
2100
|
case 0:
|
|
1878
2101
|
fullUrl = serverUrl + '/v1/products/groups';
|
|
1879
|
-
|
|
1880
|
-
|
|
2102
|
+
BATCH_SIZE = 40;
|
|
2103
|
+
productsPackages = [];
|
|
2104
|
+
groupIndex = 0;
|
|
2105
|
+
i = 0;
|
|
2106
|
+
case 5:
|
|
2107
|
+
if (!(i < products.length)) {
|
|
2108
|
+
_context16.next = 15;
|
|
2109
|
+
break;
|
|
2110
|
+
}
|
|
2111
|
+
if (!products[i].baseProduct) {
|
|
2112
|
+
_context16.next = 9;
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
baseProduct = products[i];
|
|
2116
|
+
return _context16.abrupt("continue", 12);
|
|
2117
|
+
case 9:
|
|
2118
|
+
if (BATCH_SIZE < ((_productsPackages$gro = (_productsPackages$gro2 = productsPackages[groupIndex]) === null || _productsPackages$gro2 === void 0 ? void 0 : _productsPackages$gro2.length) !== null && _productsPackages$gro !== void 0 ? _productsPackages$gro : 0)) groupIndex++;
|
|
2119
|
+
if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
|
|
2120
|
+
productsPackages[groupIndex].push(products[i]);
|
|
2121
|
+
case 12:
|
|
2122
|
+
i++;
|
|
2123
|
+
_context16.next = 5;
|
|
2124
|
+
break;
|
|
2125
|
+
case 15:
|
|
2126
|
+
responseProducts = [];
|
|
2127
|
+
_i2 = 0;
|
|
2128
|
+
case 17:
|
|
2129
|
+
if (!(_i2 < productsPackages.length)) {
|
|
2130
|
+
_context16.next = 40;
|
|
2131
|
+
break;
|
|
2132
|
+
}
|
|
2133
|
+
if (baseProduct) productsPackages[_i2].unshift(baseProduct);
|
|
2134
|
+
_context16.prev = 19;
|
|
2135
|
+
_context16.next = 22;
|
|
1881
2136
|
return fetch(fullUrl, {
|
|
1882
2137
|
method: 'PUT',
|
|
1883
2138
|
headers: {
|
|
@@ -1885,8 +2140,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1885
2140
|
'Content-Type': 'application/json'
|
|
1886
2141
|
},
|
|
1887
2142
|
body: JSON.stringify({
|
|
1888
|
-
|
|
1889
|
-
products: products,
|
|
2143
|
+
products: productsPackages[_i2],
|
|
1890
2144
|
removedProductIds: removedProductIds,
|
|
1891
2145
|
awaitPDF: awaitPDF
|
|
1892
2146
|
})
|
|
@@ -1897,32 +2151,64 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1897
2151
|
}
|
|
1898
2152
|
return res.json();
|
|
1899
2153
|
});
|
|
1900
|
-
case
|
|
1901
|
-
response =
|
|
2154
|
+
case 22:
|
|
2155
|
+
response = _context16.sent;
|
|
1902
2156
|
if (!response.Error) {
|
|
1903
|
-
|
|
2157
|
+
_context16.next = 25;
|
|
1904
2158
|
break;
|
|
1905
2159
|
}
|
|
1906
2160
|
throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
|
|
1907
|
-
case
|
|
1908
|
-
|
|
2161
|
+
case 25:
|
|
2162
|
+
_context16.next = 30;
|
|
1909
2163
|
break;
|
|
1910
|
-
case
|
|
1911
|
-
|
|
1912
|
-
|
|
2164
|
+
case 27:
|
|
2165
|
+
_context16.prev = 27;
|
|
2166
|
+
_context16.t0 = _context16["catch"](19);
|
|
1913
2167
|
throw Error(status);
|
|
1914
|
-
case
|
|
1915
|
-
|
|
1916
|
-
|
|
2168
|
+
case 30:
|
|
2169
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop2(j) {
|
|
2170
|
+
return _regeneratorRuntime__default["default"].wrap(function _loop2$(_context15) {
|
|
2171
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2172
|
+
case 0:
|
|
2173
|
+
if (response.products[_i2].baseProduct) baseProduct = response.products[_i2];
|
|
2174
|
+
if (!responseProducts.find(function (p) {
|
|
2175
|
+
return p._id == response.products[j]._id;
|
|
2176
|
+
})) {
|
|
2177
|
+
responseProducts.push(response.products[j]);
|
|
2178
|
+
}
|
|
2179
|
+
case 2:
|
|
2180
|
+
case "end":
|
|
2181
|
+
return _context15.stop();
|
|
2182
|
+
}
|
|
2183
|
+
}, _loop2);
|
|
2184
|
+
});
|
|
2185
|
+
j = 0;
|
|
2186
|
+
case 32:
|
|
2187
|
+
if (!(j < response.products.length)) {
|
|
2188
|
+
_context16.next = 37;
|
|
2189
|
+
break;
|
|
2190
|
+
}
|
|
2191
|
+
return _context16.delegateYield(_loop2(j), "t1", 34);
|
|
2192
|
+
case 34:
|
|
2193
|
+
j++;
|
|
2194
|
+
_context16.next = 32;
|
|
2195
|
+
break;
|
|
2196
|
+
case 37:
|
|
2197
|
+
_i2++;
|
|
2198
|
+
_context16.next = 17;
|
|
2199
|
+
break;
|
|
2200
|
+
case 40:
|
|
2201
|
+
return _context16.abrupt("return", responseProducts);
|
|
2202
|
+
case 41:
|
|
1917
2203
|
case "end":
|
|
1918
|
-
return
|
|
2204
|
+
return _context16.stop();
|
|
1919
2205
|
}
|
|
1920
|
-
},
|
|
2206
|
+
}, _callee14, null, [[19, 27]]);
|
|
1921
2207
|
}));
|
|
1922
|
-
function
|
|
1923
|
-
return
|
|
2208
|
+
function apiSaveProducts(_x24, _x25, _x26, _x27, _x28) {
|
|
2209
|
+
return _apiSaveProducts.apply(this, arguments);
|
|
1924
2210
|
}
|
|
1925
|
-
return
|
|
2211
|
+
return apiSaveProducts;
|
|
1926
2212
|
}()
|
|
1927
2213
|
}, {
|
|
1928
2214
|
key: "parseFilter",
|
|
@@ -1954,54 +2240,54 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1954
2240
|
}], [{
|
|
1955
2241
|
key: "isSameProduct",
|
|
1956
2242
|
value: function isSameProduct(product, setHash, diva3dProject, orderLines, varinatData, catalogCodex) {
|
|
1957
|
-
var _product$
|
|
2243
|
+
var _product$configuratio, _product$configuratio2, _product$configuratio3;
|
|
1958
2244
|
//For new products we store the setHash and Diva3DProject in order to determine if the product changed.
|
|
1959
2245
|
if (product.uniqueHash !== undefined) {
|
|
1960
2246
|
return product.uniqueHash === 'v1' + setHash + (diva3dProject ? DivaUtils.md5(diva3dProject) : '');
|
|
1961
2247
|
}
|
|
1962
2248
|
|
|
1963
2249
|
//For older products without setHash we use the old comparison logic
|
|
1964
|
-
if (((_product$
|
|
2250
|
+
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
2251
|
return false;
|
|
1966
2252
|
}
|
|
1967
2253
|
if (!varinatData) {
|
|
1968
2254
|
//the old logic was only for variants, not for base products
|
|
1969
2255
|
return true;
|
|
1970
2256
|
}
|
|
1971
|
-
var
|
|
1972
|
-
|
|
1973
|
-
var article =
|
|
2257
|
+
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 : [];
|
|
2258
|
+
var _loop3 = function _loop3() {
|
|
2259
|
+
var article = orderlines[i];
|
|
1974
2260
|
var orderLine = orderLines.find(function (ol) {
|
|
1975
|
-
return ol.ArticleCodex == article.
|
|
2261
|
+
return ol.ArticleCodex == article.ArticleCodex && catalogCodex == article.CatalogCodex;
|
|
1976
2262
|
});
|
|
1977
|
-
if (!orderLine
|
|
2263
|
+
if (!orderLine) {
|
|
1978
2264
|
return {
|
|
1979
2265
|
v: false
|
|
1980
2266
|
};
|
|
1981
2267
|
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
v:
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
var
|
|
1997
|
-
|
|
1998
|
-
|
|
2268
|
+
if (article.VariantBasketDatas.length) {
|
|
2269
|
+
var _loop4 = function _loop4() {
|
|
2270
|
+
var varinatValue = article.VariantBasketDatas[j];
|
|
2271
|
+
if (!varinatData.find(function (vb) {
|
|
2272
|
+
return vb.OPT == varinatValue['OPT'] && vb.OPV == varinatValue['OPV'];
|
|
2273
|
+
})) {
|
|
2274
|
+
return {
|
|
2275
|
+
v: {
|
|
2276
|
+
v: false
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
},
|
|
2281
|
+
_ret2;
|
|
2282
|
+
for (var j = 0; j < article.VariantBasketDatas.length; j++) {
|
|
2283
|
+
_ret2 = _loop4();
|
|
2284
|
+
if (_ret2) return _ret2.v;
|
|
2285
|
+
}
|
|
1999
2286
|
}
|
|
2000
2287
|
},
|
|
2001
2288
|
_ret;
|
|
2002
|
-
for (var i = 0; i <
|
|
2003
|
-
|
|
2004
|
-
_ret = _loop2();
|
|
2289
|
+
for (var i = 0; i < orderlines.length; i++) {
|
|
2290
|
+
_ret = _loop3();
|
|
2005
2291
|
if (_ret) return _ret.v;
|
|
2006
2292
|
}
|
|
2007
2293
|
return true;
|
|
@@ -2079,7 +2365,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2079
2365
|
//calculate defaultShortDescription from template string
|
|
2080
2366
|
var shortDescriptionTemplate = (_configurationData$sh = configurationData === null || configurationData === void 0 ? void 0 : configurationData.shortDescription) !== null && _configurationData$sh !== void 0 ? _configurationData$sh : '${modelName} ${subCategory} ${mainColor}';
|
|
2081
2367
|
var parts = shortDescriptionTemplate.split(/\${|}/);
|
|
2082
|
-
var
|
|
2368
|
+
var _loop5 = function _loop5() {
|
|
2083
2369
|
var _classificationConfig2, _classificationConfig4, _value;
|
|
2084
2370
|
var field = parts[i];
|
|
2085
2371
|
var value;
|
|
@@ -2111,7 +2397,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2111
2397
|
shortDescriptionTemplate = shortDescriptionTemplate.replace("${".concat(field, "}"), (_value = value) !== null && _value !== void 0 ? _value : '');
|
|
2112
2398
|
};
|
|
2113
2399
|
for (var i = 1; i < parts.length; i = i + 2) {
|
|
2114
|
-
|
|
2400
|
+
_loop5();
|
|
2115
2401
|
}
|
|
2116
2402
|
|
|
2117
2403
|
//as long as shortDescription is not modified by user, autocalc it
|
|
@@ -2127,16 +2413,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2127
2413
|
}, {
|
|
2128
2414
|
key: "assign",
|
|
2129
2415
|
value: function assign(target) {
|
|
2130
|
-
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0),
|
|
2131
|
-
sources[
|
|
2416
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
|
|
2417
|
+
sources[_key3 - 1] = arguments[_key3];
|
|
2132
2418
|
}
|
|
2133
2419
|
return Object.assign.apply(Object, [target].concat(_toConsumableArray__default["default"](sources.filter(function (s) {
|
|
2134
2420
|
return s;
|
|
2135
2421
|
}).map(function (x) {
|
|
2136
|
-
return Object.fromEntries(Object.entries(x).filter(function (
|
|
2137
|
-
var
|
|
2138
|
-
|
|
2139
|
-
var value =
|
|
2422
|
+
return Object.fromEntries(Object.entries(x).filter(function (_ref47) {
|
|
2423
|
+
var _ref48 = _slicedToArray__default["default"](_ref47, 2);
|
|
2424
|
+
_ref48[0];
|
|
2425
|
+
var value = _ref48[1];
|
|
2140
2426
|
return value !== undefined;
|
|
2141
2427
|
}));
|
|
2142
2428
|
}))));
|
|
@@ -2144,10 +2430,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2144
2430
|
}, {
|
|
2145
2431
|
key: "loadSelectOptions",
|
|
2146
2432
|
value: function () {
|
|
2147
|
-
var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
2433
|
+
var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
|
|
2148
2434
|
var values, apiUrl, i, apiResult, _i3, value, text;
|
|
2149
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
2150
|
-
while (1) switch (
|
|
2435
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context17) {
|
|
2436
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2151
2437
|
case 0:
|
|
2152
2438
|
values = [];
|
|
2153
2439
|
apiUrl = dataSource.url;
|
|
@@ -2156,7 +2442,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2156
2442
|
apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
|
|
2157
2443
|
}
|
|
2158
2444
|
}
|
|
2159
|
-
|
|
2445
|
+
_context17.next = 5;
|
|
2160
2446
|
return fetch(apiUrl, {
|
|
2161
2447
|
headers: {
|
|
2162
2448
|
sessionGuid: sessionGuid
|
|
@@ -2168,7 +2454,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2168
2454
|
return res.json();
|
|
2169
2455
|
});
|
|
2170
2456
|
case 5:
|
|
2171
|
-
apiResult =
|
|
2457
|
+
apiResult = _context17.sent;
|
|
2172
2458
|
if (dataSource.useKey) {
|
|
2173
2459
|
apiResult = apiResult[dataSource.useKey];
|
|
2174
2460
|
}
|
|
@@ -2180,14 +2466,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2180
2466
|
text: text
|
|
2181
2467
|
});
|
|
2182
2468
|
}
|
|
2183
|
-
return
|
|
2469
|
+
return _context17.abrupt("return", values);
|
|
2184
2470
|
case 9:
|
|
2185
2471
|
case "end":
|
|
2186
|
-
return
|
|
2472
|
+
return _context17.stop();
|
|
2187
2473
|
}
|
|
2188
|
-
},
|
|
2474
|
+
}, _callee15);
|
|
2189
2475
|
}));
|
|
2190
|
-
function loadSelectOptions(
|
|
2476
|
+
function loadSelectOptions(_x29, _x30, _x31) {
|
|
2191
2477
|
return _loadSelectOptions.apply(this, arguments);
|
|
2192
2478
|
}
|
|
2193
2479
|
return loadSelectOptions;
|
|
@@ -2200,6 +2486,36 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2200
2486
|
return rv;
|
|
2201
2487
|
}, {});
|
|
2202
2488
|
}
|
|
2489
|
+
}, {
|
|
2490
|
+
key: "getVariantBasketDatasByOrderlines",
|
|
2491
|
+
value: function getVariantBasketDatasByOrderlines(orderLines, catalogData) {
|
|
2492
|
+
var variantBasketDatas = [];
|
|
2493
|
+
var _loop6 = function _loop6() {
|
|
2494
|
+
var ol = orderLines[i];
|
|
2495
|
+
var catalog = catalogData.find(function (c) {
|
|
2496
|
+
return c.codex === ol.CatalogCodex;
|
|
2497
|
+
});
|
|
2498
|
+
if (!ol.VariantBasketDatas) return 1; // continue
|
|
2499
|
+
for (var j = 0; j < ol.VariantBasketDatas.length; j++) {
|
|
2500
|
+
var v = ol.VariantBasketDatas[j];
|
|
2501
|
+
var opt = catalog === null || catalog === void 0 ? void 0 : catalog.options['OPT' + v.OPT];
|
|
2502
|
+
var opv = catalog === null || catalog === void 0 ? void 0 : catalog.optionValues['OPV' + v.OPV];
|
|
2503
|
+
{
|
|
2504
|
+
variantBasketDatas.push({
|
|
2505
|
+
BasketID: ol.BasketID,
|
|
2506
|
+
OPT: v.OPT,
|
|
2507
|
+
OPV: v.OPV,
|
|
2508
|
+
OPTName: opt.Name,
|
|
2509
|
+
OPVName: opv.Name
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
for (var i = 0; i < orderLines.length; i++) {
|
|
2515
|
+
if (_loop6()) continue;
|
|
2516
|
+
}
|
|
2517
|
+
return variantBasketDatas;
|
|
2518
|
+
}
|
|
2203
2519
|
}]);
|
|
2204
2520
|
}();
|
|
2205
2521
|
_ProductHandlerAbstract = ProductHandlerAbstract;
|