@hmcts/ccd-case-ui-toolkit 7.3.48-pofcc-105 → 7.3.48-xui-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.
|
@@ -3933,6 +3933,7 @@ class FieldsUtils {
|
|
|
3933
3933
|
static SERVER_RESPONSE_FIELD_TYPE_COLLECTION = 'Collection';
|
|
3934
3934
|
static SERVER_RESPONSE_FIELD_TYPE_COMPLEX = 'Complex';
|
|
3935
3935
|
static SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE = ['DynamicList', 'DynamicRadioList'];
|
|
3936
|
+
static SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_MULTISELECT_LIST_TYPE = 'DynamicMultiSelectList';
|
|
3936
3937
|
static defaultTabList = {
|
|
3937
3938
|
"PRLAPPS": "Summary"
|
|
3938
3939
|
};
|
|
@@ -4183,31 +4184,53 @@ class FieldsUtils {
|
|
|
4183
4184
|
static textForInvalidField(type, invalidValue) {
|
|
4184
4185
|
return `{ Invalid ${type}: ${invalidValue} }`;
|
|
4185
4186
|
}
|
|
4186
|
-
static setDynamicListDefinition(caseField, caseFieldType, rootCaseField) {
|
|
4187
|
+
static setDynamicListDefinition(caseField, caseFieldType, rootCaseField, isWithinCollection = false) {
|
|
4187
4188
|
if (caseFieldType.type === FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COMPLEX) {
|
|
4188
4189
|
caseFieldType.complex_fields.forEach(field => {
|
|
4189
4190
|
try {
|
|
4190
4191
|
const isDynamicField = FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_LIST_TYPE.indexOf(field.field_type.type) !== -1;
|
|
4191
|
-
|
|
4192
|
+
const isDynamicMultiSelectField = field.field_type.type === FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_DYNAMIC_MULTISELECT_LIST_TYPE;
|
|
4193
|
+
if (isDynamicField || isDynamicMultiSelectField) {
|
|
4192
4194
|
const dynamicListValue = this.getDynamicListValue(rootCaseField.value, field.id);
|
|
4193
4195
|
if (dynamicListValue) {
|
|
4194
|
-
const list_items = dynamicListValue
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4196
|
+
const list_items = dynamicListValue.find(data => data?.list_items !== undefined)?.list_items;
|
|
4197
|
+
if (list_items !== undefined) {
|
|
4198
|
+
field.list_items = list_items;
|
|
4199
|
+
field.formatted_value = {
|
|
4200
|
+
...field.formatted_value,
|
|
4201
|
+
list_items
|
|
4202
|
+
};
|
|
4203
|
+
}
|
|
4204
|
+
if (isDynamicMultiSelectField) {
|
|
4205
|
+
if (!isWithinCollection) {
|
|
4206
|
+
const value = dynamicListValue[0]?.value;
|
|
4207
|
+
if (value !== undefined) {
|
|
4208
|
+
field.value = value;
|
|
4209
|
+
field.formatted_value = {
|
|
4210
|
+
...field.formatted_value,
|
|
4211
|
+
value
|
|
4212
|
+
};
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
else {
|
|
4217
|
+
const complexValue = dynamicListValue.map(data => data.value);
|
|
4218
|
+
const value = {
|
|
4219
|
+
list_items,
|
|
4220
|
+
value: complexValue.length > 0 ? complexValue : undefined
|
|
4221
|
+
};
|
|
4222
|
+
field.value = {
|
|
4223
|
+
...value
|
|
4224
|
+
};
|
|
4225
|
+
field.formatted_value = {
|
|
4226
|
+
...field.formatted_value,
|
|
4227
|
+
...value
|
|
4228
|
+
};
|
|
4229
|
+
}
|
|
4207
4230
|
}
|
|
4208
4231
|
}
|
|
4209
4232
|
else {
|
|
4210
|
-
this.setDynamicListDefinition(field, field.field_type, rootCaseField);
|
|
4233
|
+
this.setDynamicListDefinition(field, field.field_type, rootCaseField, isWithinCollection);
|
|
4211
4234
|
}
|
|
4212
4235
|
}
|
|
4213
4236
|
catch (error) {
|
|
@@ -4217,7 +4240,7 @@ class FieldsUtils {
|
|
|
4217
4240
|
}
|
|
4218
4241
|
else if (caseFieldType.type === FieldsUtils.SERVER_RESPONSE_FIELD_TYPE_COLLECTION) {
|
|
4219
4242
|
if (caseFieldType.collection_field_type) {
|
|
4220
|
-
this.setDynamicListDefinition(caseField, caseFieldType.collection_field_type, rootCaseField);
|
|
4243
|
+
this.setDynamicListDefinition(caseField, caseFieldType.collection_field_type, rootCaseField, true);
|
|
4221
4244
|
}
|
|
4222
4245
|
}
|
|
4223
4246
|
}
|
|
@@ -5880,37 +5903,55 @@ class FieldTypeSanitiser {
|
|
|
5880
5903
|
}
|
|
5881
5904
|
ensureDynamicMultiSelectListPopulated(caseFields) {
|
|
5882
5905
|
return caseFields.map((field) => {
|
|
5883
|
-
|
|
5906
|
+
const fieldData = field._value || field.value;
|
|
5907
|
+
if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5908
|
+
this.checkNestedDynamicList(field, fieldData);
|
|
5909
|
+
}
|
|
5910
|
+
else if (field.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COLLECTION &&
|
|
5911
|
+
field.field_type.collection_field_type?.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5912
|
+
this.checkNestedDynamicList(field, fieldData, true);
|
|
5913
|
+
}
|
|
5914
|
+
else {
|
|
5884
5915
|
return field;
|
|
5885
5916
|
}
|
|
5886
|
-
const caseFieldData = field._value;
|
|
5887
|
-
// Process each complex field
|
|
5888
|
-
field.field_type.complex_fields.forEach((complexField) => {
|
|
5889
|
-
if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5890
|
-
this.checkNestedDynamicList(complexField, caseFieldData?.[complexField.id]);
|
|
5891
|
-
}
|
|
5892
|
-
else if (this.isDynamicList(complexField.field_type.type) &&
|
|
5893
|
-
complexField.display_context !== 'HIDDEN' &&
|
|
5894
|
-
field._value?.[complexField.id]) {
|
|
5895
|
-
complexField.list_items = field._value[complexField.id]?.list_items;
|
|
5896
|
-
}
|
|
5897
|
-
});
|
|
5898
5917
|
// Final transformation: construct updated field object
|
|
5899
5918
|
return { ...field, field_type: { ...field?.field_type } };
|
|
5900
5919
|
});
|
|
5901
5920
|
}
|
|
5902
|
-
checkNestedDynamicList(caseField, fieldData = null) {
|
|
5903
|
-
|
|
5921
|
+
checkNestedDynamicList(caseField, fieldData = null, isCollection = false) {
|
|
5922
|
+
const complexFields = isCollection
|
|
5923
|
+
? caseField.field_type.collection_field_type?.complex_fields || []
|
|
5924
|
+
: caseField.field_type.complex_fields;
|
|
5925
|
+
complexFields.forEach((complexField) => {
|
|
5926
|
+
const childData = isCollection
|
|
5927
|
+
? this.getFirstCollectionFieldData(fieldData, complexField.id)
|
|
5928
|
+
: fieldData?.[complexField.id];
|
|
5904
5929
|
if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5905
|
-
this.checkNestedDynamicList(complexField,
|
|
5930
|
+
this.checkNestedDynamicList(complexField, childData);
|
|
5931
|
+
}
|
|
5932
|
+
else if (complexField.field_type.type === FieldTypeSanitiser.FIELD_TYPE_COLLECTION &&
|
|
5933
|
+
complexField.field_type.collection_field_type?.type === FieldTypeSanitiser.FIELD_TYPE_COMPLEX) {
|
|
5934
|
+
this.checkNestedDynamicList(complexField, childData, true);
|
|
5906
5935
|
}
|
|
5907
5936
|
else if (this.isDynamicList(complexField.field_type.type) &&
|
|
5908
5937
|
complexField.display_context !== 'HIDDEN' &&
|
|
5909
|
-
|
|
5910
|
-
complexField.list_items =
|
|
5938
|
+
childData) {
|
|
5939
|
+
complexField.list_items = childData.list_items;
|
|
5911
5940
|
}
|
|
5912
5941
|
});
|
|
5913
5942
|
}
|
|
5943
|
+
getFirstCollectionFieldData(collectionData, fieldId) {
|
|
5944
|
+
if (!Array.isArray(collectionData)) {
|
|
5945
|
+
return null;
|
|
5946
|
+
}
|
|
5947
|
+
for (const item of collectionData) {
|
|
5948
|
+
const value = item?.value || item;
|
|
5949
|
+
if (value?.[fieldId] !== undefined) {
|
|
5950
|
+
return value[fieldId];
|
|
5951
|
+
}
|
|
5952
|
+
}
|
|
5953
|
+
return null;
|
|
5954
|
+
}
|
|
5914
5955
|
isDynamicList(fieldType) {
|
|
5915
5956
|
return FieldTypeSanitiser.DYNAMIC_LIST_TYPE.indexOf(fieldType) !== -1;
|
|
5916
5957
|
}
|
|
@@ -6234,7 +6275,7 @@ class FormValueService {
|
|
|
6234
6275
|
* @param clearEmpty Whether or not we should clear out empty, optional, complex objects.
|
|
6235
6276
|
* @param clearNonCase Whether or not we should clear out non-case fields at the top level.
|
|
6236
6277
|
*/
|
|
6237
|
-
removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = []) {
|
|
6278
|
+
removeUnnecessaryFields(data, caseFields, clearEmpty = false, clearNonCase = false, fromPreviousPage = false, currentPageCaseFields = [], isNested = false) {
|
|
6238
6279
|
if (data && caseFields && caseFields.length > 0) {
|
|
6239
6280
|
// check if there is any data at the top level of the form that's not in the caseFields
|
|
6240
6281
|
if (clearNonCase) {
|
|
@@ -6245,9 +6286,9 @@ class FormValueService {
|
|
|
6245
6286
|
// Retain anything that is readonly and not a label.
|
|
6246
6287
|
continue;
|
|
6247
6288
|
}
|
|
6248
|
-
if (
|
|
6289
|
+
if (this.shouldRemoveHiddenField(field, isNested)) {
|
|
6249
6290
|
// Delete anything that is hidden (that is NOT readonly), and that
|
|
6250
|
-
//
|
|
6291
|
+
// is not explicitly retained. Nested hidden fields should be dropped by default.
|
|
6251
6292
|
delete data[field.id];
|
|
6252
6293
|
}
|
|
6253
6294
|
else if (field.field_type) {
|
|
@@ -6262,7 +6303,7 @@ class FormValueService {
|
|
|
6262
6303
|
}
|
|
6263
6304
|
break;
|
|
6264
6305
|
case 'Complex':
|
|
6265
|
-
this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty);
|
|
6306
|
+
this.removeUnnecessaryFields(data[field.id], field.field_type.complex_fields, clearEmpty, false, false, [], true);
|
|
6266
6307
|
// Also remove any optional complex objects that are completely empty.
|
|
6267
6308
|
// EUI-4244: Ritesh's fix, passing true instead of clearEmpty.
|
|
6268
6309
|
if (FormValueService.clearOptionalEmpty(true, data[field.id], field)) {
|
|
@@ -6285,8 +6326,8 @@ class FormValueService {
|
|
|
6285
6326
|
if (field.field_type.collection_field_type.type === 'Complex') {
|
|
6286
6327
|
// Iterate through the elements and remove any unnecessary fields within.
|
|
6287
6328
|
for (const item of collection) {
|
|
6288
|
-
this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty);
|
|
6289
|
-
this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false);
|
|
6329
|
+
this.removeUnnecessaryFields(item, field.field_type.collection_field_type.complex_fields, clearEmpty, false, false, [], true);
|
|
6330
|
+
this.removeUnnecessaryFields(item.value, field.field_type.collection_field_type.complex_fields, false, false, false, [], true);
|
|
6290
6331
|
}
|
|
6291
6332
|
}
|
|
6292
6333
|
}
|
|
@@ -6300,6 +6341,12 @@ class FormValueService {
|
|
|
6300
6341
|
// Clear out any MultiSelect labels.
|
|
6301
6342
|
FormValueService.removeMultiSelectLabels(data);
|
|
6302
6343
|
}
|
|
6344
|
+
shouldRemoveHiddenField(field, isNested) {
|
|
6345
|
+
return field.hidden === true
|
|
6346
|
+
&& field.id !== 'caseLinks'
|
|
6347
|
+
&& !field.retain_hidden_value
|
|
6348
|
+
&& (isNested || (field.display_context !== 'HIDDEN' && field.display_context !== 'HIDDEN_TEMP'));
|
|
6349
|
+
}
|
|
6303
6350
|
removeInvalidCollectionData(data, field) {
|
|
6304
6351
|
if (data[field.id] && data[field.id].length > 0) {
|
|
6305
6352
|
for (const objCollection of data[field.id]) {
|
|
@@ -9708,8 +9755,10 @@ class CaseEditComponent {
|
|
|
9708
9755
|
return form.value.event.id;
|
|
9709
9756
|
}
|
|
9710
9757
|
generateCaseEventData({ eventTrigger, form }) {
|
|
9758
|
+
const formData = this.replaceHiddenFormValuesWithOriginalCaseData(form.get('data'), eventTrigger.case_fields);
|
|
9759
|
+
this.formValueService.sanitiseDynamicLists(eventTrigger.case_fields, { data: formData });
|
|
9711
9760
|
const caseEventData = {
|
|
9712
|
-
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(
|
|
9761
|
+
data: this.replaceEmptyComplexFieldValues(this.formValueService.sanitise(formData, this.isCaseFlagSubmission)),
|
|
9713
9762
|
event: form.value.event
|
|
9714
9763
|
};
|
|
9715
9764
|
this.formValueService.clearNonCaseFields(caseEventData.data, eventTrigger.case_fields);
|
|
@@ -19809,18 +19858,12 @@ class MoneyGbpInputComponent {
|
|
|
19809
19858
|
writeValue(obj) {
|
|
19810
19859
|
if (obj) {
|
|
19811
19860
|
this.rawValue = obj;
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
|
|
19816
|
-
else {
|
|
19817
|
-
const integerPart = obj.slice(0, -2) || '0';
|
|
19818
|
-
let decimalPart = obj.slice(-2);
|
|
19819
|
-
while (2 > decimalPart.length) {
|
|
19820
|
-
decimalPart += '0';
|
|
19821
|
-
}
|
|
19822
|
-
this.displayValue = [integerPart, decimalPart].join('.');
|
|
19861
|
+
const integerPart = obj.slice(0, -2) || '0';
|
|
19862
|
+
let decimalPart = obj.slice(-2);
|
|
19863
|
+
while (2 > decimalPart.length) {
|
|
19864
|
+
decimalPart += '0';
|
|
19823
19865
|
}
|
|
19866
|
+
this.displayValue = [integerPart, decimalPart].join('.');
|
|
19824
19867
|
}
|
|
19825
19868
|
}
|
|
19826
19869
|
registerOnChange(fn) {
|