@veloceapps/sdk 3.1.17-1 → 3.1.17
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 +68 -212
- package/bundles/veloce-sdk-core.umd.js.map +1 -1
- package/bundles/veloce-sdk-runtime.umd.js +6 -5
- package/bundles/veloce-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloce-sdk.umd.js +35 -42
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +17 -11
- package/core/services/quote-draft.service.d.ts +7 -41
- package/esm2015/core/modules/configuration/services/configuration.service.js +3 -3
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +49 -43
- package/esm2015/core/services/quote-draft.service.js +22 -138
- 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 +3 -2
- package/esm2015/runtime/services/section.service.js +1 -1
- package/esm2015/src/components/header/header.component.js +19 -23
- 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 +5 -8
- package/esm2015/src/resolvers/quote.resolver.js +11 -4
- package/esm2015/src/services/flow.service.js +5 -6
- package/fesm2015/veloce-sdk-core.js +66 -177
- package/fesm2015/veloce-sdk-core.js.map +1 -1
- package/fesm2015/veloce-sdk-runtime.js +4 -3
- package/fesm2015/veloce-sdk-runtime.js.map +1 -1
- package/fesm2015/veloce-sdk.js +36 -38
- 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 +2 -5
- package/src/components/header/header.types.d.ts +1 -0
- package/src/pages/product/product.component.d.ts +0 -1
- package/src/resolvers/quote.resolver.d.ts +1 -0
@@ -450,25 +450,16 @@
|
|
450
450
|
}], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
|
451
451
|
|
452
452
|
var QuoteDraftService = /** @class */ (function () {
|
453
|
-
function QuoteDraftService(context, quoteApiService, priceApiService
|
454
|
-
var _this = this;
|
453
|
+
function QuoteDraftService(context, quoteApiService, priceApiService) {
|
455
454
|
this.context = context;
|
456
455
|
this.quoteApiService = quoteApiService;
|
457
456
|
this.priceApiService = priceApiService;
|
458
|
-
this.sfApiService = sfApiService;
|
459
457
|
this.quoteSubj$ = new rxjs.BehaviorSubject(null);
|
460
458
|
this.resetSubj$ = new rxjs.BehaviorSubject(true);
|
461
|
-
|
462
|
-
* @key pricePlanId
|
463
|
-
* @value priceListId
|
464
|
-
*/
|
465
|
-
this.planIdsMap = {};
|
459
|
+
this.priceLists = [];
|
466
460
|
this.isInitialized = false;
|
467
|
-
this.allPriceLists = [];
|
468
|
-
this.assetPriceLists = [];
|
469
461
|
this.hasUnsavedChanges = false;
|
470
462
|
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); }));
|
472
463
|
}
|
473
464
|
QuoteDraftService.prototype.reset = function () {
|
474
465
|
this.resetSubj$.next(true);
|
@@ -476,52 +467,41 @@
|
|
476
467
|
};
|
477
468
|
QuoteDraftService.prototype.init = function (quoteId, params) {
|
478
469
|
var _this = this;
|
479
|
-
return rxjs.zip(this.
|
480
|
-
var
|
481
|
-
_this.allPriceLists = allPriceLists;
|
470
|
+
return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists(), this.context.resolve$()).pipe(operators.tap(function (_a) {
|
471
|
+
var _b = __read(_a, 3), quote = _b[0], priceLists = _b[1], context = _b[2];
|
482
472
|
_this.quoteSubj$.next(quote);
|
473
|
+
_this.priceLists = priceLists;
|
474
|
+
_this.quotePriceList = priceLists.find(function (p) { return p.id === context.properties.PriceListId; });
|
483
475
|
_this.context.update(Object.assign(Object.assign(Object.assign({}, context), quote.context), { properties: Object.assign(Object.assign({}, context.properties), quote.context.properties) }));
|
484
|
-
}), operators.
|
476
|
+
}), operators.map(function () {
|
477
|
+
_this.isInitialized = true;
|
478
|
+
}), operators.take(1));
|
485
479
|
};
|
486
480
|
QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
|
487
|
-
var
|
488
|
-
if (!
|
481
|
+
var quote = this.quoteSubj$.value;
|
482
|
+
if (!quote) {
|
489
483
|
return;
|
490
484
|
}
|
491
|
-
this.quoteSubj$.next(Object.assign(Object.assign({},
|
485
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quote), { currentState: lineItems }));
|
492
486
|
this.markAsUpdated();
|
493
487
|
};
|
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
|
-
};
|
504
488
|
QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
|
505
|
-
var
|
506
|
-
if (!
|
489
|
+
var quote = this.quoteSubj$.value;
|
490
|
+
if (!quote) {
|
507
491
|
return;
|
508
492
|
}
|
509
|
-
|
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 }));
|
493
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quote), { currentState: priceSummary.lineItems, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
514
494
|
this.markAsUpdated();
|
515
495
|
};
|
516
|
-
Object.defineProperty(QuoteDraftService.prototype, "
|
496
|
+
Object.defineProperty(QuoteDraftService.prototype, "quote$", {
|
517
497
|
get: function () {
|
518
498
|
var _this = this;
|
519
|
-
return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.
|
499
|
+
return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteSnapshot; }), operators.filter(function (quote) { return Boolean(quote); }));
|
520
500
|
},
|
521
501
|
enumerable: false,
|
522
502
|
configurable: true
|
523
503
|
});
|
524
|
-
Object.defineProperty(QuoteDraftService.prototype, "
|
504
|
+
Object.defineProperty(QuoteDraftService.prototype, "quoteSnapshot", {
|
525
505
|
get: function () {
|
526
506
|
var quote = this.quoteSubj$.value;
|
527
507
|
if (!quote) {
|
@@ -532,75 +512,6 @@
|
|
532
512
|
enumerable: false,
|
533
513
|
configurable: true
|
534
514
|
});
|
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
|
-
});
|
604
515
|
Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
|
605
516
|
get: function () {
|
606
517
|
return this.context.resolve().properties.standalone === 'true';
|
@@ -622,65 +533,6 @@
|
|
622
533
|
}
|
623
534
|
return false;
|
624
535
|
};
|
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
|
-
};
|
684
536
|
QuoteDraftService.prototype.markAsUpdated = function () {
|
685
537
|
if (this.isInitialized && !this.hasUnsavedChanges) {
|
686
538
|
this.hasUnsavedChanges = true;
|
@@ -688,12 +540,12 @@
|
|
688
540
|
};
|
689
541
|
return QuoteDraftService;
|
690
542
|
}());
|
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 }
|
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 });
|
692
544
|
QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
|
693
545
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
|
694
546
|
type: i0.Injectable,
|
695
547
|
args: [{ providedIn: 'root' }]
|
696
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }
|
548
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
|
697
549
|
|
698
550
|
var RuntimeContextService = /** @class */ (function () {
|
699
551
|
function RuntimeContextService(configurationApiService, messageService) {
|
@@ -1103,6 +955,8 @@
|
|
1103
955
|
var qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
|
1104
956
|
var lineItem = (_e = this.states.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
|
1105
957
|
var configurationRequest = this.createRequest(lineItem);
|
958
|
+
configurationRequest.lineItems = this.states.currentState || [];
|
959
|
+
configurationRequest.asset = this.states.asset;
|
1106
960
|
var mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
|
1107
961
|
var pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
1108
962
|
return this.configurationApiService
|
@@ -1136,8 +990,6 @@
|
|
1136
990
|
step: !this.lineItem.value ? exports.RuntimeStep.START : exports.RuntimeStep.UPDATE,
|
1137
991
|
attributeDomainMode: 'ALL',
|
1138
992
|
context: this.contextService.resolve(),
|
1139
|
-
lineItems: this.states.currentState || [],
|
1140
|
-
asset: this.states.asset,
|
1141
993
|
};
|
1142
994
|
};
|
1143
995
|
ConfigurationService.prototype.showInactiveProductsConfirmation = function () {
|
@@ -1294,79 +1146,83 @@
|
|
1294
1146
|
}] });
|
1295
1147
|
|
1296
1148
|
var FlowConfigurationService = /** @class */ (function () {
|
1297
|
-
function FlowConfigurationService(
|
1298
|
-
this.
|
1149
|
+
function FlowConfigurationService(priceApiService, contextService, quoteDraftService, messageService, updateService, configurationService) {
|
1150
|
+
this.priceApiService = priceApiService;
|
1299
1151
|
this.contextService = contextService;
|
1300
1152
|
this.quoteDraftService = quoteDraftService;
|
1153
|
+
this.messageService = messageService;
|
1301
1154
|
this.updateService = updateService;
|
1302
1155
|
this.configurationService = configurationService;
|
1156
|
+
this.charges = new rxjs.BehaviorSubject({});
|
1157
|
+
this.bounceBackUpdate$ = new rxjs.BehaviorSubject(true);
|
1303
1158
|
}
|
1304
|
-
FlowConfigurationService.prototype.
|
1159
|
+
FlowConfigurationService.prototype.reset = function () {
|
1160
|
+
this.charges.next({});
|
1161
|
+
};
|
1162
|
+
FlowConfigurationService.prototype.initialize$ = function () {
|
1305
1163
|
var _this = this;
|
1306
|
-
var
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
return this.proceduresApiService.apply$(quoteDraft).pipe(rxjs.tap(function (result) { return _this.quoteDraftService.updateQuoteDraft(result); }), rxjs.map(rxjs.noop));
|
1164
|
+
var _a;
|
1165
|
+
(_a = this.resetSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
1166
|
+
this.resetSubscription = this.quoteDraftService.reset$.subscribe(function () { return _this.reset(); });
|
1167
|
+
return this.calculate$(this.getSnapshot()).pipe(rxjs.map(rxjs.noop));
|
1311
1168
|
};
|
1312
|
-
FlowConfigurationService.prototype.calculate = function () {
|
1313
|
-
this
|
1169
|
+
FlowConfigurationService.prototype.calculate$ = function (currentState) {
|
1170
|
+
var _this = this;
|
1171
|
+
var context = this.contextService.resolve();
|
1172
|
+
return this.priceApiService.calculate({ context: context, currentState: currentState }).pipe(rxjs.tap(function (result) {
|
1173
|
+
_this.quoteDraftService.updateByPriceSummary(result);
|
1174
|
+
_this.charges.next(result.charges);
|
1175
|
+
if (context) {
|
1176
|
+
_this.contextService.update({ properties: context.properties });
|
1177
|
+
}
|
1178
|
+
}), this.handleError());
|
1179
|
+
};
|
1180
|
+
FlowConfigurationService.prototype.calculate = function (currentState) {
|
1181
|
+
this.calculate$(currentState).subscribe();
|
1314
1182
|
};
|
1315
1183
|
FlowConfigurationService.prototype.update$ = function (updates) {
|
1316
1184
|
var _this = this;
|
1317
|
-
var
|
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));
|
1185
|
+
var lineItems = lodash.cloneDeep(this.getSnapshot());
|
1186
|
+
return rxjs.of([]).pipe(rxjs.tap(function () { return _this.updateService.update(lineItems, updates); }), this.handleError(), rxjs.switchMap(function () { return _this.calculate$(lineItems); }));
|
1323
1187
|
};
|
1324
1188
|
FlowConfigurationService.prototype.update = function (updates) {
|
1325
1189
|
this.update$(updates).subscribe();
|
1326
1190
|
};
|
1327
1191
|
FlowConfigurationService.prototype.delete$ = function (ids) {
|
1328
1192
|
var _this = this;
|
1329
|
-
|
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));
|
1193
|
+
return rxjs.of([]).pipe(rxjs.map(function () { return ids.reduce(function (result, id) { return _this.updateService.delete(result, id); }, _this.getSnapshot()); }), this.handleError(), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
|
1334
1194
|
};
|
1335
1195
|
FlowConfigurationService.prototype.delete = function (ids) {
|
1336
1196
|
this.delete$(ids).subscribe();
|
1337
1197
|
};
|
1338
|
-
FlowConfigurationService.prototype.
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1198
|
+
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());
|
1342
1203
|
};
|
1343
1204
|
FlowConfigurationService.prototype.addToCart$ = function (productId, qty) {
|
1344
1205
|
var _this = this;
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function () { return _this.quoteDraftService.activeCurrentState; }), rxjs.shareReplay());
|
1206
|
+
return this.configurationService.configureExternal$(productId, qty).pipe(rxjs.tap(function (lineItem) {
|
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));
|
1351
1211
|
};
|
1352
1212
|
FlowConfigurationService.prototype.getSnapshot = function () {
|
1353
1213
|
var _a, _b;
|
1354
|
-
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
1214
|
+
return (_b = (_a = this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
1355
1215
|
};
|
1356
1216
|
Object.defineProperty(FlowConfigurationService.prototype, "charges$", {
|
1357
1217
|
get: function () {
|
1358
|
-
return this.
|
1359
|
-
var charges = _c.charges;
|
1360
|
-
return charges;
|
1361
|
-
}));
|
1218
|
+
return this.charges.asObservable();
|
1362
1219
|
},
|
1363
1220
|
enumerable: false,
|
1364
1221
|
configurable: true
|
1365
1222
|
});
|
1366
1223
|
Object.defineProperty(FlowConfigurationService.prototype, "chargesSnapshot", {
|
1367
1224
|
get: function () {
|
1368
|
-
|
1369
|
-
return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
1225
|
+
return this.charges.value;
|
1370
1226
|
},
|
1371
1227
|
enumerable: false,
|
1372
1228
|
configurable: true
|
@@ -1385,24 +1241,24 @@
|
|
1385
1241
|
enumerable: false,
|
1386
1242
|
configurable: true
|
1387
1243
|
});
|
1388
|
-
FlowConfigurationService.prototype.
|
1244
|
+
FlowConfigurationService.prototype.handleError = function () {
|
1389
1245
|
var _this = this;
|
1390
1246
|
return function (source$) {
|
1391
1247
|
return source$.pipe(rxjs.catchError(function (error) {
|
1392
1248
|
console.error(error);
|
1393
1249
|
// bounce back if configuration call has failed
|
1394
|
-
_this.
|
1250
|
+
_this.bounceBackUpdate$.next(true);
|
1395
1251
|
return rxjs.throwError(function () { return error; });
|
1396
1252
|
}));
|
1397
1253
|
};
|
1398
1254
|
};
|
1399
1255
|
return FlowConfigurationService;
|
1400
1256
|
}());
|
1401
|
-
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.
|
1257
|
+
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.PriceApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: i2__namespace.MessageService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1402
1258
|
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService });
|
1403
1259
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
|
1404
1260
|
type: i0.Injectable
|
1405
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.
|
1261
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.PriceApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: i2__namespace.MessageService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1406
1262
|
|
1407
1263
|
var FlowConfigurationModule = /** @class */ (function () {
|
1408
1264
|
function FlowConfigurationModule() {
|