@hmcts/ccd-case-ui-toolkit 6.16.2-ccpay-upgrade → 6.18.0-restricted-case-access

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.
@@ -481,7 +481,7 @@
481
481
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
482
482
  PERFORMANCE OF THIS SOFTWARE.
483
483
  ***************************************************************************** */
484
- /* global Reflect, Promise */
484
+ /* global Reflect, Promise, SuppressedError, Symbol */
485
485
  var extendStatics = function (d, b) {
486
486
  extendStatics = Object.setPrototypeOf ||
487
487
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -560,11 +560,11 @@
560
560
  if (_ = accept(result.set))
561
561
  descriptor.set = _;
562
562
  if (_ = accept(result.init))
563
- initializers.push(_);
563
+ initializers.unshift(_);
564
564
  }
565
565
  else if (_ = accept(result)) {
566
566
  if (kind === "field")
567
- initializers.push(_);
567
+ initializers.unshift(_);
568
568
  else
569
569
  descriptor[key] = _;
570
570
  }
@@ -851,6 +851,85 @@
851
851
  throw new TypeError("Cannot use 'in' operator on non-object");
852
852
  return typeof state === "function" ? receiver === state : state.has(receiver);
853
853
  }
854
+ function __addDisposableResource(env, value, async) {
855
+ if (value !== null && value !== void 0) {
856
+ if (typeof value !== "object")
857
+ throw new TypeError("Object expected.");
858
+ var dispose;
859
+ if (async) {
860
+ if (!Symbol.asyncDispose)
861
+ throw new TypeError("Symbol.asyncDispose is not defined.");
862
+ dispose = value[Symbol.asyncDispose];
863
+ }
864
+ if (dispose === void 0) {
865
+ if (!Symbol.dispose)
866
+ throw new TypeError("Symbol.dispose is not defined.");
867
+ dispose = value[Symbol.dispose];
868
+ }
869
+ if (typeof dispose !== "function")
870
+ throw new TypeError("Object not disposable.");
871
+ env.stack.push({ value: value, dispose: dispose, async: async });
872
+ }
873
+ else if (async) {
874
+ env.stack.push({ async: true });
875
+ }
876
+ return value;
877
+ }
878
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
879
+ var e = new Error(message);
880
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
881
+ };
882
+ function __disposeResources(env) {
883
+ function fail(e) {
884
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
885
+ env.hasError = true;
886
+ }
887
+ function next() {
888
+ while (env.stack.length) {
889
+ var rec = env.stack.pop();
890
+ try {
891
+ var result = rec.dispose && rec.dispose.call(rec.value);
892
+ if (rec.async)
893
+ return Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
894
+ }
895
+ catch (e) {
896
+ fail(e);
897
+ }
898
+ }
899
+ if (env.hasError)
900
+ throw env.error;
901
+ }
902
+ return next();
903
+ }
904
+ var tslib_es6 = {
905
+ __extends: __extends,
906
+ __assign: __assign,
907
+ __rest: __rest,
908
+ __decorate: __decorate,
909
+ __param: __param,
910
+ __metadata: __metadata,
911
+ __awaiter: __awaiter,
912
+ __generator: __generator,
913
+ __createBinding: __createBinding,
914
+ __exportStar: __exportStar,
915
+ __values: __values,
916
+ __read: __read,
917
+ __spread: __spread,
918
+ __spreadArrays: __spreadArrays,
919
+ __spreadArray: __spreadArray,
920
+ __await: __await,
921
+ __asyncGenerator: __asyncGenerator,
922
+ __asyncDelegator: __asyncDelegator,
923
+ __asyncValues: __asyncValues,
924
+ __makeTemplateObject: __makeTemplateObject,
925
+ __importStar: __importStar,
926
+ __importDefault: __importDefault,
927
+ __classPrivateFieldGet: __classPrivateFieldGet,
928
+ __classPrivateFieldSet: __classPrivateFieldSet,
929
+ __classPrivateFieldIn: __classPrivateFieldIn,
930
+ __addDisposableResource: __addDisposableResource,
931
+ __disposeResources: __disposeResources,
932
+ };
854
933
 
