@veloceapps/sdk 8.0.0-113 → 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/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/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/package.json +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
3
|
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, ChargeGroupUtils, 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, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
|
-
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
|
4
|
+
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';
|
5
5
|
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
6
6
|
import * as i1 from '@veloceapps/api';
|
7
7
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
@@ -710,6 +710,7 @@ class FlowStateService {
|
|
710
710
|
this.toastService = toastService;
|
711
711
|
this.customizationService = customizationService;
|
712
712
|
this.NOT_INITIALIZED = Symbol();
|
713
|
+
this._hasStatefulUnsavedChanges = false;
|
713
714
|
this.stateId$ = new BehaviorSubject(null);
|
714
715
|
this.processors = {};
|
715
716
|
this.subscriptions = {};
|
@@ -719,7 +720,7 @@ class FlowStateService {
|
|
719
720
|
all subscriptions get their updates according to updated QuoteDraft
|
720
721
|
*/
|
721
722
|
this.isInitialized$()
|
722
|
-
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.quoteDraftService.quoteDraft$), skip$1(1), switchMap(() => this.executeRequest$({})))
|
723
|
+
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.quoteDraftService.quoteDraft$), skip$1(1), switchMap(() => this.executeRequest$({}, true)))
|
723
724
|
.subscribe();
|
724
725
|
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
725
726
|
if (!(flow === null || flow === void 0 ? void 0 : flow.properties.stateful)) {
|
@@ -775,6 +776,11 @@ class FlowStateService {
|
|
775
776
|
this.processors = {};
|
776
777
|
this.cleanup$.next();
|
777
778
|
}
|
779
|
+
get hasUnsavedChanges() {
|
780
|
+
return this.getFlowSafe().properties.stateful
|
781
|
+
? this._hasStatefulUnsavedChanges
|
782
|
+
: this.quoteDraftService.hasUnsavedChanges;
|
783
|
+
}
|
778
784
|
isInitialized$() {
|
779
785
|
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
780
786
|
}
|
@@ -833,7 +839,9 @@ class FlowStateService {
|
|
833
839
|
this.executeRequest$(request).subscribe();
|
834
840
|
}
|
835
841
|
}
|
836
|
-
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED),
|
842
|
+
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), distinctUntilChanged((p, c) => {
|
843
|
+
return isEqual(p, c);
|
844
|
+
}), map$1(data => data), finalize(() => {
|
837
845
|
if (!this.subscriptions[requestId].data$.observed) {
|
838
846
|
delete this.subscriptions[requestId];
|
839
847
|
}
|
@@ -848,10 +856,10 @@ class FlowStateService {
|
|
848
856
|
else {
|
849
857
|
const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
|
850
858
|
if (quoteDraft) {
|
851
|
-
return this.quoteApiService.upsertQuote(quoteDraft)
|
859
|
+
return this.quoteApiService.upsertQuote(quoteDraft);
|
852
860
|
}
|
853
861
|
}
|
854
|
-
return of(
|
862
|
+
return of({ quoteId: '' });
|
855
863
|
}
|
856
864
|
submit$() {
|
857
865
|
if (this.getFlowSafe().properties.stateful) {
|
@@ -862,10 +870,10 @@ class FlowStateService {
|
|
862
870
|
else {
|
863
871
|
const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
|
864
872
|
if (quoteDraft) {
|
865
|
-
return this.quoteApiService.submitQuote(quoteDraft)
|
873
|
+
return this.quoteApiService.submitQuote(quoteDraft);
|
866
874
|
}
|
867
875
|
}
|
868
|
-
return of(
|
876
|
+
return of({ quoteId: '' });
|
869
877
|
}
|
870
878
|
getOwnerIdByScope(scope) {
|
871
879
|
var _a;
|
@@ -895,10 +903,10 @@ class FlowStateService {
|
|
895
903
|
}, {}),
|
896
904
|
};
|
897
905
|
}
|
898
|
-
executeRequest$(request) {
|
906
|
+
executeRequest$(request, forceSubscriptions = false) {
|
899
907
|
var _a;
|
900
908
|
const fullRequest = cloneDeep(request);
|
901
|
-
if ((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) {
|
909
|
+
if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
|
902
910
|
for (const subscription of Object.values(this.subscriptions)) {
|
903
911
|
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
904
912
|
}
|
@@ -953,9 +961,12 @@ class FlowStateService {
|
|
953
961
|
if (!this.stateId$.value) {
|
954
962
|
throw 'Stateful session is not initialized';
|
955
963
|
}
|
956
|
-
return this.flowStateApiService
|
957
|
-
|
958
|
-
|
964
|
+
return this.flowStateApiService.execute(this.stateId$.value, request).pipe(tap$1(response => {
|
965
|
+
var _a;
|
966
|
+
if ((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length) {
|
967
|
+
this._hasStatefulUnsavedChanges = true;
|
968
|
+
}
|
969
|
+
}), tap$1(response => this.stateId$.next(response.stateId)));
|
959
970
|
}
|
960
971
|
initStateless$() {
|
961
972
|
var _a;
|