@hmcts/ccd-case-ui-toolkit 7.3.61 → 7.3.62

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.
@@ -11528,7 +11528,7 @@ class CaseEditPageComponent {
11528
11528
  CaseEditPageComponent.setFocusToTop();
11529
11529
  }
11530
11530
  // Adding validation message to show it as Error Summary
11531
- generateErrorMessage(fields, container, path) {
11531
+ generateErrorMessage(fields, container, path, sourceFromComplexField) {
11532
11532
  const group = container || this.editForm.controls['data'];
11533
11533
  let validErrorFieldFound = false;
11534
11534
  let validationErrorAmount = this.validationErrors.length;
@@ -11545,7 +11545,7 @@ class CaseEditPageComponent {
11545
11545
  if (fieldElement) {
11546
11546
  const label = casefield.label || 'Field';
11547
11547
  let id = casefield.id;
11548
- if (fieldElement['component'] && fieldElement['component'].parent) {
11548
+ if (fieldElement['component'] && (fieldElement['component'].parent || sourceFromComplexField)) {
11549
11549
  if (fieldElement['component'].idPrefix.indexOf(`_${id}_`) === -1) {
11550
11550
  id = `${fieldElement['component'].idPrefix}${id}`;
11551
11551
  }
@@ -11557,7 +11557,7 @@ class CaseEditPageComponent {
11557
11557
  if (casefield.id === 'AddressLine1') {
11558
11558
  // EUI-1067 - Display more relevant error message to user and correctly navigate to the field
11559
11559
  this.addressService.setMandatoryError(true);
11560
- this.caseEditDataService.addFormValidationError({ id: `${path}_${path}`, message: `An address is required` });
11560
+ this.caseEditDataService.addFormValidationError({ id, message: `An address is required` });
11561
11561
  }
11562
11562
  else {
11563
11563
  this.caseEditDataService.addFormValidationError({ id, message: `%FIELDLABEL% is required`, label });
@@ -11583,7 +11583,7 @@ class CaseEditPageComponent {
11583
11583
  }
11584
11584
  else if (fieldElement.invalid) {
11585
11585
  if (casefield.isComplex()) {
11586
- errorPresent = this.generateErrorMessage(casefield.field_type.complex_fields, fieldElement, id);
11586
+ errorPresent = this.generateErrorMessage(casefield.field_type.complex_fields, fieldElement, id, true);
11587
11587
  }
11588
11588
  else if (casefield.isCollection() && casefield.field_type.collection_field_type.type === 'Complex') {
11589
11589
  const fieldArray = fieldElement;
@@ -15355,9 +15355,20 @@ class WriteCollectionFieldComponent extends AbstractFieldWriteComponent {
15355
15355
  }
15356
15356
  }
15357
15357
  focusLastItem() {
15358
- const item = this.items.last.nativeElement.querySelector('.form-control');
15359
- if (item) {
15360
- item.focus();
15358
+ const root = this.items.last?.nativeElement;
15359
+ if (!root) {
15360
+ return;
15361
+ }
15362
+ const controls = Array.from(root.querySelectorAll('.form-control'));
15363
+ const focusTarget = controls.find(control => {
15364
+ if (!(control instanceof HTMLInputElement)) {
15365
+ return true;
15366
+ }
15367
+ const type = (control.type || '').toLowerCase();
15368
+ return type !== 'radio';
15369
+ });
15370
+ if (focusTarget) {
15371
+ focusTarget.focus();
15361
15372
  }
15362
15373
  }
15363
15374
  removeItem(index) {
@@ -19976,12 +19987,18 @@ class MoneyGbpInputComponent {
19976
19987
  writeValue(obj) {
19977
19988
  if (obj) {
19978
19989
  this.rawValue = obj;
19979
- const integerPart = obj.slice(0, -2) || '0';
19980
- let decimalPart = obj.slice(-2);
19981
- while (2 > decimalPart.length) {
19982
- decimalPart += '0';
19990
+ // If already contains decimal, use it directly
19991
+ if (obj.includes('.')) {
19992
+ this.displayValue = obj;
19993
+ }
19994
+ else {
19995
+ const integerPart = obj.slice(0, -2) || '0';
19996
+ let decimalPart = obj.slice(-2);
19997
+ while (2 > decimalPart.length) {
19998
+ decimalPart += '0';
19999
+ }
20000
+ this.displayValue = [integerPart, decimalPart].join('.');
19983
20001
  }
19984
- this.displayValue = [integerPart, decimalPart].join('.');
19985
20002
  }
19986
20003
  }
19987
20004
  registerOnChange(fn) {