@veloceapps/sdk 8.0.0-185 → 8.0.0-187
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/vendor-map.d.ts +3 -4
- package/core/modules/configuration/services/configuration-state.service.d.ts +2 -4
- package/core/modules/configuration/services/configuration.service.d.ts +1 -1
- package/core/services/flow-state.service.d.ts +1 -0
- package/core/services/quote-draft.service.d.ts +8 -31
- package/core/types/flow-state.types.d.ts +5 -0
- package/core/types/integration.types.d.ts +0 -1
- package/core/utils/line-item.utils.d.ts +1 -2
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +16 -7
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +10 -8
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +3 -3
- package/esm2020/core/services/flow-state.service.mjs +31 -25
- package/esm2020/core/services/quote-draft.service.mjs +27 -100
- package/esm2020/core/types/flow-state.types.mjs +1 -1
- package/esm2020/core/types/integration.types.mjs +1 -1
- package/esm2020/core/utils/line-item.utils.mjs +4 -18
- package/esm2020/src/pages/product/product.component.mjs +15 -12
- package/esm2020/src/services/flow.service.mjs +38 -18
- package/fesm2015/veloceapps-sdk-core.mjs +455 -522
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +47 -28
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +418 -487
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +50 -27
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/pages/product/product.component.d.ts +1 -1
- package/src/services/flow.service.d.ts +1 -0
@@ -755,11 +755,16 @@ class FlowService {
|
|
755
755
|
initSubscriptions() {
|
756
756
|
this.integrationState
|
757
757
|
.listen$(FlowAction.FLOW_CONFIGURE_PRODUCT)
|
758
|
-
.pipe(
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
758
|
+
.pipe(switchMap(payload => {
|
759
|
+
if (this.flowInfoService.isLegacy) {
|
760
|
+
const productId = payload.productId ??
|
761
|
+
this.quoteDraftService.currentState.find(li => li.id === payload.lineItemId)?.productId;
|
762
|
+
return of({ ...payload, productId });
|
763
|
+
}
|
764
|
+
return this.prepareConfiguration$(payload);
|
765
|
+
}), tap(payload => {
|
766
|
+
if (payload.productId) {
|
767
|
+
this.flowRouterService.navigateToProductConfiguration(payload.productId, payload.lineItemId);
|
763
768
|
}
|
764
769
|
else {
|
765
770
|
console.warn("Parameter 'productId' is needed to start configuration");
|
@@ -808,9 +813,9 @@ class FlowService {
|
|
808
813
|
return this.legacyApplyConfiguration();
|
809
814
|
}
|
810
815
|
else {
|
811
|
-
return this.configurationStateService
|
812
|
-
|
813
|
-
|
816
|
+
return this.configurationStateService
|
817
|
+
.saveConfiguration('', true)
|
818
|
+
.pipe(switchMap(() => this.configurationStateService.cancelConfiguration()));
|
814
819
|
}
|
815
820
|
}), tap(() => {
|
816
821
|
this.configurationService.hasUnsavedChanges = false;
|
@@ -828,6 +833,29 @@ class FlowService {
|
|
828
833
|
.pipe(map(path => path.queryParams['productId']), takeUntil(this.cleanup$))
|
829
834
|
.subscribe(productId => this.integrationState.patchState({ productId }));
|
830
835
|
}
|
836
|
+
prepareConfiguration$(payload) {
|
837
|
+
if (!payload.productId && !payload.lineItemId) {
|
838
|
+
return of(payload);
|
839
|
+
}
|
840
|
+
// When reconfiguring asset, PriceList should be updated with priceListId of an asset
|
841
|
+
const actions = [
|
842
|
+
{ name: 'UPDATE_PRICE_LIST', inputData: { lineItemId: payload.lineItemId } },
|
843
|
+
];
|
844
|
+
const selectors = {};
|
845
|
+
if (!payload.productId) {
|
846
|
+
selectors['productIdResult'] = { name: 'FIND_PRODUCT_ID', inputData: { lineItemId: payload.lineItemId } };
|
847
|
+
}
|
848
|
+
return this.flowStateService.execute$(UITemplateType.FLOW_ENGINE, { actions, selectors }).pipe(map(({ productIdResult }) => {
|
849
|
+
if (!productIdResult) {
|
850
|
+
return payload;
|
851
|
+
}
|
852
|
+
const productId = productIdResult.success && typeof productIdResult.result === 'string' ? productIdResult.result : undefined;
|
853
|
+
return {
|
854
|
+
...payload,
|
855
|
+
productId,
|
856
|
+
};
|
857
|
+
}));
|
858
|
+
}
|
831
859
|
legacyApplyConfiguration() {
|
832
860
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
833
861
|
const lineItem = this.configurationService.getSnapshot();
|
@@ -835,7 +863,6 @@ class FlowService {
|
|
835
863
|
return of(undefined);
|
836
864
|
}
|
837
865
|
const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
|
838
|
-
const assetId = lineItem.assetId || lineItem.openOrderLineItemId;
|
839
866
|
let updatedState;
|
840
867
|
if (isNewLineItem) {
|
841
868
|
updatedState = [...quoteDraft.currentState, lineItem];
|
@@ -843,14 +870,7 @@ class FlowService {
|
|
843
870
|
else {
|
844
871
|
updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
845
872
|
}
|
846
|
-
return this.flowConfigurationService.calculate$({ ...quoteDraft, currentState: updatedState })
|
847
|
-
if (assetId) {
|
848
|
-
const modifiedAssets = this.integrationState.state.modifiedAssets ?? {};
|
849
|
-
this.integrationState.patchState({
|
850
|
-
modifiedAssets: { ...modifiedAssets, [assetId]: true },
|
851
|
-
});
|
852
|
-
}
|
853
|
-
}));
|
873
|
+
return this.flowConfigurationService.calculate$({ ...quoteDraft, currentState: updatedState });
|
854
874
|
}
|
855
875
|
}
|
856
876
|
FlowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowService, deps: [{ token: i5.IntegrationState }, { token: FlowRouterService }, { token: i2.QuoteDraftService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: FlowDialogService }, { token: i2.FlowConfigurationService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
@@ -1483,12 +1503,11 @@ class ProductComponent {
|
|
1483
1503
|
const offeringId = contextProperties.offeringId;
|
1484
1504
|
return this.configurationRuntimeService.init({ productId, offeringId });
|
1485
1505
|
}
|
1486
|
-
const
|
1487
|
-
|
1488
|
-
|
1489
|
-
this.configurationService.setConfigurableRamp(currentStateItem);
|
1506
|
+
const lineItem = this.getLineItem(quote, productId, contextProperties.lineItemId);
|
1507
|
+
if (lineItem) {
|
1508
|
+
this.configurationService.setConfigurableRamp(lineItem);
|
1490
1509
|
}
|
1491
|
-
const { offeringId } =
|
1510
|
+
const { offeringId } = lineItem ?? {};
|
1492
1511
|
return this.configurationRuntimeService.init({ productId, offeringId });
|
1493
1512
|
}), switchMap(() => this.customizeUI$()), tap(() => {
|
1494
1513
|
const uiDefinition = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer?.source;
|
@@ -1505,13 +1524,17 @@ class ProductComponent {
|
|
1505
1524
|
}
|
1506
1525
|
}), switchMap(() => this.configurationStateService.init$()));
|
1507
1526
|
}
|
1508
|
-
|
1527
|
+
getLineItem(quote, productId, lineItemId) {
|
1509
1528
|
// search by lineItemId first
|
1510
|
-
let
|
1511
|
-
if (!
|
1512
|
-
|
1529
|
+
let li = quote.currentState.find(li => li.id === lineItemId);
|
1530
|
+
if (!li && this.quoteDraftService.isStandalone) {
|
1531
|
+
li = quote.currentState.find(li => li.productId === productId);
|
1532
|
+
}
|
1533
|
+
// If still not found, is could be an asset
|
1534
|
+
if (!li) {
|
1535
|
+
li = this.quoteDraftService.assetsState?.currentState.find(li => li.id === lineItemId);
|
1513
1536
|
}
|
1514
|
-
return
|
1537
|
+
return li;
|
1515
1538
|
}
|
1516
1539
|
}
|
1517
1540
|
ProductComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductComponent, deps: [{ token: i2.ContextService }, { token: i2.ConfigurationRuntimeService }, { token: i2.ConfigurationService }, { token: i2.ConfigurationStateService }, { token: i2.QuoteDraftService }, { token: i2.FlowInfoService }, { token: i2.FlowStateService }, { token: i2.IntegrationState }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|