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