@hmcts/ccd-case-ui-toolkit 7.4.19-broken-access → 7.4.19-exui-5450-rc1

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.
@@ -10818,6 +10818,62 @@ class ValidPageListCaseFieldsService {
10818
10818
  type: Injectable
10819
10819
  }], () => [{ type: FieldsUtils }], null); })();
10820
10820
 
10821
+ /** Uses current form-control visibility and the configured retention policy. */
10822
+ class HiddenFieldValues {
10823
+ static clearHiddenValues(data, control, parentHidden = false, collectionItem = false) {
10824
+ if (!control || data === null || data === undefined) {
10825
+ return data;
10826
+ }
10827
+ const field = control.caseField;
10828
+ const displayContext = field?.display_context?.toUpperCase();
10829
+ if (displayContext === 'READONLY' || displayContext === 'HIDDEN' ||
10830
+ displayContext === 'HIDDEN_TEMP' || field?.id === 'caseLinks') {
10831
+ return data;
10832
+ }
10833
+ const hidden = parentHidden || field?.hidden === true;
10834
+ if (hidden && field && !collectionItem) {
10835
+ if (!field.retain_hidden_value) {
10836
+ return control instanceof FormArray ? [] : null;
10837
+ }
10838
+ const hasComplexChildren = field.field_type?.type === 'Complex' ||
10839
+ (field.field_type?.type === 'Collection' && field.field_type.collection_field_type?.type === 'Complex');
10840
+ if (!hasComplexChildren) {
10841
+ // Documents, lists and other composite controls retain their whole value.
10842
+ return data;
10843
+ }
10844
+ // Complex children have their own retention settings; they do not inherit Yes.
10845
+ }
10846
+ if (control instanceof FormArray) {
10847
+ return this.clearCollectionValues(data, control, hidden);
10848
+ }
10849
+ if (control instanceof FormGroup) {
10850
+ const result = { ...data };
10851
+ Object.keys(result).forEach((key) => {
10852
+ result[key] = this.clearHiddenValues(result[key], control.controls[key], hidden);
10853
+ });
10854
+ return result;
10855
+ }
10856
+ return data;
10857
+ }
10858
+ static clearCollectionValues(data, control, hidden) {
10859
+ if (!Array.isArray(data)) {
10860
+ return data;
10861
+ }
10862
+ return data.map((item, index) => {
10863
+ const row = control.at(index);
10864
+ const valueControl = row instanceof FormGroup ? row.controls.value : undefined;
10865
+ if (valueControl && item && typeof item === 'object' && Object.hasOwn(item, 'value')) {
10866
+ return {
10867
+ ...item,
10868
+ // The value group is a collection-item container, not another configurable case field.
10869
+ value: this.clearHiddenValues(item.value, valueControl, hidden, valueControl instanceof FormGroup)
10870
+ };
10871
+ }
10872
+ return this.clearHiddenValues(item, row, hidden);
10873
+ });
10874
+ }
10875
+ }
10876
+
10821
10877
  function CaseEditComponent_div_1_Template(rf, ctx) { if (rf & 1) {
10822
10878
  const _r1 = i0.ɵɵgetCurrentView();
10823
10879
  i0.ɵɵelementStart(0, "div", 1)(1, "div", 2)(2, "h2", 3);
@@ -11079,8 +11135,11 @@ class CaseEditComponent {
11079
11135
  return form.value.event.id;
11080
11136
  }
11081
11137
  generateCaseEventData({ eventTrigger, form }) {
11082
- const formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
11138
+ let formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
11083
11139
  this.formValueService.sanitiseDynamicLists(eventTrigger.case_fields, { data: formData });
11140
+ if (!this.isCaseFlagSubmission) {
11141
+ formData = HiddenFieldValues.clearHiddenValues(formData, form.get('data'));
11142
+ }
11084
11143
  const caseEventData = {
11085
11144
  data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(formData, this.isCaseFlagSubmission)),
11086
11145
  event: form.value.event
@@ -11406,7 +11465,7 @@ class CaseEditComponent {
11406
11465
  }], submitted: [{
11407
11466
  type: Output
11408
11467
  }] }); })();
