@veloceapps/sdk 3.1.17 → 3.1.19
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/README.md +2 -6
- package/bundles/veloce-sdk-core.umd.js +212 -68
- 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 +52 -38
- package/bundles/veloce-sdk.umd.js.map +1 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +11 -17
- 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 +43 -49
- 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/flow.resolver.js +8 -4
- package/esm2015/src/resolvers/quote.resolver.js +4 -11
- package/esm2015/src/services/flow.service.js +6 -5
- package/fesm2015/veloce-sdk-core.js +177 -66
- 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 +44 -39
- 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/flow.resolver.d.ts +3 -1
- package/src/resolvers/quote.resolver.d.ts +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import { HttpErrorResponse } from '@angular/common/http';
|
2
2
|
import { Injectable } from '@angular/core';
|
3
|
-
import { catchError, from, of
|
3
|
+
import { catchError, from, of } from 'rxjs';
|
4
4
|
import * as i0 from "@angular/core";
|
5
5
|
import * as i1 from "@angular/router";
|
6
6
|
import * as i2 from "@veloce/sdk/core";
|
@@ -17,21 +17,14 @@ export class QuoteResolver {
|
|
17
17
|
const parentUrl = this.routerService.getFlowRootPath(route);
|
18
18
|
return from(this.router.navigate([parentUrl, '404'], { state: { message } }));
|
19
19
|
}
|
20
|
-
initFlow$() {
|
21
|
-
if (this.quoteDraftService.isStandalone) {
|
22
|
-
return of(undefined);
|
23
|
-
}
|
24
|
-
return this.flowConfiguration.initialize$();
|
25
|
-
}
|
26
20
|
resolve(route) {
|
27
21
|
const { headerId } = this.contextService.resolve();
|
28
|
-
const quote = this.quoteDraftService.
|
22
|
+
const quote = this.quoteDraftService.quoteDraft;
|
29
23
|
if (quote && quote.quoteId === headerId) {
|
30
24
|
return of(true);
|
31
25
|
}
|
32
26
|
const { queryParams } = route;
|
33
|
-
this.
|
34
|
-
return this.quoteDraftService.init(headerId, queryParams).pipe(switchMap(() => this.initFlow$()), catchError(e => {
|
27
|
+
return this.quoteDraftService.init(headerId, queryParams).pipe(catchError(e => {
|
35
28
|
const message = e instanceof HttpErrorResponse ? e.error.message : e;
|
36
29
|
return this.handleError(route, message);
|
37
30
|
}));
|
@@ -42,4 +35,4 @@ QuoteResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", versio
|
|
42
35
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteResolver, decorators: [{
|
43
36
|
type: Injectable
|
44
37
|
}], ctorParameters: function () { return [{ type: i1.Router }, { type: i2.QuoteDraftService }, { type: i3.FlowRouterService }, { type: i2.ContextService }, { type: i2.FlowConfigurationService }]; } });
|
45
|
-
//# sourceMappingURL=data:application/json;base64,
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVvdGUucmVzb2x2ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL3Nkay9zcmMvcmVzb2x2ZXJzL3F1b3RlLnJlc29sdmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFHM0MsT0FBTyxFQUFFLFVBQVUsRUFBRSxJQUFJLEVBQWMsRUFBRSxFQUFFLE1BQU0sTUFBTSxDQUFDOzs7OztBQUl4RCxNQUFNLE9BQU8sYUFBYTtJQUN4QixZQUNVLE1BQWMsRUFDZCxpQkFBb0MsRUFDcEMsYUFBZ0MsRUFDaEMsY0FBOEIsRUFDOUIsaUJBQTJDO1FBSjNDLFdBQU0sR0FBTixNQUFNLENBQVE7UUFDZCxzQkFBaUIsR0FBakIsaUJBQWlCLENBQW1CO1FBQ3BDLGtCQUFhLEdBQWIsYUFBYSxDQUFtQjtRQUNoQyxtQkFBYyxHQUFkLGNBQWMsQ0FBZ0I7UUFDOUIsc0JBQWlCLEdBQWpCLGlCQUFpQixDQUEwQjtJQUNsRCxDQUFDO0lBRUksV0FBVyxDQUFDLEtBQTZCLEVBQUUsT0FBZTtRQUNoRSxNQUFNLFNBQVMsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLGVBQWUsQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUM1RCxPQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxDQUFDLFNBQVMsRUFBRSxLQUFLLENBQUMsRUFBRS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yb3V0ZSk7XG4gICAgcmV0dXJuIGZyb20odGhpcy5yb3V0ZXIubmF2aWdhdGUoW3BhcmVudFVybCwgJzQwNCddLCB7IHN0YXRlOiB7IG1lc3NhZ2UgfSB9KSk7XG4gIH1cblxuICByZXNvbHZlKHJvdXRlOiBBY3RpdmF0ZWRSb3V0ZVNuYXBzaG90KTogT2JzZXJ2YWJsZTx2b2lkIHwgYm9vbGVhbj4ge1xuICAgIGNvbnN0IHsgaGVhZGVySWQgfSA9IHRoaXMuY29udGV4dFNlcnZpY2UucmVzb2x2ZSgpO1xuICAgIGNvbnN0IHF1b3RlID0gdGhpcy5xdW90ZURyYWZ0U2VydmljZS5xdW90ZURyYWZ0O1xuXG4gICAgaWYgKHF1b3RlICYmIHF1b3RlLnF1b3RlSWQgPT09IGhlYWRlcklkKSB7XG4gICAgICByZXR1cm4gb2YodHJ1ZSk7XG4gICAgfVxuXG4gICAgY29uc3QgeyBxdWVyeVBhcmFtcyB9ID0gcm91dGU7XG5cbiAgICByZXR1cm4gdGhpcy5xdW90ZURyYWZ0U2VydmljZS5pbml0KGhlYWRlcklkLCBxdWVyeVBhcmFtcykucGlwZShcbiAgICAgIGNhdGNoRXJyb3IoZSA9PiB7XG4gICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBlIGluc3RhbmNlb2YgSHR0cEVycm9yUmVzcG9uc2UgPyBlLmVycm9yLm1lc3NhZ2UgOiBlO1xuICAgICAgICByZXR1cm4gdGhpcy5oYW5kbGVFcnJvcihyb3V0ZSwgbWVzc2FnZSk7XG4gICAgICB9KSxcbiAgICApO1xuICB9XG59XG4iXX0=
|
@@ -18,8 +18,8 @@ export class FlowService {
|
|
18
18
|
this.integrationState
|
19
19
|
.listen$(FlowAction.FLOW_CONFIGURE_PRODUCT)
|
20
20
|
.pipe(takeUntil(this.cleanup$), tap(payload => {
|
21
|
-
var _a, _b
|
22
|
-
const productId = (_a = payload.productId) !== null && _a !== void 0 ? _a : (
|
21
|
+
var _a, _b;
|
22
|
+
const productId = (_a = payload.productId) !== null && _a !== void 0 ? _a : (_b = this.quoteDraftService.currentState.find(li => li.id === payload.lineItemId)) === null || _b === void 0 ? void 0 : _b.productId;
|
23
23
|
if (productId) {
|
24
24
|
this.flowRouterService.navigateToProductConfiguration(productId, payload.lineItemId);
|
25
25
|
}
|
@@ -39,7 +39,7 @@ export class FlowService {
|
|
39
39
|
if (!lineItem) {
|
40
40
|
return of(undefined);
|
41
41
|
}
|
42
|
-
const currentState = this.
|
42
|
+
const currentState = this.quoteDraftService.currentState;
|
43
43
|
const isNewLineItem = currentState.every(li => li.id !== lineItem.id);
|
44
44
|
let updatedState;
|
45
45
|
if (isNewLineItem) {
|
@@ -48,7 +48,8 @@ export class FlowService {
|
|
48
48
|
else {
|
49
49
|
updatedState = currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
50
50
|
}
|
51
|
-
|
51
|
+
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
52
|
+
return this.flowConfigurationService.calculate$();
|
52
53
|
}), tap(() => {
|
53
54
|
this.configurationService.hasUnsavedChanges = false;
|
54
55
|
this.flowRouterService.navigateToShoppingCart();
|
@@ -64,4 +65,4 @@ FlowService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version:
|
|
64
65
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowService, decorators: [{
|
65
66
|
type: Injectable
|
66
67
|
}], ctorParameters: function () { return [{ type: i1.IntegrationState }, { type: i2.FlowRouterService }, { type: i3.QuoteDraftService }, { type: i3.ConfigurationService }, { type: i3.FlowConfigurationService }]; } });
|
67
|
-
//# sourceMappingURL=data:application/json;base64,
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmxvdy5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9zZGsvc3J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HVybiB0aGlzLmZsb3dDb25maWd1cmF0aW9uU2VydmljZS5jYWxjdWxhdGUkKCk7XG4gICAgICAgIH0pLFxuICAgICAgICB0YXAoKCkgPT4ge1xuICAgICAgICAgIHRoaXMuY29uZmlndXJhdGlvblNlcnZpY2UuaGFzVW5zYXZlZENoYW5nZXMgPSBmYWxzZTtcbiAgICAgICAgICB0aGlzLmZsb3dSb3V0ZXJTZXJ2aWNlLm5hdmlnYXRlVG9TaG9wcGluZ0NhcnQoKTtcbiAgICAgICAgfSksXG4gICAgICApXG4gICAgICAuc3Vic2NyaWJlKCk7XG4gIH1cblxuICBwdWJsaWMgY2xlYW51cCgpOiB2b2lkIHtcbiAgICB0aGlzLmNsZWFudXAkLm5leHQoKTtcbiAgfVxufVxuIl19
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, NgModule } from '@angular/core';
|
3
3
|
import { UUID, ConfigurationContext, ConfigurationContextMode, RuntimeModel, SalesforceIdUtils, ConfigurationMode } from '@veloce/core';
|
4
|
-
import { BehaviorSubject, map as map$1, distinctUntilChanged, catchError, of, tap as tap$1, zip, combineLatest, throwError, shareReplay
|
5
|
-
import { filter, tap, map, take, first, catchError as catchError$1,
|
4
|
+
import { BehaviorSubject, map as map$1, distinctUntilChanged, catchError, of, tap as tap$1, zip, noop, combineLatest, throwError, shareReplay as shareReplay$1, switchMap as switchMap$1 } from 'rxjs';
|
5
|
+
import { filter, tap, map, switchMap, take, shareReplay, first, catchError as catchError$1, finalize } from 'rxjs/operators';
|
6
6
|
import * as i1 from '@veloce/api';
|
7
7
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloce/api';
|
8
8
|
import { merge, flatten, sortBy, cloneDeep } from 'lodash';
|
@@ -100,57 +100,119 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
100
100
|
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
101
101
|
|
102
102
|
class QuoteDraftService {
|
103
|
-
constructor(context, quoteApiService, priceApiService) {
|
103
|
+
constructor(context, quoteApiService, priceApiService, sfApiService) {
|
104
104
|
this.context = context;
|
105
105
|
this.quoteApiService = quoteApiService;
|
106
106
|
this.priceApiService = priceApiService;
|
107
|
+
this.sfApiService = sfApiService;
|
107
108
|
this.quoteSubj$ = new BehaviorSubject(null);
|
108
109
|
this.resetSubj$ = new BehaviorSubject(true);
|
109
|
-
|
110
|
+
/**
|
111
|
+
* @key pricePlanId
|
112
|
+
* @value priceListId
|
113
|
+
*/
|
114
|
+
this.planIdsMap = {};
|
110
115
|
this.isInitialized = false;
|
116
|
+
this.allPriceLists = [];
|
117
|
+
this.assetPriceLists = [];
|
111
118
|
this.hasUnsavedChanges = false;
|
112
119
|
this.reset$ = this.resetSubj$.asObservable();
|
120
|
+
this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), filter((priceList) => Boolean(priceList)));
|
113
121
|
}
|
114
122
|
reset() {
|
115
123
|
this.resetSubj$.next(true);
|
116
124
|
this.quoteSubj$.next(null);
|
117
125
|
}
|
118
126
|
init(quoteId, params) {
|
119
|
-
return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()
|
127
|
+
return zip(this.context.resolve$(), this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([context, quote, allPriceLists]) => {
|
128
|
+
this.allPriceLists = allPriceLists;
|
120
129
|
this.quoteSubj$.next(quote);
|
121
|
-
this.priceLists = priceLists;
|
122
|
-
this.quotePriceList = priceLists.find(p => p.id === context.properties.PriceListId);
|
123
130
|
this.context.update(Object.assign(Object.assign(Object.assign({}, context), quote.context), { properties: Object.assign(Object.assign({}, context.properties), quote.context.properties) }));
|
124
|
-
}), map(() =>
|
125
|
-
this.isInitialized = true;
|
126
|
-
}), take(1));
|
131
|
+
}), switchMap(() => this.populateActivePriceLists$()), map(() => noop()), tap(() => (this.isInitialized = true)), take(1));
|
127
132
|
}
|
128
133
|
setCurrentLineItemState(lineItems) {
|
129
|
-
const
|
130
|
-
if (!
|
134
|
+
const quoteDraft = this.quoteSubj$.value;
|
135
|
+
if (!quoteDraft) {
|
131
136
|
return;
|
132
137
|
}
|
133
|
-
this.quoteSubj$.next(Object.assign(Object.assign({},
|
138
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
134
139
|
this.markAsUpdated();
|
135
140
|
}
|
141
|
+
updateQuoteDraft(update) {
|
142
|
+
const quoteDraft = this.quoteSubj$.value;
|
143
|
+
if (!quoteDraft) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
if (update.context) {
|
147
|
+
this.context.update(update.context);
|
148
|
+
}
|
149
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
150
|
+
}
|
136
151
|
updateByPriceSummary(priceSummary) {
|
137
|
-
const
|
138
|
-
if (!
|
152
|
+
const quoteDraft = this.quoteSubj$.value;
|
153
|
+
if (!quoteDraft) {
|
139
154
|
return;
|
140
155
|
}
|
141
|
-
this.
|
156
|
+
const updatedCurrentState = this.currentState.map(lineItem => {
|
157
|
+
const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
|
158
|
+
return updated !== null && updated !== void 0 ? updated : lineItem;
|
159
|
+
});
|
160
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
142
161
|
this.markAsUpdated();
|
143
162
|
}
|
144
|
-
get
|
145
|
-
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.
|
163
|
+
get quoteDraft$() {
|
164
|
+
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
146
165
|
}
|
147
|
-
get
|
166
|
+
get quoteDraft() {
|
148
167
|
const quote = this.quoteSubj$.value;
|
149
168
|
if (!quote) {
|
150
169
|
return null;
|
151
170
|
}
|
152
171
|
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
153
172
|
}
|
173
|
+
get currentState$() {
|
174
|
+
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
175
|
+
}
|
176
|
+
get currentState() {
|
177
|
+
var _a, _b;
|
178
|
+
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
179
|
+
}
|
180
|
+
/**
|
181
|
+
* Stream of activeCurrentState
|
182
|
+
*/
|
183
|
+
get activeCurrentState$() {
|
184
|
+
return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
|
185
|
+
}
|
186
|
+
/**
|
187
|
+
* activeCurrentState is currentState passed through additional filters
|
188
|
+
*/
|
189
|
+
get activeCurrentState() {
|
190
|
+
var _a, _b;
|
191
|
+
const ctx = this.context.resolve();
|
192
|
+
let currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
193
|
+
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
194
|
+
currentState = this.filterByActivePriceList(currentState);
|
195
|
+
}
|
196
|
+
return currentState;
|
197
|
+
}
|
198
|
+
/**
|
199
|
+
* Stream of activeInitialState
|
200
|
+
*/
|
201
|
+
get activeInitialState$() {
|
202
|
+
return this.quoteDraft$.pipe(map(() => this.activeInitialState));
|
203
|
+
}
|
204
|
+
/**
|
205
|
+
* activeInitialState is initialState passed through additional filters
|
206
|
+
*/
|
207
|
+
get activeInitialState() {
|
208
|
+
var _a, _b;
|
209
|
+
const ctx = this.context.resolve();
|
210
|
+
let initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
211
|
+
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
212
|
+
initialState = this.filterByActivePriceList(initialState);
|
213
|
+
}
|
214
|
+
return initialState;
|
215
|
+
}
|
154
216
|
get isStandalone() {
|
155
217
|
return this.context.resolve().properties.standalone === 'true';
|
156
218
|
}
|
@@ -167,18 +229,72 @@ class QuoteDraftService {
|
|
167
229
|
}
|
168
230
|
return false;
|
169
231
|
}
|
232
|
+
updateActivePriceList(priceListId) {
|
233
|
+
this.context.update({ properties: { PriceListId: priceListId } });
|
234
|
+
}
|
235
|
+
/**
|
236
|
+
* Query PricePlan infos for the assets
|
237
|
+
* TODO: remove when backend will send priceListId for assets
|
238
|
+
*/
|
239
|
+
getAssetsPlanInfos$(quoteDraft) {
|
240
|
+
var _a;
|
241
|
+
const pricePlanIds = (_a = quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.initialState.map(li => li.planId).filter((id) => typeof id === 'string').filter((item, i, arr) => arr.indexOf(item) === i)) !== null && _a !== void 0 ? _a : [];
|
242
|
+
if (!pricePlanIds.length) {
|
243
|
+
return of([]);
|
244
|
+
}
|
245
|
+
const priceListIdFieldName = 'VELOCPQ__PriceListId__c';
|
246
|
+
const searchRequest = {
|
247
|
+
rawCondition: `Id in ('${pricePlanIds.join("','")}')`,
|
248
|
+
fields: ['Id', priceListIdFieldName],
|
249
|
+
};
|
250
|
+
return this.sfApiService
|
251
|
+
.query(searchRequest, 'VELOCPQ__PricePlan__c')
|
252
|
+
.pipe(map(result => result.map(item => ({ id: item.Id, priceListId: item[priceListIdFieldName] })).filter(Boolean)));
|
253
|
+
}
|
254
|
+
populateActivePriceLists$() {
|
255
|
+
const ctx = this.context.resolve();
|
256
|
+
const quoteDraft = this.quoteDraft;
|
257
|
+
if (!quoteDraft) {
|
258
|
+
return of(undefined);
|
259
|
+
}
|
260
|
+
// In ACCOUNT mode populate price lists from related assets
|
261
|
+
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
262
|
+
return this.getAssetsPlanInfos$(quoteDraft).pipe(tap(pricePlanInfos => {
|
263
|
+
this.assetPriceLists = pricePlanInfos.map(item => {
|
264
|
+
var _a, _b;
|
265
|
+
return ({
|
266
|
+
id: item.priceListId,
|
267
|
+
name: (_b = (_a = this.allPriceLists.find(priceList => priceList.id === item.priceListId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
268
|
+
});
|
269
|
+
});
|
270
|
+
this.planIdsMap = pricePlanInfos.reduce((trunk, item) => (Object.assign(Object.assign({}, trunk), { [item.id]: item.priceListId })), {});
|
271
|
+
const activePriceList = this.assetPriceLists[0];
|
272
|
+
this.updateActivePriceList(activePriceList.id);
|
273
|
+
// Update PriceListId in context properties
|
274
|
+
// TODO: remove it when backend will have such logic
|
275
|
+
if (this.assetPriceLists.length) {
|
276
|
+
this.context.update({ properties: { PriceListId: activePriceList.id } });
|
277
|
+
}
|
278
|
+
}), map(noop));
|
279
|
+
}
|
280
|
+
return of(undefined);
|
281
|
+
}
|
282
|
+
filterByActivePriceList(lineItems) {
|
283
|
+
const ctx = this.context.resolve();
|
284
|
+
return lineItems.filter(li => !li.planId || this.planIdsMap[li.planId] === ctx.properties.PriceListId);
|
285
|
+
}
|
170
286
|
markAsUpdated() {
|
171
287
|
if (this.isInitialized && !this.hasUnsavedChanges) {
|
172
288
|
this.hasUnsavedChanges = true;
|
173
289
|
}
|
174
290
|
}
|
175
291
|
}
|
176
|
-
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
292
|
+
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }, { token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
177
293
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
|
178
294
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, decorators: [{
|
179
295
|
type: Injectable,
|
180
296
|
args: [{ providedIn: 'root' }]
|
181
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
|
297
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: i1.SalesforceApiService }]; } });
|
182
298
|
|
183
299
|
class RuntimeContextService {
|
184
300
|
constructor(configurationApiService, messageService) {
|
@@ -498,7 +614,7 @@ class ConfigurationService {
|
|
498
614
|
this.states = Object.assign(Object.assign({}, this.states), update);
|
499
615
|
}
|
500
616
|
get() {
|
501
|
-
return this.lineItem.asObservable().pipe(shareReplay());
|
617
|
+
return this.lineItem.asObservable().pipe(shareReplay$1());
|
502
618
|
}
|
503
619
|
getSnapshot() {
|
504
620
|
return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
|
@@ -532,8 +648,6 @@ class ConfigurationService {
|
|
532
648
|
const qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
|
533
649
|
const lineItem = (_e = this.states.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
|
534
650
|
const configurationRequest = this.createRequest(lineItem);
|
535
|
-
configurationRequest.lineItems = this.states.currentState || [];
|
536
|
-
configurationRequest.asset = this.states.asset;
|
537
651
|
const mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
|
538
652
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
539
653
|
return this.configurationApiService
|
@@ -565,6 +679,8 @@ class ConfigurationService {
|
|
565
679
|
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
566
680
|
attributeDomainMode: 'ALL',
|
567
681
|
context: this.contextService.resolve(),
|
682
|
+
lineItems: this.states.currentState || [],
|
683
|
+
asset: this.states.asset,
|
568
684
|
};
|
569
685
|
}
|
570
686
|
showInactiveProductsConfirmation() {
|
@@ -709,70 +825,65 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
709
825
|
}] });
|
710
826
|
|
711
827
|
class FlowConfigurationService {
|
712
|
-
constructor(
|
713
|
-
this.
|
828
|
+
constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
|
829
|
+
this.proceduresApiService = proceduresApiService;
|
714
830
|
this.contextService = contextService;
|
715
831
|
this.quoteDraftService = quoteDraftService;
|
716
|
-
this.messageService = messageService;
|
717
832
|
this.updateService = updateService;
|
718
833
|
this.configurationService = configurationService;
|
719
|
-
this.charges = new BehaviorSubject({});
|
720
|
-
this.bounceBackUpdate$ = new BehaviorSubject(true);
|
721
834
|
}
|
722
|
-
|
723
|
-
this.
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
this.resetSubscription = this.quoteDraftService.reset$.subscribe(() => this.reset());
|
729
|
-
return this.calculate$(this.getSnapshot()).pipe(map$1(noop));
|
730
|
-
}
|
731
|
-
calculate$(currentState) {
|
732
|
-
const context = this.contextService.resolve();
|
733
|
-
return this.priceApiService.calculate({ context, currentState }).pipe(tap$1((result) => {
|
734
|
-
this.quoteDraftService.updateByPriceSummary(result);
|
735
|
-
this.charges.next(result.charges);
|
736
|
-
if (context) {
|
737
|
-
this.contextService.update({ properties: context.properties });
|
738
|
-
}
|
739
|
-
}), this.handleError());
|
835
|
+
calculate$() {
|
836
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
837
|
+
if (!quoteDraft || !quoteDraft.currentState.length) {
|
838
|
+
return of(undefined);
|
839
|
+
}
|
840
|
+
return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => this.quoteDraftService.updateQuoteDraft(result)), map$1(noop));
|
740
841
|
}
|
741
|
-
calculate(
|
742
|
-
this.calculate$(
|
842
|
+
calculate() {
|
843
|
+
this.calculate$().subscribe();
|
743
844
|
}
|
744
845
|
update$(updates) {
|
745
|
-
const
|
746
|
-
return of([]).pipe(tap$1(() =>
|
846
|
+
const currentState = this.quoteDraftService.currentState;
|
847
|
+
return of([]).pipe(tap$1(() => {
|
848
|
+
const updatedState = cloneDeep(currentState);
|
849
|
+
this.updateService.update(updatedState, updates);
|
850
|
+
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
851
|
+
}), switchMap$1(() => this.calculate$()), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack(currentState));
|
747
852
|
}
|
748
853
|
update(updates) {
|
749
854
|
this.update$(updates).subscribe();
|
750
855
|
}
|
751
856
|
delete$(ids) {
|
752
|
-
|
857
|
+
const currentState = this.quoteDraftService.currentState;
|
858
|
+
return of([]).pipe(tap$1(() => {
|
859
|
+
const updatedState = ids.reduce((result, id) => this.updateService.delete(result, id), currentState);
|
860
|
+
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
861
|
+
}), switchMap$1(() => this.calculate$()), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack(currentState));
|
753
862
|
}
|
754
863
|
delete(ids) {
|
755
864
|
this.delete$(ids).subscribe();
|
756
865
|
}
|
757
|
-
|
758
|
-
|
866
|
+
addTerm$(term) {
|
867
|
+
const currentState = this.quoteDraftService.currentState;
|
868
|
+
return of([]).pipe(tap$1(() => this.quoteDraftService.setCurrentLineItemState([...currentState, term])), switchMap$1(() => this.calculate$()), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack(currentState));
|
759
869
|
}
|
760
870
|
addToCart$(productId, qty) {
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
871
|
+
const currentState = this.quoteDraftService.currentState;
|
872
|
+
return this.configurationService.configureExternal$(productId, qty).pipe(tap$1(lineItem => this.quoteDraftService.setCurrentLineItemState([...currentState, lineItem])), switchMap$1(() => this.calculate$()), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack(currentState));
|
873
|
+
}
|
874
|
+
get() {
|
875
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
|
766
876
|
}
|
767
877
|
getSnapshot() {
|
768
878
|
var _a, _b;
|
769
|
-
return (_b = (_a = this.quoteDraftService
|
879
|
+
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
770
880
|
}
|
771
881
|
get charges$() {
|
772
|
-
return this.
|
882
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
|
773
883
|
}
|
774
884
|
get chargesSnapshot() {
|
775
|
-
|
885
|
+
var _a, _b;
|
886
|
+
return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
776
887
|
}
|
777
888
|
get contextSnapshot() {
|
778
889
|
return this.contextService.resolve();
|
@@ -780,22 +891,22 @@ class FlowConfigurationService {
|
|
780
891
|
get context$() {
|
781
892
|
return this.contextService.resolve$();
|
782
893
|
}
|
783
|
-
|
894
|
+
handleErrorAndBounceBack(stateToRestore) {
|
784
895
|
return (source$) => {
|
785
896
|
return source$.pipe(catchError(error => {
|
786
897
|
console.error(error);
|
787
898
|
// bounce back if configuration call has failed
|
788
|
-
this.
|
899
|
+
this.quoteDraftService.setCurrentLineItemState(stateToRestore);
|
789
900
|
return throwError(() => error);
|
790
901
|
}));
|
791
902
|
};
|
792
903
|
}
|
793
904
|
}
|
794
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.
|
905
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
795
906
|
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService });
|
796
907
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
797
908
|
type: Injectable
|
798
|
-
}], ctorParameters: function () { return [{ type: i1.
|
909
|
+
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
799
910
|
|
800
911
|
class FlowConfigurationModule {
|
801
912
|
}
|