@veloceapps/sdk 8.0.0-185 → 8.0.0-187
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/cms/vendor-map.d.ts +3 -4
- package/core/modules/configuration/services/configuration-state.service.d.ts +2 -4
- package/core/modules/configuration/services/configuration.service.d.ts +1 -1
- package/core/services/flow-state.service.d.ts +1 -0
- package/core/services/quote-draft.service.d.ts +8 -31
- package/core/types/flow-state.types.d.ts +5 -0
- package/core/types/integration.types.d.ts +0 -1
- package/core/utils/line-item.utils.d.ts +1 -2
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +16 -7
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +10 -8
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +3 -3
- package/esm2020/core/services/flow-state.service.mjs +31 -25
- package/esm2020/core/services/quote-draft.service.mjs +27 -100
- package/esm2020/core/types/flow-state.types.mjs +1 -1
- package/esm2020/core/types/integration.types.mjs +1 -1
- package/esm2020/core/utils/line-item.utils.mjs +4 -18
- package/esm2020/src/pages/product/product.component.mjs +15 -12
- package/esm2020/src/services/flow.service.mjs +38 -18
- package/fesm2015/veloceapps-sdk-core.mjs +455 -522
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +47 -28
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +418 -487
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +50 -27
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/pages/product/product.component.d.ts +1 -1
- package/src/services/flow.service.d.ts +1 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
|
3
3
|
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
|
4
|
-
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1,
|
|
4
|
+
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, zip, combineLatest, Subject, filter as filter$1, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
|
|
5
5
|
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
|
6
6
|
import * as i1 from '@veloceapps/api';
|
|
7
7
|
import { ApiModule } from '@veloceapps/api';
|
|
8
|
-
import { merge, isEmpty, flatten, entries, sortBy, map as map$2, omit,
|
|
8
|
+
import { merge, isEmpty, isEqual, cloneDeep, assign, flatten, entries, sortBy, map as map$2, omit, uniqBy, transform } from 'lodash';
|
|
9
9
|
import * as i6 from '@veloceapps/components';
|
|
10
10
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
|
11
11
|
import moment from 'moment';
|
|
@@ -256,271 +256,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
256
256
|
}] }];
|
|
257
257
|
} });
|
|
258
258
|
|
|
259
|
-
const findLineItem = (id, lineItems) => {
|
|
260
|
-
return findLineItemWithComparator(lineItems, (li) => li.id === id);
|
|
261
|
-
};
|
|
262
|
-
const findLineItemWithComparator = (lineItems, comparator) => {
|
|
263
|
-
let currentLevel = lineItems;
|
|
264
|
-
while (currentLevel.length) {
|
|
265
|
-
const found = currentLevel.find(comparator);
|
|
266
|
-
if (found) {
|
|
267
|
-
return found;
|
|
268
|
-
}
|
|
269
|
-
currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
|
|
270
|
-
}
|
|
271
|
-
return;
|
|
272
|
-
};
|
|
273
|
-
const insertLineItem = (lineItem, parentId, toInsert) => {
|
|
274
|
-
const insertData = lineItem.id === parentId ? [toInsert] : [];
|
|
275
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: [
|
|
276
|
-
...insertData,
|
|
277
|
-
...lineItem.lineItems.map(li => {
|
|
278
|
-
return insertLineItem(li, parentId, toInsert);
|
|
279
|
-
}),
|
|
280
|
-
] });
|
|
281
|
-
};
|
|
282
|
-
const removeLineItem = (lineItem, idToRemove) => {
|
|
283
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
|
|
284
|
-
.map(li => {
|
|
285
|
-
if (li.id === idToRemove) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
else if (li.lineItems.length) {
|
|
289
|
-
return removeLineItem(li, idToRemove);
|
|
290
|
-
}
|
|
291
|
-
return li;
|
|
292
|
-
})
|
|
293
|
-
.filter(r => !!r) });
|
|
294
|
-
};
|
|
295
|
-
const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
|
|
296
|
-
if (lineItem.id === replaceTo.id) {
|
|
297
|
-
if (!skipCardinalityCalculation) {
|
|
298
|
-
return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return Object.assign({}, replaceTo);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)) });
|
|
305
|
-
};
|
|
306
|
-
const collectCardinalityComputations = (portDomains) => {
|
|
307
|
-
const cardinalityComputations = new Map();
|
|
308
|
-
entries(portDomains).forEach(([key, portDomain]) => {
|
|
309
|
-
cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
|
|
310
|
-
});
|
|
311
|
-
return cardinalityComputations;
|
|
312
|
-
};
|
|
313
|
-
const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
|
|
314
|
-
const cardVars = new Map();
|
|
315
|
-
lineItems
|
|
316
|
-
.filter(({ port, type }) => !!port && !!type)
|
|
317
|
-
.forEach(li => {
|
|
318
|
-
var _a;
|
|
319
|
-
if (cardinalityComputations.get(`${li.port}`)) {
|
|
320
|
-
const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
|
|
321
|
-
cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
return cardVars;
|
|
325
|
-
};
|
|
326
|
-
const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
|
|
327
|
-
const recalculateCardinalityVariables = (original, updated) => {
|
|
328
|
-
var _a, _b;
|
|
329
|
-
const cardinalityComputations = collectCardinalityComputations((_b = (_a = updated.portDomains) !== null && _a !== void 0 ? _a : original.portDomains) !== null && _b !== void 0 ? _b : {});
|
|
330
|
-
const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
|
|
331
|
-
const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
|
|
332
|
-
originalCardinalityVariables.forEach((value, key) => {
|
|
333
|
-
var _a;
|
|
334
|
-
const execArray = cardinalityRegexp.exec(key);
|
|
335
|
-
const portName = (_a = execArray === null || execArray === void 0 ? void 0 : execArray.groups) === null || _a === void 0 ? void 0 : _a['portName'];
|
|
336
|
-
if (!portName || cardinalityComputations.get(portName)) {
|
|
337
|
-
if (cardinalityVariables.get(key) === value) {
|
|
338
|
-
// no need to update cardinality if no changes
|
|
339
|
-
cardinalityVariables.delete(key);
|
|
340
|
-
}
|
|
341
|
-
else if (!cardinalityVariables.has(key)) {
|
|
342
|
-
// remove last item from port
|
|
343
|
-
cardinalityVariables.set(key, 0);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))) });
|
|
348
|
-
};
|
|
349
|
-
const mapAttributes = (attributes) => {
|
|
350
|
-
return attributes.reduce((acc, { name, value }) => (Object.assign(Object.assign({}, acc), { [name]: value })), {});
|
|
351
|
-
};
|
|
352
|
-
const getAttributes = (attributes, names = []) => {
|
|
353
|
-
const filtered = attributes.filter(({ name }) => names.includes(name));
|
|
354
|
-
return sortBy(filtered, [({ name }) => names.indexOf(name)]);
|
|
355
|
-
};
|
|
356
|
-
const upsertAttributes = (originalAttributes, attributesToUpsert) => {
|
|
357
|
-
return attributesToUpsert.reduce((acc, { name, value }) => {
|
|
358
|
-
const [origAttr] = getAttributes(acc, [name]);
|
|
359
|
-
return [
|
|
360
|
-
...acc.filter(attr => attr.name !== name),
|
|
361
|
-
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name, type: '' })), { cfgStatus: origAttr ? 'Changed' : 'User', value }),
|
|
362
|
-
];
|
|
363
|
-
}, originalAttributes);
|
|
364
|
-
};
|
|
365
|
-
const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
|
|
366
|
-
const lineItem = findLineItem(id, [rootLineItem]);
|
|
367
|
-
if (!lineItem) {
|
|
368
|
-
return rootLineItem;
|
|
369
|
-
}
|
|
370
|
-
const attributes = upsertAttributes(lineItem.attributes, attrs);
|
|
371
|
-
return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes }), skipCardinalityCalculation);
|
|
372
|
-
};
|
|
373
|
-
const getAttributeValue = (attributes, name) => { var _a; return (_a = attributes.find(attr => attr.name === name)) === null || _a === void 0 ? void 0 : _a.value; };
|
|
374
|
-
const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
|
|
375
|
-
return {
|
|
376
|
-
id: UUID.UUID(),
|
|
377
|
-
port,
|
|
378
|
-
type,
|
|
379
|
-
actionCode: 'ADD',
|
|
380
|
-
cfgStatus: 'New',
|
|
381
|
-
attributes: attributes.map(({ name, value }) => ({ cfgStatus: 'User', name, value })),
|
|
382
|
-
lineItems,
|
|
383
|
-
parentId,
|
|
384
|
-
qty: 1,
|
|
385
|
-
};
|
|
386
|
-
};
|
|
387
|
-
const getRecommendedPrices = (portDomain, type) => {
|
|
388
|
-
var _a, _b;
|
|
389
|
-
const domainType = portDomain.domainTypes.find(({ name }) => name === type);
|
|
390
|
-
const [net, list] = (_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(({ chargeMethod }) => chargeMethod === 'ONE_TIME').reduce((acc, rp) => {
|
|
391
|
-
const [netPrice, listPrice] = acc;
|
|
392
|
-
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
|
393
|
-
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0];
|
|
394
|
-
return { net, list };
|
|
395
|
-
};
|
|
396
|
-
const generateModifiedAssetsMap = (lineItems) => {
|
|
397
|
-
return lineItems.reduce((acc, li) => {
|
|
398
|
-
var _a;
|
|
399
|
-
const isModified = isLineItemModified(li);
|
|
400
|
-
if (!isModified) {
|
|
401
|
-
return acc;
|
|
402
|
-
}
|
|
403
|
-
const target = getOriginParent(lineItems, li);
|
|
404
|
-
const id = (_a = target === null || target === void 0 ? void 0 : target.assetId) !== null && _a !== void 0 ? _a : target === null || target === void 0 ? void 0 : target.openOrderLineItemId;
|
|
405
|
-
if (id) {
|
|
406
|
-
acc[id] = true;
|
|
407
|
-
}
|
|
408
|
-
return acc;
|
|
409
|
-
}, {});
|
|
410
|
-
};
|
|
411
|
-
const getOriginParent = (lineItems, currentLineItem) => {
|
|
412
|
-
let target = currentLineItem;
|
|
413
|
-
while (target && target.rampInstanceId) {
|
|
414
|
-
target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
|
|
415
|
-
}
|
|
416
|
-
return target;
|
|
417
|
-
};
|
|
418
|
-
const isLineItemModified = (lineItem) => {
|
|
419
|
-
if (lineItem.actionCode === 'EXIST' && lineItem.status === 'PENDING') {
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
return lineItem.actionCode !== 'EXIST';
|
|
423
|
-
};
|
|
424
|
-
const multiplyLineItems = (lineItem, qty, split) => {
|
|
425
|
-
if (split) {
|
|
426
|
-
const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
|
|
427
|
-
return map$2(new Array(qty), () => unifyIds(lineItem));
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
return [
|
|
431
|
-
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
|
432
|
-
];
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
const isTechnicalAttribute = (name) => {
|
|
436
|
-
return name.startsWith('#') || name.startsWith('$');
|
|
437
|
-
};
|
|
438
|
-
const filterOutTechnicalAttributes = (attributes) => {
|
|
439
|
-
return attributes.filter(({ name }) => !isTechnicalAttribute(name));
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
443
|
-
__proto__: null,
|
|
444
|
-
filterOutTechnicalAttributes: filterOutTechnicalAttributes,
|
|
445
|
-
findLineItem: findLineItem,
|
|
446
|
-
findLineItemWithComparator: findLineItemWithComparator,
|
|
447
|
-
generateLineItem: generateLineItem,
|
|
448
|
-
generateModifiedAssetsMap: generateModifiedAssetsMap,
|
|
449
|
-
getAttributeValue: getAttributeValue,
|
|
450
|
-
getAttributes: getAttributes,
|
|
451
|
-
getOriginParent: getOriginParent,
|
|
452
|
-
getRecommendedPrices: getRecommendedPrices,
|
|
453
|
-
insertLineItem: insertLineItem,
|
|
454
|
-
isLineItemModified: isLineItemModified,
|
|
455
|
-
isTechnicalAttribute: isTechnicalAttribute,
|
|
456
|
-
mapAttributes: mapAttributes,
|
|
457
|
-
multiplyLineItems: multiplyLineItems,
|
|
458
|
-
patchAttributes: patchAttributes,
|
|
459
|
-
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
|
460
|
-
removeLineItem: removeLineItem,
|
|
461
|
-
replaceLineItem: replaceLineItem,
|
|
462
|
-
upsertAttributes: upsertAttributes
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
class LineItemWorker {
|
|
466
|
-
constructor(src) {
|
|
467
|
-
this.li = Object.assign({}, src);
|
|
468
|
-
}
|
|
469
|
-
insert(parentId, toInsert) {
|
|
470
|
-
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
|
471
|
-
}
|
|
472
|
-
remove(id) {
|
|
473
|
-
return new LineItemWorker(removeLineItem(this.li, id));
|
|
474
|
-
}
|
|
475
|
-
replace(toReplace, skipCardinalityCalculation = false) {
|
|
476
|
-
return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
|
|
477
|
-
}
|
|
478
|
-
patchAttribute(attrs, id, skipCardinalityCalculation = false) {
|
|
479
|
-
return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs, skipCardinalityCalculation));
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function extractMetadata(uiDefinition) {
|
|
484
|
-
return omit(uiDefinition, [
|
|
485
|
-
'children',
|
|
486
|
-
'pages',
|
|
487
|
-
'components',
|
|
488
|
-
]);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
class IntegrationState {
|
|
492
|
-
constructor() {
|
|
493
|
-
this.stateSubj$ = new BehaviorSubject({});
|
|
494
|
-
this.action$ = new Subject();
|
|
495
|
-
}
|
|
496
|
-
get state$() {
|
|
497
|
-
return this.stateSubj$.asObservable();
|
|
498
|
-
}
|
|
499
|
-
get state() {
|
|
500
|
-
return this.stateSubj$.getValue();
|
|
501
|
-
}
|
|
502
|
-
patchState(update) {
|
|
503
|
-
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
|
|
504
|
-
}
|
|
505
|
-
dispatch(action) {
|
|
506
|
-
this.action$.next(action);
|
|
507
|
-
}
|
|
508
|
-
listen$(actionType) {
|
|
509
|
-
return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
|
|
510
|
-
}
|
|
511
|
-
listenAll$() {
|
|
512
|
-
return this.action$.asObservable();
|
|
513
|
-
}
|
|
514
|
-
clear() {
|
|
515
|
-
this.stateSubj$.next({});
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
519
|
-
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
|
|
520
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
|
|
521
|
-
type: Injectable
|
|
522
|
-
}] });
|
|
523
|
-
|
|
524
259
|
class QuoteDraftService {
|
|
525
260
|
get isInitialized$() {
|
|
526
261
|
return this.isInitializedSubj$.asObservable();
|
|
@@ -547,30 +282,30 @@ class QuoteDraftService {
|
|
|
547
282
|
return this.quoteSubj$.pipe(map(() => this.hasProducts));
|
|
548
283
|
}
|
|
549
284
|
get hasProducts() {
|
|
550
|
-
|
|
551
|
-
return
|
|
285
|
+
var _a;
|
|
286
|
+
return Boolean((_a = this.quoteSubj$.value) === null || _a === void 0 ? void 0 : _a.currentState.length);
|
|
552
287
|
}
|
|
553
288
|
get hasAssets$() {
|
|
554
|
-
return this.
|
|
289
|
+
return this.assetsSubj$.pipe(map(() => this.hasAssets));
|
|
555
290
|
}
|
|
556
291
|
get hasAssets() {
|
|
557
|
-
|
|
558
|
-
return
|
|
292
|
+
var _a;
|
|
293
|
+
return Boolean((_a = this.assetsSubj$.value) === null || _a === void 0 ? void 0 : _a.currentState.length);
|
|
559
294
|
}
|
|
560
|
-
|
|
295
|
+
get assetsState() {
|
|
296
|
+
return this.assetsSubj$.value;
|
|
297
|
+
}
|
|
298
|
+
constructor(context, accountApiService, quoteApiService) {
|
|
561
299
|
this.context = context;
|
|
300
|
+
this.accountApiService = accountApiService;
|
|
562
301
|
this.quoteApiService = quoteApiService;
|
|
563
|
-
this.priceApiService = priceApiService;
|
|
564
|
-
this.integrationState = integrationState;
|
|
565
302
|
this.quoteSubj$ = new BehaviorSubject(null);
|
|
303
|
+
this.assetsSubj$ = new BehaviorSubject(null);
|
|
566
304
|
this.resetSubj$ = new BehaviorSubject(true);
|
|
567
305
|
this.isInitializedSubj$ = new BehaviorSubject(false);
|
|
568
306
|
this.initialCurrentState = [];
|
|
569
307
|
this._hasUnsavedChanges = false;
|
|
570
|
-
this.allPriceLists = [];
|
|
571
|
-
this.assetPriceLists = [];
|
|
572
308
|
this.reset$ = this.resetSubj$.asObservable();
|
|
573
|
-
this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList !== null && priceList !== void 0 ? priceList : null));
|
|
574
309
|
this.isInitializedSubj$
|
|
575
310
|
.pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
|
576
311
|
.subscribe();
|
|
@@ -578,19 +313,24 @@ class QuoteDraftService {
|
|
|
578
313
|
reset() {
|
|
579
314
|
this.resetSubj$.next(true);
|
|
580
315
|
this.quoteSubj$.next(null);
|
|
316
|
+
this.assetsSubj$.next(null);
|
|
581
317
|
this.isInitialized = false;
|
|
582
318
|
this.hasUnsavedChanges = false;
|
|
583
319
|
}
|
|
584
|
-
init(
|
|
585
|
-
|
|
586
|
-
|
|
320
|
+
init(headerId, params) {
|
|
321
|
+
const { mode } = this.context.resolve();
|
|
322
|
+
const assets$ = mode === ConfigurationContextMode.ACCOUNT
|
|
323
|
+
? this.accountApiService.getAssetsState(headerId, params)
|
|
324
|
+
: of(undefined);
|
|
325
|
+
return zip(assets$, this.quoteApiService.getQuoteState(headerId, params)).pipe(tap(([assets, quote]) => {
|
|
326
|
+
if (assets) {
|
|
327
|
+
this.assetsSubj$.next(assets);
|
|
328
|
+
}
|
|
587
329
|
this.quoteSubj$.next(quote);
|
|
588
330
|
this.context.update(quote.context);
|
|
589
|
-
this.populateActivePriceLists$();
|
|
590
331
|
}), map(() => noop()), take(1));
|
|
591
332
|
}
|
|
592
333
|
finalizeInit() {
|
|
593
|
-
this.initializeModifiedAssetsMap();
|
|
594
334
|
this.isInitialized = true;
|
|
595
335
|
this.hasUnsavedChanges = false;
|
|
596
336
|
}
|
|
@@ -622,6 +362,9 @@ class QuoteDraftService {
|
|
|
622
362
|
});
|
|
623
363
|
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
|
624
364
|
}
|
|
365
|
+
setAssetsState(assetsState) {
|
|
366
|
+
this.assetsSubj$.next(assetsState);
|
|
367
|
+
}
|
|
625
368
|
get quoteDraft$() {
|
|
626
369
|
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
|
627
370
|
}
|
|
@@ -632,13 +375,6 @@ class QuoteDraftService {
|
|
|
632
375
|
}
|
|
633
376
|
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
|
634
377
|
}
|
|
635
|
-
get quoteDraftForActivePriceList() {
|
|
636
|
-
const quoteDraft = this.quoteDraft;
|
|
637
|
-
if (!quoteDraft) {
|
|
638
|
-
return null;
|
|
639
|
-
}
|
|
640
|
-
return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
|
|
641
|
-
}
|
|
642
378
|
get currentState$() {
|
|
643
379
|
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
|
644
380
|
}
|
|
@@ -646,39 +382,6 @@ class QuoteDraftService {
|
|
|
646
382
|
var _a, _b;
|
|
647
383
|
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
|
648
384
|
}
|
|
649
|
-
/**
|
|
650
|
-
* Stream of activeCurrentState
|
|
651
|
-
*/
|
|
652
|
-
get activeCurrentState$() {
|
|
653
|
-
return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* activeCurrentState is currentState passed through additional filters
|
|
657
|
-
*/
|
|
658
|
-
get activeCurrentState() {
|
|
659
|
-
var _a, _b;
|
|
660
|
-
let currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
|
661
|
-
currentState = this.filterByActivePriceList(currentState);
|
|
662
|
-
return currentState;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Stream of activeInitialState
|
|
666
|
-
*/
|
|
667
|
-
get activeInitialState$() {
|
|
668
|
-
return this.quoteDraft$.pipe(map(() => this.activeInitialState));
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* activeInitialState is initialState passed through additional filters
|
|
672
|
-
*/
|
|
673
|
-
get activeInitialState() {
|
|
674
|
-
var _a, _b;
|
|
675
|
-
const ctx = this.context.resolve();
|
|
676
|
-
let initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
|
677
|
-
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
|
678
|
-
initialState = this.filterByActivePriceList(initialState);
|
|
679
|
-
}
|
|
680
|
-
return initialState;
|
|
681
|
-
}
|
|
682
385
|
get isStandalone() {
|
|
683
386
|
return this.context.resolve().properties.standalone === 'true';
|
|
684
387
|
}
|
|
@@ -696,40 +399,10 @@ class QuoteDraftService {
|
|
|
696
399
|
if (context.mode === ConfigurationContextMode.ACCOUNT) {
|
|
697
400
|
return true;
|
|
698
401
|
}
|
|
699
|
-
if (context.mode === ConfigurationContextMode.QUOTE) {
|
|
700
|
-
return context.properties.Status === 'Draft';
|
|
701
|
-
}
|
|
702
|
-
return false;
|
|
703
|
-
}
|
|
704
|
-
updateActivePriceList(priceListId) {
|
|
705
|
-
this.context.update({ properties: { PriceListId: priceListId } });
|
|
706
|
-
}
|
|
707
|
-
populateActivePriceLists$() {
|
|
708
|
-
const ctx = this.context.resolve();
|
|
709
|
-
const quoteDraft = this.quoteDraft;
|
|
710
|
-
if (!quoteDraft) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
// In ACCOUNT mode populate price lists from related assets
|
|
714
|
-
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
|
715
|
-
// Populate list of price lists
|
|
716
|
-
this.assetPriceLists = quoteDraft.currentState
|
|
717
|
-
.map(({ priceListId }) => priceListId)
|
|
718
|
-
.reduce((trunk, priceListId) => {
|
|
719
|
-
var _a, _b;
|
|
720
|
-
if (!priceListId || trunk.some(item => item.id === priceListId)) {
|
|
721
|
-
return trunk;
|
|
722
|
-
}
|
|
723
|
-
return [
|
|
724
|
-
...trunk,
|
|
725
|
-
{ id: priceListId, name: (_b = (_a = this.allPriceLists.find(item => item.id === priceListId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
|
|
726
|
-
];
|
|
727
|
-
}, []);
|
|
402
|
+
if (context.mode === ConfigurationContextMode.QUOTE) {
|
|
403
|
+
return context.properties.Status === 'Draft';
|
|
728
404
|
}
|
|
729
|
-
|
|
730
|
-
filterByActivePriceList(lineItems) {
|
|
731
|
-
const ctx = this.context.resolve();
|
|
732
|
-
return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
|
|
405
|
+
return false;
|
|
733
406
|
}
|
|
734
407
|
markAsUpdated(quote) {
|
|
735
408
|
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === ConfigurationContextMode.ACCOUNT) {
|
|
@@ -739,17 +412,12 @@ class QuoteDraftService {
|
|
|
739
412
|
this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
|
740
413
|
}
|
|
741
414
|
}
|
|
742
|
-
initializeModifiedAssetsMap() {
|
|
743
|
-
this.integrationState.patchState({
|
|
744
|
-
modifiedAssets: generateModifiedAssetsMap(this.currentState),
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
415
|
}
|
|
748
|
-
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.
|
|
416
|
+
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.AccountApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
749
417
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
|
|
750
418
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
|
|
751
419
|
type: Injectable
|
|
752
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.
|
|
420
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.AccountApiService }, { type: i1.QuoteApiService }]; } });
|
|
753
421
|
|
|
754
422
|
class FlowStateService {
|
|
755
423
|
constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
|
|
@@ -781,8 +449,8 @@ class FlowStateService {
|
|
|
781
449
|
this.isInitialized$()
|
|
782
450
|
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
|
783
451
|
.subscribe();
|
|
784
|
-
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(
|
|
785
|
-
if (
|
|
452
|
+
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
|
453
|
+
if (this.flowInfoService.isLegacy) {
|
|
786
454
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
|
|
787
455
|
}
|
|
788
456
|
else {
|
|
@@ -790,10 +458,10 @@ class FlowStateService {
|
|
|
790
458
|
cold: true,
|
|
791
459
|
}).pipe(map$1(response => (response.success ? response.result : {})));
|
|
792
460
|
}
|
|
793
|
-
}),
|
|
461
|
+
}), shareReplay$1(1));
|
|
794
462
|
this.charges$.subscribe();
|
|
795
|
-
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(
|
|
796
|
-
if (
|
|
463
|
+
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
|
464
|
+
if (this.flowInfoService.isLegacy) {
|
|
797
465
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
|
|
798
466
|
}
|
|
799
467
|
else {
|
|
@@ -801,10 +469,10 @@ class FlowStateService {
|
|
|
801
469
|
cold: true,
|
|
802
470
|
}).pipe(map$1(response => (response.success ? response.result : {})));
|
|
803
471
|
}
|
|
804
|
-
}),
|
|
472
|
+
}), shareReplay$1(1));
|
|
805
473
|
this.pricePlans$.subscribe();
|
|
806
|
-
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(
|
|
807
|
-
if (
|
|
474
|
+
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
|
475
|
+
if (this.flowInfoService.isLegacy) {
|
|
808
476
|
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
|
|
809
477
|
}
|
|
810
478
|
else {
|
|
@@ -812,8 +480,19 @@ class FlowStateService {
|
|
|
812
480
|
cold: true,
|
|
813
481
|
}).pipe(map$1(response => (response.success ? response.result : [])));
|
|
814
482
|
}
|
|
815
|
-
}),
|
|
483
|
+
}), shareReplay$1(1));
|
|
816
484
|
this.activeMetrics$.subscribe();
|
|
485
|
+
this.isPriceListLocked$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(() => {
|
|
486
|
+
if (this.flowInfoService.isLegacy) {
|
|
487
|
+
return of(false);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'IS_PRICE_LIST_LOCKED', null, {
|
|
491
|
+
cold: true,
|
|
492
|
+
}).pipe(map$1(response => (response.success ? response.result : false)));
|
|
493
|
+
}
|
|
494
|
+
}), shareReplay$1(1));
|
|
495
|
+
this.isPriceListLocked$.subscribe();
|
|
817
496
|
}
|
|
818
497
|
init$() {
|
|
819
498
|
return this.initProcessors$().pipe(switchMap(() => {
|
|
@@ -921,7 +600,7 @@ class FlowStateService {
|
|
|
921
600
|
}
|
|
922
601
|
}
|
|
923
602
|
else {
|
|
924
|
-
const quoteDraft = this.quoteDraftService.
|
|
603
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
925
604
|
if (quoteDraft) {
|
|
926
605
|
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
|
|
927
606
|
this.contextService.update({ properties: { ConfigurationId: configurationId } });
|
|
@@ -937,7 +616,7 @@ class FlowStateService {
|
|
|
937
616
|
}
|
|
938
617
|
}
|
|
939
618
|
else {
|
|
940
|
-
const quoteDraft = this.quoteDraftService.
|
|
619
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
941
620
|
if (quoteDraft) {
|
|
942
621
|
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
|
|
943
622
|
this.contextService.update({ properties: { ConfigurationId: configurationId } });
|
|
@@ -1064,7 +743,12 @@ class FlowStateService {
|
|
|
1064
743
|
initStateless$() {
|
|
1065
744
|
var _a;
|
|
1066
745
|
const { headerId } = this.contextService.resolve();
|
|
1067
|
-
return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(
|
|
746
|
+
return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(tap$1(() => {
|
|
747
|
+
const assets = this.quoteDraftService.assetsState;
|
|
748
|
+
if (assets) {
|
|
749
|
+
this.flowStore = Object.assign(Object.assign({}, this.flowStore), { assets });
|
|
750
|
+
}
|
|
751
|
+
}), switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
|
1068
752
|
}
|
|
1069
753
|
calculate$() {
|
|
1070
754
|
var _a;
|
|
@@ -1121,144 +805,350 @@ class FlowStateService {
|
|
|
1121
805
|
});
|
|
1122
806
|
this.quoteDraftService.updateQuoteDraft(flowState);
|
|
1123
807
|
}
|
|
1124
|
-
executeStatelessSelectors(request) {
|
|
1125
|
-
var _a;
|
|
1126
|
-
if (!this.quoteDraftService.quoteDraft) {
|
|
1127
|
-
throw 'QuoteDraft is not initialized';
|
|
1128
|
-
}
|
|
1129
|
-
const flowState = this.quoteDraftService.quoteDraft;
|
|
1130
|
-
return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
|
1131
|
-
try {
|
|
1132
|
-
result.selectors[key] = {
|
|
1133
|
-
success: true,
|
|
1134
|
-
result: this.executeSelectorScript(flowState, selector),
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
catch (e) {
|
|
1138
|
-
console.error(e);
|
|
1139
|
-
result.selectors[key] = {
|
|
1140
|
-
success: false,
|
|
1141
|
-
errorMessage: String(e),
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
return result;
|
|
1145
|
-
}, { stateId: '', selectors: {} });
|
|
808
|
+
executeStatelessSelectors(request) {
|
|
809
|
+
var _a;
|
|
810
|
+
if (!this.quoteDraftService.quoteDraft) {
|
|
811
|
+
throw 'QuoteDraft is not initialized';
|
|
812
|
+
}
|
|
813
|
+
const flowState = this.quoteDraftService.quoteDraft;
|
|
814
|
+
return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
|
815
|
+
try {
|
|
816
|
+
result.selectors[key] = {
|
|
817
|
+
success: true,
|
|
818
|
+
result: this.executeSelectorScript(flowState, selector),
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
catch (e) {
|
|
822
|
+
console.error(e);
|
|
823
|
+
result.selectors[key] = {
|
|
824
|
+
success: false,
|
|
825
|
+
errorMessage: String(e),
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
return result;
|
|
829
|
+
}, { stateId: '', selectors: {} });
|
|
830
|
+
}
|
|
831
|
+
getFlowSafe() {
|
|
832
|
+
if (!this.flowInfoService.flow) {
|
|
833
|
+
throw 'Flow is not defined';
|
|
834
|
+
}
|
|
835
|
+
return this.flowInfoService.flow;
|
|
836
|
+
}
|
|
837
|
+
initProcessors$() {
|
|
838
|
+
var _a;
|
|
839
|
+
const hasOverrides = Boolean((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors);
|
|
840
|
+
const flow = this.getFlowSafe();
|
|
841
|
+
if (flow.properties.stateful && !hasOverrides) {
|
|
842
|
+
// Skip initialization as backend will take processors from SF
|
|
843
|
+
return of(undefined);
|
|
844
|
+
}
|
|
845
|
+
const owners$ = Object.values(this.flowInfoService.templates)
|
|
846
|
+
.map(template => {
|
|
847
|
+
var _a, _b, _c;
|
|
848
|
+
if (!template) {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
const localProcessors$ = (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors) === null || _b === void 0 ? void 0 : _b.call(_a, template.name)) !== null && _c !== void 0 ? _c : of(null);
|
|
852
|
+
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
|
|
853
|
+
const processorsMap = processors.reduce((acc, p) => {
|
|
854
|
+
acc[p.apiName] = p;
|
|
855
|
+
return acc;
|
|
856
|
+
}, {});
|
|
857
|
+
this.processors[template.id] = processorsMap;
|
|
858
|
+
}));
|
|
859
|
+
})
|
|
860
|
+
.filter(isDefined);
|
|
861
|
+
if (!owners$.length) {
|
|
862
|
+
return of(undefined);
|
|
863
|
+
}
|
|
864
|
+
return forkJoin(owners$).pipe(map$1(noop));
|
|
865
|
+
}
|
|
866
|
+
executeActionScript(request, executable) {
|
|
867
|
+
var _a;
|
|
868
|
+
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
|
869
|
+
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
|
870
|
+
const scope = this.getScopeByOwnerId(executable.ownerId);
|
|
871
|
+
const scopeText = scope ? ` in ${scope}` : '';
|
|
872
|
+
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
|
873
|
+
}
|
|
874
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
|
875
|
+
}
|
|
876
|
+
executeSelectorScript(request, executable) {
|
|
877
|
+
var _a;
|
|
878
|
+
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
|
879
|
+
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
|
880
|
+
const scope = this.getScopeByOwnerId(executable.ownerId);
|
|
881
|
+
const scopeText = scope ? ` in ${scope}` : '';
|
|
882
|
+
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
|
883
|
+
}
|
|
884
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
|
885
|
+
}
|
|
886
|
+
executeProcessorScript(request, configurationProcessor, inputData) {
|
|
887
|
+
var _a;
|
|
888
|
+
const scope = this.getScopeByOwnerId((_a = configurationProcessor.ownerId) !== null && _a !== void 0 ? _a : '');
|
|
889
|
+
let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
|
|
890
|
+
if (!functionToExecute) {
|
|
891
|
+
const script = `${configurationProcessor.script}\nreturn transform;`;
|
|
892
|
+
const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
|
|
893
|
+
functionToExecute = new Function(script + sourceMap)();
|
|
894
|
+
this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
|
|
895
|
+
}
|
|
896
|
+
return functionToExecute({
|
|
897
|
+
request,
|
|
898
|
+
inputData,
|
|
899
|
+
flowStore: this.flowStore,
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
generateRequestId(scope, selectorName, inputData) {
|
|
903
|
+
const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
|
|
904
|
+
return `${scope}/${selectorName}/${inputDataHash}`;
|
|
905
|
+
}
|
|
906
|
+
getDefaultExecutionRequestDTO() {
|
|
907
|
+
var _a;
|
|
908
|
+
const request = {
|
|
909
|
+
actions: [],
|
|
910
|
+
selectors: {},
|
|
911
|
+
};
|
|
912
|
+
if (this.getFlowSafe().properties.standalone) {
|
|
913
|
+
return request;
|
|
914
|
+
}
|
|
915
|
+
const flowEngineTemplateId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
|
|
916
|
+
(_a = request.actions) === null || _a === void 0 ? void 0 : _a.push({
|
|
917
|
+
apiName: 'UPDATE_CONTEXT_PROPERTIES',
|
|
918
|
+
ownerId: flowEngineTemplateId,
|
|
919
|
+
inputData: this.contextService.resolve().properties,
|
|
920
|
+
});
|
|
921
|
+
return request;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
925
|
+
FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
|
|
926
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
|
|
927
|
+
type: Injectable
|
|
928
|
+
}], ctorParameters: function () {
|
|
929
|
+
return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
|
|
930
|
+
type: Optional
|
|
931
|
+
}, {
|
|
932
|
+
type: Inject,
|
|
933
|
+
args: [FLOW_CUSTOMIZATION]
|
|
934
|
+
}] }];
|
|
935
|
+
} });
|
|
936
|
+
|
|
937
|
+
const findLineItem = (id, lineItems) => {
|
|
938
|
+
return findLineItemWithComparator(lineItems, (li) => li.id === id);
|
|
939
|
+
};
|
|
940
|
+
const findLineItemWithComparator = (lineItems, comparator) => {
|
|
941
|
+
let currentLevel = lineItems;
|
|
942
|
+
while (currentLevel.length) {
|
|
943
|
+
const found = currentLevel.find(comparator);
|
|
944
|
+
if (found) {
|
|
945
|
+
return found;
|
|
946
|
+
}
|
|
947
|
+
currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
|
|
948
|
+
}
|
|
949
|
+
return;
|
|
950
|
+
};
|
|
951
|
+
const insertLineItem = (lineItem, parentId, toInsert) => {
|
|
952
|
+
const insertData = lineItem.id === parentId ? [toInsert] : [];
|
|
953
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: [
|
|
954
|
+
...insertData,
|
|
955
|
+
...lineItem.lineItems.map(li => {
|
|
956
|
+
return insertLineItem(li, parentId, toInsert);
|
|
957
|
+
}),
|
|
958
|
+
] });
|
|
959
|
+
};
|
|
960
|
+
const removeLineItem = (lineItem, idToRemove) => {
|
|
961
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
|
|
962
|
+
.map(li => {
|
|
963
|
+
if (li.id === idToRemove) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
else if (li.lineItems.length) {
|
|
967
|
+
return removeLineItem(li, idToRemove);
|
|
968
|
+
}
|
|
969
|
+
return li;
|
|
970
|
+
})
|
|
971
|
+
.filter(r => !!r) });
|
|
972
|
+
};
|
|
973
|
+
const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
|
|
974
|
+
if (lineItem.id === replaceTo.id) {
|
|
975
|
+
if (!skipCardinalityCalculation) {
|
|
976
|
+
return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
|
|
977
|
+
}
|
|
978
|
+
else {
|
|
979
|
+
return Object.assign({}, replaceTo);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)) });
|
|
983
|
+
};
|
|
984
|
+
const collectCardinalityComputations = (portDomains) => {
|
|
985
|
+
const cardinalityComputations = new Map();
|
|
986
|
+
entries(portDomains).forEach(([key, portDomain]) => {
|
|
987
|
+
cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
|
|
988
|
+
});
|
|
989
|
+
return cardinalityComputations;
|
|
990
|
+
};
|
|
991
|
+
const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
|
|
992
|
+
const cardVars = new Map();
|
|
993
|
+
lineItems
|
|
994
|
+
.filter(({ port, type }) => !!port && !!type)
|
|
995
|
+
.forEach(li => {
|
|
996
|
+
var _a;
|
|
997
|
+
if (cardinalityComputations.get(`${li.port}`)) {
|
|
998
|
+
const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
|
|
999
|
+
cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
return cardVars;
|
|
1003
|
+
};
|
|
1004
|
+
const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
|
|
1005
|
+
const recalculateCardinalityVariables = (original, updated) => {
|
|
1006
|
+
var _a, _b;
|
|
1007
|
+
const cardinalityComputations = collectCardinalityComputations((_b = (_a = updated.portDomains) !== null && _a !== void 0 ? _a : original.portDomains) !== null && _b !== void 0 ? _b : {});
|
|
1008
|
+
const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
|
|
1009
|
+
const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
|
|
1010
|
+
originalCardinalityVariables.forEach((value, key) => {
|
|
1011
|
+
var _a;
|
|
1012
|
+
const execArray = cardinalityRegexp.exec(key);
|
|
1013
|
+
const portName = (_a = execArray === null || execArray === void 0 ? void 0 : execArray.groups) === null || _a === void 0 ? void 0 : _a['portName'];
|
|
1014
|
+
if (!portName || cardinalityComputations.get(portName)) {
|
|
1015
|
+
if (cardinalityVariables.get(key) === value) {
|
|
1016
|
+
// no need to update cardinality if no changes
|
|
1017
|
+
cardinalityVariables.delete(key);
|
|
1018
|
+
}
|
|
1019
|
+
else if (!cardinalityVariables.has(key)) {
|
|
1020
|
+
// remove last item from port
|
|
1021
|
+
cardinalityVariables.set(key, 0);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))) });
|
|
1026
|
+
};
|
|
1027
|
+
const mapAttributes = (attributes) => {
|
|
1028
|
+
return attributes.reduce((acc, { name, value }) => (Object.assign(Object.assign({}, acc), { [name]: value })), {});
|
|
1029
|
+
};
|
|
1030
|
+
const getAttributes = (attributes, names = []) => {
|
|
1031
|
+
const filtered = attributes.filter(({ name }) => names.includes(name));
|
|
1032
|
+
return sortBy(filtered, [({ name }) => names.indexOf(name)]);
|
|
1033
|
+
};
|
|
1034
|
+
const upsertAttributes = (originalAttributes, attributesToUpsert) => {
|
|
1035
|
+
return attributesToUpsert.reduce((acc, { name, value }) => {
|
|
1036
|
+
const [origAttr] = getAttributes(acc, [name]);
|
|
1037
|
+
return [
|
|
1038
|
+
...acc.filter(attr => attr.name !== name),
|
|
1039
|
+
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name, type: '' })), { cfgStatus: origAttr ? 'Changed' : 'User', value }),
|
|
1040
|
+
];
|
|
1041
|
+
}, originalAttributes);
|
|
1042
|
+
};
|
|
1043
|
+
const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
|
|
1044
|
+
const lineItem = findLineItem(id, [rootLineItem]);
|
|
1045
|
+
if (!lineItem) {
|
|
1046
|
+
return rootLineItem;
|
|
1047
|
+
}
|
|
1048
|
+
const attributes = upsertAttributes(lineItem.attributes, attrs);
|
|
1049
|
+
return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes }), skipCardinalityCalculation);
|
|
1050
|
+
};
|
|
1051
|
+
const getAttributeValue = (attributes, name) => { var _a; return (_a = attributes.find(attr => attr.name === name)) === null || _a === void 0 ? void 0 : _a.value; };
|
|
1052
|
+
const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
|
|
1053
|
+
return {
|
|
1054
|
+
id: UUID.UUID(),
|
|
1055
|
+
port,
|
|
1056
|
+
type,
|
|
1057
|
+
actionCode: 'ADD',
|
|
1058
|
+
cfgStatus: 'New',
|
|
1059
|
+
attributes: attributes.map(({ name, value }) => ({ cfgStatus: 'User', name, value })),
|
|
1060
|
+
lineItems,
|
|
1061
|
+
parentId,
|
|
1062
|
+
qty: 1,
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
const getRecommendedPrices = (portDomain, type) => {
|
|
1066
|
+
var _a, _b;
|
|
1067
|
+
const domainType = portDomain.domainTypes.find(({ name }) => name === type);
|
|
1068
|
+
const [net, list] = (_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(({ chargeMethod }) => chargeMethod === 'ONE_TIME').reduce((acc, rp) => {
|
|
1069
|
+
const [netPrice, listPrice] = acc;
|
|
1070
|
+
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
|
1071
|
+
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0];
|
|
1072
|
+
return { net, list };
|
|
1073
|
+
};
|
|
1074
|
+
const getOriginParent = (lineItems, currentLineItem) => {
|
|
1075
|
+
let target = currentLineItem;
|
|
1076
|
+
while (target && target.rampInstanceId) {
|
|
1077
|
+
target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
|
|
1078
|
+
}
|
|
1079
|
+
return target;
|
|
1080
|
+
};
|
|
1081
|
+
const assetPredicateFn = (lineItem, assetId) => {
|
|
1082
|
+
if (!assetId) {
|
|
1083
|
+
return false;
|
|
1146
1084
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1085
|
+
return lineItem.assetId === assetId || lineItem.openOrderLineItemId === assetId;
|
|
1086
|
+
};
|
|
1087
|
+
const multiplyLineItems = (lineItem, qty, split) => {
|
|
1088
|
+
if (split) {
|
|
1089
|
+
const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
|
|
1090
|
+
return map$2(new Array(qty), () => unifyIds(lineItem));
|
|
1152
1091
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
if (flow.properties.stateful && !hasOverrides) {
|
|
1158
|
-
// Skip initialization as backend will take processors from SF
|
|
1159
|
-
return of(undefined);
|
|
1160
|
-
}
|
|
1161
|
-
const owners$ = Object.values(this.flowInfoService.templates)
|
|
1162
|
-
.map(template => {
|
|
1163
|
-
var _a, _b, _c;
|
|
1164
|
-
if (!template) {
|
|
1165
|
-
return;
|
|
1166
|
-
}
|
|
1167
|
-
const localProcessors$ = (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors) === null || _b === void 0 ? void 0 : _b.call(_a, template.name)) !== null && _c !== void 0 ? _c : of(null);
|
|
1168
|
-
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
|
|
1169
|
-
const processorsMap = processors.reduce((acc, p) => {
|
|
1170
|
-
acc[p.apiName] = p;
|
|
1171
|
-
return acc;
|
|
1172
|
-
}, {});
|
|
1173
|
-
this.processors[template.id] = processorsMap;
|
|
1174
|
-
}));
|
|
1175
|
-
})
|
|
1176
|
-
.filter(isDefined);
|
|
1177
|
-
if (!owners$.length) {
|
|
1178
|
-
return of(undefined);
|
|
1179
|
-
}
|
|
1180
|
-
return forkJoin(owners$).pipe(map$1(noop));
|
|
1092
|
+
else {
|
|
1093
|
+
return [
|
|
1094
|
+
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
|
1095
|
+
];
|
|
1181
1096
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1097
|
+
};
|
|
1098
|
+
const isTechnicalAttribute = (name) => {
|
|
1099
|
+
return name.startsWith('#') || name.startsWith('$');
|
|
1100
|
+
};
|
|
1101
|
+
const filterOutTechnicalAttributes = (attributes) => {
|
|
1102
|
+
return attributes.filter(({ name }) => !isTechnicalAttribute(name));
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
1106
|
+
__proto__: null,
|
|
1107
|
+
assetPredicateFn: assetPredicateFn,
|
|
1108
|
+
filterOutTechnicalAttributes: filterOutTechnicalAttributes,
|
|
1109
|
+
findLineItem: findLineItem,
|
|
1110
|
+
findLineItemWithComparator: findLineItemWithComparator,
|
|
1111
|
+
generateLineItem: generateLineItem,
|
|
1112
|
+
getAttributeValue: getAttributeValue,
|
|
1113
|
+
getAttributes: getAttributes,
|
|
1114
|
+
getOriginParent: getOriginParent,
|
|
1115
|
+
getRecommendedPrices: getRecommendedPrices,
|
|
1116
|
+
insertLineItem: insertLineItem,
|
|
1117
|
+
isTechnicalAttribute: isTechnicalAttribute,
|
|
1118
|
+
mapAttributes: mapAttributes,
|
|
1119
|
+
multiplyLineItems: multiplyLineItems,
|
|
1120
|
+
patchAttributes: patchAttributes,
|
|
1121
|
+
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
|
1122
|
+
removeLineItem: removeLineItem,
|
|
1123
|
+
replaceLineItem: replaceLineItem,
|
|
1124
|
+
upsertAttributes: upsertAttributes
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
class LineItemWorker {
|
|
1128
|
+
constructor(src) {
|
|
1129
|
+
this.li = Object.assign({}, src);
|
|
1191
1130
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
|
1195
|
-
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
|
1196
|
-
const scope = this.getScopeByOwnerId(executable.ownerId);
|
|
1197
|
-
const scopeText = scope ? ` in ${scope}` : '';
|
|
1198
|
-
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
|
1199
|
-
}
|
|
1200
|
-
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
|
1131
|
+
insert(parentId, toInsert) {
|
|
1132
|
+
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
|
1201
1133
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
const scope = this.getScopeByOwnerId((_a = configurationProcessor.ownerId) !== null && _a !== void 0 ? _a : '');
|
|
1205
|
-
let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
|
|
1206
|
-
if (!functionToExecute) {
|
|
1207
|
-
const script = `${configurationProcessor.script}\nreturn transform;`;
|
|
1208
|
-
const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
|
|
1209
|
-
functionToExecute = new Function(script + sourceMap)();
|
|
1210
|
-
this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
|
|
1211
|
-
}
|
|
1212
|
-
return functionToExecute({
|
|
1213
|
-
request,
|
|
1214
|
-
inputData,
|
|
1215
|
-
flowStore: this.flowStore,
|
|
1216
|
-
});
|
|
1134
|
+
remove(id) {
|
|
1135
|
+
return new LineItemWorker(removeLineItem(this.li, id));
|
|
1217
1136
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
return `${scope}/${selectorName}/${inputDataHash}`;
|
|
1137
|
+
replace(toReplace, skipCardinalityCalculation = false) {
|
|
1138
|
+
return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
|
|
1221
1139
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
const request = {
|
|
1225
|
-
actions: [],
|
|
1226
|
-
selectors: {},
|
|
1227
|
-
};
|
|
1228
|
-
if (this.getFlowSafe().properties.standalone) {
|
|
1229
|
-
return request;
|
|
1230
|
-
}
|
|
1231
|
-
const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
|
|
1232
|
-
(_a = request.actions) === null || _a === void 0 ? void 0 : _a.push({
|
|
1233
|
-
apiName: 'UPDATE_PRICE_LIST',
|
|
1234
|
-
ownerId,
|
|
1235
|
-
inputData: {},
|
|
1236
|
-
});
|
|
1237
|
-
(_b = request.actions) === null || _b === void 0 ? void 0 : _b.push({
|
|
1238
|
-
apiName: 'UPDATE_ASSET_IDS',
|
|
1239
|
-
ownerId,
|
|
1240
|
-
inputData: {},
|
|
1241
|
-
});
|
|
1242
|
-
(_c = request.actions) === null || _c === void 0 ? void 0 : _c.push({
|
|
1243
|
-
apiName: 'UPDATE_CONTEXT_PROPERTIES',
|
|
1244
|
-
ownerId,
|
|
1245
|
-
inputData: this.contextService.resolve().properties,
|
|
1246
|
-
});
|
|
1247
|
-
return request;
|
|
1140
|
+
patchAttribute(attrs, id, skipCardinalityCalculation = false) {
|
|
1141
|
+
return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs, skipCardinalityCalculation));
|
|
1248
1142
|
}
|
|
1249
1143
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
type: Inject,
|
|
1259
|
-
args: [FLOW_CUSTOMIZATION]
|
|
1260
|
-
}] }];
|
|
1261
|
-
} });
|
|
1144
|
+
|
|
1145
|
+
function extractMetadata(uiDefinition) {
|
|
1146
|
+
return omit(uiDefinition, [
|
|
1147
|
+
'children',
|
|
1148
|
+
'pages',
|
|
1149
|
+
'components',
|
|
1150
|
+
]);
|
|
1151
|
+
}
|
|
1262
1152
|
|
|
1263
1153
|
class FlowUpdateService {
|
|
1264
1154
|
update(rootLineItems, updates, charges) {
|
|
@@ -1681,6 +1571,15 @@ class ConfigurationService {
|
|
|
1681
1571
|
}
|
|
1682
1572
|
return lineItem;
|
|
1683
1573
|
}
|
|
1574
|
+
getAsset() {
|
|
1575
|
+
var _a, _b;
|
|
1576
|
+
const lineItem = this.configurableRamp;
|
|
1577
|
+
if (!lineItem) {
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
const assetId = (_a = lineItem.assetId) !== null && _a !== void 0 ? _a : lineItem.openOrderLineItemId;
|
|
1581
|
+
return (_b = this.quoteDraftService.assetsState) === null || _b === void 0 ? void 0 : _b.initialState.find(li => assetPredicateFn(li, assetId));
|
|
1582
|
+
}
|
|
1684
1583
|
getUIDefinitionProperties() {
|
|
1685
1584
|
var _a, _b, _c;
|
|
1686
1585
|
return Object.assign(Object.assign({}, ((_b = (_a = this.getRuntimeContext().uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {})), ((_c = this.runtimeService.uiDefinitionProperties) !== null && _c !== void 0 ? _c : {}));
|
|
@@ -1709,14 +1608,6 @@ class ConfigurationService {
|
|
|
1709
1608
|
}
|
|
1710
1609
|
});
|
|
1711
1610
|
}
|
|
1712
|
-
getAsset() {
|
|
1713
|
-
var _a;
|
|
1714
|
-
const lineItem = this.configurableRamp;
|
|
1715
|
-
if (!lineItem) {
|
|
1716
|
-
return;
|
|
1717
|
-
}
|
|
1718
|
-
return (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
|
|
1719
|
-
}
|
|
1720
1611
|
}
|
|
1721
1612
|
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6$1.DialogService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1722
1613
|
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
|
@@ -1764,7 +1655,7 @@ class FlowConfigurationService {
|
|
|
1764
1655
|
revert$(lineItemId) {
|
|
1765
1656
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
1766
1657
|
const initialCurrentState = this.quoteDraftService.getInitialCurrentState();
|
|
1767
|
-
const currentState = this.quoteDraftService.
|
|
1658
|
+
const currentState = this.quoteDraftService.currentState;
|
|
1768
1659
|
const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
|
|
1769
1660
|
const currentLineItem = currentState[currentLineItemIndex];
|
|
1770
1661
|
const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === (currentLineItem === null || currentLineItem === void 0 ? void 0 : currentLineItem.integrationId));
|
|
@@ -1813,7 +1704,7 @@ class FlowConfigurationService {
|
|
|
1813
1704
|
}), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
|
1814
1705
|
}
|
|
1815
1706
|
get() {
|
|
1816
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.
|
|
1707
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.currentState), shareReplay$1());
|
|
1817
1708
|
}
|
|
1818
1709
|
getSnapshot() {
|
|
1819
1710
|
var _a, _b;
|
|
@@ -1922,6 +1813,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
1922
1813
|
type: Injectable
|
|
1923
1814
|
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
|
|
1924
1815
|
|
|
1816
|
+
class IntegrationState {
|
|
1817
|
+
constructor() {
|
|
1818
|
+
this.stateSubj$ = new BehaviorSubject({});
|
|
1819
|
+
this.action$ = new Subject();
|
|
1820
|
+
}
|
|
1821
|
+
get state$() {
|
|
1822
|
+
return this.stateSubj$.asObservable();
|
|
1823
|
+
}
|
|
1824
|
+
get state() {
|
|
1825
|
+
return this.stateSubj$.getValue();
|
|
1826
|
+
}
|
|
1827
|
+
patchState(update) {
|
|
1828
|
+
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
|
|
1829
|
+
}
|
|
1830
|
+
dispatch(action) {
|
|
1831
|
+
this.action$.next(action);
|
|
1832
|
+
}
|
|
1833
|
+
listen$(actionType) {
|
|
1834
|
+
return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
|
|
1835
|
+
}
|
|
1836
|
+
listenAll$() {
|
|
1837
|
+
return this.action$.asObservable();
|
|
1838
|
+
}
|
|
1839
|
+
clear() {
|
|
1840
|
+
this.stateSubj$.next({});
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1844
|
+
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
|
|
1845
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
|
|
1846
|
+
type: Injectable
|
|
1847
|
+
}] });
|
|
1848
|
+
|
|
1925
1849
|
class ProductImagesService {
|
|
1926
1850
|
constructor(productApiService) {
|
|
1927
1851
|
this.productApiService = productApiService;
|
|
@@ -2189,7 +2113,7 @@ class ConfigurationStateService {
|
|
|
2189
2113
|
}), takeUntil(this.canceledConfiguration$));
|
|
2190
2114
|
}
|
|
2191
2115
|
saveConfiguration(quoteId, flow) {
|
|
2192
|
-
var _a, _b;
|
|
2116
|
+
var _a, _b, _c, _d;
|
|
2193
2117
|
if (this.isStatefulConfiguration) {
|
|
2194
2118
|
return this.flowStateApiService
|
|
2195
2119
|
.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
|
|
@@ -2201,10 +2125,12 @@ class ConfigurationStateService {
|
|
|
2201
2125
|
return of({ quoteId: '' });
|
|
2202
2126
|
}
|
|
2203
2127
|
const rootLineItem = this.configurationService.getSnapshot();
|
|
2128
|
+
const asset = this.configurationService.getAsset();
|
|
2204
2129
|
const currentState = rootLineItem ? [rootLineItem] : [];
|
|
2130
|
+
const initialState = asset ? [asset] : [];
|
|
2205
2131
|
return this.quoteApiService
|
|
2206
|
-
.
|
|
2207
|
-
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState }))));
|
|
2132
|
+
.getQuoteState(quoteId)
|
|
2133
|
+
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState, initialState }))));
|
|
2208
2134
|
}
|
|
2209
2135
|
else {
|
|
2210
2136
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
|
@@ -2213,15 +2139,22 @@ class ConfigurationStateService {
|
|
|
2213
2139
|
return of({ quoteId: '' });
|
|
2214
2140
|
}
|
|
2215
2141
|
const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
|
|
2216
|
-
let
|
|
2142
|
+
let currentState;
|
|
2217
2143
|
if (isNewLineItem) {
|
|
2218
|
-
|
|
2144
|
+
currentState = [...quoteDraft.currentState, lineItem];
|
|
2219
2145
|
}
|
|
2220
2146
|
else {
|
|
2221
|
-
|
|
2147
|
+
currentState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
|
2148
|
+
}
|
|
2149
|
+
const asset = this.configurationService.getAsset();
|
|
2150
|
+
const initialState = [...((_d = (_c = this.quoteDraftService.quoteDraft) === null || _c === void 0 ? void 0 : _c.initialState) !== null && _d !== void 0 ? _d : [])];
|
|
2151
|
+
if (asset) {
|
|
2152
|
+
if (!initialState.some(li => li.id === asset.id)) {
|
|
2153
|
+
initialState.push(asset);
|
|
2154
|
+
}
|
|
2222
2155
|
}
|
|
2223
2156
|
return this.flowConfigurationService
|
|
2224
|
-
.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState
|
|
2157
|
+
.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState, initialState }))
|
|
2225
2158
|
.pipe(map$1(() => ({ quoteId: '' })));
|
|
2226
2159
|
}
|
|
2227
2160
|
}
|
|
@@ -2607,5 +2540,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2607
2540
|
* Generated bundle index. Do not edit.
|
|
2608
2541
|
*/
|
|
2609
2542
|
|
|
2610
|
-
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem,
|
|
2543
|
+
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, assetPredicateFn, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
|
2611
2544
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|