@hmcts/ccd-case-ui-toolkit 7.3.65 → 7.3.67-exui-3740-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.
|
@@ -4435,7 +4435,11 @@ class FieldsUtils {
|
|
|
4435
4435
|
caseFieldType.complex_fields.forEach(field => {
|
|
4436
4436
|
try {
|
|
4437
4437
|
const isDynamicField = FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
|
|
4438
|
-
|
|
4438
|
+
const isDynamicMultiSelectField = field.field_type.type === 'DynamicMultiSelectList';
|
|
4439
|
+
if (isDynamicMultiSelectField) {
|
|
4440
|
+
this.setDynamicMultiSelectListDefinition(field, rootCaseField);
|
|
4441
|
+
}
|
|
4442
|
+
else if (isDynamicField) {
|
|
4439
4443
|
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4440
4444
|
if (dynamicListValue) {
|
|
4441
4445
|
const list_items = dynamicListValue[0].list_items;
|
|
@@ -4468,6 +4472,29 @@ class FieldsUtils {
|
|
|
4468
4472
|
}
|
|
4469
4473
|
}
|
|
4470
4474
|
}
|
|
4475
|
+
static setDynamicMultiSelectListDefinition(field, rootCaseField) {
|
|
4476
|
+
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4477
|
+
if (dynamicListValue) {
|
|
4478
|
+
const list_items = dynamicListValue.find(data => data?.list_items !== undefined)?.list_items;
|
|
4479
|
+
if (list_items !== undefined) {
|
|
4480
|
+
field.list_items = list_items;
|
|
4481
|
+
field.formatted_value = {
|
|
4482
|
+
...field.formatted_value,
|
|
4483
|
+
list_items
|
|
4484
|
+
};
|
|
4485
|
+
}
|
|
4486
|
+
if (rootCaseField.field_type.type !== FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
|
|
4487
|
+
const value = dynamicListValue[0]?.value;
|
|
4488
|
+
if (value !== undefined) {
|
|
4489
|
+
field.value = value;
|
|
4490
|
+
field.formatted_value = {
|
|
4491
|
+
...field.formatted_value,
|
|
4492
|
+
value
|
|
4493
|
+
};
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
}
|
|
4497
|
+
}
|
|
4471
4498
|
static getDynamicListValue(jsonBlock, key) {
|
|
4472
4499
|
const data = jsonBlock ? this.getNestedFieldValues(jsonBlock, key, []) : [];
|
|
4473
4500
|
return data.length > 0 ? data : null;
|
|
@@ -6119,8 +6146,12 @@ class FieldTypeSanitiser {
|
|
|
6119
6146
|
break;
|
|
6120
6147
|
case FieldTypeSanitiser.FIELD_TYPE_COLLECTION:
|
|
6121
6148
|
if (Array.isArray(data[caseField.id])) {
|
|
6122
|
-
data[caseField.id].forEach((formElement) => {
|
|
6123
|
-
|
|
6149
|
+
data[caseField.id].forEach((formElement, index) => {
|
|
6150
|
+
const matchingItem = Array.isArray(caseField.value) && formElement?.id !== undefined
|
|
6151
|
+
? caseField.value.find((item) => item?.id === formElement.id)
|
|
6152
|
+
: null;
|
|
6153
|
+
const collectionItem = matchingItem || (Array.isArray(caseField.value) ? caseField.value[index] : null);
|
|
6154
|
+
this.sanitiseLists(this.copyCaseFieldsWithCollectionData(caseField.field_type.collection_field_type.complex_fields, collectionItem?.value || collectionItem), formElement.value);
|
|
6124
6155
|
});
|
|
6125
6156
|
}
|
|
6126
6157
|
break;
|
|
@@ -6160,6 +6191,25 @@ class FieldTypeSanitiser {
|
|
|
6160
6191
|
}
|
|
6161
6192
|
});
|
|
6162
6193
|
}
|
|
6194
|
+
copyCaseFieldsWithCollectionData(caseFields, collectionItemData) {
|
|
6195
|
+
return caseFields.map((field) => {
|
|
6196
|
+
const fieldData = collectionItemData?.[field.id];
|
|
6197
|
+
if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
6198
|
+
return {
|
|
6199
|
+
...field,
|
|
6200
|
+
field_type: {
|
|
6201
|
+
...field.field_type,
|
|
6202
|
+
complex_fields: this.copyCaseFieldsWithCollectionData(field.field_type.complex_fields, fieldData)
|
|
6203
|
+
}
|
|
6204
|
+
};
|
|
6205
|
+
}
|
|
6206
|
+
return this.isDynamicList(field.field_type.type) &&
|
|
6207
|
+
field.display_context !== 'HIDDEN' &&
|
|
6208
|
+
fieldData?.list_items !== undefined
|
|
6209
|
+
? { ...field, list_items: fieldData.list_items }
|
|
6210
|
+
: field;
|
|
6211
|
+
});
|
|
6212
|
+
}
|
|
6163
6213
|
isDynamicList(fieldType) {
|
|
6164
6214
|
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
|
|
6165
6215
|
}
|
|
@@ -9959,8 +10009,10 @@ class CaseEditComponent {
|
|
|
9959
10009
|
return form.value.event.id;
|
|
9960
10010
|
}
|
|
9961
10011
|
generateCaseEventData({ eventTrigger, form }) {
|
|
10012
|
+
const formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
|
|
10013
|
+
this.formValueService.sanitiseDynamicLists(eventTrigger.case_fields, { data: formData });
|
|
9962
10014
|
const caseEventData = {
|
|
9963
|
-
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(
|
|
10015
|
+
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(formData, this.isCaseFlagSubmission)),
|
|
9964
10016
|
event: form.value.event
|
|
9965
10017
|
};
|
|
9966
10018
|
this.formValueService.clearNonCaseFields(caseEventData.data, eventTrigger.case_fields);
|