11409
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseEditComponent, { className: "CaseEditComponent", filePath: "lib/shared/components/case-editor/case-edit/case-edit.component.ts", lineNumber: 39 }); })();
11468
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseEditComponent, { className: "CaseEditComponent", filePath: "lib/shared/components/case-editor/case-edit/case-edit.component.ts", lineNumber: 40 }); })();
11410
11469
 
11411
11470
  const EVENT_START_FIRST_PAGE_REDIRECT = 'eventStartFirstPageRedirect';
11412
11471
  function convertNonASCIICharacter(character) {
@@ -13300,6 +13359,9 @@ class CaseEditPageComponent {
13300
13359
  const formFields = this.formValueService.filterCurrentPageFields(caseFields, formValue);
13301
13360
  // Sort out the dynamic lists.
13302
13361
  this.formValueService.sanitiseDynamicLists(caseFields, formFields);
13362
+ if (!this.caseEdit.isCaseFlagSubmission) {
13363
+ formFields.data = HiddenFieldValues.clearHiddenValues(formFields.data, this.editForm.get('data'));
13364
+ }
13303
13365
  // Get hold of the CaseEventData.
13304
13366
  const caseEventData = this.formValueService.sanitise(formFields);
13305
13367
  // delete fields which are not part of the case event journey wizard pages case fields
@@ -13403,7 +13465,7 @@ class CaseEditPageComponent {
13403
13465
  type: ViewChildren,
13404
13466
  args: [CaseEditFormComponent]
13405
13467
  }] }); })();
13406
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseEditPageComponent, { className: "CaseEditPageComponent", filePath: "lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts", lineNumber: 38 }); })();
13468
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseEditPageComponent, { className: "CaseEditPageComponent", filePath: "lib/shared/components/case-editor/case-edit-page/case-edit-page.component.ts", lineNumber: 39 }); })();
13407
13469
 
13408
13470
  class CallbackErrorsContext {
13409
13471
  triggerText;
@@ -14883,7 +14945,7 @@ class CaseFileViewFieldComponent {
14883
14945
  }
14884
14946
  setMediaViewerFile(document) {
14885
14947
  const documentDetails = {
14886
- document_binary_url: this.withLegacyDocumentAccessContext(this.documentManagementService.getDocumentBinaryUrl(document)),
14948
+ document_binary_url: document.document_binary_url,
14887
14949
  document_filename: document.document_filename,
14888
14950
  content_type: document.content_type
14889
14951
  };
@@ -14898,19 +14960,6 @@ class CaseFileViewFieldComponent {
14898
14960
  const mediaViewerInfo = this.documentManagementService.getMediaViewerInfo(documentDetails);
14899
14961
  this.currentDocument = JSON.parse(mediaViewerInfo);
14900
14962
  }
14901
- withLegacyDocumentAccessContext(documentBinaryUrl) {
14902
- if (!documentBinaryUrl || !this.caseId) {
14903
- return documentBinaryUrl;
14904
- }
14905
- const [path, query = ''] = documentBinaryUrl.split('?');
14906
- if (!/^\/documents\/[^/]+\/binary\/?$/.test(path)) {
14907
- return documentBinaryUrl;
14908
- }
14909
- // XUI validates legacy document access against the case before proxying the binary request.
14910
- const searchParams = new URLSearchParams(query);
14911
- searchParams.set('caseId', this.caseId);
14912
- return `${path}?${searchParams.toString()}`;
14913
- }
14914
14963
  moveDocument(data) {
14915
14964
  const cid = this.route.snapshot.paramMap.get(CaseFileViewFieldComponent.PARAM_CASE_ID);
14916
14965
  const loadingToken = this.loadingService.register();