@hmcts/ccd-case-ui-toolkit 7.2.58 → 7.2.59-3552

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.
@@ -8,10 +8,10 @@ import * as i1$1 from '@angular/router';
8
8
  import { RouterModule, NavigationStart, NavigationEnd } from '@angular/router';
9
9
  import * as i4 from '@angular/forms';
10
10
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormArray, FormGroup, FormControl, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
11
- import { BehaviorSubject, throwError, Subject, EMPTY, Observable, of, combineLatest, timer, forkJoin, fromEvent, Subscription } from 'rxjs';
11
+ import { BehaviorSubject, throwError, Subject, EMPTY, Observable, skip, of, timer, forkJoin, fromEvent, combineLatest, Subscription } from 'rxjs';
12
12
  import * as i1$2 from '@angular/common/http';
13
13
  import { HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
14
- import { distinctUntilChanged, catchError, map, publish, refCount, switchMap, debounceTime, take, delay, finalize, timeout, mergeMap, retryWhen, tap, delayWhen, publishReplay, first, takeUntil, filter } from 'rxjs/operators';
14
+ import { distinctUntilChanged, catchError, map, publish, refCount, switchMap, debounceTime, delay, finalize, timeout, mergeMap, retryWhen, tap, delayWhen, publishReplay, take, first, takeUntil, filter } from 'rxjs/operators';
15
15
  import { polling } from 'rx-polling-hmcts';
16
16
  import { Type, Exclude, Expose, plainToClassFromExist, plainToClass } from 'class-transformer';
17
17
  import moment from 'moment';
@@ -6533,11 +6533,8 @@ class LabelSubstitutorDirective {
6533
6533
  this.initialHintText = this.caseField.hint_text;
6534
6534
  this.caseField.originalLabel = this.caseField.label;
6535
6535
  this.formGroup = this.formGroup || new FormGroup({});
6536
- this.languageSubscription = this.rpxTranslationService.language$.subscribe(() => {
6537
- // timeout is required to prevent race conditions with translation pipe
6538
- setTimeout(() => {
6539
- this.onLanguageChange();
6540
- }, 100);
6536
+ this.languageSubscription = this.rpxTranslationService.language$.pipe(skip(1)).subscribe(() => {
6537
+ this.onLanguageChange();
6541
6538
  });
6542
6539
  this.applySubstitutions();
6543
6540
  }
@@ -7134,89 +7131,9 @@ class ReadCookieService {
7134
7131
  args: [DOCUMENT]
7135
7132
  }] }], null); })();
7136
7133
 
