@hmcts/ccd-case-ui-toolkit 7.3.2-user-by-idam → 7.3.3-3859

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.
@@ -7148,6 +7148,7 @@ class ReadCookieService {
7148
7148
  class DocumentManagementService {
7149
7149
  http;
7150
7150
  appConfig;
7151
+ sessionStorageService;
7151
7152
  static PDF = 'pdf';
7152
7153
  static IMAGE = 'image';
7153
7154
  static WORD = 'word';
@@ -7162,29 +7163,22 @@ class DocumentManagementService {
7162
7163
  static wordList = ['DOC', 'DOCX', 'doc', 'docx'];
7163
7164
  static excelList = ['XLS', 'XLSX', 'xls', 'xlsx'];
7164
7165
  static powerpointList = ['PPT', 'PPTX', 'ppt', 'pptx'];
7165
- caseTypeId = '';
7166
- constructor(http, appConfig) {
7166
+ caseTypeId;
7167
+ caseId;
7168
+ constructor(http, appConfig, sessionStorageService) {
7167
7169
  this.http = http;
7168
7170
  this.appConfig = appConfig;
7169
- const currUrl = window.location.pathname;
7170
- if (currUrl.includes('/case-details/')) {
7171
- this.caseTypeId = currUrl.split('/')[4];
7172
- }
7173
- console.log(this.caseTypeId);
7174
- //if the user refreshes on the case creation page the above logic will not work, we can get the caseTypeId from the URL
7175
- if (!this.caseTypeId) {
7176
- if (currUrl.indexOf('/case-create/') > -1) {
7177
- const parts = currUrl.split('/');
7178
- this.caseTypeId = parts[parts.indexOf('case-create') + 2];
7179
- }
7180
- }
7171
+ this.sessionStorageService = sessionStorageService;
7172
+ const caseInfo = this.parseCaseInfo(this.sessionStorageService.getItem('caseInfo'));
7173
+ const currUrl = this.getCurrentPathname();
7174
+ this.caseTypeId = this.resolveCaseTypeId(caseInfo, currUrl);
7181
7175
  }
7182
7176
  uploadFile(formData) {
7183
7177
  const url = this.getDocStoreUrl();
7184
7178
  // Do not set any headers, such as "Accept" or "Content-Type", with null values; this is not permitted with the
7185
7179
  // Angular HttpClient in @angular/common/http. Just create and pass a new HttpHeaders object. Angular will add the
7186
7180
  // correct headers and values automatically
7187
- this.appConfig.logMessage(`Uploading document for case type: ${this.caseTypeId}, with url: ${url}`);
7181
+ this.appConfig.logMessage(`DMS:: Uploading document for case type: ${this.caseTypeId}, with url: ${url}, and case id: ${this.caseId}`);
7188
7182
  const headers = new HttpHeaders();
7189
7183
  return this.http
7190
7184
  .post(url, formData, { headers, observe: 'body' })
@@ -7249,6 +7243,40 @@ class DocumentManagementService {
7249
7243
  isPowerpoint(powerpointType) {
7250
7244
  return DocumentManagementService.powerpointList.find(e => e === powerpointType) !== undefined;
7251
7245
  }
7246
+ parseCaseInfo(caseInfo) {
7247
+ if (!caseInfo) {
7248
+ return null;
7249
+ }
7250
+ try {
7251
+ return JSON.parse(caseInfo);
7252
+ }
7253
+ catch (error) {
7254
+ this.appConfig.logMessage('Failed to parse caseInfo from session storage');
7255
+ return null;
7256
+ }
7257
+ }
7258
+ getCurrentPathname() {
7259
+ if (typeof window === 'undefined' || !window.location) {
7260
+ return '';
7261
+ }
7262
+ return window.location.pathname || '';
7263
+ }
7264
+ resolveCaseTypeId(caseInfo, currUrl) {
7265
+ const caseTypeIdFromSession = caseInfo?.caseType;
7266
+ if (caseTypeIdFromSession) {
7267
+ this.caseId = caseInfo?.caseId;
7268
+ return caseTypeIdFromSession;
7269
+ }
7270
+ const parts = currUrl.split('/');
7271
+ if (currUrl.includes('/case-details/') && parts.length > 4) {
7272
+ return parts[4];
7273
+ }
7274
+ const caseCreateIndex = parts.indexOf('case-create');
7275
+ if (currUrl.includes('/case-create/') && caseCreateIndex > -1 && parts.length > caseCreateIndex + 2) {
7276
+ return parts[caseCreateIndex + 2];
7277
+ }
7278
+ return '';
7279
+ }
7252
7280
  transformDocumentUrl(documentBinaryUrl) {
7253
7281
  const remoteHrsPattern = new RegExp(this.appConfig.getRemoteHrsUrl());
7254
7282
  documentBinaryUrl = documentBinaryUrl.replace(remoteHrsPattern, this.appConfig.getHrsUrl());
@@ -7272,12 +7300,12 @@ class DocumentManagementService {
7272
7300
  // if documentSecureModeEnabled is true, and case is in the exclusion list, return false
7273
7301
  return false;
7274
7302
  }
7275
- static ɵfac = function DocumentManagementService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DocumentManagementService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig)); };
7303
+ static ɵfac = function DocumentManagementService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DocumentManagementService)(i0.ɵɵinject(HttpService), i0.ɵɵinject(AbstractAppConfig), i0.ɵɵinject(SessionStorageService)); };
7276
7304
  static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DocumentManagementService, factory: DocumentManagementService.ɵfac });
