@dsivd/prestations-ng 14.5.15 → 14.5.16-beta1

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/CHANGELOG.md CHANGED
@@ -25,7 +25,16 @@ A change is considered **breaking** if you have to change your code or update yo
25
25
  - adding a new constructor argument in one of our service is OK, if you just have to update your constructor's signature and your call to `super(...)`
26
26
 
27
27
  ---
28
+ ## [14.5.16]
28
29
 
30
+ ### Updated
31
+
32
+ - [session-info.service.ts](projects/prestations-ng/src/sdk-session-info/session-info.service.ts)
33
+ - `SessionInfoData` data getter now depends on `neverConnected` attribute to avoid unnecessary calls to sessionInfo api (PRESTAKIT-364).
34
+ - To retrieve `SessionInfoData` data from api url, you need to explicitly set `neverConnected` attribute to `false`.
35
+
36
+ - [foehn-page.component.ts](projects/prestations-ng/src/foehn-page/foehn-page.component.ts)
37
+ - `@Input() neverConnected` is now set to `false` by default to retrieve `SessionInfoData` data for backwards compatibility purposes.
29
38
 
30
39
  ## [14.5.15]
31
40
  ### Added
@@ -867,52 +867,79 @@
867
867
 
868
868
  var SESSION_INFO_API_URL = 'api/sessionInfo/data';
869
869
  var SessionInfo = /** @class */ (function () {
870
- function SessionInfo(http) {
870
+ function SessionInfo(http, growlService, ngZone) {
871
871
  this.http = http;
872
+ this.growlService = growlService;
873
+ this.ngZone = ngZone;
874
+ this.neverConnected_ = new rxjs.BehaviorSubject(undefined);
872
875
  }
873
876
  Object.defineProperty(SessionInfo.prototype, "data", {
874
877
  get: function () {
875
878
  var _this = this;
876
- if (this.neverConnected_) {
877
- return rxjs.of(null);
878
- }
879
- else {
880
- if (!this.pulling_) {
881
- this.pulling_ = this.http
882
- .get(SESSION_INFO_API_URL)
883
- .pipe(operators.map(function (r) {
884
- if (r) {
885
- return (_this.sessionData = r);
886
- }
887
- return null;
888
- }), operators.shareReplay(1));
879
+ return this.neverConnected_.asObservable().pipe(operators.tap(function () {
880
+ if (_this.timeoutLogError) {
881
+ clearTimeout(_this.timeoutLogError);
889
882
  }
890
- return this.pulling_;
891
- }
883
+ }), operators.switchMap(function (neverConnected) {
884
+ if (neverConnected !== false) {
885
+ if (neverConnected === undefined) {
886
+ _this.logErrorNeverConnectedIsNotSet();
887
+ }
888
+ if (!_this.onMicroTaskEmptyPulling_) {
889
+ // Need 'onMicrotaskEmpty' to avoid 'ExpressionChangedAfterItHasBeenCheckedError'
890
+ _this.onMicroTaskEmptyPulling_ = _this.ngZone.onMicrotaskEmpty.pipe(operators.first(), operators.map(function () { return null; }), operators.shareReplay(1));
891
+ }
892
+ return _this.onMicroTaskEmptyPulling_;
893
+ }
894
+ else {
895
+ if (!_this.pulling_) {
896
+ _this.pulling_ = _this.http
897
+ .get(SESSION_INFO_API_URL)
898
+ .pipe(operators.catchError(function () {
899
+ var message = 'Impossible de récupérer les informations de la personne connectée';
900
+ _this.growlService.addWithType(GrowlType.DANGER, message);
901
+ return rxjs.of(null);
902
+ }), operators.map(function (r) {
903
+ if (r) {
904
+ return (_this.sessionData = r);
905
+ }
906
+ return null;
907
+ }), operators.shareReplay(1));
908
+ }
909
+ return _this.pulling_;
910
+ }
911
+ }));
892
912
  },
893
913
  enumerable: false,
894
914
  configurable: true
895
915
  });
896
916
  Object.defineProperty(SessionInfo.prototype, "neverConnected", {
897
917
  get: function () {
898
- return this.neverConnected_;
918
+ return this.neverConnected_.getValue();
899
919
  },
900
920
  set: function (neverConnected) {
901
- this.neverConnected_ = neverConnected;
921
+ this.neverConnected_.next(neverConnected);
902
922
  },
903
923
  enumerable: false,
904
924
  configurable: true
905
925
  });
926
+ SessionInfo.prototype.logErrorNeverConnectedIsNotSet = function () {
927
+ // Use of setTimeout to avoid unnecessary error log
928
+ this.timeoutLogError = setTimeout(function () {
929
+ console.error("Error: 'neverConnected' is not set. " +
930
+ 'Find more at https://dsi-vd.github.io/prestations-ng/CHANGELOG.md#_14_5_16_');
931
+ }, 2000);
932
+ };
906
933
  return SessionInfo;
907
934
  }());
908
- SessionInfo.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: SessionInfo, deps: [{ token: i1__namespace.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
935
+ SessionInfo.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: SessionInfo, deps: [{ token: i1__namespace.HttpClient }, { token: GrowlBrokerService }, { token: i0__namespace.NgZone }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
909
936
  SessionInfo.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: SessionInfo, providedIn: 'root' });
910
937
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: SessionInfo, decorators: [{
911
938
  type: i0.Injectable,
912
939
  args: [{
913
940
  providedIn: 'root'
914
941
  }]
915
- }], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }]; } });
942
+ }], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: GrowlBrokerService }, { type: i0__namespace.NgZone }]; } });
916
943
 
917
944
  var GesdemHandlerService = /** @class */ (function () {
918
945
  function GesdemHandlerService(http, growlService, validationHandlerService, router, route, errorHandlerService, sessionInfo) {
@@ -3262,12 +3289,14 @@
3262
3289
  else {
3263
3290
  this._validationHandlerService.shouldDisplayErrors(true);
3264
3291
  }
3265
- this.sendForFormConcurrentSafe.subscribe(function () { return _this.onFormSent(goToNextPage); });
3292
+ this.sendForFormConcurrentSafe
3293
+ .pipe(operators.first())
3294
+ .subscribe(function () { return _this.onFormSent(goToNextPage); });
3266
3295
  };
3267
3296
  AbstractPageComponent.prototype.transmit = function () {
3268
3297
  var _this = this;
3269
3298
  this._validationHandlerService.shouldDisplayErrors(true);
3270
- this.transmitConcurrentSafe.subscribe(function () {
3299
+ this.transmitConcurrentSafe.pipe(operators.first()).subscribe(function () {
3271
3300
  if (!_this._gesdemService.lastResponse.errors.length) {
3272
3301
  _this._gesdemEventService.formTransmittedSubject.next(_this._gesdemService.lastResponse);
3273
3302
  _this._navigation.next();
@@ -5738,6 +5767,7 @@
5738
5767
  this.sessionInfo = sessionInfo;
5739
5768
  this.foehnPageModalService = foehnPageModalService;
5740
5769
  this.sdkDictionaryService = sdkDictionaryService;
5770
+ this.neverConnected = false;
5741
5771
  this.supportAlertEnabled = true;
5742
5772
  this.userConnectedAsDisplayed = true;
5743
5773
  this.confirmLeavingAlert = {