@hmcts/ccd-case-ui-toolkit 7.3.52-exui-3740 → 7.3.52-exui-4297
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.
|
@@ -3934,7 +3934,6 @@ class FieldsUtils {
|
|
|
3934
3934
|
static SERVER_RESPONSE_FIELD_TYPE_COLLECTION = 'Collection';
|
|
3935
3935
|
static SERVER_RESPONSE_FIELD_TYPE_COMPLEX = 'Complex';
|
|
3936
3936
|
static SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE = ['DynamicList', 'DynamicRadioList'];
|
|
3937
|
-
static SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_MULTISELECT_LIST_TYPE = 'DynamicMultiSelectList';
|
|
3938
3937
|
static defaultTabList = {
|
|
3939
3938
|
"PRLAPPS": "Summary"
|
|
3940
3939
|
};
|
|
@@ -4185,53 +4184,31 @@ class FieldsUtils {
|
|
|
4185
4184
|
static textForInvalidField(type, invalidValue) {
|
|
4186
4185
|
return `{ Invalid ${type}: ${invalidValue} }`;
|
|
4187
4186
|
}
|
|
4188
|
-
static setDynamicListDefinition(caseField, caseFieldType, rootCaseField
|
|
4187
|
+
static setDynamicListDefinition(caseField, caseFieldType, rootCaseField) {
|
|
4189
4188
|
if (caseFieldType.type === FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COMPLEX) {
|
|
4190
4189
|
caseFieldType.complex_fields.forEach(field => {
|
|
4191
4190
|
try {
|
|
4192
4191
|
const isDynamicField = FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
|
|
4193
|
-
|
|
4194
|
-
if (isDynamicField || isDynamicMultiSelectField) {
|
|
4192
|
+
if (isDynamicField) {
|
|
4195
4193
|
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4196
4194
|
if (dynamicListValue) {
|
|
4197
|
-
const list_items = dynamicListValue.
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
field.formatted_value = {
|
|
4211
|
-
...field.formatted_value,
|
|
4212
|
-
value
|
|
4213
|
-
};
|
|
4214
|
-
}
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
else {
|
|
4218
|
-
const complexValue = dynamicListValue.map(data => data.value);
|
|
4219
|
-
const value = {
|
|
4220
|
-
list_items,
|
|
4221
|
-
value: complexValue.length > 0 ? complexValue : undefined
|
|
4222
|
-
};
|
|
4223
|
-
field.value = {
|
|
4224
|
-
...value
|
|
4225
|
-
};
|
|
4226
|
-
field.formatted_value = {
|
|
4227
|
-
...field.formatted_value,
|
|
4228
|
-
...value
|
|
4229
|
-
};
|
|
4230
|
-
}
|
|
4195
|
+
const list_items = dynamicListValue[0].list_items;
|
|
4196
|
+
const complexValue = dynamicListValue.map(data => data.value);
|
|
4197
|
+
const value = {
|
|
4198
|
+
list_items,
|
|
4199
|
+
value: complexValue.length > 0 ? complexValue : undefined
|
|
4200
|
+
};
|
|
4201
|
+
field.value = {
|
|
4202
|
+
...value
|
|
4203
|
+
};
|
|
4204
|
+
field.formatted_value = {
|
|
4205
|
+
...field.formatted_value,
|
|
4206
|
+
...value
|
|
4207
|
+
};
|
|
4231
4208
|
}
|
|
4232
4209
|
}
|
|
4233
4210
|
else {
|
|
4234
|
-
this.setDynamicListDefinition(field, field.field_type, rootCaseField
|
|
4211
|
+
this.setDynamicListDefinition(field, field.field_type, rootCaseField);
|
|
4235
4212
|
}
|
|
4236
4213
|
}
|
|
4237
4214
|
catch (error) {
|
|
@@ -4241,7 +4218,7 @@ class FieldsUtils {
|
|
|
4241
4218
|
}
|
|
4242
4219
|
else if (caseFieldType.type === FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
|
|
4243
4220
|
if (caseFieldType.collection_field_type) {
|
|
4244
|
-
this.setDynamicListDefinition(caseField, caseFieldType.collection_field_type, rootCaseField
|
|
4221
|
+
this.setDynamicListDefinition(caseField, caseFieldType.collection_field_type, rootCaseField);
|
|
4245
4222
|
}
|
|
4246
4223
|
}
|
|
4247
4224
|
}
|
|
@@ -5904,55 +5881,37 @@ class FieldTypeSanitiser {
|
|
|
5904
5881
|
}
|
|
5905
5882
|
ensureDynamicMultiSelectListPopulated(caseFields) {
|
|
5906
5883
|
return caseFields.map((field) => {
|
|
5907
|
-
|
|
5908
|
-
if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5909
|
-
this.checkNestedDynamicList(field, fieldData);
|
|
5910
|
-
}
|
|
5911
|
-
else if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COLLECTION &&
|
|
5912
|
-
field.field_type.collection_field_type?.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5913
|
-
this.checkNestedDynamicList(field, fieldData, true);
|
|
5914
|
-
}
|
|
5915
|
-
else {
|
|
5884
|
+
if (field.field_type.type !== 'Complex') {
|
|
5916
5885
|
return field;
|
|
5917
5886
|
}
|
|
5887
|
+
const caseFieldData = field._value;
|
|
5888
|
+
// Process each complex field
|
|
5889
|
+
field.field_type.complex_fields.forEach((complexField) => {
|
|
5890
|
+
if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5891
|
+
this.checkNestedDynamicList(complexField, caseFieldData?.[complexField.id]);
|
|
5892
|
+
}
|
|
5893
|
+
else if (this.isDynamicList(complexField.field_type.type) &&
|
|
5894
|
+
complexField.display_context !== 'HIDDEN' &&
|
|
5895
|
+
field._value?.[complexField.id]) {
|
|
5896
|
+
complexField.list_items = field._value[complexField.id]?.list_items;
|
|
5897
|
+
}
|
|
5898
|
+
});
|
|
5918
5899
|
// Final transformation: construct updated field object
|
|
5919
5900
|
return { ...field, field_type: { ...field?.field_type } };
|
|
5920
5901
|
});
|
|
5921
5902
|
}
|
|
5922
|
-
checkNestedDynamicList(caseField, fieldData = null
|
|
5923
|
-
|
|
5924
|
-
? caseField.field_type.collection_field_type?.complex_fields || []
|
|
5925
|
-
: caseField.field_type.complex_fields;
|
|
5926
|
-
complexFields.forEach((complexField) => {
|
|
5927
|
-
const childData = isCollection
|
|
5928
|
-
? this.getFirstCollectionFieldData(fieldData, complexField.id)
|
|
5929
|
-
: fieldData?.[complexField.id];
|
|
5903
|
+
checkNestedDynamicList(caseField, fieldData = null) {
|
|
5904
|
+
caseField.field_type.complex_fields.forEach((complexField) => {
|
|
5930
5905
|
if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5931
|
-
this.checkNestedDynamicList(complexField,
|
|
5932
|
-
}
|
|
5933
|
-
else if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COLLECTION &&
|
|
5934
|
-
complexField.field_type.collection_field_type?.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5935
|
-
this.checkNestedDynamicList(complexField, childData, true);
|
|
5906
|
+
this.checkNestedDynamicList(complexField, fieldData?.[complexField.id]);
|
|
5936
5907
|
}
|
|
5937
5908
|
else if (this.isDynamicList(complexField.field_type.type) &&
|
|
5938
5909
|
complexField.display_context !== 'HIDDEN' &&
|
|
5939
|
-
|
|
5940
|
-
complexField.list_items =
|
|
5910
|
+
fieldData?.[complexField.id]) {
|
|
5911
|
+
complexField.list_items = fieldData?.[complexField.id]?.list_items;
|
|
5941
5912
|
}
|
|
5942
5913
|
});
|
|
5943
5914
|
}
|
|
5944
|
-
getFirstCollectionFieldData(collectionData, fieldId) {
|
|
5945
|
-
if (!Array.isArray(collectionData)) {
|
|
5946
|
-
return null;
|
|
5947
|
-
}
|
|
5948
|
-
for (const item of collectionData) {
|
|
5949
|
-
const value = item?.value || item;
|
|
5950
|
-
if (value?.[fieldId] !== undefined) {
|
|
5951
|
-
return value[fieldId];
|
|
5952
|
-
}
|
|
5953
|
-
}
|
|
5954
|
-
return null;
|
|
5955
|
-
}
|
|
5956
5915
|
isDynamicList(fieldType) {
|
|
5957
5916
|
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
|
|
5958
5917
|
}
|
|
@@ -6276,7 +6235,7 @@ class FormValueService {
|
|
|
6276
6235
|
* @param clearEmpty Whether or not we should clear out empty, optional, complex objects.
|
|
6277
6236
|
* @param clearNonCase Whether or not we should clear out non-case fields at the top level.
|
|
6278
6237
|
*/
|
|
6279
|
-
removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = []
|
|
6238
|
+
removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = []) {
|
|
6280
6239
|
if (data && caseFields && caseFields.length > 0) {
|
|
6281
6240
|
// check if there is any data at the top level of the form that's not in the caseFields
|
|
6282
6241
|
if (clearNonCase) {
|
|
@@ -6287,9 +6246,9 @@ class FormValueService {
|
|
|
6287
6246
|
// Retain anything that is readonly and not a label.
|
|
6288
6247
|
continue;
|
|
6289
6248
|
}
|
|
6290
|
-
if (
|
|
6249
|
+
if (field.hidden === true && field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP' && field.id !== 'caseLinks' && !field.retain_hidden_value) {
|
|
6291
6250
|
// Delete anything that is hidden (that is NOT readonly), and that
|
|
6292
|
-
//
|
|
6251
|
+
// hasn't had its display_context overridden to make it hidden.
|
|
6293
6252
|
delete data[field.id];
|
|
6294
6253
|
}
|
|
6295
6254
|
else if (field.field_type) {
|
|
@@ -6304,7 +6263,7 @@ class FormValueService {
|
|
|
6304
6263
|
}
|
|
6305
6264
|
break;
|
|
6306
6265
|
case 'Complex':
|
|
6307
|
-
this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty
|
|
6266
|
+
this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty);
|
|
6308
6267
|
// Also remove any optional complex objects that are completely empty.
|
|
6309
6268
|
// EUI-4244: Ritesh's fix, passing true instead of clearEmpty.
|
|
6310
6269
|
if (FormValueService.clearOptionalEmpty(true, data[field.id], field)) {
|
|
@@ -6327,8 +6286,8 @@ class FormValueService {
|
|
|
6327
6286
|
if (field.field_type.collection_field_type.type === 'Complex') {
|
|
6328
6287
|
// Iterate through the elements and remove any unnecessary fields within.
|
|
6329
6288
|
for (const item of collection) {
|
|
6330
|
-
this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty
|
|
6331
|
-
this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false
|
|
6289
|
+
this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty);
|
|
6290
|
+
this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false);
|
|
6332
6291
|
}
|
|
6333
6292
|
}
|
|
6334
6293
|
}
|
|
@@ -6342,12 +6301,6 @@ class FormValueService {
|
|
|
6342
6301
|
// Clear out any MultiSelect labels.
|
|
6343
6302
|
FormValueService.removeMultiSelectLabels(data);
|
|
6344
6303
|
}
|
|
6345
|
-
shouldRemoveHiddenField(field, isNested) {
|
|
6346
|
-
return field.hidden === true
|
|
6347
|
-
&& field.id !== 'caseLinks'
|
|
6348
|
-
&& !field.retain_hidden_value
|
|
6349
|
-
&& (isNested || (field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP'));
|
|
6350
|
-
}
|
|
6351
6304
|
removeInvalidCollectionData(data, field) {
|
|
6352
6305
|
if (data[field.id] && data[field.id].length > 0) {
|
|
6353
6306
|
for (const objCollection of data[field.id]) {
|
|
@@ -9756,10 +9709,8 @@ class CaseEditComponent {
|
|
|
9756
9709
|
return form.value.event.id;
|
|
9757
9710
|
}
|
|
9758
9711
|
generateCaseEventData({ eventTrigger, form }) {
|
|
9759
|
-
const formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
|
|
9760
|
-
this.formValueService.sanitiseDynamicLists(eventTrigger.case_fields, { data: formData });
|
|
9761
9712
|
const caseEventData = {
|
|
9762
|
-
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(
|
|
9713
|
+
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields), this.isCaseFlagSubmission)),
|
|
9763
9714
|
event: form.value.event
|
|
9764
9715
|
};
|
|
9765
9716
|
this.formValueService.clearNonCaseFields(caseEventData.data, eventTrigger.case_fields);
|