7137
- class CaseNotifier {
7138
- casesService;
7139
- static CASE_NAME = 'caseNameHmctsInternal';
7140
- static CASE_LOCATION = 'caseManagementLocation';
7141
- caseViewSource = new BehaviorSubject(new CaseView());
7142
- caseView = this.caseViewSource.asObservable();
7143
- cachedCaseView;
7144
- constructor(casesService) {
7145
- this.casesService = casesService;
7146
- }
7147
- removeCachedCase() {
7148
- this.cachedCaseView = null;
7149
- }
7150
- announceCase(c) {
7151
- this.caseViewSource.next(c);
7152
- }
7153
- fetchAndRefresh(cid) {
7154
- return this.casesService
7155
- .getCaseViewV2(cid)
7156
- .pipe(map(caseView => {
7157
- this.cachedCaseView = plainToClassFromExist(new CaseView(), caseView);
7158
- this.setBasicFields(this.cachedCaseView.tabs);
7159
- this.announceCase(this.cachedCaseView);
7160
- return this.cachedCaseView;
7161
- }));
7162
- }
7163
- setBasicFields(tabs) {
7164
- tabs.forEach((t) => {
7165
- const caseName = t.fields.find(f => f.id === CaseNotifier.CASE_NAME);
7166
- const caseLocation = t.fields.find(f => f.id === CaseNotifier.CASE_LOCATION);
7167
- if (caseName || caseLocation) {
7168
- this.cachedCaseView.basicFields = {
7169
- caseNameHmctsInternal: caseName ? caseName.value : null,
7170
- caseManagementLocation: caseLocation ? caseLocation.value : null
7171
- };
7172
- }
7173
- });
7174
- }
7175
- static ɵfac = function CaseNotifier_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaseNotifier)(i0.ɵɵinject(CasesService)); };
7176
- static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CaseNotifier, factory: CaseNotifier.ɵfac });
7177
- }
7178
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseNotifier, [{
7179
- type: Injectable
7180
- }], () => [{ type: CasesService }], null); })();
7181
-
7182
- class JurisdictionService {
7183
- httpService;
7184
- // We retain the Subject observable because subscribing code couldn't happen a null value
7185
- selectedJurisdictionSource = new Subject();
7186
- _selectedJurisdictionBS = new BehaviorSubject(null);
7187
- selectedJurisdiction;
7188
- constructor(httpService) {
7189
- this.httpService = httpService;
7190
- this.selectedJurisdiction = this.selectedJurisdictionSource.asObservable();
7191
- }
7192
- getJurisdictions() {
7193
- return this.httpService.get('/aggregated/caseworkers/:uid/jurisdictions?access=read');
7194
- }
7195
- announceSelectedJurisdiction(jurisdiction) {
7196
- this.selectedJurisdictionSource.next(jurisdiction);
7197
- this._selectedJurisdictionBS.next(jurisdiction);
7198
- }
7199
- getSelectedJurisdiction() {
7200
- return this._selectedJurisdictionBS;
7201
- }
7202
- searchJudicialUsers(searchTerm, serviceId) {
7203
- return this.httpService.post('api/prd/judicial/getJudicialUsersSearch', { searchString: searchTerm, serviceCode: serviceId });
7204
- }
7205
- searchJudicialUsersByPersonalCodes(personalCodes) {
7206
- return this.httpService.post('api/prd/judicial/searchJudicialUserByPersonalCodes', { personal_code: personalCodes });
7207
- }
7208
- static ɵfac = function JurisdictionService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || JurisdictionService)(i0.ɵɵinject(HttpService)); };
7209
- static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: JurisdictionService, factory: JurisdictionService.ɵfac });
7210
- }
7211
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(JurisdictionService, [{
7212
- type: Injectable
7213
- }], () => [{ type: HttpService }], null); })();
7214
-
7215
7134
  class DocumentManagementService {
7216
7135
  http;
7217
7136
  appConfig;
7218
- caseNotifierService;
7219
- jurisdictionService;
7220
7137
  static PDF = 'pdf';
7221
7138
  static IMAGE = 'image';
7222
7139
  static WORD = 'word';
@@ -7232,32 +7149,21 @@ class DocumentManagementService {
7232
7149
  static excelList = ['XLS', 'XLSX', 'xls', 'xlsx'];
7233
7150
  static powerpointList = ['PPT', 'PPTX', 'ppt', 'pptx'];
7234
7151
  caseTypeId = '';
7235
- constructor(http, appConfig, caseNotifierService, jurisdictionService) {
7152
+ constructor(http, appConfig) {
7236
7153
  this.http = http;
7237
7154
  this.appConfig = appConfig;
7238
- this.caseNotifierService = caseNotifierService;
7239
- this.jurisdictionService = jurisdictionService;
7240
- combineLatest([
7241
- this.caseNotifierService.caseView.pipe(take(1)),
7242
- this.jurisdictionService.getSelectedJurisdiction()
7243
- ]).subscribe(([caseDetails, jurisdiction]) => {
7244
- if (caseDetails) {
7245
- this.caseTypeId = caseDetails?.case_type?.id;
7246
- }
7247
- if (jurisdiction) {
7248
- if (jurisdiction.currentCaseType) {
7249
- this.caseTypeId = jurisdiction.currentCaseType.id;
7250
- }
7251
- }
7252
- //if the user refreshes on the case creation page the above logic will not work, we can get the caseTypeId from the URL
7253
- if (!this.caseTypeId) {
7254
- const url = window.location.pathname;
7255
- if (url.indexOf('/case-create/') > -1) {
7256
- const parts = url.split('/');
7257
- this.caseTypeId = parts[parts.indexOf('case-create') + 2];
7258
- }
7155
+ const currUrl = window.location.pathname;
7156
+ if (currUrl.includes('/case-details/')) {
7157
+ this.caseTypeId = currUrl.split('/')[4];
7158
+ }
7159
+ console.log(this.caseTypeId);
7160
+ //if the user refreshes on the case creation page the above logic will not work, we can get the caseTypeId from the URL
7161
+ if (!this.caseTypeId) {
7162
+ if (currUrl.indexOf('/case-create/') > -1) {
7163
+ const parts = currUrl.split('/');
7164
+ this.caseTypeId = parts[parts.indexOf('case-create') + 2];
7259
7165
  }
7260
- });
7166
+ }
7261
7167
  }
7262
7168
  uploadFile(formData) {
7263
7169
  const url = this.getDocStoreUrl();
@@ -7346,19 +7252,18 @@ class DocumentManagementService {
7346
7252
  isDocumentSecureModeEnabled() {
7347
7253
  const documentSecureModeCaseTypeExclusions = this.appConfig.getCdamExclusionList()?.split(',');
7348
7254
  const isDocumentOnExclusionList = documentSecureModeCaseTypeExclusions?.includes(this.caseTypeId);
7349
- this.appConfig.logMessage(`isDocumentOnExclusionList: ${isDocumentOnExclusionList}`);
7350
7255
  if (!isDocumentOnExclusionList) {
7351
7256
  return true;
7352
7257
  }
7353
7258
  // if documentSecureModeEnabled is true, and case is in the exclusion list, return false
7354
7259
  return false;
7355
7260
  }
7356
- static ɵfac = function DocumentManagementService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DocumentManagementService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig), i0.ɵɵinject(CaseNotifier), i0.ɵɵinject(JurisdictionService)); };
7261
+ static ɵfac = function DocumentManagementService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DocumentManagementService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig)); };
7357
7262
  static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DocumentManagementService, factory: DocumentManagementService.ɵfac });
