@hmcts/ccd-case-ui-toolkit 7.4.6-exui-3740 → 7.4.6
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.
|
@@ -4530,11 +4530,7 @@ class FieldsUtils {
|
|
|
4530
4530
|
caseFieldType.complex_fields.forEach(field => {
|
|
4531
4531
|
try {
|
|
4532
4532
|
const isDynamicField = FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
|
|
4533
|
-
|
|
4534
|
-
if (isDynamicMultiSelectField) {
|
|
4535
|
-
this.setDynamicMultiSelectListDefinition(field, rootCaseField);
|
|
4536
|
-
}
|
|
4537
|
-
else if (isDynamicField) {
|
|
4533
|
+
if (isDynamicField) {
|
|
4538
4534
|
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4539
4535
|
if (dynamicListValue) {
|
|
4540
4536
|
const list_items = dynamicListValue[0].list_items;
|
|
@@ -4567,29 +4563,6 @@ class FieldsUtils {
|
|
|
4567
4563
|
}
|
|
4568
4564
|
}
|
|
4569
4565
|
}
|
|
4570
|
-
static setDynamicMultiSelectListDefinition(field, rootCaseField) {
|
|
4571
|
-
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4572
|
-
if (dynamicListValue) {
|
|
4573
|
-
const list_items = dynamicListValue.find(data => data?.list_items !== undefined)?.list_items;
|
|
4574
|
-
if (list_items !== undefined) {
|
|
4575
|
-
field.list_items = list_items;
|
|
4576
|
-
field.formatted_value = {
|
|
4577
|
-
...field.formatted_value,
|
|
4578
|
-
list_items
|
|
4579
|
-
};
|
|
4580
|
-
}
|
|
4581
|
-
if (rootCaseField.field_type.type !== FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
|
|
4582
|
-
const value = dynamicListValue[0]?.value;
|
|
4583
|
-
if (value !== undefined) {
|
|
4584
|
-
field.value = value;
|
|
4585
|
-
field.formatted_value = {
|
|
4586
|
-
...field.formatted_value,
|
|
4587
|
-
value
|
|
4588
|
-
};
|
|
4589
|
-
}
|
|
4590
|
-
}
|
|
4591
|
-
}
|
|
4592
|
-
}
|
|
4593
4566
|
static getDynamicListValue(jsonBlock, key) {
|
|
4594
4567
|
const data = jsonBlock ? this.getNestedFieldValues(jsonBlock, key, []) : [];
|
|
4595
4568
|
return data.length > 0 ? data : null;
|
|
@@ -7096,12 +7069,8 @@ class FieldTypeSanitiser {
|
|
|
7096
7069
|
break;
|
|
7097
7070
|
case FieldTypeSanitiser.FIELD_TYPE_COLLECTION:
|
|
7098
7071
|
if (Array.isArray(data[caseField.id])) {
|
|
7099
|
-
data[caseField.id].forEach((formElement
|
|
7100
|
-
|
|
7101
|
-
? caseField.value.find((item) => item?.id === formElement.id)
|
|
7102
|
-
: null;
|
|
7103
|
-
const collectionItem = matchingItem || (Array.isArray(caseField.value) ? caseField.value[index] : null);
|
|
7104
|
-
this.sanitiseLists(this.copyCaseFieldsWithCollectionData(caseField.field_type.collection_field_type.complex_fields, collectionItem?.value || collectionItem), formElement.value);
|
|
7072
|
+
data[caseField.id].forEach((formElement) => {
|
|
7073
|
+
this.sanitiseLists(caseField.field_type.collection_field_type.complex_fields, formElement.value);
|
|
7105
7074
|
});
|
|
7106
7075
|
}
|
|
7107
7076
|
break;
|
|
@@ -7141,25 +7110,6 @@ class FieldTypeSanitiser {
|
|
|
7141
7110
|
}
|
|
7142
7111
|
});
|
|
7143
7112
|
}
|
|
7144
|
-
copyCaseFieldsWithCollectionData(caseFields, collectionItemData) {
|
|
7145
|
-
return caseFields.map((field) => {
|
|
7146
|
-
const fieldData = collectionItemData?.[field.id];
|
|
7147
|
-
if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
7148
|
-
return {
|
|
7149
|
-
...field,
|
|
7150
|
-
field_type: {
|
|
7151
|
-
...field.field_type,
|
|
7152
|
-
complex_fields: this.copyCaseFieldsWithCollectionData(field.field_type.complex_fields, fieldData)
|
|
7153
|
-
}
|
|
7154
|
-
};
|
|
7155
|
-
}
|
|
7156
|
-
return this.isDynamicList(field.field_type.type) &&
|
|
7157
|
-
field.display_context !== 'HIDDEN' &&
|
|
7158
|
-
fieldData?.list_items !== undefined
|
|
7159
|
-
? { ...field, list_items: fieldData.list_items }
|
|
7160
|
-
: field;
|
|
7161
|
-
});
|
|
7162
|
-
}
|
|
7163
7113
|
isDynamicList(fieldType) {
|
|
7164
7114
|
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
|
|
7165
7115
|
}
|