@veloceapps/sdk 11.0.0-13 → 11.0.0-15
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/esm2020/core/services/sales-transaction.service.mjs +3 -3
- package/esm2020/src/flow-routing.module.mjs +3 -2
- package/esm2020/src/pages/product/product.component.mjs +14 -68
- package/esm2020/src/resolvers/ui-definition.resolver.mjs +41 -0
- package/fesm2015/veloceapps-sdk-core.mjs +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +47 -66
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +47 -63
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/pages/product/product.component.d.ts +5 -12
- package/src/resolvers/ui-definition.resolver.d.ts +3 -0
@@ -13,8 +13,9 @@ import { FLOW_CUSTOMIZATION, RuntimeSettingsService, FlowStateService, FlowInfoS
|
|
13
13
|
import * as i3 from 'primeng/button';
|
14
14
|
import { ButtonModule } from 'primeng/button';
|
15
15
|
import * as i1 from 'primeng/dynamicdialog';
|
16
|
-
import { BehaviorSubject, Subject, filter, first, tap, takeUntil, catchError, of, map, switchMap, shareReplay, startWith, distinctUntilChanged, from, take, combineLatest
|
16
|
+
import { BehaviorSubject, Subject, filter, first, tap, takeUntil, catchError, of, map, switchMap, shareReplay, startWith, distinctUntilChanged, from, take, combineLatest } from 'rxjs';
|
17
17
|
import * as i1$1 from '@veloceapps/api/v2';
|
18
|
+
import { UIDefinitionsApiService } from '@veloceapps/api/v2';
|
18
19
|
import { DomHandler } from 'primeng/dom';
|
19
20
|
import * as i1$2 from '@angular/router';
|
20
21
|
import { NavigationEnd, NavigationStart, NavigationCancel, NavigationError, RouterModule } from '@angular/router';
|
@@ -1167,83 +1168,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1167
1168
|
}] });
|
1168
1169
|
|
1169
1170
|
class ProductComponent {
|
1170
|
-
constructor(
|
1171
|
-
|
1172
|
-
configurationService, configurationStateService, salesTransactionService, flowInfoService, integrationState, uiDefinitionsApiService, customizationService) {
|
1173
|
-
this.configurationService = configurationService;
|
1171
|
+
constructor(route, configurationStateService) {
|
1172
|
+
this.route = route;
|
1174
1173
|
this.configurationStateService = configurationStateService;
|
1175
|
-
this.salesTransactionService = salesTransactionService;
|
1176
|
-
this.flowInfoService = flowInfoService;
|
1177
|
-
this.integrationState = integrationState;
|
1178
|
-
this.uiDefinitionsApiService = uiDefinitionsApiService;
|
1179
|
-
this.customizationService = customizationService;
|
1180
1174
|
this.uiDefinitionContainer$ = new BehaviorSubject(null);
|
1175
|
+
const uiDefContainer = this.route.snapshot.data['uiDef'];
|
1176
|
+
this.uiDefinitionContainer$.next(uiDefContainer);
|
1181
1177
|
this.config = {
|
1182
1178
|
init$: () => this.init$(),
|
1183
1179
|
};
|
1184
1180
|
}
|
1185
|
-
customizeUI$() {
|
1186
|
-
var _a;
|
1187
|
-
const { productId } = this.flowInfoService.context;
|
1188
|
-
if (!productId || !((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getUiDefinition)) {
|
1189
|
-
return of(undefined);
|
1190
|
-
}
|
1191
|
-
return this.customizationService.getUiDefinition(productId).pipe(map(uiDefinitionContainer => {
|
1192
|
-
this.uiDefinitionContainer$.next(uiDefinitionContainer);
|
1193
|
-
}));
|
1194
|
-
}
|
1195
|
-
fetchUIDefinition$() {
|
1196
|
-
const flowContext = this.flowInfoService.context;
|
1197
|
-
if (flowContext.requiredUIDefinitionId) {
|
1198
|
-
return this.uiDefinitionsApiService
|
1199
|
-
.fetchUIDefinition$(flowContext.requiredUIDefinitionId)
|
1200
|
-
.pipe(map((uiDefContainer) => this.uiDefinitionContainer$.next(uiDefContainer)));
|
1201
|
-
}
|
1202
|
-
return this.uiDefinitionsApiService
|
1203
|
-
.fetchUIDefinitions$({
|
1204
|
-
productId: flowContext.productId,
|
1205
|
-
defaultUIDefinitionId: flowContext.defaultUIDefinitionId,
|
1206
|
-
})
|
1207
|
-
.pipe(map((uiDefinitionContainers) => {
|
1208
|
-
const uiDefContainer = uiDefinitionContainers[0];
|
1209
|
-
if (uiDefContainer) {
|
1210
|
-
this.uiDefinitionContainer$.next(uiDefContainer);
|
1211
|
-
}
|
1212
|
-
}));
|
1213
|
-
}
|
1214
1181
|
init$() {
|
1215
|
-
|
1216
|
-
if (!this.flowInfoService.isStateful) {
|
1217
|
-
state$ = this.salesTransactionService.state$;
|
1218
|
-
}
|
1219
|
-
else {
|
1220
|
-
state$ = of(undefined);
|
1221
|
-
}
|
1222
|
-
return state$.pipe(first(), tap(() => {
|
1223
|
-
if (!this.flowInfoService.context.productId) {
|
1224
|
-
throw new Error(`Unable to start configuration for 'productId == null'`);
|
1225
|
-
}
|
1226
|
-
}), switchMap(() => this.customizeUI$()), switchMap(() => (this.uiDefinitionContainer$.value ? of(undefined) : this.fetchUIDefinition$())), tap(() => {
|
1227
|
-
if (!this.uiDefinitionContainer$.value) {
|
1228
|
-
throw new Error('Product does not have Configuration UI');
|
1229
|
-
}
|
1230
|
-
}), switchMap(() => this.configurationStateService.init$()), switchMap(() => timer(1)), // wait until updates inputs on child components
|
1231
|
-
map(noop));
|
1182
|
+
return this.configurationStateService.init$();
|
1232
1183
|
}
|
1233
1184
|
}
|
1234
|
-
ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, deps: [{ token:
|
1185
|
+
ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, deps: [{ token: i1$2.ActivatedRoute }, { token: i2.ConfigurationStateService }], target: i0.ɵɵFactoryTarget.Component });
|
1235
1186
|
ProductComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ProductComponent, selector: "vl-flow-product", ngImport: i0, template: "<vl-cms-preview [uiDefinition]=\"(uiDefinitionContainer$ | async)?.source\" [config]=\"config\"></vl-cms-preview>\n", styles: [""], dependencies: [{ kind: "component", type: i5.PreviewComponent, selector: "vl-cms-preview", inputs: ["uiDefinition", "config"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
1236
1187
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, decorators: [{
|
1237
1188
|
type: Component,
|
1238
1189
|
args: [{ selector: 'vl-flow-product', changeDetection: ChangeDetectionStrategy.OnPush, template: "<vl-cms-preview [uiDefinition]=\"(uiDefinitionContainer$ | async)?.source\" [config]=\"config\"></vl-cms-preview>\n" }]
|
1239
|
-
}], ctorParameters: function () {
|
1240
|
-
return [{ type: i2.ConfigurationService }, { type: i2.ConfigurationStateService }, { type: i2.SalesTransactionService }, { type: i2.FlowInfoService }, { type: i2.IntegrationState }, { type: i1$1.UIDefinitionsApiService }, { type: undefined, decorators: [{
|
1241
|
-
type: Optional
|
1242
|
-
}, {
|
1243
|
-
type: Inject,
|
1244
|
-
args: [FLOW_CUSTOMIZATION]
|
1245
|
-
}] }];
|
1246
|
-
} });
|
1190
|
+
}], ctorParameters: function () { return [{ type: i1$2.ActivatedRoute }, { type: i2.ConfigurationStateService }]; } });
|
1247
1191
|
|
1248
1192
|
class ProductModule {
|
1249
1193
|
}
|
@@ -1516,6 +1460,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1516
1460
|
type: Injectable
|
1517
1461
|
}], ctorParameters: function () { return [{ type: i1$2.Router }, { type: i2.QuoteDraftService }, { type: FlowRouterService }, { type: i2.FlowInfoService }, { type: i2.FlowStateService }]; } });
|
1518
1462
|
|
1463
|
+
const resolveUIDefinition = () => {
|
1464
|
+
const customizationService = inject(FLOW_CUSTOMIZATION, { optional: true });
|
1465
|
+
const flowInfoService = inject(FlowInfoService);
|
1466
|
+
const uiDefinitionsApiService = inject(UIDefinitionsApiService);
|
1467
|
+
const { productId } = flowInfoService.context;
|
1468
|
+
if (!productId) {
|
1469
|
+
throw new Error(`Unable to start configuration for 'productId == null'`);
|
1470
|
+
}
|
1471
|
+
return of(undefined).pipe(switchMap(() => {
|
1472
|
+
// Try resolving via customization service
|
1473
|
+
if (!productId || !(customizationService === null || customizationService === void 0 ? void 0 : customizationService.getUiDefinition)) {
|
1474
|
+
return of(undefined);
|
1475
|
+
}
|
1476
|
+
return customizationService.getUiDefinition(productId);
|
1477
|
+
}), switchMap(uiDefContainer => {
|
1478
|
+
// Resolve UIDefinition from the org
|
1479
|
+
if (uiDefContainer) {
|
1480
|
+
return of(uiDefContainer);
|
1481
|
+
}
|
1482
|
+
if (flowInfoService.context.requiredUIDefinitionId) {
|
1483
|
+
return uiDefinitionsApiService.fetchUIDefinition$(flowInfoService.context.requiredUIDefinitionId);
|
1484
|
+
}
|
1485
|
+
return uiDefinitionsApiService
|
1486
|
+
.fetchUIDefinitions$({
|
1487
|
+
productId,
|
1488
|
+
defaultUIDefinitionId: flowInfoService.context.defaultUIDefinitionId,
|
1489
|
+
})
|
1490
|
+
.pipe(map((uiDefinitionContainers) => {
|
1491
|
+
const uiDefContainer = uiDefinitionContainers[0];
|
1492
|
+
if (!uiDefContainer) {
|
1493
|
+
throw new Error(`UI Definition for productId=${productId} is not resolved`);
|
1494
|
+
}
|
1495
|
+
return uiDefContainer;
|
1496
|
+
}));
|
1497
|
+
}));
|
1498
|
+
};
|
1499
|
+
|
1519
1500
|
const rootRoute = {
|
1520
1501
|
id: VELOCE_FLOW_ROOT_ROUTE,
|
1521
1502
|
path: '',
|
@@ -1538,7 +1519,7 @@ const rootRoute = {
|
|
1538
1519
|
path: 'product',
|
1539
1520
|
component: ProductComponent,
|
1540
1521
|
runGuardsAndResolvers: 'paramsOrQueryParamsChange',
|
1541
|
-
resolve: { quote: QuoteResolver },
|
1522
|
+
resolve: { quote: QuoteResolver, uiDef: resolveUIDefinition },
|
1542
1523
|
canDeactivate: [ProductUnloadGuard],
|
1543
1524
|
data: { showHeader: true },
|
1544
1525
|
},
|