@hmcts/ccd-case-ui-toolkit 6.19.5-restricted-case-access → 6.19.5

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.
@@ -7708,7 +7708,6 @@
7708
7708
  return this.httpService.get('/aggregated/caseworkers/:uid/jurisdictions?access=read');
7709
7709
  };
7710
7710
  JurisdictionService.prototype.announceSelectedJurisdiction = function (jurisdiction) {
7711
- console.info('Announcing selected jurisdiction = ' + (jurisdiction === null || jurisdiction === void 0 ? void 0 : jurisdiction.id));
7712
7711
  this.selectedJurisdictionSource.next(jurisdiction);
7713
7712
  this.selectedJurisdictionBS.next(jurisdiction);
7714
7713
  };
@@ -9374,23 +9373,16 @@
9374
9373
  this.cachedCaseView = null;
9375
9374
  };
9376
9375
  CaseNotifier.prototype.announceCase = function (c) {
9377
- console.info('announceCase started.');
9378
9376
  this.caseViewSource.next(c);
9379
- console.info('announceCase finished.');
9380
9377
  };
9381
9378
  CaseNotifier.prototype.fetchAndRefresh = function (cid) {
9382
9379
  var _this = this;
9383
- console.info('fetchAndRefresh started.');
9384
9380
  return this.casesService
9385
9381
  .getCaseViewV2(cid)
9386
9382
  .pipe(operators.map(function (caseView) {
9387
- console.info('mapping caseView started.');
9388
- // this.casesService.syncWait(10);
9389
- // throw new Error('******************************************************');
9390
9383
  _this.cachedCaseView = classTransformer.plainToClassFromExist(new CaseView(), caseView);
9391
9384
  _this.setBasicFields(_this.cachedCaseView.tabs);
9392
9385
  _this.announceCase(_this.cachedCaseView);
9393
- console.info('mapping caseView finished. Returning it.');
9394
9386
  return _this.cachedCaseView;
9395
9387
  }));
9396
9388
  };
@@ -14635,18 +14627,19 @@
14635
14627
  var _c1$k = function (a0) { return { "form-group-error bottom-30": a0 }; };
