@hmcts/ccd-case-ui-toolkit 7.4.5 → 7.4.6-exui-3740
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.
|
@@ -3299,7 +3299,8 @@ class IsCompoundPipe {
|
|
|
3299
3299
|
];
|
|
3300
3300
|
static EXCLUDE = [
|
|
3301
3301
|
'CaseLink',
|
|
3302
|
-
'JudicialUser'
|
|
3302
|
+
'JudicialUser',
|
|
3303
|
+
'StaffUser'
|
|
3303
3304
|
];
|
|
3304
3305
|
transform(field) {
|
|
3305
3306
|
if (!field || !field.field_type || !field.field_type.type) {
|
|
@@ -4529,7 +4530,11 @@ class FieldsUtils {
|
|
|
4529
4530
|
caseFieldType.complex_fields.forEach(field => {
|
|
4530
4531
|
try {
|
|
4531
4532
|
const isDynamicField = FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
|
|
4532
|
-
|
|
4533
|
+
const isDynamicMultiSelectField = field.field_type.type === 'DynamicMultiSelectList';
|
|
4534
|
+
if (isDynamicMultiSelectField) {
|
|
4535
|
+
this.setDynamicMultiSelectListDefinition(field, rootCaseField);
|
|
4536
|
+
}
|
|
4537
|
+
else if (isDynamicField) {
|
|
4533
4538
|
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4534
4539
|
if (dynamicListValue) {
|
|
4535
4540
|
const list_items = dynamicListValue[0].list_items;
|
|
@@ -4562,6 +4567,29 @@ class FieldsUtils {
|
|
|
4562
4567
|
}
|
|
4563
4568
|
}
|
|
4564
4569
|
}
|
|
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
|
+
}
|
|
4565
4593
|
static getDynamicListValue(jsonBlock, key) {
|
|
4566
4594
|
const data = jsonBlock ? this.getNestedFieldValues(jsonBlock, key, []) : [];
|
|
4567
4595
|
return data.length > 0 ? data : null;
|
|
@@ -7068,8 +7096,12 @@ class FieldTypeSanitiser {
|
|
|
7068
7096
|
break;
|
|
7069
7097
|
case FieldTypeSanitiser.FIELD_TYPE_COLLECTION:
|
|
7070
7098
|
if (Array.isArray(data[caseField.id])) {
|
|
7071
|
-
data[caseField.id].forEach((formElement) => {
|
|
7072
|
-
|
|
7099
|
+
data[caseField.id].forEach((formElement, index) => {
|
|
7100
|
+
const matchingItem = Array.isArray(caseField.value) && formElement?.id !== undefined
|
|
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);
|
|
7073
7105
|
});
|
|
7074
7106
|
}
|
|
7075
7107
|
break;
|
|
@@ -7109,6 +7141,25 @@ class FieldTypeSanitiser {
|
|
|
7109
7141
|
}
|
|
7110
7142
|
});
|
|
7111
7143
|
}
|
|
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
|
+
}
|
|
7112
7163
|
isDynamicList(fieldType) {
|
|
7113
7164
|
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
|
|
7114
7165
|
}
|