From 7c17bc1b05e45e68ea65ddd0034513a19e024da9 Mon Sep 17 00:00:00 2001 From: Daniel Lam Date: Fri, 8 Dec 2023 11:10:08 +0000 Subject: [PATCH] EUI-8737: Fix FirstErrorPipe implementation and Welsh Translation support (#1541) Reimplement `FirstErrorPipe` to use the `RpxTranslationService` directly instead of `RpxTranslatePipe`; remove incorrect use of `RpxTranslatePipe` from palette components where `FirstErrorPipe` is used in the component's HTML template. Co-authored-by: David Rajkumar Jayakumar <107850923+DavidJayakumar@users.noreply.github.com> --- RELEASE-NOTES.md | 6 ++ package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- .../write-case-link-field.component.spec.ts | 8 ++- .../case-link/write-case-link-field.html | 2 +- .../collection/write-collection-field.html | 2 +- .../palette/date/write-date-field.html | 2 +- .../datetime-picker.component.html | 2 +- .../write-dynamic-list-field.html | 2 +- .../write-dynamic-radio-list-field.html | 2 +- .../palette/email/write-email-field.html | 2 +- .../fixed-list/write-fixed-list-field.html | 2 +- .../write-fixed-radio-list-field.html | 2 +- .../money-gbp/write-money-gbp-field.html | 2 +- .../write-multi-select-list-field.html | 2 +- .../palette/number/write-number-field.html | 2 +- .../phone-uk/write-phone-uk-field.html | 2 +- .../text-area/write-text-area-field.html | 2 +- .../palette/text/write-text-field.html | 2 +- .../palette/utils/first-error.pipe.spec.ts | 63 ++++++++++++++----- .../palette/utils/first-error.pipe.ts | 29 ++++++--- .../palette/yes-no/write-yes-no-field.html | 2 +- 22 files changed, 98 insertions(+), 44 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index bbe08960b1..57aba46bcb 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,4 +1,7 @@ ## RELEASE NOTES +### Version 6.19.15-welsh-translation-FirstErrorPipe-fix +**EUI-8737** Re-tag for re-release following deployment of Restricted Case Access feature to live + ### Version 6.19.15-case-flags-v2-manage-case-flags-flag-update-comments-fix-2 **EUI-9035** Re-tag for re-release following deployment of Restricted Case Access feature to live @@ -11,6 +14,9 @@ ### Version 6.19.6-restricted-case-access-v4 **EUI-6645** Restricted case access +### Version 6.19.13-welsh-translation-FirstErrorPipe-fix +**EUI-8737** Reimplement `FirstErrorPipe` to use the `RpxTranslationService` directly instead of `RpxTranslatePipe`; remove incorrect use of `RpxTranslatePipe` from palette components where `FirstErrorPipe` is used in the component's HTML template + ### Version 6.19.13-case-flags-v2-manage-case-flags-value-caching-fix **EUI-9020** Fix bug where previous changes to a flag are retained in the UI when the user starts over and selects the same flag to update again diff --git a/package.json b/package.json index e2ebeda72e..dd763d23b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "6.19.15-welsh-yes-no-fixes-v1", + "version": "6.19.15-welsh-translation-FirstErrorPipe-fix", "engines": { "yarn": "^3.5.0", "npm": "^8.10.0" diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 875ad85714..95239bb9f1 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "6.19.15-welsh-yes-no-fixes-v1", + "version": "6.19.15-welsh-translation-FirstErrorPipe-fix", "engines": { "yarn": "^3.5.0", "npm": "^8.10.0" diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.component.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.component.spec.ts index 804c549de6..aa60b7f2b5 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.component.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.component.spec.ts @@ -1,7 +1,8 @@ import { DebugElement } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; -import { RpxTranslatePipe } from 'rpx-xui-translation'; +import { RpxTranslatePipe, RpxTranslationService } from 'rpx-xui-translation'; +import { of } from 'rxjs'; import { CaseField, FieldType } from '../../../domain/definition'; import { MockRpxTranslatePipe } from '../../../test/mock-rpx-translate.pipe'; import { PaletteUtilsModule } from '../utils'; @@ -37,6 +38,8 @@ describe('WriteCaseLinkFieldComponent', () => { let component: WriteCaseLinkFieldComponent; let fixture: ComponentFixture; let de: DebugElement; + const rpxTranslationServiceSpy = jasmine.createSpyObj('RpxTranslationService', ['getTranslation$', 'translate']); + rpxTranslationServiceSpy.getTranslation$.and.callFake((someString: string) => of(someString)); beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -49,7 +52,8 @@ describe('WriteCaseLinkFieldComponent', () => { MockRpxTranslatePipe ], providers: [ - { provide: RpxTranslatePipe, useClass: MockRpxTranslatePipe } + { provide: RpxTranslatePipe, useClass: MockRpxTranslatePipe }, + { provide: RpxTranslationService, useValue: rpxTranslationServiceSpy } ] }) .compileComponents(); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.html index 12016dd410..9edd8c669c 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-link/write-case-link-field.html @@ -4,7 +4,7 @@ {{caseField.hint_text | rpxTranslate}} - {{ caseReferenceControl.errors | ccdFirstError:caseField.label | rpxTranslate}} + {{caseReferenceControl.errors | ccdFirstError:caseField.label}} diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/collection/write-collection-field.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/collection/write-collection-field.html index 0068897433..efdd67daef 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/collection/write-collection-field.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/collection/write-collection-field.html @@ -9,7 +9,7 @@

{{caseField.hint_text | rpxTranslate }} - {{(formArray.errors | ccdFirstError:caseField.label ) | rpxTranslate}} + {{(formArray.errors | ccdFirstError:caseField.label)}}

diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/date/write-date-field.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/date/write-date-field.html index 842d291025..ab2b46f959 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/date/write-date-field.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/date/write-date-field.html @@ -6,7 +6,7 @@ {{caseField.hint_text | rpxTranslate}} - {{ (dateControl.errors | ccdFirstError:caseField.label ) | rpxTranslate}} + {{(dateControl.errors | ccdFirstError:caseField.label)}} {{(caseField | ccdFieldLabel) | rpxTranslate }} {{caseField.hint_text | rpxTranslate}} {{(dateControl.errors | ccdFirstError:caseField.label) | rpxTranslate}} + *ngIf="dateControl && dateControl.errors && dateControl.dirty && !(minError || maxError)">{{(dateControl.errors | ccdFirstError:caseField.label)}} {{'This date is older than the minimum date allowed' | rpxTranslate}} {{'Select an option from the dropdown' | rpxTranslate}} {{(dynamicListFormControl.errors | - ccdFirstError:caseField.label) | rpxTranslate}} + ccdFirstError:caseField.label)}} diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/fixed-list/write-fixed-list-field.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/fixed-list/write-fixed-list-field.html index 8043a0dc80..53e2e051c9 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/fixed-list/write-fixed-list-field.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/fixed-list/write-fixed-list-field.html @@ -5,7 +5,7 @@ {{caseField.hint_text | rpxTranslate}} - {{ (fixedListFormControl.errors | ccdFirstError:caseField.label ) | rpxTranslate}} + {{(fixedListFormControl.errors | ccdFirstError:caseField.label)}} {{caseField.hint_text | rpxTranslate}} - {{phoneUkControl.errors | ccdFirstError:caseField.label | rpxTranslate}} + {{phoneUkControl.errors | ccdFirstError:caseField.label}} diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/text-area/write-text-area-field.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/text-area/write-text-area-field.html index 9371cb5eb2..70473b2488 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/text-area/write-text-area-field.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/text-area/write-text-area-field.html @@ -5,7 +5,7 @@ {{caseField.hint_text | rpxTranslate}} - {{textareaControl.errors | ccdFirstError:caseField.label | rpxTranslate}} + {{textareaControl.errors | ccdFirstError:caseField.label}}