14636
14628
  var WriteDocumentFieldComponent = /** @class */ (function (_super) {
14637
14629
  __extends(WriteDocumentFieldComponent, _super);
14638
- function WriteDocumentFieldComponent(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService) {
14630
+ function WriteDocumentFieldComponent(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService, jurisdictionService) {
14639
14631
  var _this = _super.call(this) || this;
14640
14632
  _this.appConfig = appConfig;
14641
14633
  _this.caseNotifier = caseNotifier;
14642
14634
  _this.documentManagement = documentManagement;
14643
14635
  _this.dialog = dialog;
14644
14636
  _this.fileUploadStateService = fileUploadStateService;
14637
+ _this.jurisdictionService = jurisdictionService;
14645
14638
  _this.valid = true;
14646
14639
  return _this;
14647
14640
  }
14648
14641
  WriteDocumentFieldComponent.prototype.clickout = function (event) {
14649
- // Capturing the event of of the associated ElementRef <input type="file" #fileInpu
14642
+ // Capturing the event of the associated ElementRef <input type="file" #fileInpu
14650
14643
  if (this.fileInput.nativeElement.contains(event.target)) {
14651
14644
  this.clickInsideTheDocument = true;
14652
14645
  }
@@ -14656,6 +14649,9 @@
14656
14649
  };
14657
14650
  WriteDocumentFieldComponent.prototype.ngOnInit = function () {
14658
14651
  this.secureModeOn = this.appConfig.getDocumentSecureMode();
14652
+ if (this.secureModeOn) {
14653
+ this.subscribeToCaseDetails();
14654
+ }
14659
14655
  this.dialogConfig = initDialog();
14660
14656
  // EUI-3403. The field was not being registered when there was no value and the field
14661
14657
  // itself was not mandatory, which meant that show_conditions would not be evaluated.
@@ -14668,9 +14664,6 @@
14668
14664
  else {
14669
14665
  this.createDocumentForm(document);
14670
14666
  }
14671
- if (this.appConfig.getDocumentSecureMode()) {
14672
- this.subscribeToCaseDetails();
14673
- }
14674
14667
  };
14675
14668
  WriteDocumentFieldComponent.prototype.ngOnDestroy = function () {
14676
14669
  if (this.fileUploadSubscription) {
@@ -14679,8 +14672,11 @@
14679
14672
  if (this.dialogSubscription) {
14680
14673
  this.dialogSubscription.unsubscribe();
14681
14674
  }
14682
- if (this.caseEventSubscription) {
14683
- this.caseEventSubscription.unsubscribe();
14675
+ if (this.caseNotifierSubscription) {
14676
+ this.caseNotifierSubscription.unsubscribe();
14677
+ }
14678
+ if (this.jurisdictionSubs) {
14679
+ this.jurisdictionSubs.unsubscribe();
14684
14680
  }
14685
14681
  };
14686
14682
  WriteDocumentFieldComponent.prototype.isUploadInProgress = function () {
@@ -14732,7 +14728,9 @@
14732
14728
  WriteDocumentFieldComponent.prototype.triggerReplace = function () {
14733
14729
  if (this.confirmReplaceResult === 'Replace') {
14734
14730
  this.openFileDialog();
14731
+ return true;
14735
14732
  }
14733
+ return false;
14736
14734
  };
14737
14735
  WriteDocumentFieldComponent.prototype.getUploadedFileName = function () {
14738
14736
  if (this.uploadedDocument) {
@@ -14767,11 +14765,28 @@
14767
14765
  _this.triggerReplace();
14768
14766
  });
14769
14767
  };
14768
+ // Depending on the context, we can get the case type and jurisdiction from different sources
14769
+ // If we are running an event, the caseNotifier will have the current case
14770
+ // If we are creating a case, the case doesn't exist yet, so the caseNotifier can't help
14771
+ // Instead we can use the eventTrigger to get the case type, and the jurisdiction service to
14772
+ // get the currently selected jurisdiction
14770
14773
  WriteDocumentFieldComponent.prototype.subscribeToCaseDetails = function () {
14771
14774
  var _this = this;
14772
- this.caseEventSubscription = this.caseNotifier.caseView.subscribe({
14775
+ this.caseNotifierSubscription = this.caseNotifier.caseView.subscribe({
14773
14776
  next: function (caseDetails) {
14774
- _this.caseDetails = caseDetails;
14777
+ var _a, _b;
14778
+ _this.caseTypeId = caseDetails === null || caseDetails === void 0 ? void 0 : caseDetails.case_id;
14779
+ _this.jurisdictionId = (_b = (_a = caseDetails === null || caseDetails === void 0 ? void 0 : caseDetails.case_type) === null || _a === void 0 ? void 0 : _a.jurisdiction) === null || _b === void 0 ? void 0 : _b.id;
14780
+ }
14781
+ });
14782
+ this.jurisdictionSubs = this.jurisdictionService.selectedJurisdictionBS.subscribe({
14783
+ next: function (jurisdiction) {
14784
+ if (jurisdiction) {
14785
+ _this.jurisdictionId = jurisdiction.id;
14786
+ if (jurisdiction.currentCaseType) {
14787
+ _this.caseTypeId = jurisdiction.currentCaseType.id;
14788
+ }
14789
+ }
14775
14790
  }
14776
14791
  });
14777
14792
  };
@@ -14835,13 +14850,8 @@
14835
14850
  documentUpload.append('files', selectedFile, selectedFile.name);
14836
14851
  documentUpload.append('classification', 'PUBLIC');
14837
14852
  if (this.appConfig.getDocumentSecureMode()) {
14838
- var caseTypeId = this.caseDetails &&
14839
- this.caseDetails.case_type &&
14840
- this.caseDetails.case_type.id ? this.caseDetails.case_type.id : null;
14841
- var caseTypeJurisdictionId = this.caseDetails &&
14842
- this.caseDetails.case_type &&
14843
- this.caseDetails.case_type.jurisdiction &&
14844
- this.caseDetails.case_type.jurisdiction.id ? this.caseDetails.case_type.jurisdiction.id : null;
14853
+ var caseTypeId = this.caseTypeId ? this.caseTypeId : null;
14854
+ var caseTypeJurisdictionId = this.jurisdictionId ? this.jurisdictionId : null;
14845
14855
  documentUpload.append('caseTypeId', caseTypeId);
14846
14856
  documentUpload.append('jurisdictionId', caseTypeJurisdictionId);
14847
14857
  }
@@ -14889,7 +14899,7 @@
14889
14899
  WriteDocumentFieldComponent.UPLOAD_ERROR_FILE_REQUIRED = 'File required';
14890
14900
  WriteDocumentFieldComponent.UPLOAD_ERROR_NOT_AVAILABLE = 'Document upload facility is not available at the moment';
14891
14901
  WriteDocumentFieldComponent.UPLOAD_WAITING_FILE_STATUS = 'Uploading...';
14892
- WriteDocumentFieldComponent.ɵfac = function WriteDocumentFieldComponent_Factory(t) { return new (t || WriteDocumentFieldComponent)(i0__namespace.ɵɵdirectiveInject(AbstractAppConfig), i0__namespace.ɵɵdirectiveInject(CaseNotifier), i0__namespace.ɵɵdirectiveInject(DocumentManagementService), i0__namespace.ɵɵdirectiveInject(i1__namespace$3.MatDialog), i0__namespace.ɵɵdirectiveInject(FileUploadStateService)); };
14902
+ WriteDocumentFieldComponent.ɵfac = function WriteDocumentFieldComponent_Factory(t) { return new (t || WriteDocumentFieldComponent)(i0__namespace.ɵɵdirectiveInject(AbstractAppConfig), i0__namespace.ɵɵdirectiveInject(CaseNotifier), i0__namespace.ɵɵdirectiveInject(DocumentManagementService), i0__namespace.ɵɵdirectiveInject(i1__namespace$3.MatDialog), i0__namespace.ɵɵdirectiveInject(FileUploadStateService), i0__namespace.ɵɵdirectiveInject(JurisdictionService)); };
14893
14903
  WriteDocumentFieldComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: WriteDocumentFieldComponent, selectors: [["ccd-write-document-field"]], viewQuery: function WriteDocumentFieldComponent_Query(rf, ctx) {
14894
14904
  if (rf & 1) {
14895
14905
  i0__namespace.ɵɵviewQuery(_c0$N, 1);
@@ -14967,7 +14977,7 @@
14967
14977
  selector: 'ccd-write-document-field',
14968
14978
  templateUrl: './write-document-field.html'
14969
14979
  }]
14970
- }], function () { return [{ type: AbstractAppConfig }, { type: CaseNotifier }, { type: DocumentManagementService }, { type: i1__namespace$3.MatDialog }, { type: FileUploadStateService }]; }, { fileInput: [{
14980
+ }], function () { return [{ type: AbstractAppConfig }, { type: CaseNotifier }, { type: DocumentManagementService }, { type: i1__namespace$3.MatDialog }, { type: FileUploadStateService }, { type: JurisdictionService }]; }, { fileInput: [{
14971
14981
  type: i0.ViewChild,
14972
14982
  args: ['fileInput', { static: false }]
14973
14983
  }], clickout: [{
@@ -31010,7 +31020,7 @@
31010
31020
  else {
31011
31021
  console.info('getAndCacheCaseView - Path B.');
31012
31022
  return this.caseNotifier.fetchAndRefresh(cid)
31013
- .pipe(operators.catchError(function (error) { return _this.processErrorInCaseFetch(error, cid); }))
31023
+ .pipe(operators.catchError(function (error) { return _this.processErrorInCaseFetch(error); }))
31014
31024
  .toPromise();
31015
31025
  }
31016
31026
  }
@@ -31023,9 +31033,9 @@
31023
31033
  _this.caseNotifier.cachedCaseView = classTransformer.plainToClassFromExist(new CaseView(), caseView);
31024
31034
  _this.caseNotifier.announceCase(_this.caseNotifier.cachedCaseView);
31025
31035
  return _this.caseNotifier.cachedCaseView;
31026
- }), operators.catchError(function (error) { return _this.processErrorInCaseFetch(error, cid); })).toPromise();
31036
+ }), operators.catchError(function (error) { return _this.processErrorInCaseFetch(error); })).toPromise();
31027
31037
  };
31028
- CaseResolver.prototype.processErrorInCaseFetch = function (error, caseReference) {
31038
+ CaseResolver.prototype.processErrorInCaseFetch = function (error) {
31029
31039
  console.error('!!! processErrorInCaseFetch !!!');
31030
31040
  console.error(error);
31031
31041
  // TODO Should be logged to remote logging infrastructure
@@ -31033,16 +31043,12 @@
31033
31043
  this.router.navigate(['/search/noresults']);
31034
31044
  return rxjs.of(null);
31035
31045
  }
31046
+ console.error(error);
31036
31047
  if (CaseResolver.EVENT_REGEX.test(this.previousUrl) && error.status === 404) {
31037
31048
  this.router.navigate(['/list/case']);
31038
31049
  return rxjs.of(null);
31039
31050
  }
31040
- // Error 403, navigate to restricted case access page
31041
- if (error.status === 403) {
31042
- this.router.navigate(["/cases/restricted-case-access/" + caseReference]);
31043
- return rxjs.of(null);
31044
- }
31045
- if (error.status !== 401) {
31051
+ if (error.status !== 401 && error.status !== 403) {
31046
31052
  this.router.navigate(['/error']);
31047
31053
  }
31048
31054
  this.goToDefaultPage();