@veloceapps/sdk 3.1.17-1 → 3.1.18
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 +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
@@ -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 : (_b = this.quoteDraftService.currentState.find(li => li.id === payload.lineItemId)) === null ||
|
21
|
+
var _a, _b, _c;
|
22
|
+
const productId = (_a = payload.productId) !== null && _a !== void 0 ? _a : (_c = (_b = this.quoteDraftService.quoteSnapshot) === null || _b === void 0 ? void 0 : _b.currentState.find(li => li.id === payload.lineItemId)) === null || _c === void 0 ? void 0 : _c.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.flowConfigurationService.getSnapshot();
|
43
43
|
const isNewLineItem = currentState.every(li => li.id !== lineItem.id);
|
44
44
|
let updatedState;
|
45
45
|
if (isNewLineItem) {
|
@@ -48,8 +48,7 @@ export class FlowService {
|
|
48
48
|
else {
|
49
49
|
updatedState = currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
50
50
|
}
|
51
|
-
this.
|
52
|
-
return this.flowConfigurationService.calculate$();
|
51
|
+
return this.flowConfigurationService.calculate$(updatedState);
|
53
52
|
}), tap(() => {
|
54
53
|
this.configurationService.hasUnsavedChanges = false;
|
55
54
|
this.flowRouterService.navigateToShoppingCart();
|
@@ -65,4 +64,4 @@ FlowService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version:
|
|
65
64
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowService, decorators: [{
|
66
65
|
type: Injectable
|
67
66
|
}], ctorParameters: function () { return [{ type: i1.IntegrationState }, { type: i2.FlowRouterService }, { type: i3.QuoteDraftService }, { type: i3.ConfigurationService }, { type: i3.FlowConfigurationService }]; } });
|
68
|
-
//# sourceMappingURL=data:application/json;base64,
|
67
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmxvdy5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9zZGsvc3JjL3NlcnZpY2VzL2Zsb3cuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRTNDLE9BQU8sRUFBRSxVQUFVLEVBQW9CLE1BQU0saUJBQWlCLENBQUM7QUFFL0QsT0FBTyxFQUFFLEVBQUUsRUFBRSxPQUFPLEVBQUUsU0FBUyxFQUFFLFNBQVMsRUFBRSxHQUFHLEVBQUUsTUFBTSxNQUFNLENBQUM7Ozs7O0FBSTlELE1BQU0sT0FBTyxXQUFXO0lBR3RCLFlBQ1UsZ0JBQWtDLEVBQ2xDLGlCQUFvQyxFQUNwQyxpQkFBb0MsRUFDcEMsb0JBQTBDLEVBQzFDLHdCQUFrRDtRQUpsRCxxQkFBZ0IsR0FBaEIsZ0JBQWdCLENBQWtCO1FBQ2xDLHNCQUFpQixHQUFqQixpQkFBaUIsQ0FBbUI7UUFDcEMsc0JBQWlCLEdBQWpCLGlCQUFpQixDQUFtQjtRQUNwQyx5QkFBb0IsR0FBcEIsb0JBQW9CLENBQXNCO1FBQzFDLDZCQUF3QixHQUF4Qix3QkFBd0IsQ0FBMEI7UUFQcEQsYUFBUSxHQUFHLElBQUksT0FBTyxFQUFRLENBQUM7SUFRcEMsQ0FBQztJQUVHLGlCQUFpQjtRQUN0QixJQUFJLENBQUMsZ0JBQWdCO2FBQ2xCLE9BQU8sQ0FBOEMsVUFBVSxDQUFDLH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Ul0ZW1dO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB1cGRhdGVkU3RhdGUgPSBjdXJyZW50U3RhdGUubWFwKGxpID0+IChsaS5pZCA9PT0gbGluZUl0ZW0uaWQgPyBsaW5lSXRlbSA6IGxpKSk7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgcmV0dXJuIHRoaXMuZmxvd0NvbmZpZ3VyYXRpb25TZXJ2aWNlLmNhbGN1bGF0ZSQodXBkYXRlZFN0YXRlKTtcbiAgICAgICAgfSksXG4gICAgICAgIHRhcCgoKSA9PiB7XG4gICAgICAgICAgdGhpcy5jb25maWd1cmF0aW9uU2VydmljZS5oYXNVbnNhdmVkQ2hhbmdlcyA9IGZhbHNlO1xuICAgICAgICAgIHRoaXMuZmxvd1JvdXRlclNlcnZpY2UubmF2aWdhdGVUb1Nob3BwaW5nQ2FydCgpO1xuICAgICAgICB9KSxcbiAgICAgIClcbiAgICAgIC5zdWJzY3JpYmUoKTtcbiAgfVxuXG4gIHB1YmxpYyBjbGVhbnVwKCk6IHZvaWQge1xuICAgIHRoaXMuY2xlYW51cCQubmV4dCgpO1xuICB9XG59XG4iXX0=
|
@@ -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,
|
5
|
-
import { filter, tap, map,
|
4
|
+
import { BehaviorSubject, map as map$1, distinctUntilChanged, catchError, of, tap as tap$1, zip, combineLatest, throwError, shareReplay, noop, switchMap as switchMap$1 } from 'rxjs';
|
5
|
+
import { filter, tap, map, take, first, catchError as catchError$1, switchMap, 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,119 +100,57 @@ 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) {
|
104
104
|
this.context = context;
|
105
105
|
this.quoteApiService = quoteApiService;
|
106
106
|
this.priceApiService = priceApiService;
|
107
|
-
this.sfApiService = sfApiService;
|
108
107
|
this.quoteSubj$ = new BehaviorSubject(null);
|
109
108
|
this.resetSubj$ = new BehaviorSubject(true);
|
110
|
-
|
111
|
-
* @key pricePlanId
|
112
|
-
* @value priceListId
|
113
|
-
*/
|
114
|
-
this.planIdsMap = {};
|
109
|
+
this.priceLists = [];
|
115
110
|
this.isInitialized = false;
|
116
|
-
this.allPriceLists = [];
|
117
|
-
this.assetPriceLists = [];
|
118
111
|
this.hasUnsavedChanges = false;
|
119
112
|
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)));
|
121
113
|
}
|
122
114
|
reset() {
|
123
115
|
this.resetSubj$.next(true);
|
124
116
|
this.quoteSubj$.next(null);
|
125
117
|
}
|
126
118
|
init(quoteId, params) {
|
127
|
-
return zip(this.
|
128
|
-
this.allPriceLists = allPriceLists;
|
119
|
+
return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists(), this.context.resolve$()).pipe(tap(([quote, priceLists, context]) => {
|
129
120
|
this.quoteSubj$.next(quote);
|
121
|
+
this.priceLists = priceLists;
|
122
|
+
this.quotePriceList = priceLists.find(p => p.id === context.properties.PriceListId);
|
130
123
|
this.context.update(Object.assign(Object.assign(Object.assign({}, context), quote.context), { properties: Object.assign(Object.assign({}, context.properties), quote.context.properties) }));
|
131
|
-
}),
|
124
|
+
}), map(() => {
|
125
|
+
this.isInitialized = true;
|
126
|
+
}), take(1));
|
132
127
|
}
|
133
128
|
setCurrentLineItemState(lineItems) {
|
134
|
-
const
|
135
|
-
if (!
|
129
|
+
const quote = this.quoteSubj$.value;
|
130
|
+
if (!quote) {
|
136
131
|
return;
|
137
132
|
}
|
138
|
-
this.quoteSubj$.next(Object.assign(Object.assign({},
|
133
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quote), { currentState: lineItems }));
|
139
134
|
this.markAsUpdated();
|
140
135
|
}
|
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
|
-
}
|
151
136
|
updateByPriceSummary(priceSummary) {
|
152
|
-
const
|
153
|
-
if (!
|
137
|
+
const quote = this.quoteSubj$.value;
|
138
|
+
if (!quote) {
|
154
139
|
return;
|
155
140
|
}
|
156
|
-
|
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 }));
|
141
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quote), { currentState: priceSummary.lineItems, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
161
142
|
this.markAsUpdated();
|
162
143
|
}
|
163
|
-
get
|
164
|
-
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.
|
144
|
+
get quote$() {
|
145
|
+
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteSnapshot), filter((quote) => Boolean(quote)));
|
165
146
|
}
|
166
|
-
get
|
147
|
+
get quoteSnapshot() {
|
167
148
|
const quote = this.quoteSubj$.value;
|
168
149
|
if (!quote) {
|
169
150
|
return null;
|
170
151
|
}
|
171
152
|
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
172
153
|
}
|
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
|
-
}
|
216
154
|
get isStandalone() {
|
217
155
|
return this.context.resolve().properties.standalone === 'true';
|
218
156
|
}
|
@@ -229,72 +167,18 @@ class QuoteDraftService {
|
|
229
167
|
}
|
230
168
|
return false;
|
231
169
|
}
|
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
|
-
}
|
286
170
|
markAsUpdated() {
|
287
171
|
if (this.isInitialized && !this.hasUnsavedChanges) {
|
288
172
|
this.hasUnsavedChanges = true;
|
289
173
|
}
|
290
174
|
}
|
291
175
|
}
|
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 }
|
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 });
|
293
177
|
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
|
294
178
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, decorators: [{
|
295
179
|
type: Injectable,
|
296
180
|
args: [{ providedIn: 'root' }]
|
297
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }
|
181
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
|
298
182
|
|
299
183
|
class RuntimeContextService {
|
300
184
|
constructor(configurationApiService, messageService) {
|
@@ -614,7 +498,7 @@ class ConfigurationService {
|
|
614
498
|
this.states = Object.assign(Object.assign({}, this.states), update);
|
615
499
|
}
|
616
500
|
get() {
|
617
|
-
return this.lineItem.asObservable().pipe(shareReplay
|
501
|
+
return this.lineItem.asObservable().pipe(shareReplay());
|
618
502
|
}
|
619
503
|
getSnapshot() {
|
620
504
|
return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
|
@@ -648,6 +532,8 @@ class ConfigurationService {
|
|
648
532
|
const qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
|
649
533
|
const lineItem = (_e = this.states.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
|
650
534
|
const configurationRequest = this.createRequest(lineItem);
|
535
|
+
configurationRequest.lineItems = this.states.currentState || [];
|
536
|
+
configurationRequest.asset = this.states.asset;
|
651
537
|
const mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
|
652
538
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
653
539
|
return this.configurationApiService
|
@@ -679,8 +565,6 @@ class ConfigurationService {
|
|
679
565
|
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
680
566
|
attributeDomainMode: 'ALL',
|
681
567
|
context: this.contextService.resolve(),
|
682
|
-
lineItems: this.states.currentState || [],
|
683
|
-
asset: this.states.asset,
|
684
568
|
};
|
685
569
|
}
|
686
570
|
showInactiveProductsConfirmation() {
|
@@ -825,65 +709,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
825
709
|
}] });
|
826
710
|
|
827
711
|
class FlowConfigurationService {
|
828
|
-
constructor(
|
829
|
-
this.
|
712
|
+
constructor(priceApiService, contextService, quoteDraftService, messageService, updateService, configurationService) {
|
713
|
+
this.priceApiService = priceApiService;
|
830
714
|
this.contextService = contextService;
|
831
715
|
this.quoteDraftService = quoteDraftService;
|
716
|
+
this.messageService = messageService;
|
832
717
|
this.updateService = updateService;
|
833
718
|
this.configurationService = configurationService;
|
719
|
+
this.charges = new BehaviorSubject({});
|
720
|
+
this.bounceBackUpdate$ = new BehaviorSubject(true);
|
834
721
|
}
|
835
|
-
|
836
|
-
|
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));
|
722
|
+
reset() {
|
723
|
+
this.charges.next({});
|
841
724
|
}
|
842
|
-
|
843
|
-
|
725
|
+
initialize$() {
|
726
|
+
var _a;
|
727
|
+
(_a = this.resetSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
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());
|
740
|
+
}
|
741
|
+
calculate(currentState) {
|
742
|
+
this.calculate$(currentState).subscribe();
|
844
743
|
}
|
845
744
|
update$(updates) {
|
846
|
-
const
|
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));
|
745
|
+
const lineItems = cloneDeep(this.getSnapshot());
|
746
|
+
return of([]).pipe(tap$1(() => this.updateService.update(lineItems, updates)), this.handleError(), switchMap$1(() => this.calculate$(lineItems)));
|
852
747
|
}
|
853
748
|
update(updates) {
|
854
749
|
this.update$(updates).subscribe();
|
855
750
|
}
|
856
751
|
delete$(ids) {
|
857
|
-
|
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));
|
752
|
+
return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), this.getSnapshot())), this.handleError(), switchMap$1(currentState => this.calculate$(currentState)));
|
862
753
|
}
|
863
754
|
delete(ids) {
|
864
755
|
this.delete$(ids).subscribe();
|
865
756
|
}
|
866
|
-
|
867
|
-
|
868
|
-
return of([]).pipe(tap$1(() => this.quoteDraftService.setCurrentLineItemState([...currentState, term])), switchMap$1(() => this.calculate$()), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack(currentState));
|
757
|
+
get() {
|
758
|
+
return combineLatest([this.quoteDraftService.quote$, this.bounceBackUpdate$]).pipe(map$1(([quoteDraft]) => quoteDraft.currentState), shareReplay());
|
869
759
|
}
|
870
760
|
addToCart$(productId, qty) {
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
761
|
+
return this.configurationService.configureExternal$(productId, qty).pipe(tap$1(lineItem => {
|
762
|
+
var _a, _b;
|
763
|
+
const currentState = (_b = (_a = this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
764
|
+
this.quoteDraftService.setCurrentLineItemState([...currentState, lineItem]);
|
765
|
+
}), map$1(noop));
|
876
766
|
}
|
877
767
|
getSnapshot() {
|
878
768
|
var _a, _b;
|
879
|
-
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
769
|
+
return (_b = (_a = this.quoteDraftService.quoteSnapshot) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
880
770
|
}
|
881
771
|
get charges$() {
|
882
|
-
return this.
|
772
|
+
return this.charges.asObservable();
|
883
773
|
}
|
884
774
|
get chargesSnapshot() {
|
885
|
-
|
886
|
-
return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
775
|
+
return this.charges.value;
|
887
776
|
}
|
888
777
|
get contextSnapshot() {
|
889
778
|
return this.contextService.resolve();
|
@@ -891,22 +780,22 @@ class FlowConfigurationService {
|
|
891
780
|
get context$() {
|
892
781
|
return this.contextService.resolve$();
|
893
782
|
}
|
894
|
-
|
783
|
+
handleError() {
|
895
784
|
return (source$) => {
|
896
785
|
return source$.pipe(catchError(error => {
|
897
786
|
console.error(error);
|
898
787
|
// bounce back if configuration call has failed
|
899
|
-
this.
|
788
|
+
this.bounceBackUpdate$.next(true);
|
900
789
|
return throwError(() => error);
|
901
790
|
}));
|
902
791
|
};
|
903
792
|
}
|
904
793
|
}
|
905
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.
|
794
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.PriceApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: i2.MessageService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
906
795
|
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService });
|
907
796
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
908
797
|
type: Injectable
|
909
|
-
}], ctorParameters: function () { return [{ type: i1.
|
798
|
+
}], ctorParameters: function () { return [{ type: i1.PriceApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: i2.MessageService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
910
799
|
|
911
800
|
class FlowConfigurationModule {
|
912
801
|
}
|