@hmcts/ccd-case-ui-toolkit 7.4.24 → 7.4.25-exui-5450-rc2

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.
@@ -4053,6 +4053,7 @@ class CaseTab {
4053
4053
  order;
4054
4054
  fields;
4055
4055
  show_condition;
4056
+ defaultFocus;
4056
4057
  }
4057
4058
  __decorate([
4058
4059
  Type(() => CaseField),
@@ -10818,6 +10819,62 @@ class ValidPageListCaseFieldsService {
10818
10819
  type: Injectable
10819
10820
  }], () => [{ type: FieldsUtils }], null); })();
10820
10821
 
10822
+ /** Uses current form-control visibility and the configured retention policy. */
10823
+ class HiddenFieldValues {
10824
+ static clearHiddenValues(data, control, parentHidden = false, collectionItem = false) {
10825
+ if (!control || data === null || data === undefined) {
10826
+ return data;
10827
+ }
10828
+ const field = control.caseField;
10829
+ const displayContext = field?.display_context?.toUpperCase();
10830
+ if (displayContext === 'READONLY' || displayContext === 'HIDDEN' ||
10831
+ displayContext === 'HIDDEN_TEMP' || field?.id === 'caseLinks') {
10832
+ return data;
10833
+ }
10834
+ const hidden = parentHidden || field?.hidden === true;
10835
+ if (hidden && field && !collectionItem) {
10836
+ if (!field.retain_hidden_value) {
10837
+ return control instanceof FormArray ? [] : null;
10838
+ }
10839
+ const hasComplexChildren = field.field_type?.type === 'Complex' ||
10840
+ (field.field_type?.type === 'Collection' && field.field_type.collection_field_type?.type === 'Complex');
10841
+ if (!hasComplexChildren) {
10842
+ // Documents, lists and other composite controls retain their whole value.
10843
+ return data;
10844
+ }
10845
+ // Complex children have their own retention settings; they do not inherit Yes.
10846
+ }
10847
+ if (control instanceof FormArray) {
10848
+ return this.clearCollectionValues(data, control, hidden);
10849
+ }
10850
+ if (control instanceof FormGroup) {
10851
+ const result = { ...data };
10852
+ Object.keys(result).forEach((key) => {
10853
+ result[key] = this.clearHiddenValues(result[key], control.controls[key], hidden);
10854
+ });
10855
+ return result;
10856
+ }
10857
+ return data;
10858
+ }
10859
+ static clearCollectionValues(data, control, hidden) {
10860
+ if (!Array.isArray(data)) {
10861
+ return data;
10862
+ }
10863
+ return data.map((item, index) => {
10864
+ const row = control.at(index);
10865
+ const valueControl = row instanceof FormGroup ? row.controls.value : undefined;
10866
+ if (valueControl && item && typeof item === 'object' && Object.hasOwn(item, 'value')) {
10867
+ return {
10868
+ ...item,
10869
+ // The value group is a collection-item container, not another configurable case field.
10870
+ value: this.clearHiddenValues(item.value, valueControl, hidden, valueControl instanceof FormGroup)
10871
+ };
10872
+ }
10873
+ return this.clearHiddenValues(item, row, hidden);
10874
+ });
10875
+ }
10876
+ }
10877
+
10821
10878
  function CaseEditComponent_div_1_Template(rf, ctx) { if (rf & 1) {
10822
10879
  const _r1 = i0.ɵɵgetCurrentView();
10823
10880
  i0.ɵɵelementStart(0, "div", 1)(1, "div", 2)(2, "h2", 3);
@@ -11079,8 +11136,11 @@ class CaseEditComponent {
11079
11136
  return form.value.event.id;
11080
11137
  }
11081
11138
  generateCaseEventData({ eventTrigger, form }) {
11082
- const formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
11139
+ let formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
11083
11140
  this.formValueService.sanitiseDynamicLists(eventTrigger.case_fields, { data: formData });
11141
+ if (!this.isCaseFlagSubmission) {
11142
+ formData = HiddenFieldValues.clearHiddenValues(formData, form.get('data'));
11143
+ }
11084
11144
  const caseEventData = {
11085
11145
  data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(formData, this.isCaseFlagSubmission)),
11086
11146
  event: form.value.event
@@ -11406,7 +11466,7 @@ class CaseEditComponent {
11406
11466
  }], submitted: [{
11407
11467
  type: Output
11408
11468
  }] }); })();