855
934
  var _c0$X = function (a0) { return { "govuk-input--error": a0 }; };
856
935
  function DateInputComponent_div_16_Template(rf, ctx) {
@@ -10623,7 +10702,7 @@
10623
10702
  this.wizard = this.caseEdit.wizard;
10624
10703
  this.caseFields = this.getCaseFields();
10625
10704
  this.syncCaseEditDataService();
10626
- this.route.params
10705
+ this.routeParamsSub = this.route.params
10627
10706
  .subscribe(function (params) {
10628
10707
  var _a, _b;
10629
10708
  var pageId = params['page'];
@@ -10645,13 +10724,14 @@
10645
10724
  }
10646
10725
  });
10647
10726
  CaseEditPageComponent.setFocusToTop();
10648
- this.caseEditDataService.caseEditForm$.subscribe({
10727
+ this.caseEditFormSub = this.caseEditDataService.caseEditForm$.subscribe({
10649
10728
  next: function (editForm) { return _this.editForm = editForm; }
10650
10729
  });
10651
- this.caseEditDataService.caseIsLinkedCasesJourneyAtFinalStep$.subscribe({
10652
- next: function (isLinkedCasesJourneyAtFinalStep) { return _this.isLinkedCasesJourneyAtFinalStep = isLinkedCasesJourneyAtFinalStep; }
10653
- });
10654
- this.caseEditDataService.caseTriggerSubmitEvent$.subscribe({
10730
+ this.caseIsLinkedCasesJourneyAtFinalStepSub =
10731
+ this.caseEditDataService.caseIsLinkedCasesJourneyAtFinalStep$.subscribe({
10732
+ next: function (isLinkedCasesJourneyAtFinalStep) { return _this.isLinkedCasesJourneyAtFinalStep = isLinkedCasesJourneyAtFinalStep; }
10733
+ });
10734
+ this.caseTriggerSubmitEventSub = this.caseEditDataService.caseTriggerSubmitEvent$.subscribe({
10655
10735
  next: function (state) {
10656
10736
  if (state) {
10657
10737
  _this.caseEditDataService.setTriggerSubmitEvent(false);
@@ -10664,6 +10744,17 @@
10664
10744
  CaseEditPageComponent.prototype.ngAfterViewChecked = function () {
10665
10745
  this.cdRef.detectChanges();
10666
10746
  };
10747
+ CaseEditPageComponent.prototype.ngOnDestroy = function () {
10748
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10749
+ (_a = this.routeParamsSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
10750
+ (_b = this.caseEditFormSub) === null || _b === void 0 ? void 0 : _b.unsubscribe();
10751
+ (_c = this.caseIsLinkedCasesJourneyAtFinalStepSub) === null || _c === void 0 ? void 0 : _c.unsubscribe();
10752
+ (_d = this.caseTriggerSubmitEventSub) === null || _d === void 0 ? void 0 : _d.unsubscribe();
10753
+ (_e = this.validateSub) === null || _e === void 0 ? void 0 : _e.unsubscribe();
10754
+ (_f = this.dialogRefAfterClosedSub) === null || _f === void 0 ? void 0 : _f.unsubscribe();
10755
+ (_g = this.saveDraftSub) === null || _g === void 0 ? void 0 : _g.unsubscribe();
10756
+ (_h = this.caseFormValidationErrorsSub) === null || _h === void 0 ? void 0 : _h.unsubscribe();
10757
+ };
10667
10758
  CaseEditPageComponent.prototype.applyValuesChanged = function (valuesChanged) {
10668
10759
  this.formValuesChanged = valuesChanged;
10669
10760
  };
@@ -10738,7 +10829,7 @@
10738
10829
  _this.generateErrorMessage(casefield.field_type.collection_field_type.complex_fields, c.get('value'), id_1);
10739
10830
  });
10740
10831
  }
10741
- else if (FieldsUtils.isFlagLauncherCaseField(casefield)) {
10832
+ else if (FieldsUtils.isCaseFieldOfType(casefield, ['FlagLauncher'])) {
10742
10833
  // Check whether the case field DisplayContextParameter is signalling "create" mode or "update" mode
10743
10834
  // (expected always to be one of the two), to set the correct error message
10744
10835
  var action = '';
@@ -10793,7 +10884,7 @@
10793
10884
  this.caseEdit.error = null;
10794
10885
  var caseEventData = this.buildCaseEventData();
10795
10886
  var loadingSpinnerToken_1 = this.loadingService.register();
10796
- this.caseEdit.validate(caseEventData, this.currentPage.id)
10887
+ this.validateSub = this.caseEdit.validate(caseEventData, this.currentPage.id)
10797
10888
  .pipe(operators.finalize(function () {
10798
10889
  _this.loadingService.unregister(loadingSpinnerToken_1);
10799
10890
  }))
@@ -10812,10 +10903,10 @@
10812
10903
  CaseEditPageComponent.setFocusToTop();
10813
10904
  };
10814
10905
  CaseEditPageComponent.prototype.updateFormData = function (jsonData) {
10815
- var e_1, _c;
10906
+ var e_1, _j;
10816
10907
  try {
10817
- for (var _d = __values(Object.keys(jsonData.data)), _e = _d.next(); !_e.done; _e = _d.next()) {
10818
- var caseFieldId = _e.value;
10908
+ for (var _k = __values(Object.keys(jsonData.data)), _l = _k.next(); !_l.done; _l = _k.next()) {
10909
+ var caseFieldId = _l.value;
10819
10910
  /* istanbul ignore else */
10820
10911
  if (this.pageWithFieldExists(caseFieldId)) {
10821
10912
  this.updateEventTriggerCaseFields(caseFieldId, jsonData, this.caseEdit.eventTrigger);
@@ -10826,7 +10917,7 @@
10826
10917
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
10827
10918
  finally {
10828
10919
  try {
10829
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
10920
+ if (_l && !_l.done && (_j = _k.return)) _j.call(_k);
10830
10921
  }
10831
10922
  finally { if (e_1) throw e_1.error; }
10832
10923
  }
@@ -10855,12 +10946,12 @@
10855
10946
  CaseEditPageComponent.prototype.updateJsonDataObject = function (caseFieldId, jsonData, element) {
10856
10947
  var _this = this;
10857
10948
  return Object.keys(jsonData.data[caseFieldId]).reduce(function (acc, key) {
10858
- var _c;
10949
+ var _j;
10859
10950
  var elementValue = element.value[key];
10860
10951
  var jsonDataValue = jsonData.data[caseFieldId][key];
10861
10952
  var hasElementGotValueProperty = _this.isAnObject(elementValue) && elementValue.value !== undefined;
10862
10953
  var jsonDataOrElementValue = (jsonDataValue === null || jsonDataValue === void 0 ? void 0 : jsonDataValue.value) !== null && (jsonDataValue === null || jsonDataValue === void 0 ? void 0 : jsonDataValue.value) !== undefined ? jsonDataValue : elementValue;
10863
- return Object.assign(Object.assign({}, acc), (_c = {}, _c["" + key] = hasElementGotValueProperty ? jsonDataOrElementValue : jsonDataValue, _c));
10954
+ return Object.assign(Object.assign({}, acc), (_j = {}, _j["" + key] = hasElementGotValueProperty ? jsonDataOrElementValue : jsonDataValue, _j));
10864
10955
  }, {});
10865
10956
  };
10866
10957
  CaseEditPageComponent.prototype.isAnObject = function (property) {
@@ -10908,7 +10999,7 @@
10908
10999
  if (this.eventTrigger.can_save_draft) {
10909
11000
  if (this.formValuesChanged) {
10910
11001
  var dialogRef = this.dialog.open(SaveOrDiscardDialogComponent, this.dialogConfig);
10911
- dialogRef.afterClosed().subscribe(function (result) {
11002
+ this.dialogRefAfterClosedSub = dialogRef.afterClosed().subscribe(function (result) {
10912
11003
  if (result === 'Discard') {
10913
11004
  _this.discard();
10914
11005
  }
@@ -10995,7 +11086,7 @@
10995
11086
  var draftCaseEventData = this.formValueService.sanitise(this.editForm.value);
10996
11087
  draftCaseEventData.event_token = this.eventTrigger.event_token;
10997
11088
  draftCaseEventData.ignore_warning = this.caseEdit.ignoreWarning;
10998
- this.caseEdit.saveDraft(draftCaseEventData).subscribe(function (draft) { return _this.eventTrigger.case_id = DRAFT_PREFIX + draft.id; }, function (error) { return _this.handleError(error); });
11089
+ this.saveDraftSub = this.caseEdit.saveDraft(draftCaseEventData).subscribe(function (draft) { return _this.eventTrigger.case_id = DRAFT_PREFIX + draft.id; }, function (error) { return _this.handleError(error); });
10999
11090
  }
11000
11091
  };
11001
11092
  CaseEditPageComponent.prototype.getCaseFields = function () {
@@ -11063,7 +11154,7 @@
11063
11154
  this.caseEditDataService.setCaseEventTriggerName(this.eventTrigger.name);
11064
11155
  this.caseEditDataService.setCaseTitle(this.getCaseTitle());
11065
11156
  this.caseEditDataService.setCaseEditForm(this.editForm);
11066
- this.caseEditDataService.caseFormValidationErrors$.subscribe({
11157
+ this.caseFormValidationErrorsSub = this.caseEditDataService.caseFormValidationErrors$.subscribe({
11067
11158
  next: function (validationErrors) { return _this.validationErrors = validationErrors; }
11068
11159
  });
11069
11160
  };
@@ -29932,7 +30023,7 @@
29932
30023
  }
29933
30024
  else {
29934
30025
  return this.caseNotifier.fetchAndRefresh(cid)
29935
- .pipe(operators.catchError(function (error) { return _this.checkAuthorizationError(error); }))
30026
+ .pipe(operators.catchError(function (error) { return _this.checkAuthorizationError(error, cid); }))
29936
30027
  .toPromise();
29937
30028
  }
29938
30029
  }
@@ -29945,20 +30036,24 @@
29945
30036
  _this.caseNotifier.cachedCaseView = classTransformer.plainToClassFromExist(new CaseView(), caseView);
29946
30037
  _this.caseNotifier.announceCase(_this.caseNotifier.cachedCaseView);
29947
30038
  return _this.caseNotifier.cachedCaseView;
29948
- }), operators.catchError(function (error) { return _this.checkAuthorizationError(error); })).toPromise();
30039
+ }), operators.catchError(function (error) { return _this.checkAuthorizationError(error, cid); })).toPromise();
29949
30040
  };
29950
- CaseResolver.prototype.checkAuthorizationError = function (error) {
30041
+ CaseResolver.prototype.checkAuthorizationError = function (error, caseReference) {
29951
30042
  // TODO Should be logged to remote logging infrastructure
29952
30043
  if (error.status === 400) {
29953
30044
  this.router.navigate(['/search/noresults']);
29954
30045
  return rxjs.of(null);
29955
30046
  }
29956
- console.error(error);
29957
30047
  if (CaseResolver.EVENT_REGEX.test(this.previousUrl) && error.status === 404) {
29958
30048
  this.router.navigate(['/list/case']);
29959
30049
  return rxjs.of(null);
29960
30050
  }
29961
- if (error.status !== 401 && error.status !== 403) {
30051
+ // Error 403, navigate to restricted case access page
30052
+ if (error.status === 403) {
30053
+ this.router.navigate(["/cases/restricted-case-access/" + caseReference]);
30054
+ return rxjs.of(null);
30055
+ }
30056
+ if (error.status !== 401) {
29962
30057
  this.router.navigate(['/error']);
29963
30058
  }
29964
30059
  this.goToDefaultPage();