@hmcts/ccd-case-ui-toolkit 7.3.35 → 7.3.36-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.
|
@@ -6050,8 +6050,8 @@ class FormValueService {
|
|
|
6050
6050
|
constructor(fieldTypeSanitiser) {
|
|
6051
6051
|
this.fieldTypeSanitiser = fieldTypeSanitiser;
|
|
6052
6052
|
}
|
|
6053
|
-
sanitise(rawValue) {
|
|
6054
|
-
return this.sanitiseObject(rawValue);
|
|
6053
|
+
sanitise(rawValue, isCaseFlagJourney = false) {
|
|
6054
|
+
return this.sanitiseObject(rawValue, isCaseFlagJourney);
|
|
6055
6055
|
}
|
|
6056
6056
|
sanitiseCaseReference(reference) {
|
|
6057
6057
|
// strip non digits
|
|
@@ -6073,7 +6073,7 @@ class FormValueService {
|
|
|
6073
6073
|
sanitiseDynamicLists(caseFields, editForm) {
|
|
6074
6074
|
return this.fieldTypeSanitiser.sanitiseLists(caseFields, editForm.data);
|
|
6075
6075
|
}
|
|
6076
|
-
sanitiseObject(rawObject) {
|
|
6076
|
+
sanitiseObject(rawObject, isCaseFlagJourney = false) {
|
|
6077
6077
|
if (!rawObject) {
|
|
6078
6078
|
return rawObject;
|
|
6079
6079
|
}
|
|
@@ -6087,14 +6087,17 @@ class FormValueService {
|
|
|
6087
6087
|
break;
|
|
6088
6088
|
}
|
|
6089
6089
|
else if ('CaseReference' === key) {
|
|
6090
|
-
sanitisedObject[key] = this.sanitiseValue(this.sanitiseCaseReference(String(rawObject[key])));
|
|
6090
|
+
sanitisedObject[key] = this.sanitiseValue(this.sanitiseCaseReference(String(rawObject[key])), isCaseFlagJourney);
|
|
6091
6091
|
}
|
|
6092
6092
|
else {
|
|
6093
|
-
sanitisedObject[key] = this.sanitiseValue(rawObject[key]);
|
|
6093
|
+
sanitisedObject[key] = this.sanitiseValue(rawObject[key], isCaseFlagJourney);
|
|
6094
6094
|
if (Array.isArray(sanitisedObject[key])) {
|
|
6095
6095
|
// If the 'sanitised' array is empty, whereas the original array had 1 or more items
|
|
6096
6096
|
// delete the property from the sanatised object
|
|
6097
|
-
|
|
6097
|
+
const shouldDeleteField = sanitisedObject[key].length === 0
|
|
6098
|
+
&& rawObject[key].length > 0
|
|
6099
|
+
&& !isCaseFlagJourney;
|
|
6100
|
+
if (shouldDeleteField) {
|
|
6098
6101
|
delete sanitisedObject[key];
|
|
6099
6102
|
}
|
|
6100
6103
|
}
|
|
@@ -6102,13 +6105,13 @@ class FormValueService {
|
|
|
6102
6105
|
}
|
|
6103
6106
|
return sanitisedObject;
|
|
6104
6107
|
}
|
|
6105
|
-
sanitiseArray(rawArray) {
|
|
6108
|
+
sanitiseArray(rawArray, isCaseFlagJourney = false) {
|
|
6106
6109
|
if (!rawArray) {
|
|
6107
6110
|
return rawArray;
|
|
6108
6111
|
}
|
|
6109
6112
|
rawArray.forEach(item => {
|
|
6110
6113
|
if (item && item.hasOwnProperty('value')) {
|
|
6111
|
-
item.value = this.sanitiseValue(item.value);
|
|
6114
|
+
item.value = this.sanitiseValue(item.value, isCaseFlagJourney);
|
|
6112
6115
|
}
|
|
6113
6116
|
});
|
|
6114
6117
|
// Filter the array to ensure only truthy values are returned; double-bang operator returns the boolean true/false
|
|
@@ -6118,13 +6121,13 @@ class FormValueService {
|
|
|
6118
6121
|
.filter(item => !!item)
|
|
6119
6122
|
.filter(item => item.hasOwnProperty('value') ? FieldsUtils.containsNonEmptyValues(item.value) : true);
|
|
6120
6123
|
}
|
|
6121
|
-
sanitiseValue(rawValue) {
|
|
6124
|
+
sanitiseValue(rawValue, isCaseFlagJourney = false) {
|
|
6122
6125
|
if (Array.isArray(rawValue)) {
|
|
6123
|
-
return this.sanitiseArray(rawValue);
|
|
6126
|
+
return this.sanitiseArray(rawValue, isCaseFlagJourney);
|
|
6124
6127
|
}
|
|
6125
6128
|
switch (typeof rawValue) {
|
|
6126
6129
|
case 'object':
|
|
6127
|
-
return this.sanitiseObject(rawValue);
|
|
6130
|
+
return this.sanitiseObject(rawValue, isCaseFlagJourney);
|
|
6128
6131
|
case 'string':
|
|
6129
6132
|
return rawValue.trim();
|
|
6130
6133
|
case 'number':
|
|
@@ -6305,6 +6308,60 @@ class FormValueService {
|
|
|
6305
6308
|
}
|
|
6306
6309
|
}
|
|
6307
6310
|
}
|
|
6311
|
+
// exui-3582 When a form field becomes hidden based on user’s input in the event journey,
|
|
6312
|
+
// its stored value must be cleared and it must not be submitted or persisted.
|
|
6313
|
+
removeHiddenField(data, caseFields, clearNonCase, formControls) {
|
|
6314
|
+
if (clearNonCase && data && caseFields && caseFields.length > 0) {
|
|
6315
|
+
for (const field of caseFields) {
|
|
6316
|
+
if (!FormValueService.isLabel(field) && FormValueService.isReadOnly(field)) {
|
|
6317
|
+
// Retain anything that is readonly and not a label.
|
|
6318
|
+
continue;
|
|
6319
|
+
}
|
|
6320
|
+
// Check if formControls[field.id] exists before accessing its properties
|
|
6321
|
+
const caseField = formControls[field.id] ? formControls[field.id]['caseField'] : undefined;
|
|
6322
|
+
if (caseField === undefined || field.hidden === true) {
|
|
6323
|
+
continue;
|
|
6324
|
+
}
|
|
6325
|
+
const hasValue = data.hasOwnProperty(field.id) && data[field.id] != null &&
|
|
6326
|
+
(typeof data[field.id] !== 'object' || Object.keys(data[field.id]).length > 0);
|
|
6327
|
+
if (caseField?.hidden === true &&
|
|
6328
|
+
field.display_context !== 'HIDDEN' &&
|
|
6329
|
+
field.display_context !== 'HIDDEN_TEMP' &&
|
|
6330
|
+
!field.retain_hidden_value &&
|
|
6331
|
+
field.id !== 'caseLinks' &&
|
|
6332
|
+
hasValue) {
|
|
6333
|
+
data[field.id] = null;
|
|
6334
|
+
continue; // If field is now hidden, skip checking its children
|
|
6335
|
+
}
|
|
6336
|
+
if (field.field_type) {
|
|
6337
|
+
switch (field.field_type.type) {
|
|
6338
|
+
case 'Complex':
|
|
6339
|
+
const complexData = data[field.id] ?? data['value'];
|
|
6340
|
+
if (complexData && formControls[field.id] && formControls[field.id]['controls']) {
|
|
6341
|
+
this.removeHiddenField(complexData, field.field_type.complex_fields, clearNonCase, formControls[field.id]['controls']);
|
|
6342
|
+
}
|
|
6343
|
+
break;
|
|
6344
|
+
case 'Collection':
|
|
6345
|
+
const collection = data[field.id];
|
|
6346
|
+
if (collection && Array.isArray(collection) && field.field_type.collection_field_type.type === 'Complex') {
|
|
6347
|
+
collection.forEach((item, index) => {
|
|
6348
|
+
if (formControls[field.id] && formControls[field.id]['controls'] && formControls[field.id]['controls'][index]) {
|
|
6349
|
+
const itemControls = formControls[field.id]?.['controls']?.[index]?.['controls']?.['value'];
|
|
6350
|
+
const collectionData = item['value'] ?? item;
|
|
6351
|
+
if (collectionData && itemControls?.['controls']) {
|
|
6352
|
+
this.removeHiddenField(collectionData, field.field_type.collection_field_type.complex_fields, clearNonCase, itemControls['controls']);
|
|
6353
|
+
}
|
|
6354
|
+
}
|
|
6355
|
+
});
|
|
6356
|
+
}
|
|
6357
|
+
break;
|
|
6358
|
+
default:
|
|
6359
|
+
break;
|
|
6360
|
+
}
|
|
6361
|
+
}
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6364
|
+
}
|
|
6308
6365
|
/**
|
|
6309
6366
|
* Remove any empty collection fields where a value of greater than zero is specified in the field's {@link FieldType}
|
|
6310
6367
|
* `min` attribute.
|
|
@@ -9630,7 +9687,7 @@ class CaseEditComponent {
|
|
|
9630
9687
|
}
|
|
9631
9688
|
generateCaseEventData({ eventTrigger, form }) {
|
|
9632
9689
|
const caseEventData = {
|
|
9633
|
-
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields))),
|
|
9690
|
+
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields), this.isCaseFlagSubmission)),
|
|
9634
9691
|
event: form.value.event
|
|
9635
9692
|
};
|
|
9636
9693
|
this.formValueService.clearNonCaseFields(caseEventData.data, eventTrigger.case_fields);
|
|
@@ -9653,6 +9710,11 @@ class CaseEditComponent {
|
|
|
9653
9710
|
if (!this.isCaseFlagSubmission) {
|
|
9654
9711
|
this.formValueService.removeUnnecessaryFields(caseEventData.data, pageListCaseFields, true, true);
|
|
9655
9712
|
}
|
|
9713
|
+
// removeHiddenFields while are hidden in the UI
|
|
9714
|
+
// Only remove hidden fields if editForm and its controls are available
|
|
9715
|
+
if (form?.controls?.['data']?.['controls']) {
|
|
9716
|
+
this.formValueService.removeHiddenField(caseEventData.data, pageListCaseFields, true, form.controls['data']['controls']);
|
|
9717
|
+
}
|
|
9656
9718
|
caseEventData.event_token = eventTrigger.event_token;
|
|
9657
9719
|
caseEventData.ignore_warning = this.ignoreWarning;
|
|
9658
9720
|
if (this.confirmation) {
|
|
@@ -11797,6 +11859,11 @@ class CaseEditPageComponent {
|
|
|
11797
11859
|
this.validPageListCaseFieldsService.deleteNonValidatedFields(this.caseEdit.validPageList, caseEventData.data, this.eventTrigger.case_fields, fromPreviousPage, this.editForm.controls['data'].value);
|
|
11798
11860
|
// Tidy it up before we return it.
|
|
11799
11861
|
this.formValueService.removeUnnecessaryFields(caseEventData.data, caseFields, clearEmpty, clearNonCase, fromPreviousPage, this.currentPage.case_fields);
|
|
11862
|
+
// removeHiddenFields while are hidden in the UI
|
|
11863
|
+
// Only remove hidden fields if editForm and its controls are available
|
|
11864
|
+
if (this.editForm?.controls?.['data']?.['controls']) {
|
|
11865
|
+
this.formValueService.removeHiddenField(caseEventData.data, caseFields, clearNonCase, this.editForm.controls['data']['controls']);
|
|
11866
|
+
}
|
|
11800
11867
|
return caseEventData;
|
|
11801
11868
|
}
|
|
11802
11869
|
syncCaseEditDataService() {
|