@hmcts/ccd-case-ui-toolkit 5.0.51-restricted-case-access → 5.0.53-prevent-clear-page-from-cya

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.
@@ -10400,12 +10400,35 @@
10400
10400
  return this.wizard.findWizardPage(caseFieldId);
10401
10401
  };
10402
10402
  CaseEditPageComponent.prototype.updateEventTriggerCaseFields = function (caseFieldId, jsonData, eventTrigger) {
10403
- if (eventTrigger.case_fields) {
10403
+ var _this = this;
10404
+ if (eventTrigger === null || eventTrigger === void 0 ? void 0 : eventTrigger.case_fields) {
10404
10405
  eventTrigger.case_fields
10405
10406
  .filter(function (element) { return element.id === caseFieldId; })
10406
- .forEach(function (element) { return element.value = jsonData.data[caseFieldId]; });
10407
+ .forEach(function (element) {
10408
+ if (_this.isAnObject(element.value)) {
10409
+ var updatedJsonDataObject = _this.updateJsonDataObject(caseFieldId, jsonData, element);
10410
+ element.value = Object.assign(Object.assign({}, element.value), updatedJsonDataObject);
10411
+ }
10412
+ else {
10413
+ element.value = jsonData.data[caseFieldId];
10414
+ }
10415
+ });
10407
10416
  }
10408
10417
  };
10418
+ CaseEditPageComponent.prototype.updateJsonDataObject = function (caseFieldId, jsonData, element) {
10419
+ var _this = this;
10420
+ return Object.keys(jsonData.data[caseFieldId]).reduce(function (acc, key) {
10421
+ var _a;
10422
+ var elementValue = element.value[key];
10423
+ var jsonDataValue = jsonData.data[caseFieldId][key];
10424
+ var hasElementGotValueProperty = _this.isAnObject(elementValue) && elementValue.value !== undefined;
10425
+ var jsonDataOrElementValue = (jsonDataValue === null || jsonDataValue === void 0 ? void 0 : jsonDataValue.value) !== null && (jsonDataValue === null || jsonDataValue === void 0 ? void 0 : jsonDataValue.value) !== undefined ? jsonDataValue : elementValue;
10426
+ return Object.assign(Object.assign({}, acc), (_a = {}, _a["" + key] = hasElementGotValueProperty ? jsonDataOrElementValue : jsonDataValue, _a));
10427
+ }, {});
10428
+ };
10429
+ CaseEditPageComponent.prototype.isAnObject = function (property) {
10430
+ return typeof property === 'object' && !Array.isArray(property) && property !== null;
10431
+ };
10409
10432
  CaseEditPageComponent.prototype.updateFormControlsValue = function (formGroup, caseFieldId, value) {
10410
10433
  var theControl = formGroup.controls['data'].get(caseFieldId);
10411
10434
  if (theControl && theControl['status'] !== 'DISABLED') {
@@ -29218,7 +29241,7 @@
29218
29241
  }
29219
29242
  else {
29220
29243
  return this.caseNotifier.fetchAndRefresh(cid)
29221
- .pipe(operators.catchError(function (error) { return _this.checkAuthorizationError(error, cid); }))
29244
+ .pipe(operators.catchError(function (error) { return _this.checkAuthorizationError(error); }))
29222
29245
  .toPromise();
29223
29246
  }
29224
29247
  }
@@ -29231,24 +29254,20 @@
29231
29254
  _this.caseNotifier.cachedCaseView = classTransformer.plainToClassFromExist(new CaseView(), caseView);
29232
29255
  _this.caseNotifier.announceCase(_this.caseNotifier.cachedCaseView);
29233
29256
  return _this.caseNotifier.cachedCaseView;
29234
- }), operators.catchError(function (error) { return _this.checkAuthorizationError(error, cid); })).toPromise();
29257
+ }), operators.catchError(function (error) { return _this.checkAuthorizationError(error); })).toPromise();
29235
29258
  };
29236
- CaseResolver.prototype.checkAuthorizationError = function (error, caseReference) {
29259
+ CaseResolver.prototype.checkAuthorizationError = function (error) {
29237
29260
  // TODO Should be logged to remote logging infrastructure
29238
29261
  if (error.status === 400) {
29239
29262
  this.router.navigate(['/search/noresults']);
29240
29263
  return rxjs.of(null);
29241
29264
  }
29265
+ console.error(error);
29242
29266
  if (CaseResolver.EVENT_REGEX.test(this.previousUrl) && error.status === 404) {
29243
29267
  this.router.navigate(['/list/case']);
29244
29268
  return rxjs.of(null);
29245
29269
  }
29246
- // Error 403, navigate to restricted case access page
29247
- if (error.status === 403) {
29248
- this.router.navigate(["/cases/restricted-case-access/" + caseReference]);
29249
- return rxjs.of(null);
29250
- }
29251
- if (error.status !== 401) {
29270
+ if (error.status !== 401 && error.status !== 403) {
29252
29271
  this.router.navigate(['/error']);
29253
29272
  }
29254
29273
  this.goToDefaultPage();