7277
7305
  }
7278
7306
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DocumentManagementService, [{
7279
7307
  type: Injectable
7280
- }], () => [{ type: HttpService }, { type: AbstractAppConfig }], null); })();
7308
+ }], () => [{ type: HttpService }, { type: AbstractAppConfig }, { type: SessionStorageService }], null); })();
7281
7309
 
7282
7310
  class ErrorNotifierService {
7283
7311
  errorSource = new BehaviorSubject(null);
@@ -8605,10 +8633,10 @@ class CaseworkerService {
8605
8633
  this.appConfig = appConfig;
8606
8634
  this.errorService = errorService;
8607
8635
  }
8608
- getUserByIdamId(idamId) {
8609
- const url = `${this.appConfig.getWorkAllocationApiUrl()}/caseworker/getUserByIdamId`;
8636
+ getCaseworkers(serviceId) {
8637
+ const url = `${this.appConfig.getWorkAllocationApiUrl()}/caseworker/getUsersByServiceName`;
8610
8638
  return this.http
8611
- .post(url, idamId)
8639
+ .post(url, { services: [serviceId] })
8612
8640
  .pipe(catchError(error => {
8613
8641
  this.errorService.setError(error);
8614
8642
  return throwError(error);
@@ -12054,9 +12082,12 @@ class CaseEventCompletionTaskReassignedComponent {
12054
12082
  this.jurisdiction = task.jurisdiction;
12055
12083
  this.caseType = task.case_type_id;
12056
12084
  // Current user is a caseworker?
12057
- this.caseworkerSubscription = this.caseworkerService.getUserByIdamId(task.assignee).subscribe(caseworker => {
12058
- if (caseworker) {
12059
- this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
12085
+ this.caseworkerSubscription = this.caseworkerService.getCaseworkers(task.jurisdiction).subscribe(result => {
12086
+ if (result && result[0].service === task.jurisdiction && result[0].caseworkers) {
12087
+ const caseworker = result[0].caseworkers.find(x => x.idamId === task.assignee);
12088
+ if (caseworker) {
12089
+ this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
12090
+ }
12060
12091
  }
12061
12092
  if (!this.assignedUserName) {
12062
12093
  // Current user is a judicial user?
@@ -15223,6 +15254,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15223
15254
  dialog;
15224
15255
  fileUploadStateService;
15225
15256
  jurisdictionService;
15257
+ sessionStorageService;
15226
15258
  static DOCUMENT_URL = 'document_url';
15227
15259
  static DOCUMENT_BINARY_URL = 'document_binary_url';
15228
15260
  static DOCUMENT_FILENAME = 'document_filename';
@@ -15252,7 +15284,8 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15252
15284
  caseId;
15253
15285
  // Should the file upload use CDAM
15254
15286
  fileSecureModeOn = false;
15255
- constructor(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService, jurisdictionService) {
15287
+ gotFromCaseInfo = false;
15288
+ constructor(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService, jurisdictionService, sessionStorageService) {
15256
15289
  super();
15257
15290
  this.appConfig = appConfig;
15258
15291
  this.caseNotifier = caseNotifier;
@@ -15260,12 +15293,20 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15260
15293
  this.dialog = dialog;
15261
15294
  this.fileUploadStateService = fileUploadStateService;
15262
15295
  this.jurisdictionService = jurisdictionService;
15296
+ this.sessionStorageService = sessionStorageService;
15263
15297
  }
15264
15298
  ngOnInit() {
15265
15299
  // Wait for both observables to emit at least once
15300
+ const caseInfo = this.documentManagement.parseCaseInfo(this.sessionStorageService.getItem('caseInfo'));
15266
15301
  const currUrl = window.location.pathname;
15267
- if (currUrl.includes('/case-details/')) {
15268
- this.caseTypeId = currUrl.split('/')[4];
15302
+ if (caseInfo) {
15303
+ this.gotFromCaseInfo = true;
15304
+ this.caseTypeId = caseInfo.caseType;
15305
+ }
15306
+ else {
15307
+ if (currUrl.includes('/case-details/')) {
15308
+ this.caseTypeId = currUrl.split('/')[4];
15309
+ }
15269
15310
  }
15270
15311
  this.caseNotifierSubscription = combineLatest([
15271
15312
  this.caseNotifier.caseView.pipe(take(1)),
@@ -15526,10 +15567,10 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15526
15567
  handleDocumentUploadResult(result) {
15527
15568
  // use the documentManagement service to check if the document upload should use CDAM
15528
15569
  if (this.documentManagement.isDocumentSecureModeEnabled()) {
15529
- this.appConfig.logMessage(`CDAM is enabled for case with case ref:: ${this.caseId}`);
15570
+ this.appConfig.logMessage(`WDF:: CDAM is enabled for case with case ref:: ${this.caseId}, case type:: ${this.caseTypeId}, gotFromCaseInfo:: ${this.gotFromCaseInfo}`);
15530
15571
  }
15531
15572
  else {
15532
- this.appConfig.logMessage(`CDAM is disabled for case with case ref:: ${this.caseId}`);
15573
+ this.appConfig.logMessage(`WDF:: CDAM is disabled for case with case ref:: ${this.caseId}, case type:: ${this.caseTypeId}, gotFromCaseInfo:: ${this.gotFromCaseInfo}`);
15533
15574
  }
15534
15575
  if (!this.uploadedDocument) {
15535
15576
  if (this.fileSecureModeOn) {
@@ -15563,7 +15604,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15563
15604
  this.valid = false;
15564
15605
  this.fileUploadStateService.setUploadInProgress(false);
15565
15606
  }
15566
- static ɵfac = function WriteDocumentFieldComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || WriteDocumentFieldComponent)(i0.ɵɵdirectiveInject(AbstractAppConfig), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(DocumentManagementService), i0.ɵɵdirectiveInject(i1$3.MatLegacyDialog), i0.ɵɵdirectiveInject(FileUploadStateService), i0.ɵɵdirectiveInject(JurisdictionService)); };
15607
+ static ɵfac = function WriteDocumentFieldComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || WriteDocumentFieldComponent)(i0.ɵɵdirectiveInject(AbstractAppConfig), i0.ɵɵdirectiveInject(CaseNotifier), i0.ɵɵdirectiveInject(DocumentManagementService), i0.ɵɵdirectiveInject(i1$3.MatLegacyDialog), i0.ɵɵdirectiveInject(FileUploadStateService), i0.ɵɵdirectiveInject(JurisdictionService), i0.ɵɵdirectiveInject(SessionStorageService)); };
15567
15608
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteDocumentFieldComponent, selectors: [["ccd-write-document-field"]], viewQuery: function WriteDocumentFieldComponent_Query(rf, ctx) { if (rf & 1) {
15568
15609
  i0.ɵɵviewQuery(_c0$S, 5);
15569
15610
  } if (rf & 2) {
@@ -15624,11 +15665,11 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15624
15665
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteDocumentFieldComponent, [{
15625
15666
  type: Component,
15626
15667
  args: [{ selector: 'ccd-write-document-field', standalone: false, template: "<div class=\"form-group\" [ngClass]=\"{'form-group-error bottom-30': !valid}\">\n <label [for]=\"id()\">\n <span class=\"form-label\" attr.aria-label=\"{{caseField | ccdFieldLabel}}\">{{(caseField | ccdFieldLabel)}}</span>\n </label>\n <span class=\"form-hint\" *ngIf=\"caseField.hint_text\">\n <markdown [data]=\"caseField.hint_text | rpxTranslate\"></markdown>\n </span>\n <span class=\"error-message\"\n role=\"alert\"\n tabindex=\"0\"\n [hidden]=\"!(fileUploadMessages && !valid)\">\n {{ fileUploadMessages | rpxTranslate }}\n </span>\n <div>\n <!--<span *ngIf=\"getUploadedFileName()\" class=\"text-16\">File name: {{getUploadedFileName()}}</span>-->\n <ccd-read-document-field *ngIf=\"caseField\" [caseField]=\"caseField\"></ccd-read-document-field>\n </div>\n\n <div style='position:relative'>\n <div [id]=\"createElementId('fileInputWrapper')\" (click)=\"fileSelectEvent()\" (keyup)=\"fileSelectEvent()\"></div>\n <input class=\"form-control bottom-30\" [id]=\"id()\" type=\"file\" (keydown.Tab)=\"fileValidationsOnTab()\" (change)=\"fileChangeEvent($event, caseField.field_type.regular_expression)\"\n accept=\"{{caseField.field_type.regular_expression}}\" #fileInput/>\n </div>\n</div>\n<div class=\"form-group bottom-30\">\n <button class=\"button button-secondary\" type=\"button\" aria-label=\"Cancel upload\" (click)=\"cancelUpload()\" [disabled]=\"!isUploadInProgress()\">{{'Cancel upload' | rpxTranslate}}</button>\n</div>\n" }]
15627
- }], () => [{ type: AbstractAppConfig }, { type: CaseNotifier }, { type: DocumentManagementService }, { type: i1$3.MatLegacyDialog }, { type: FileUploadStateService }, { type: JurisdictionService }], { fileInput: [{
15668
+ }], () => [{ type: AbstractAppConfig }, { type: CaseNotifier }, { type: DocumentManagementService }, { type: i1$3.MatLegacyDialog }, { type: FileUploadStateService }, { type: JurisdictionService }, { type: SessionStorageService }], { fileInput: [{
15628
15669
  type: ViewChild,
15629
15670
  args: ['fileInput', { static: false }]
15630
15671
  }] }); })();
15631
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WriteDocumentFieldComponent, { className: "WriteDocumentFieldComponent", filePath: "lib/shared/components/palette/document/write-document-field.component.ts", lineNumber: 25 }); })();
15672
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WriteDocumentFieldComponent, { className: "WriteDocumentFieldComponent", filePath: "lib/shared/components/palette/document/write-document-field.component.ts", lineNumber: 26 }); })();
15632
15673
 
15633
15674
  class DynamicListPipe {
15634
15675
  static EMPTY = '';
@@ -34545,9 +34586,18 @@ class CaseResolver {
34545
34586
  this.navigateToCaseList();
34546
34587
  }
34547
34588
  else {
34548
- return this.isRootCaseViewRoute(route) ? this.getAndCacheCaseView(cid)
34589
+ const resultPromise = this.isRootCaseViewRoute(route) ? this.getAndCacheCaseView(cid)
34549
34590
  : this.caseNotifier.cachedCaseView ? Promise.resolve(this.caseNotifier.cachedCaseView)
34550
34591
  : this.getAndCacheCaseView(cid);
34592
+ return resultPromise.then((caseView) => {
34593
+ const newCaseInfo = {
34594
+ caseId: caseView.case_id,
34595
+ jurisdiction: caseView.case_type.jurisdiction.id,
34596
+ caseType: caseView.case_type.id
34597
+ };
34598
+ this.sessionStorage.setItem('caseInfo', JSON.stringify(newCaseInfo));
34599
+ return caseView;
34600
+ });
34551
34601
  }
34552
34602
  }
34553
34603
  navigateToCaseList() {
@@ -35662,7 +35712,6 @@ class CaseFullAccessViewComponent {
35662
35712
  });
35663
35713
  }
35664
35714
  this.checkRouteAndSetCaseViewTab();
35665
- this.setCaseInfo();
35666
35715
  // Check for active Case Flags
35667
35716
  this.activeCaseFlags = this.hasActiveCaseFlags();
35668
35717
  this.linkedCasesService.resetLinkedCaseData();
@@ -35675,18 +35724,6 @@ class CaseFullAccessViewComponent {
35675
35724
  this.organiseTabPosition();
35676
35725
  }
35677
35726
  }
35678
- setCaseInfo() {
35679
- const caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo') || '{}');
35680
- console.log('Case Info from session storage: ', caseInfo);
35681
- if (caseInfo?.caseId !== this.caseDetails.case_id) {
35682
- const newCaseInfo = {
35683
- caseId: this.caseDetails.case_id,
35684
- jurisdiction: this.caseDetails.case_type.jurisdiction.id,
35685
- caseType: this.caseDetails.case_type.id
35686
- };
35687
- this.sessionStorageService.setItem('caseInfo', JSON.stringify(newCaseInfo));
35688
- }
35689
- }
35690
35727
  isPrintEnabled() {
35691
35728
  return this.caseDetails.case_type.printEnabled;
35692
35729
  }
@@ -36600,9 +36637,12 @@ class TaskAssignedComponent {
36600
36637
  // Current user is a caseworker?
36601
36638
  this.jurisdiction = this.task.jurisdiction;
36602
36639
  this.caseType = this.task.case_type_id;
36603
- this.caseworkerSubscription = this.caseworkerService.getUserByIdamId(this.task.assignee).subscribe(caseworker => {
36604
- if (caseworker) {
36605
- this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
36640
+ this.caseworkerSubscription = this.caseworkerService.getCaseworkers(this.task.jurisdiction).subscribe(result => {
36641
+ if (result && result[0].service === this.task.jurisdiction && result[0].caseworkers) {
36642
+ const caseworker = result[0].caseworkers.find(x => x.idamId === this.task.assignee);
36643
+ if (caseworker) {
36644
+ this.assignedUserName = `${caseworker.firstName} ${caseworker.lastName}`;
36645
+ }
36606
36646
  }
36607
36647
  if (!this.assignedUserName) {
36608
36648
  // Current user is a judicial user?