7358
7263
  }
7359
7264
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DocumentManagementService, [{
7360
7265
  type: Injectable
7361
- }], () => [{ type: HttpService }, { type: AbstractAppConfig }, { type: CaseNotifier }, { type: JurisdictionService }], null); })();
7266
+ }], () => [{ type: HttpService }, { type: AbstractAppConfig }], null); })();
7362
7267
 
7363
7268
  class ErrorNotifierService {
7364
7269
  errorSource = new BehaviorSubject(null);
@@ -7550,6 +7455,39 @@ class MultipageComponentStateService {
7550
7455
  }]
7551
7456
  }], null, null); })();
7552
7457
 
7458
+ class JurisdictionService {
7459
+ httpService;
7460
+ // We retain the Subject observable because subscribing code couldn't happen a null value
7461
+ selectedJurisdictionSource = new Subject();
7462
+ _selectedJurisdictionBS = new BehaviorSubject(null);
7463
+ selectedJurisdiction;
7464
+ constructor(httpService) {
7465
+ this.httpService = httpService;
7466
+ this.selectedJurisdiction = this.selectedJurisdictionSource.asObservable();
7467
+ }
7468
+ getJurisdictions() {
7469
+ return this.httpService.get('/aggregated/caseworkers/:uid/jurisdictions?access=read');
7470
+ }
7471
+ announceSelectedJurisdiction(jurisdiction) {
7472
+ this.selectedJurisdictionSource.next(jurisdiction);
7473
+ this._selectedJurisdictionBS.next(jurisdiction);
7474
+ }
7475
+ getSelectedJurisdiction() {
7476
+ return this._selectedJurisdictionBS;
7477
+ }
7478
+ searchJudicialUsers(searchTerm, serviceId) {
7479
+ return this.httpService.post('api/prd/judicial/getJudicialUsersSearch', { searchString: searchTerm, serviceCode: serviceId });
7480
+ }
7481
+ searchJudicialUsersByPersonalCodes(personalCodes) {
7482
+ return this.httpService.post('api/prd/judicial/searchJudicialUserByPersonalCodes', { personal_code: personalCodes });
7483
+ }
7484
+ static ɵfac = function JurisdictionService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || JurisdictionService)(i0.ɵɵinject(HttpService)); };
7485
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: JurisdictionService, factory: JurisdictionService.ɵfac });
7486
+ }
7487
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(JurisdictionService, [{
7488
+ type: Injectable
7489
+ }], () => [{ type: HttpService }], null); })();
7490
+
7553
7491
  class BannersService {
7554
7492
  httpService;
7555
7493
  appConfig;
@@ -8669,6 +8607,51 @@ class CaseworkerService {
8669
8607
  type: Injectable
8670
8608
  }], () => [{ type: HttpService }, { type: AbstractAppConfig }, { type: HttpErrorService }], null); })();
8671
8609
 
