@veloceapps/sdk 8.0.0-112 → 8.0.0-114
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/vendor-map.d.ts +4 -0
- package/core/services/flow-state.service.d.ts +8 -2
- package/esm2020/cms/vendor-map.mjs +5 -1
- package/esm2020/core/services/flow-state.service.mjs +24 -14
- package/esm2020/src/services/flow-dialog.service.mjs +16 -5
- package/fesm2015/veloceapps-sdk-cms.mjs +4 -1
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +23 -12
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +14 -4
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +4 -0
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +22 -12
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +14 -4
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/services/flow-dialog.service.d.ts +4 -2
@@ -3,7 +3,7 @@ import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directi
|
|
3
3
|
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
4
|
import * as i1 from '@veloceapps/api';
|
5
5
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
6
|
-
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, skip as skip$1, shareReplay as shareReplay$1, finalize, takeUntil, take as take$1
|
6
|
+
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, skip as skip$1, shareReplay as shareReplay$1, distinctUntilChanged, finalize, takeUntil, take as take$1 } from 'rxjs';
|
7
7
|
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
8
8
|
import { merge, isEmpty, flatten, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform, uniq } from 'lodash';
|
9
9
|
import * as i6 from '@veloceapps/components';
|
@@ -771,6 +771,7 @@ class FlowStateService {
|
|
771
771
|
this.toastService = toastService;
|
772
772
|
this.customizationService = customizationService;
|
773
773
|
this.NOT_INITIALIZED = Symbol();
|
774
|
+
this._hasStatefulUnsavedChanges = false;
|
774
775
|
this.stateId$ = new BehaviorSubject(null);
|
775
776
|
this.processors = {};
|
776
777
|
this.subscriptions = {};
|
@@ -780,7 +781,7 @@ class FlowStateService {
|
|
780
781
|
all subscriptions get their updates according to updated QuoteDraft
|
781
782
|
*/
|
782
783
|
this.isInitialized$()
|
783
|
-
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.quoteDraftService.quoteDraft$), skip$1(1), switchMap(() => this.executeRequest$({})))
|
784
|
+
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.quoteDraftService.quoteDraft$), skip$1(1), switchMap(() => this.executeRequest$({}, true)))
|
784
785
|
.subscribe();
|
785
786
|
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
786
787
|
if (!flow?.properties.stateful) {
|
@@ -836,6 +837,11 @@ class FlowStateService {
|
|
836
837
|
this.processors = {};
|
837
838
|
this.cleanup$.next();
|
838
839
|
}
|
840
|
+
get hasUnsavedChanges() {
|
841
|
+
return this.getFlowSafe().properties.stateful
|
842
|
+
? this._hasStatefulUnsavedChanges
|
843
|
+
: this.quoteDraftService.hasUnsavedChanges;
|
844
|
+
}
|
839
845
|
isInitialized$() {
|
840
846
|
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
841
847
|
}
|
@@ -893,7 +899,9 @@ class FlowStateService {
|
|
893
899
|
this.executeRequest$(request).subscribe();
|
894
900
|
}
|
895
901
|
}
|
896
|
-
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED),
|
902
|
+
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), distinctUntilChanged((p, c) => {
|
903
|
+
return isEqual(p, c);
|
904
|
+
}), map$1(data => data), finalize(() => {
|
897
905
|
if (!this.subscriptions[requestId].data$.observed) {
|
898
906
|
delete this.subscriptions[requestId];
|
899
907
|
}
|
@@ -908,10 +916,10 @@ class FlowStateService {
|
|
908
916
|
else {
|
909
917
|
const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
|
910
918
|
if (quoteDraft) {
|
911
|
-
return this.quoteApiService.upsertQuote(quoteDraft)
|
919
|
+
return this.quoteApiService.upsertQuote(quoteDraft);
|
912
920
|
}
|
913
921
|
}
|
914
|
-
return of(
|
922
|
+
return of({ quoteId: '' });
|
915
923
|
}
|
916
924
|
submit$() {
|
917
925
|
if (this.getFlowSafe().properties.stateful) {
|
@@ -922,10 +930,10 @@ class FlowStateService {
|
|
922
930
|
else {
|
923
931
|
const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
|
924
932
|
if (quoteDraft) {
|
925
|
-
return this.quoteApiService.submitQuote(quoteDraft)
|
933
|
+
return this.quoteApiService.submitQuote(quoteDraft);
|
926
934
|
}
|
927
935
|
}
|
928
|
-
return of(
|
936
|
+
return of({ quoteId: '' });
|
929
937
|
}
|
930
938
|
getOwnerIdByScope(scope) {
|
931
939
|
const ownerId = this.flowInfoService.templates[scope]?.id;
|
@@ -953,9 +961,9 @@ class FlowStateService {
|
|
953
961
|
}), {}),
|
954
962
|
};
|
955
963
|
}
|
956
|
-
executeRequest$(request) {
|
964
|
+
executeRequest$(request, forceSubscriptions = false) {
|
957
965
|
const fullRequest = cloneDeep(request);
|
958
|
-
if (fullRequest.actions?.length) {
|
966
|
+
if (fullRequest.actions?.length || forceSubscriptions) {
|
959
967
|
for (const subscription of Object.values(this.subscriptions)) {
|
960
968
|
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
961
969
|
}
|
@@ -1008,9 +1016,11 @@ class FlowStateService {
|
|
1008
1016
|
if (!this.stateId$.value) {
|
1009
1017
|
throw 'Stateful session is not initialized';
|
1010
1018
|
}
|
1011
|
-
return this.flowStateApiService
|
1012
|
-
|
1013
|
-
|
1019
|
+
return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(response => {
|
1020
|
+
if (request.actions?.length) {
|
1021
|
+
this._hasStatefulUnsavedChanges = true;
|
1022
|
+
}
|
1023
|
+
}), tap$1(response => this.stateId$.next(response.stateId)));
|
1014
1024
|
}
|
1015
1025
|
initStateless$() {
|
1016
1026
|
const { headerId } = this.contextService.resolve();
|