@hmcts/ccd-case-ui-toolkit 6.19.15 → 6.19.16-hearing-requirements-event-fix

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.
@@ -1985,6 +1985,13 @@
1985
1985
  error[key] = response.error.hasOwnProperty(key) && response.error[key] ? response.error[key] : error[key];
1986
1986
  });
1987
1987
  }
1988
+ // Error object in HttpErrorResponse will be empty for 403 errors
1989
+ // Set the error properties of HttpError accordingly
1990
+ if ((response === null || response === void 0 ? void 0 : response.status) === 403) {
1991
+ error.error = response.statusText;
1992
+ error.status = response.status;
1993
+ error.message = response.message;
1994
+ }
1988
1995
  return error;
1989
1996
  };
1990
1997
  return HttpError;
@@ -2083,14 +2090,13 @@
2083
2090
  this.authService = authService;
2084
2091
  }
2085
2092
  HttpErrorService.convertToHttpError = function (error) {
2093
+ var _a;
2086
2094
  if (error instanceof HttpError) {
2087
2095
  return error;
2088
2096
  }
2089
2097
  var httpError = new HttpError();
2090
2098
  if (error instanceof i1$2.HttpErrorResponse) {
2091
- if (error.headers
2092
- && error.headers.get(HttpErrorService.CONTENT_TYPE)
2093
- && error.headers.get(HttpErrorService.CONTENT_TYPE).indexOf(HttpErrorService.JSON) !== -1) {
2099
+ if (((_a = error.headers) === null || _a === void 0 ? void 0 : _a.get(HttpErrorService.CONTENT_TYPE).indexOf(HttpErrorService.JSON)) !== -1) {
2094
2100
  try {
2095
2101
  httpError = HttpError.from(error);
2096
2102
  }
@@ -2125,7 +2131,7 @@
2125
2131
  console.error('Handling error in http error service.');
2126
2132
  console.error(error);
2127
2133
  var httpError = HttpErrorService.convertToHttpError(error);
2128
- if (redirectIfNotAuthorised && (httpError.status === 401 || httpError.status === 403)) {
2134
+ if (redirectIfNotAuthorised && httpError.status === 401) {
2129
2135
  this.authService.signIn();
2130
2136
  }
2131
2137
  return rxjs.throwError(httpError);
@@ -5822,13 +5828,23 @@
5822
5828
  * @returns A new array with the mapped values
5823
5829
  */
5824
5830
  FieldsPurger.prototype.mapArrayValuesToNull = function (array) {
5825
- return array.map(function (element) {
5826
- return typeof element === 'object'
5827
- ? Object.assign.apply(Object, __spread([{}], Object.keys(element).map(function (k) {
5828
- var _a;
5829
- return (_a = {}, _a[k] = null, _a);
5830
- }))) : null;
5831
- });
5831
+ if (array && array.length > 0) {
5832
+ return array.map(function (element) {
5833
+ if (element !== undefined && element !== null) {
5834
+ return typeof element === 'object'
5835
+ ? Object.assign.apply(Object, __spread([{}], Object.keys(element).map(function (k) {
5836
+ var _a;
5837
+ return (_a = {}, _a[k] = null, _a);
5838
+ }))) : null;
5839
+ }
5840
+ else {
5841
+ return {};
5842
+ }
5843
+ });
5844
+ }
5845
+ else {
5846
+ return array;
5847
+ }
5832
5848
  };
5833
5849
  return FieldsPurger;
5834
5850
  }());
@@ -31081,13 +31097,14 @@
31081
31097
  i0__namespace.ɵɵsetComponentScope(CaseTimelineComponent, [i2__namespace.NgIf, i2__namespace.NgSwitch, i2__namespace.NgSwitchCase, EventLogComponent, CaseHistoryComponent], [i1__namespace.RpxTranslatePipe]);
31082
31098
 
31083
31099
  var CaseResolver = /** @class */ (function () {
31084
- function CaseResolver(caseNotifier, draftService, navigationNotifierService, router, sessionStorage) {
31100
+ function CaseResolver(caseNotifier, draftService, navigationNotifierService, router, sessionStorage, appConfig) {
31085
31101
  var _this = this;
31086
31102
  this.caseNotifier = caseNotifier;
31087
31103
  this.draftService = draftService;
31088
31104
  this.navigationNotifierService = navigationNotifierService;
31089
31105
  this.router = router;
31090
31106
  this.sessionStorage = sessionStorage;
31107
+ this.appConfig = appConfig;
31091
31108
  router.events.pipe(operators.filter(function (event) { return event instanceof i1$1.NavigationEnd; }))
31092
31109
  .subscribe(function (event) {
31093
31110
  _this.previousUrl = event.url;
@@ -31133,7 +31150,7 @@
31133
31150
  else {
31134
31151
  console.info('getAndCacheCaseView - Path B.');
31135
31152
  return this.caseNotifier.fetchAndRefresh(cid)
31136
- .pipe(operators.catchError(function (error) { return _this.processErrorInCaseFetch(error); }))
31153
+ .pipe(operators.catchError(function (error) { return _this.processErrorInCaseFetch(error, cid); }))
31137
31154
  .toPromise();
31138
31155
  }
31139
31156
  }
@@ -31146,9 +31163,9 @@
31146
31163
  _this.caseNotifier.cachedCaseView = classTransformer.plainToClassFromExist(new CaseView(), caseView);
31147
31164
  _this.caseNotifier.announceCase(_this.caseNotifier.cachedCaseView);
31148
31165
  return _this.caseNotifier.cachedCaseView;
31149
- }), operators.catchError(function (error) { return _this.processErrorInCaseFetch(error); })).toPromise();
31166
+ }), operators.catchError(function (error) { return _this.processErrorInCaseFetch(error, cid); })).toPromise();
31150
31167
  };
31151
- CaseResolver.prototype.processErrorInCaseFetch = function (error) {
31168
+ CaseResolver.prototype.processErrorInCaseFetch = function (error, caseReference) {
31152
31169
  console.error('!!! processErrorInCaseFetch !!!');
31153
31170
  console.error(error);
31154
31171
  // TODO Should be logged to remote logging infrastructure
@@ -31156,12 +31173,16 @@
31156
31173
  this.router.navigate(['/search/noresults']);
31157
31174
  return rxjs.of(null);
31158
31175
  }
31159
- console.error(error);
31160
31176
  if (CaseResolver.EVENT_REGEX.test(this.previousUrl) && error.status === 404) {
31161
31177
  this.router.navigate(['/list/case']);
31162
31178
  return rxjs.of(null);
31163
31179
  }
31164
- if (error.status !== 401 && error.status !== 403) {
31180
+ // Error 403 and enable-restricted-case-access Launch Darkly flag is enabled, navigate to restricted case access page
31181
+ if (error.status === 403 && this.appConfig.getEnableRestrictedCaseAccessConfig()) {
31182
+ this.router.navigate(["/cases/restricted-case-access/" + caseReference]);
31183
+ return rxjs.of(null);
31184
+ }
31185
+ if (error.status !== 401) {
31165
31186
  this.router.navigate(['/error']);
31166
31187
  }
31167
31188
  this.goToDefaultPage();
@@ -31188,12 +31209,12 @@
31188
31209
  CaseResolver.CASE_CREATED_MSG = 'The case has been created successfully';
31189
31210
  CaseResolver.defaultWAPage = '/work/my-work/list';
31190
31211
  CaseResolver.defaultPage = '/cases';
31191
- CaseResolver.ɵfac = function CaseResolver_Factory(t) { return new (t || CaseResolver)(i0__namespace.ɵɵinject(CaseNotifier), i0__namespace.ɵɵinject(DraftService), i0__namespace.ɵɵinject(NavigationNotifierService), i0__namespace.ɵɵinject(i1__namespace$1.Router), i0__namespace.ɵɵinject(SessionStorageService)); };
31212
+ CaseResolver.ɵfac = function CaseResolver_Factory(t) { return new (t || CaseResolver)(i0__namespace.ɵɵinject(CaseNotifier), i0__namespace.ɵɵinject(DraftService), i0__namespace.ɵɵinject(NavigationNotifierService), i0__namespace.ɵɵinject(i1__namespace$1.Router), i0__namespace.ɵɵinject(SessionStorageService), i0__namespace.ɵɵinject(AbstractAppConfig)); };
31192
31213
  CaseResolver.ɵprov = i0__namespace.ɵɵdefineInjectable({ token: CaseResolver, factory: CaseResolver.ɵfac });
31193
31214
  (function () {
31194
31215
  (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CaseResolver, [{
31195
31216
  type: i0.Injectable
31196
- }], function () { return [{ type: CaseNotifier }, { type: DraftService }, { type: NavigationNotifierService }, { type: i1__namespace$1.Router }, { type: SessionStorageService }]; }, null);
31217
+ }], function () { return [{ type: CaseNotifier }, { type: DraftService }, { type: NavigationNotifierService }, { type: i1__namespace$1.Router }, { type: SessionStorageService }, { type: AbstractAppConfig }]; }, null);
31197
31218
  })();
31198
31219
 
31199
31220
  var EventTriggerResolver = /** @class */ (function () {