8610
+ class CaseNotifier {
8611
+ casesService;
8612
+ static CASE_NAME = 'caseNameHmctsInternal';
8613
+ static CASE_LOCATION = 'caseManagementLocation';
8614
+ caseViewSource = new BehaviorSubject(new CaseView());
8615
+ caseView = this.caseViewSource.asObservable();
8616
+ cachedCaseView;
8617
+ constructor(casesService) {
8618
+ this.casesService = casesService;
8619
+ }
8620
+ removeCachedCase() {
8621
+ this.cachedCaseView = null;
8622
+ }
8623
+ announceCase(c) {
8624
+ this.caseViewSource.next(c);
8625
+ }
8626
+ fetchAndRefresh(cid) {
8627
+ return this.casesService
8628
+ .getCaseViewV2(cid)
8629
+ .pipe(map(caseView => {
8630
+ this.cachedCaseView = plainToClassFromExist(new CaseView(), caseView);
8631
+ this.setBasicFields(this.cachedCaseView.tabs);
8632
+ this.announceCase(this.cachedCaseView);
8633
+ return this.cachedCaseView;
8634
+ }));
8635
+ }
8636
+ setBasicFields(tabs) {
8637
+ tabs.forEach((t) => {
8638
+ const caseName = t.fields.find(f => f.id === CaseNotifier.CASE_NAME);
8639
+ const caseLocation = t.fields.find(f => f.id === CaseNotifier.CASE_LOCATION);
8640
+ if (caseName || caseLocation) {
8641
+ this.cachedCaseView.basicFields = {
8642
+ caseNameHmctsInternal: caseName ? caseName.value : null,
8643
+ caseManagementLocation: caseLocation ? caseLocation.value : null
8644
+ };
8645
+ }
8646
+ });
8647
+ }
8648
+ static ɵfac = function CaseNotifier_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaseNotifier)(i0.ɵɵinject(CasesService)); };
8649
+ static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CaseNotifier, factory: CaseNotifier.ɵfac });
8650
+ }
8651
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseNotifier, [{
8652
+ type: Injectable
8653
+ }], () => [{ type: CasesService }], null); })();
8654
+
8672
8655
  var Permissions;
8673
8656
  (function (Permissions) {
8674
8657
  Permissions["Own"] = "OWN";
@@ -15252,6 +15235,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15252
15235
  jurisdictionId;
15253
15236
  caseTypeId;
15254
15237
  caseTypeExclusions;
15238
+ caseId;
15255
15239
  // Should the file upload use CDAM
15256
15240
  fileSecureModeOn = false;
15257
15241
  constructor(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService, jurisdictionService) {
@@ -15265,19 +15249,20 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15265
15249
  }
15266
15250
  ngOnInit() {
15267
15251
  // Wait for both observables to emit at least once
15252
+ const currUrl = window.location.pathname;
15253
+ if (currUrl.includes('/case-details/')) {
15254
+ this.caseTypeId = currUrl.split('/')[4];
15255
+ }
15268
15256
  this.caseNotifierSubscription = combineLatest([
15269
15257
  this.caseNotifier.caseView.pipe(take(1)),
15270
15258
  this.jurisdictionService.getSelectedJurisdiction()
15271
15259
  ]).subscribe(([caseDetails, jurisdiction]) => {
15272
15260
  if (caseDetails) {
15273
- this.caseTypeId = caseDetails?.case_type?.id;
15274
15261
  this.jurisdictionId = caseDetails?.case_type?.jurisdiction?.id;
15262
+ this.caseId = caseDetails?.case_id;
15275
15263
  }
15276
15264
  if (jurisdiction) {
15277
15265
  this.jurisdictionId = jurisdiction.id;
15278
- if (jurisdiction.currentCaseType) {
15279
- this.caseTypeId = jurisdiction.currentCaseType.id;
15280
- }
15281
15266
  }
15282
15267
  //if we havent set the value of caseTypeId yet, we can check if its in the url. e.g. case-creation
15283
15268
  if (!this.caseTypeId) {
@@ -15290,12 +15275,8 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15290
15275
  }
15291
15276
  // use the documentManagement service to check if the document upload should use CDAM
15292
15277
  if (this.documentManagement.isDocumentSecureModeEnabled()) {
15293
- this.appConfig.logMessage(`CDAM is enabled for case with case ref:: ${caseDetails?.case_id}`);
15294
15278
  this.fileSecureModeOn = true;
15295
15279
  }
15296
- else {
15297
- this.appConfig.logMessage(`CDAM is disabled for case with case ref:: ${caseDetails?.case_id}`);
15298
- }
15299
15280
  this.dialogConfig = initDialog();
15300
15281
  let document = this.caseField.value || { document_url: null, document_binary_url: null, document_filename: null };
15301
15282
  document = this.fileSecureModeOn && !document.document_hash ? { ...document, document_hash: null } : document;
@@ -15529,6 +15510,13 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15529
15510
  return documentUpload;
15530
15511
  }
15531
15512
  handleDocumentUploadResult(result) {
15513
+ // use the documentManagement service to check if the document upload should use CDAM
15514
+ if (this.documentManagement.isDocumentSecureModeEnabled()) {
15515
+ this.appConfig.logMessage(`CDAM is enabled for case with case ref:: ${this.caseId}`);
15516
+ }
15517
+ else {
15518
+ this.appConfig.logMessage(`CDAM is disabled for case with case ref:: ${this.caseId}`);
15519
+ }
15532
15520
  if (!this.uploadedDocument) {
15533
15521
  if (this.fileSecureModeOn) {
15534
15522
  this.createDocumentForm({ document_url: null, document_binary_url: null, document_filename: null, document_hash: null });