11409
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseEditComponent, { className: "CaseEditComponent", filePath: "lib/shared/components/case-editor/case-edit/case-edit.component.ts", lineNumber: 39 }); })();
11469
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseEditComponent, { className: "CaseEditComponent", filePath: "lib/shared/components/case-editor/case-edit/case-edit.component.ts", lineNumber: 40 }); })();
11410
11470
 
11411
11471
  const EVENT_START_FIRST_PAGE_REDIRECT = 'eventStartFirstPageRedirect';
11412
11472
  function convertNonASCIICharacter(character) {
@@ -13300,6 +13360,9 @@ class CaseEditPageComponent {
13300
13360
  const formFields = this.formValueService.filterCurrentPageFields(caseFields, formValue);
13301
13361
  // Sort out the dynamic lists.
13302
13362
  this.formValueService.sanitiseDynamicLists(caseFields, formFields);
13363
+ if (!this.caseEdit.isCaseFlagSubmission) {
13364
+ formFields.data = HiddenFieldValues.clearHiddenValues(formFields.data, this.editForm.get('data'));
13365
+ }
13303
13366
  // Get hold of the CaseEventData.
13304
13367
  const caseEventData = this.formValueService.sanitise(formFields);
13305
13368
  // delete fields which are not part of the case event journey wizard pages case fields
@@ -13403,7 +13466,7 @@ class CaseEditPageComponent {
13403
13466
  type: ViewChildren,
13404
13467
  args: [CaseEditFormComponent]
13405
13468
  }] }); })();
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 }); })();
13469
+ (() => { (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
13470
 
13408
13471
  class CallbackErrorsContext {
13409
13472
  triggerText;
@@ -41714,7 +41777,7 @@ class CaseFullAccessViewComponent {
41714
41777
  if (!hasHash && !isSpecialTabPath) {
41715
41778
  const paths = url.split('/');
41716
41779
  const lastPath = decodeURIComponent(paths[paths.length - 1]);
41717
- let foundTab = null;
41780
+ let foundTab;
41718
41781
  if (!this.prependedTabs) {
41719
41782
  this.prependedTabs = [];
41720
41783
  }
@@ -41735,10 +41798,13 @@ class CaseFullAccessViewComponent {
41735
41798
  });
41736
41799
  }
41737
41800
  else {
41738
- this.caseDetails.tabs.sort((aTab, bTab) => aTab.order > bTab.order ? 1 : (bTab.order > aTab.order ? -1 : 0));
41801
+ this.caseDetails.tabs = this.orderService.sort(this.caseDetails.tabs);
41802
+ // Presuming default focus only set for one tab here - multiple tabs with default focus are not handled as is a contradiction
41803
+ let preSelectTab = this.caseDetails.tabs.find((tab) => tab.defaultFocus === true) ?? null;
41804
+ // Attempt to pre-select the tab based on the preferred label for the current case type
41739
41805
  const preferredLabel = FieldsUtils.defaultTabList?.[this.caseDetails?.case_type?.id];
41740
- let preSelectTab = null;
41741
- if (preferredLabel) {
41806
+ // If no tab has default focus, attempt to use the preferred label for the current case type
41807
+ if (!preSelectTab && preferredLabel) {
41742
41808
  preSelectTab = this.caseDetails.tabs.find((tab) => (tab.label === preferredLabel) || (tab.id === preferredLabel)) ?? null;
41743
41809
  }
41744
41810
  if (!preSelectTab) {