@hmcts/ccd-case-ui-toolkit 7.3.2 → 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);
@@ -15226,6 +15254,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15226
15254
  dialog;
15227
15255
  fileUploadStateService;
15228
15256
  jurisdictionService;
15257
+ sessionStorageService;
15229
15258
  static DOCUMENT_URL = 'document_url';
15230
15259
  static DOCUMENT_BINARY_URL = 'document_binary_url';
15231
15260
  static DOCUMENT_FILENAME = 'document_filename';
@@ -15255,7 +15284,8 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15255
15284
  caseId;
15256
15285
  // Should the file upload use CDAM
15257
15286
  fileSecureModeOn = false;
15258
- constructor(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService, jurisdictionService) {
15287
+ gotFromCaseInfo = false;
15288
+ constructor(appConfig, caseNotifier, documentManagement, dialog, fileUploadStateService, jurisdictionService, sessionStorageService) {
15259
15289
  super();
15260
15290
  this.appConfig = appConfig;
15261
15291
  this.caseNotifier = caseNotifier;
@@ -15263,12 +15293,20 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15263
15293
  this.dialog = dialog;
15264
15294
  this.fileUploadStateService = fileUploadStateService;
15265
15295
  this.jurisdictionService = jurisdictionService;
15296
+ this.sessionStorageService = sessionStorageService;
15266
15297
  }
15267
15298
  ngOnInit() {
15268
15299
  // Wait for both observables to emit at least once
15300
+ const caseInfo = this.documentManagement.parseCaseInfo(this.sessionStorageService.getItem('caseInfo'));
15269
15301
  const currUrl = window.location.pathname;
15270
- if (currUrl.includes('/case-details/')) {
15271
- 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
+ }
15272
15310
  }
15273
15311
  this.caseNotifierSubscription = combineLatest([
15274
15312
  this.caseNotifier.caseView.pipe(take(1)),
@@ -15529,10 +15567,10 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15529
15567
  handleDocumentUploadResult(result) {
15530
15568
  // use the documentManagement service to check if the document upload should use CDAM
15531
15569
  if (this.documentManagement.isDocumentSecureModeEnabled()) {
15532
- 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}`);
15533
15571
  }
15534
15572
  else {
15535
- 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}`);
15536
15574
  }
15537
15575
  if (!this.uploadedDocument) {
15538
15576
  if (this.fileSecureModeOn) {
@@ -15566,7 +15604,7 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15566
15604
  this.valid = false;
15567
15605
  this.fileUploadStateService.setUploadInProgress(false);
15568
15606
  }
15569
- 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)); };
15570
15608
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteDocumentFieldComponent, selectors: [["ccd-write-document-field"]], viewQuery: function WriteDocumentFieldComponent_Query(rf, ctx) { if (rf & 1) {
15571
15609
  i0.ɵɵviewQuery(_c0$S, 5);
15572
15610
  } if (rf & 2) {
@@ -15627,11 +15665,11 @@ class WriteDocumentFieldComponent extends AbstractFieldWriteComponent {
15627
15665
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteDocumentFieldComponent, [{
15628
15666
  type: Component,
15629
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" }]
15630
- }], () => [{ 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: [{
15631
15669
  type: ViewChild,
15632
15670
  args: ['fileInput', { static: false }]
15633
15671
  }] }); })();
15634
- (() => { (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 }); })();
15635
15673
 
15636
15674
  class DynamicListPipe {
15637
15675
  static EMPTY = '';
@@ -34548,9 +34586,18 @@ class CaseResolver {
34548
34586
  this.navigateToCaseList();
34549
34587
  }
34550
34588
  else {
34551
- return this.isRootCaseViewRoute(route) ? this.getAndCacheCaseView(cid)
34589
+ const resultPromise = this.isRootCaseViewRoute(route) ? this.getAndCacheCaseView(cid)
34552
34590
  : this.caseNotifier.cachedCaseView ? Promise.resolve(this.caseNotifier.cachedCaseView)
34553
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
+ });
34554
34601
  }
34555
34602
  }
34556
34603
  navigateToCaseList() {
@@ -35665,7 +35712,6 @@ class CaseFullAccessViewComponent {
35665
35712
  });
35666
35713
  }
35667
35714
  this.checkRouteAndSetCaseViewTab();
35668
- this.setCaseInfo();
35669
35715
  // Check for active Case Flags
35670
35716
  this.activeCaseFlags = this.hasActiveCaseFlags();
35671
35717
  this.linkedCasesService.resetLinkedCaseData();
@@ -35678,18 +35724,6 @@ class CaseFullAccessViewComponent {
35678
35724
  this.organiseTabPosition();
35679
35725
  }
35680
35726
  }
35681
- setCaseInfo() {
35682
- const caseInfo = JSON.parse(this.sessionStorageService.getItem('caseInfo') || '{}');
35683
- console.log('Case Info from session storage: ', caseInfo);
35684
- if (caseInfo?.caseId !== this.caseDetails.case_id) {
35685
- const newCaseInfo = {
35686
- caseId: this.caseDetails.case_id,
35687
- jurisdiction: this.caseDetails.case_type.jurisdiction.id,
35688
- caseType: this.caseDetails.case_type.id
35689
- };
35690
- this.sessionStorageService.setItem('caseInfo', JSON.stringify(newCaseInfo));
35691
- }
35692
- }
35693
35727
  isPrintEnabled() {
35694
35728
  return this.caseDetails.case_type.printEnabled;
35695
35729
  }