@hmcts/ccd-case-ui-toolkit 7.3.53-exui-4298 → 7.3.53-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.
|
@@ -4258,7 +4258,11 @@ class FieldsUtils {
|
|
|
4258
4258
|
caseFieldType.complex_fields.forEach(field => {
|
|
4259
4259
|
try {
|
|
4260
4260
|
const isDynamicField = FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
|
|
4261
|
-
|
|
4261
|
+
const isDynamicMultiSelectField = field.field_type.type === 'DynamicMultiSelectList';
|
|
4262
|
+
if (isDynamicMultiSelectField) {
|
|
4263
|
+
this.setDynamicMultiSelectListDefinition(field, rootCaseField);
|
|
4264
|
+
}
|
|
4265
|
+
else if (isDynamicField) {
|
|
4262
4266
|
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4263
4267
|
if (dynamicListValue) {
|
|
4264
4268
|
const list_items = dynamicListValue[0].list_items;
|
|
@@ -4291,6 +4295,29 @@ class FieldsUtils {
|
|
|
4291
4295
|
}
|
|
4292
4296
|
}
|
|
4293
4297
|
}
|
|
4298
|
+
static setDynamicMultiSelectListDefinition(field, rootCaseField) {
|
|
4299
|
+
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4300
|
+
if (dynamicListValue) {
|
|
4301
|
+
const list_items = dynamicListValue.find(data => data?.list_items !== undefined)?.list_items;
|
|
4302
|
+
if (list_items !== undefined) {
|
|
4303
|
+
field.list_items = list_items;
|
|
4304
|
+
field.formatted_value = {
|
|
4305
|
+
...field.formatted_value,
|
|
4306
|
+
list_items
|
|
4307
|
+
};
|
|
4308
|
+
}
|
|
4309
|
+
if (rootCaseField.field_type.type !== FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
|
|
4310
|
+
const value = dynamicListValue[0]?.value;
|
|
4311
|
+
if (value !== undefined) {
|
|
4312
|
+
field.value = value;
|
|
4313
|
+
field.formatted_value = {
|
|
4314
|
+
...field.formatted_value,
|
|
4315
|
+
value
|
|
4316
|
+
};
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4294
4321
|
static getDynamicListValue(jsonBlock, key) {
|
|
4295
4322
|
const data = jsonBlock ? this.getNestedFieldValues(jsonBlock, key, []) : [];
|
|
4296
4323
|
return data.length > 0 ? data : null;
|
|
@@ -5941,8 +5968,12 @@ class FieldTypeSanitiser {
|
|
|
5941
5968
|
break;
|
|
5942
5969
|
case FieldTypeSanitiser.FIELD_TYPE_COLLECTION:
|
|
5943
5970
|
if (Array.isArray(data[caseField.id])) {
|
|
5944
|
-
data[caseField.id].forEach((formElement) => {
|
|
5945
|
-
|
|
5971
|
+
data[caseField.id].forEach((formElement, index) => {
|
|
5972
|
+
const matchingItem = Array.isArray(caseField.value) && formElement?.id !== undefined
|
|
5973
|
+
? caseField.value.find((item) => item?.id === formElement.id)
|
|
5974
|
+
: null;
|
|
5975
|
+
const collectionItem = matchingItem || (Array.isArray(caseField.value) ? caseField.value[index] : null);
|
|
5976
|
+
this.sanitiseLists(this.copyCaseFieldsWithCollectionData(caseField.field_type.collection_field_type.complex_fields, collectionItem?.value || collectionItem), formElement.value);
|
|
5946
5977
|
});
|
|
5947
5978
|
}
|
|
5948
5979
|
break;
|
|
@@ -5982,6 +6013,25 @@ class FieldTypeSanitiser {
|
|
|
5982
6013
|
}
|
|
5983
6014
|
});
|
|
5984
6015
|
}
|
|
6016
|
+
copyCaseFieldsWithCollectionData(caseFields, collectionItemData) {
|
|
6017
|
+
return caseFields.map((field) => {
|
|
6018
|
+
const fieldData = collectionItemData?.[field.id];
|
|
6019
|
+
if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
6020
|
+
return {
|
|
6021
|
+
...field,
|
|
6022
|
+
field_type: {
|
|
6023
|
+
...field.field_type,
|
|
6024
|
+
complex_fields: this.copyCaseFieldsWithCollectionData(field.field_type.complex_fields, fieldData)
|
|
6025
|
+
}
|
|
6026
|
+
};
|
|
6027
|
+
}
|
|
6028
|
+
return this.isDynamicList(field.field_type.type) &&
|
|
6029
|
+
field.display_context !== 'HIDDEN' &&
|
|
6030
|
+
fieldData?.list_items !== undefined
|
|
6031
|
+
? { ...field, list_items: fieldData.list_items }
|
|
6032
|
+
: field;
|
|
6033
|
+
});
|
|
6034
|
+
}
|
|
5985
6035
|
isDynamicList(fieldType) {
|
|
5986
6036
|
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
|
|
5987
6037
|
}
|
|
@@ -9774,8 +9824,10 @@ class CaseEditComponent {
|
|
|
9774
9824
|
return form.value.event.id;
|
|
9775
9825
|
}
|
|
9776
9826
|
generateCaseEventData({ eventTrigger, form }) {
|
|
9827
|
+
const formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
|
|
9828
|
+
this.formValueService.sanitiseDynamicLists(eventTrigger.case_fields, { data: formData });
|
|
9777
9829
|
const caseEventData = {
|
|
9778
|
-
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(
|
|
9830
|
+
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(formData, this.isCaseFlagSubmission)),
|
|
9779
9831
|
event: form.value.event
|
|
9780
9832
|
};
|
|
9781
9833
|
this.formValueService.clearNonCaseFields(caseEventData.data, eventTrigger.case_fields);
|