@veloceapps/sdk 3.1.15 → 3.1.17-1
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/bundles/veloce-sdk-core.umd.js +217 -73
- package/bundles/veloce-sdk-core.umd.js.map +1 -1
- package/bundles/veloce-sdk-runtime.umd.js +5 -6
- package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloce-sdk.umd.js +42 -35
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/cms/vendor-map.d.ts +124 -116
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +13 -19
- package/core/services/quote-draft.service.d.ts +41 -7
- package/esm2015/core/modules/configuration/services/configuration.service.js +3 -3
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +52 -58
- package/esm2015/core/services/quote-draft.service.js +138 -22
- package/esm2015/runtime/components/ui-runtime/runtime.component.js +2 -2
- package/esm2015/runtime/execution/directives/section-script.directive.js +2 -2
- package/esm2015/runtime/services/cart.service.js +2 -3
- package/esm2015/runtime/services/section.service.js +1 -1
- package/esm2015/src/components/header/header.component.js +23 -19
- package/esm2015/src/components/header/header.types.js +1 -1
- package/esm2015/src/pages/legacy-product/legacy-product.component.js +4 -4
- package/esm2015/src/pages/product/product.component.js +8 -5
- package/esm2015/src/resolvers/quote.resolver.js +4 -11
- package/esm2015/src/services/flow.service.js +6 -5
- package/fesm2015/veloce-sdk-core.js +182 -71
- package/fesm2015/veloce-sdk-core.js.map +1 -1
- package/fesm2015/veloce-sdk-runtime.js +3 -4
- package/fesm2015/veloce-sdk-runtime.js.map +1 -1
- package/fesm2015/veloce-sdk.js +38 -36
- package/fesm2015/veloce-sdk.js.map +1 -1
- package/package.json +1 -1
- package/runtime/services/cart.service.d.ts +1 -1
- package/src/components/header/header.component.d.ts +5 -2
- package/src/components/header/header.types.d.ts +0 -1
- package/src/pages/product/product.component.d.ts +1 -0
- package/src/resolvers/quote.resolver.d.ts +0 -1
@@ -450,16 +450,25 @@
|
|
450
450
|
}], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
|
451
451
|
|
452
452
|
var QuoteDraftService = /** @class */ (function () {
|
453
|
-
function QuoteDraftService(context, quoteApiService, priceApiService) {
|
453
|
+
function QuoteDraftService(context, quoteApiService, priceApiService, sfApiService) {
|
454
|
+
var _this = this;
|
454
455
|
this.context = context;
|
455
456
|
this.quoteApiService = quoteApiService;
|
456
457
|
this.priceApiService = priceApiService;
|
458
|
+
this.sfApiService = sfApiService;
|
457
459
|
this.quoteSubj$ = new rxjs.BehaviorSubject(null);
|
458
460
|
this.resetSubj$ = new rxjs.BehaviorSubject(true);
|
459
|
-
|
461
|
+
/**
|
462
|
+
* @key pricePlanId
|
463
|
+
* @value priceListId
|
464
|
+
*/
|
465
|
+
this.planIdsMap = {};
|
460
466
|
this.isInitialized = false;
|
467
|
+
this.allPriceLists = [];
|
468
|
+
this.assetPriceLists = [];
|
461
469
|
this.hasUnsavedChanges = false;
|
462
470
|
this.reset$ = this.resetSubj$.asObservable();
|
471
|
+
this.activePriceList$ = this.context.resolve$().pipe(operators.map(function (ctx) { return _this.allPriceLists.find(function (priceList) { return priceList.id === ctx.properties.PriceListId; }); }), operators.filter(function (priceList) { return Boolean(priceList); }));
|
463
472
|
}
|
464
473
|
QuoteDraftService.prototype.reset = function () {
|
465
474
|
this.resetSubj$.next(true);
|
@@ -467,41 +476,52 @@
|
|
467
476
|
};
|
468
477
|
QuoteDraftService.prototype.init = function (quoteId, params) {
|
469
478
|
var _this = this;
|
470
|
-
return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()
|
471
|
-
var
|
479
|
+
return rxjs.zip(this.context.resolve$(), this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
|
480
|
+
var _d = __read(_c, 3), context = _d[0], quote = _d[1], allPriceLists = _d[2];
|
481
|
+
_this.allPriceLists = allPriceLists;
|
472
482
|
_this.quoteSubj$.next(quote);
|
473
|
-
_this.priceLists = priceLists;
|
474
|
-
_this.quotePriceList = priceLists.find(function (p) { return p.id === context.properties.PriceListId; });
|
475
483
|
_this.context.update(Object.assign(Object.assign(Object.assign({}, context), quote.context), { properties: Object.assign(Object.assign({}, context.properties), quote.context.properties) }));
|
476
|
-
}), operators.map(function () {
|
477
|
-
_this.isInitialized = true;
|
478
|
-
}), operators.take(1));
|
484
|
+
}), operators.switchMap(function () { return _this.populateActivePriceLists$(); }), operators.map(function () { return rxjs.noop(); }), operators.tap(function () { return (_this.isInitialized = true); }), operators.take(1));
|
479
485
|
};
|
480
486
|
QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
|
481
|
-
var
|
482
|
-
if (!
|
487
|
+
var quoteDraft = this.quoteSubj$.value;
|
488
|
+
if (!quoteDraft) {
|
483
489
|
return;
|
484
490
|
}
|
485
|
-
this.quoteSubj$.next(Object.assign(Object.assign({},
|
491
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
486
492
|
this.markAsUpdated();
|
487
493
|
};
|
494
|
+
QuoteDraftService.prototype.updateQuoteDraft = function (update) {
|
495
|
+
var quoteDraft = this.quoteSubj$.value;
|
496
|
+
if (!quoteDraft) {
|
497
|
+
return;
|
498
|
+
}
|
499
|
+
if (update.context) {
|
500
|
+
this.context.update(update.context);
|
501
|
+
}
|
502
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
503
|
+
};
|
488
504
|
QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
|
489
|
-
var
|
490
|
-
if (!
|
505
|
+
var quoteDraft = this.quoteSubj$.value;
|
506
|
+
if (!quoteDraft) {
|
491
507
|
return;
|
492
508
|
}
|
493
|
-
this.
|
509
|
+
var updatedCurrentState = this.currentState.map(function (lineItem) {
|
510
|
+
var updated = priceSummary.lineItems.find(function (li) { return li.id === lineItem.id; });
|
511
|
+
return updated !== null && updated !== void 0 ? updated : lineItem;
|
512
|
+
});
|
513
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
494
514
|
this.markAsUpdated();
|
495
515
|
};
|
496
|
-
Object.defineProperty(QuoteDraftService.prototype, "
|
516
|
+
Object.defineProperty(QuoteDraftService.prototype, "quoteDraft$", {
|
497
517
|
get: function () {
|
498
518
|
var _this = this;
|
499
|
-
return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.
|
519
|
+
return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteDraft; }), operators.filter(function (quote) { return Boolean(quote); }), operators.shareReplay());
|
500
520
|
},
|
501
521
|
enumerable: false,
|
502
522
|
configurable: true
|
503
523
|
});
|
504
|
-
Object.defineProperty(QuoteDraftService.prototype, "
|
524
|
+
Object.defineProperty(QuoteDraftService.prototype, "quoteDraft", {
|
505
525
|
get: function () {
|
506
526
|
var quote = this.quoteSubj$.value;
|
507
527
|
if (!quote) {
|
@@ -512,6 +532,75 @@
|
|
512
532
|
enumerable: false,
|
513
533
|
configurable: true
|
514
534
|
});
|
535
|
+
Object.defineProperty(QuoteDraftService.prototype, "currentState$", {
|
536
|
+
get: function () {
|
537
|
+
return this.quoteDraft$.pipe(operators.map(function (quote) { return quote.currentState; }));
|
538
|
+
},
|
539
|
+
enumerable: false,
|
540
|
+
configurable: true
|
541
|
+
});
|
542
|
+
Object.defineProperty(QuoteDraftService.prototype, "currentState", {
|
543
|
+
get: function () {
|
544
|
+
var _a, _b;
|
545
|
+
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
546
|
+
},
|
547
|
+
enumerable: false,
|
548
|
+
configurable: true
|
549
|
+
});
|
550
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState$", {
|
551
|
+
/**
|
552
|
+
* Stream of activeCurrentState
|
553
|
+
*/
|
554
|
+
get: function () {
|
555
|
+
var _this = this;
|
556
|
+
return this.quoteDraft$.pipe(operators.map(function () { return _this.activeCurrentState; }));
|
557
|
+
},
|
558
|
+
enumerable: false,
|
559
|
+
configurable: true
|
560
|
+
});
|
561
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState", {
|
562
|
+
/**
|
563
|
+
* activeCurrentState is currentState passed through additional filters
|
564
|
+
*/
|
565
|
+
get: function () {
|
566
|
+
var _a, _b;
|
567
|
+
var ctx = this.context.resolve();
|
568
|
+
var currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
569
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
570
|
+
currentState = this.filterByActivePriceList(currentState);
|
571
|
+
}
|
572
|
+
return currentState;
|
573
|
+
},
|
574
|
+
enumerable: false,
|
575
|
+
configurable: true
|
576
|
+
});
|
577
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeInitialState$", {
|
578
|
+
/**
|
579
|
+
* Stream of activeInitialState
|
580
|
+
*/
|
581
|
+
get: function () {
|
582
|
+
var _this = this;
|
583
|
+
return this.quoteDraft$.pipe(operators.map(function () { return _this.activeInitialState; }));
|
584
|
+
},
|
585
|
+
enumerable: false,
|
586
|
+
configurable: true
|
587
|
+
});
|
588
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeInitialState", {
|
589
|
+
/**
|
590
|
+
* activeInitialState is initialState passed through additional filters
|
591
|
+
*/
|
592
|
+
get: function () {
|
593
|
+
var _a, _b;
|
594
|
+
var ctx = this.context.resolve();
|
595
|
+
var initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
596
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
597
|
+
initialState = this.filterByActivePriceList(initialState);
|
598
|
+
}
|
599
|
+
return initialState;
|
600
|
+
},
|
601
|
+
enumerable: false,
|
602
|
+
configurable: true
|
603
|
+
});
|
515
604
|
Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
|
516
605
|
get: function () {
|
517
606
|
return this.context.resolve().properties.standalone === 'true';
|
@@ -533,6 +622,65 @@
|
|
533
622
|
}
|
534
623
|
return false;
|
535
624
|
};
|
625
|
+
QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
|
626
|
+
this.context.update({ properties: { PriceListId: priceListId } });
|
627
|
+
};
|
628
|
+
/**
|
629
|
+
* Query PricePlan infos for the assets
|
630
|
+
* TODO: remove when backend will send priceListId for assets
|
631
|
+
*/
|
632
|
+
QuoteDraftService.prototype.getAssetsPlanInfos$ = function (quoteDraft) {
|
633
|
+
var _a;
|
634
|
+
var pricePlanIds = (_a = quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.initialState.map(function (li) { return li.planId; }).filter(function (id) { return typeof id === 'string'; }).filter(function (item, i, arr) { return arr.indexOf(item) === i; })) !== null && _a !== void 0 ? _a : [];
|
635
|
+
if (!pricePlanIds.length) {
|
636
|
+
return rxjs.of([]);
|
637
|
+
}
|
638
|
+
var priceListIdFieldName = 'VELOCPQ__PriceListId__c';
|
639
|
+
var searchRequest = {
|
640
|
+
rawCondition: "Id in ('" + pricePlanIds.join("','") + "')",
|
641
|
+
fields: ['Id', priceListIdFieldName],
|
642
|
+
};
|
643
|
+
return this.sfApiService
|
644
|
+
.query(searchRequest, 'VELOCPQ__PricePlan__c')
|
645
|
+
.pipe(operators.map(function (result) { return result.map(function (item) { return ({ id: item.Id, priceListId: item[priceListIdFieldName] }); }).filter(Boolean); }));
|
646
|
+
};
|
647
|
+
QuoteDraftService.prototype.populateActivePriceLists$ = function () {
|
648
|
+
var _this = this;
|
649
|
+
var ctx = this.context.resolve();
|
650
|
+
var quoteDraft = this.quoteDraft;
|
651
|
+
if (!quoteDraft) {
|
652
|
+
return rxjs.of(undefined);
|
653
|
+
}
|
654
|
+
// In ACCOUNT mode populate price lists from related assets
|
655
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
656
|
+
return this.getAssetsPlanInfos$(quoteDraft).pipe(operators.tap(function (pricePlanInfos) {
|
657
|
+
_this.assetPriceLists = pricePlanInfos.map(function (item) {
|
658
|
+
var _a, _b;
|
659
|
+
return ({
|
660
|
+
id: item.priceListId,
|
661
|
+
name: (_b = (_a = _this.allPriceLists.find(function (priceList) { return priceList.id === item.priceListId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
662
|
+
});
|
663
|
+
});
|
664
|
+
_this.planIdsMap = pricePlanInfos.reduce(function (trunk, item) {
|
665
|
+
var _c;
|
666
|
+
return (Object.assign(Object.assign({}, trunk), (_c = {}, _c[item.id] = item.priceListId, _c)));
|
667
|
+
}, {});
|
668
|
+
var activePriceList = _this.assetPriceLists[0];
|
669
|
+
_this.updateActivePriceList(activePriceList.id);
|
670
|
+
// Update PriceListId in context properties
|
671
|
+
// TODO: remove it when backend will have such logic
|
672
|
+
if (_this.assetPriceLists.length) {
|
673
|
+
_this.context.update({ properties: { PriceListId: activePriceList.id } });
|
674
|
+
}
|
675
|
+
}), operators.map(rxjs.noop));
|
676
|
+
}
|
677
|
+
return rxjs.of(undefined);
|
678
|
+
};
|
679
|
+
QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
|
680
|
+
var _this = this;
|
681
|
+
var ctx = this.context.resolve();
|
682
|
+
return lineItems.filter(function (li) { return !li.planId || _this.planIdsMap[li.planId] === ctx.properties.PriceListId; });
|
683
|
+
};
|
536
684
|
QuoteDraftService.prototype.markAsUpdated = function () {
|
537
685
|
if (this.isInitialized && !this.hasUnsavedChanges) {
|
538
686
|
this.hasUnsavedChanges = true;
|
@@ -540,12 +688,12 @@
|
|
540
688
|
};
|
541
689
|
return QuoteDraftService;
|
542
690
|
}());
|
543
|
-
QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
691
|
+
QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }, { token: i1__namespace.SalesforceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
544
692
|
QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
|
545
693
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
|
546
694
|
type: i0.Injectable,
|
547
695
|
args: [{ providedIn: 'root' }]
|
548
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
|
696
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }, { type: i1__namespace.SalesforceApiService }]; } });
|
549
697
|
|
550
698
|
var RuntimeContextService = /** @class */ (function () {
|
551
699
|
function RuntimeContextService(configurationApiService, messageService) {
|
@@ -955,8 +1103,6 @@
|
|
955
1103
|
var qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
|
956
1104
|
var lineItem = (_e = this.states.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
|
957
1105
|
var configurationRequest = this.createRequest(lineItem);
|
958
|
-
configurationRequest.lineItems = this.states.currentState || [];
|
959
|
-
configurationRequest.asset = this.states.asset;
|
960
1106
|
var mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
|
961
1107
|
var pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
962
1108
|
return this.configurationApiService
|
@@ -990,6 +1136,8 @@
|
|
990
1136
|
step: !this.lineItem.value ? exports.RuntimeStep.START : exports.RuntimeStep.UPDATE,
|
991
1137
|
attributeDomainMode: 'ALL',
|
992
1138
|
context: this.contextService.resolve(),
|
1139
|
+
lineItems: this.states.currentState || [],
|
1140
|
+
asset: this.states.asset,
|
993
1141
|
};
|
994
1142
|
};
|
995
1143
|
ConfigurationService.prototype.showInactiveProductsConfirmation = function () {
|
@@ -1146,83 +1294,79 @@
|
|
1146
1294
|
}] });
|
1147
1295
|
|
1148
1296
|
var FlowConfigurationService = /** @class */ (function () {
|
1149
|
-
function FlowConfigurationService(
|
1150
|
-
this.
|
1297
|
+
function FlowConfigurationService(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
|
1298
|
+
this.proceduresApiService = proceduresApiService;
|
1151
1299
|
this.contextService = contextService;
|
1152
1300
|
this.quoteDraftService = quoteDraftService;
|
1153
|
-
this.messageService = messageService;
|
1154
1301
|
this.updateService = updateService;
|
1155
1302
|
this.configurationService = configurationService;
|
1156
|
-
this.charges = new rxjs.BehaviorSubject({});
|
1157
|
-
this.bounceBackUpdate$ = new rxjs.BehaviorSubject(true);
|
1158
1303
|
}
|
1159
|
-
FlowConfigurationService.prototype.
|
1160
|
-
this.charges.next({});
|
1161
|
-
};
|
1162
|
-
FlowConfigurationService.prototype.initialize$ = function () {
|
1304
|
+
FlowConfigurationService.prototype.calculate$ = function () {
|
1163
1305
|
var _this = this;
|
1164
|
-
var
|
1165
|
-
(
|
1166
|
-
|
1167
|
-
|
1306
|
+
var quoteDraft = this.quoteDraftService.quoteDraft;
|
1307
|
+
if (!quoteDraft || !quoteDraft.currentState.length) {
|
1308
|
+
return rxjs.of(undefined);
|
1309
|
+
}
|
1310
|
+
return this.proceduresApiService.apply$(quoteDraft).pipe(rxjs.tap(function (result) { return _this.quoteDraftService.updateQuoteDraft(result); }), rxjs.map(rxjs.noop));
|
1311
|
+
};
|
1312
|
+
FlowConfigurationService.prototype.calculate = function () {
|
1313
|
+
this.calculate$().subscribe();
|
1168
1314
|
};
|
1169
|
-
FlowConfigurationService.prototype.
|
1315
|
+
FlowConfigurationService.prototype.update$ = function (updates) {
|
1170
1316
|
var _this = this;
|
1171
|
-
var
|
1172
|
-
return
|
1173
|
-
|
1174
|
-
_this.
|
1175
|
-
|
1176
|
-
|
1177
|
-
}
|
1178
|
-
}), this.handleError());
|
1317
|
+
var currentState = this.quoteDraftService.currentState;
|
1318
|
+
return rxjs.of([]).pipe(rxjs.tap(function () {
|
1319
|
+
var updatedState = lodash.cloneDeep(currentState);
|
1320
|
+
_this.updateService.update(updatedState, updates);
|
1321
|
+
_this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1322
|
+
}), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
|
1179
1323
|
};
|
1180
|
-
FlowConfigurationService.prototype.
|
1181
|
-
this.
|
1324
|
+
FlowConfigurationService.prototype.update = function (updates) {
|
1325
|
+
this.update$(updates).subscribe();
|
1182
1326
|
};
|
1183
|
-
FlowConfigurationService.prototype.
|
1327
|
+
FlowConfigurationService.prototype.delete$ = function (ids) {
|
1184
1328
|
var _this = this;
|
1185
|
-
var
|
1186
|
-
return rxjs.of([]).pipe(rxjs.tap(function () {
|
1329
|
+
var currentState = this.quoteDraftService.currentState;
|
1330
|
+
return rxjs.of([]).pipe(rxjs.tap(function () {
|
1331
|
+
var updatedState = ids.reduce(function (result, id) { return _this.updateService.delete(result, id); }, currentState);
|
1332
|
+
_this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1333
|
+
}), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
|
1187
1334
|
};
|
1188
|
-
FlowConfigurationService.prototype.
|
1189
|
-
this.
|
1335
|
+
FlowConfigurationService.prototype.delete = function (ids) {
|
1336
|
+
this.delete$(ids).subscribe();
|
1190
1337
|
};
|
1191
|
-
FlowConfigurationService.prototype.
|
1338
|
+
FlowConfigurationService.prototype.addTerm$ = function (term) {
|
1192
1339
|
var _this = this;
|
1193
|
-
|
1340
|
+
var currentState = this.quoteDraftService.currentState;
|
1341
|
+
return rxjs.of([]).pipe(rxjs.tap(function () { return _this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [term])); }), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
|
1194
1342
|
};
|
1195
|
-
FlowConfigurationService.prototype.
|
1196
|
-
this
|
1343
|
+
FlowConfigurationService.prototype.addToCart$ = function (productId, qty) {
|
1344
|
+
var _this = this;
|
1345
|
+
var currentState = this.quoteDraftService.currentState;
|
1346
|
+
return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.tap(function (lineItem) { return _this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [lineItem])); }), rxjs.switchMap(function () { return _this.calculate$(); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack(currentState));
|
1197
1347
|
};
|
1198
1348
|
FlowConfigurationService.prototype.get = function () {
|
1199
|
-
return rxjs.combineLatest([this.quoteDraftService.quote$, this.bounceBackUpdate$]).pipe(rxjs.map(function (_c) {
|
1200
|
-
var _d = __read(_c, 1), quoteDraft = _d[0];
|
1201
|
-
return quoteDraft.currentState;
|
1202
|
-
}), rxjs.shareReplay());
|
1203
|
-
};
|
1204
|
-
FlowConfigurationService.prototype.addToCart$ = function (productId, qty) {
|
1205
1349
|
var _this = this;
|
1206
|
-
return this.
|
1207
|
-
var _a, _b;
|
1208
|
-
var currentState = (_b = (_a = _this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
1209
|
-
_this.quoteDraftService.setCurrentLineItemState(__spreadArray(__spreadArray([], __read(currentState)), [lineItem]));
|
1210
|
-
}), rxjs.map(rxjs.noop));
|
1350
|
+
return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function () { return _this.quoteDraftService.activeCurrentState; }), rxjs.shareReplay());
|
1211
1351
|
};
|
1212
1352
|
FlowConfigurationService.prototype.getSnapshot = function () {
|
1213
1353
|
var _a, _b;
|
1214
|
-
return (_b = (_a = this.quoteDraftService
|
1354
|
+
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
1215
1355
|
};
|
1216
1356
|
Object.defineProperty(FlowConfigurationService.prototype, "charges$", {
|
1217
1357
|
get: function () {
|
1218
|
-
return this.
|
1358
|
+
return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function (_c) {
|
1359
|
+
var charges = _c.charges;
|
1360
|
+
return charges;
|
1361
|
+
}));
|
1219
1362
|
},
|
1220
1363
|
enumerable: false,
|
1221
1364
|
configurable: true
|
1222
1365
|
});
|
1223
1366
|
Object.defineProperty(FlowConfigurationService.prototype, "chargesSnapshot", {
|
1224
1367
|
get: function () {
|
1225
|
-
|
1368
|
+
var _a, _b;
|
1369
|
+
return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
1226
1370
|
},
|
1227
1371
|
enumerable: false,
|
1228
1372
|
configurable: true
|
@@ -1241,24 +1385,24 @@
|
|
1241
1385
|
enumerable: false,
|
1242
1386
|
configurable: true
|
1243
1387
|
});
|
1244
|
-
FlowConfigurationService.prototype.
|
1388
|
+
FlowConfigurationService.prototype.handleErrorAndBounceBack = function (stateToRestore) {
|
1245
1389
|
var _this = this;
|
1246
1390
|
return function (source$) {
|
1247
1391
|
return source$.pipe(rxjs.catchError(function (error) {
|
1248
1392
|
console.error(error);
|
1249
1393
|
// bounce back if configuration call has failed
|
1250
|
-
_this.
|
1394
|
+
_this.quoteDraftService.setCurrentLineItemState(stateToRestore);
|
1251
1395
|
return rxjs.throwError(function () { return error; });
|
1252
1396
|
}));
|
1253
1397
|
};
|
1254
1398
|
};
|
1255
1399
|
return FlowConfigurationService;
|
1256
1400
|
}());
|
1257
|
-
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.
|
1401
|
+
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1258
1402
|
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService });
|
1259
1403
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
|
1260
1404
|
type: i0.Injectable
|
1261
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.
|
1405
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1262
1406
|
|
1263
1407
|
var FlowConfigurationModule = /** @class */ (function () {
|
1264
1408
|
function FlowConfigurationModule() {
|