@hmcts/ccd-case-ui-toolkit 7.3.51 → 7.3.52-3582-rc-1
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.
|
@@ -6310,6 +6310,60 @@ class FormValueService {
|
|
|
6310
6310
|
}
|
|
6311
6311
|
}
|
|
6312
6312
|
}
|
|
6313
|
+
// exui-3582 When a form field becomes hidden based on user’s input in the event journey,
|
|
6314
|
+
// its stored value must be cleared and it must not be submitted or persisted.
|
|
6315
|
+
removeHiddenField(data, caseFields, clearNonCase, formControls) {
|
|
6316
|
+
if (clearNonCase && data && caseFields && caseFields.length > 0) {
|
|
6317
|
+
for (const field of caseFields) {
|
|
6318
|
+
if (!FormValueService.isLabel(field) && FormValueService.isReadOnly(field)) {
|
|
6319
|
+
// Retain anything that is readonly and not a label.
|
|
6320
|
+
continue;
|
|
6321
|
+
}
|
|
6322
|
+
// Check if formControls[field.id] exists before accessing its properties
|
|
6323
|
+
const caseField = formControls[field.id] ? formControls[field.id]['caseField'] : undefined;
|
|
6324
|
+
if (caseField === undefined || field.hidden === true) {
|
|
6325
|
+
continue;
|
|
6326
|
+
}
|
|
6327
|
+
const hasValue = data.hasOwnProperty(field.id) && data[field.id] != null &&
|
|
6328
|
+
(typeof data[field.id] !== 'object' || Object.keys(data[field.id]).length > 0);
|
|
6329
|
+
if (caseField?.hidden === true &&
|
|
6330
|
+
field.display_context !== 'HIDDEN' &&
|
|
6331
|
+
field.display_context !== 'HIDDEN_TEMP' &&
|
|
6332
|
+
!field.retain_hidden_value &&
|
|
6333
|
+
field.id !== 'caseLinks' &&
|
|
6334
|
+
hasValue) {
|
|
6335
|
+
data[field.id] = null;
|
|
6336
|
+
continue; // If field is now hidden, skip checking its children
|
|
6337
|
+
}
|
|
6338
|
+
if (field.field_type) {
|
|
6339
|
+
switch (field.field_type.type) {
|
|
6340
|
+
case 'Complex':
|
|
6341
|
+
const complexData = data[field.id] ?? data['value'];
|
|
6342
|
+
if (complexData && formControls[field.id] && formControls[field.id]['controls']) {
|
|
6343
|
+
this.removeHiddenField(complexData, field.field_type.complex_fields, clearNonCase, formControls[field.id]['controls']);
|
|
6344
|
+
}
|
|
6345
|
+
break;
|
|
6346
|
+
case 'Collection':
|
|
6347
|
+
const collection = data[field.id];
|
|
6348
|
+
if (collection && Array.isArray(collection) && field.field_type.collection_field_type.type === 'Complex') {
|
|
6349
|
+
collection.forEach((item, index) => {
|
|
6350
|
+
if (formControls[field.id] && formControls[field.id]['controls'] && formControls[field.id]['controls'][index]) {
|
|
6351
|
+
const itemControls = formControls[field.id]?.['controls']?.[index]?.['controls']?.['value'];
|
|
6352
|
+
const collectionData = item['value'] ?? item;
|
|
6353
|
+
if (collectionData && itemControls?.['controls']) {
|
|
6354
|
+
this.removeHiddenField(collectionData, field.field_type.collection_field_type.complex_fields, clearNonCase, itemControls['controls']);
|
|
6355
|
+
}
|
|
6356
|
+
}
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
break;
|
|
6360
|
+
default:
|
|
6361
|
+
break;
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
}
|
|
6313
6367
|
/**
|
|
6314
6368
|
* Remove any empty collection fields where a value of greater than zero is specified in the field's {@link FieldType}
|
|
6315
6369
|
* `min` attribute.
|
|
@@ -9733,6 +9787,11 @@ class CaseEditComponent {
|
|
|
9733
9787
|
if (!this.isCaseFlagSubmission) {
|
|
9734
9788
|
this.formValueService.removeUnnecessaryFields(caseEventData.data, pageListCaseFields, true, true);
|
|
9735
9789
|
}
|
|
9790
|
+
// removeHiddenFields while are hidden in the UI
|
|
9791
|
+
// Only remove hidden fields if editForm and its controls are available
|
|
9792
|
+
if (form?.controls?.['data']?.['controls']) {
|
|
9793
|
+
this.formValueService.removeHiddenField(caseEventData.data, pageListCaseFields, true, form.controls['data']['controls']);
|
|
9794
|
+
}
|
|
9736
9795
|
caseEventData.event_token = eventTrigger.event_token;
|
|
9737
9796
|
caseEventData.ignore_warning = this.ignoreWarning;
|
|
9738
9797
|
if (this.confirmation) {
|
|
@@ -11877,6 +11936,11 @@ class CaseEditPageComponent {
|
|
|
11877
11936
|
this.validPageListCaseFieldsService.deleteNonValidatedFields(this.caseEdit.validPageList, caseEventData.data, this.eventTrigger.case_fields, fromPreviousPage, this.editForm.controls['data'].value);
|
|
11878
11937
|
// Tidy it up before we return it.
|
|
11879
11938
|
this.formValueService.removeUnnecessaryFields(caseEventData.data, caseFields, clearEmpty, clearNonCase, fromPreviousPage, this.currentPage.case_fields);
|
|
11939
|
+
// removeHiddenFields while are hidden in the UI
|
|
11940
|
+
// Only remove hidden fields if editForm and its controls are available
|
|
11941
|
+
if (this.editForm?.controls?.['data']?.['controls']) {
|
|
11942
|
+
this.formValueService.removeHiddenField(caseEventData.data, caseFields, clearNonCase, this.editForm.controls['data']['controls']);
|
|
11943
|
+
}
|
|
11880
11944
|
return caseEventData;
|
|
11881
11945
|
}
|
|
11882
11946
|
syncCaseEditDataService() {
|