Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## RELEASE NOTES
## RELEASE NOTES-exui-4309

### Version 7.3.52-exui-4309
**EXUI-4309** Error messaging when changing from an event to create case

### Version 7.3.54
**EXUI-4636** Revert CME-220 and EXUI-2111
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.3.54",
"version": "7.3.54-exui-4309",
"engines": {
"node": ">=20.19.0"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/ccd-case-ui-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.3.54",
"version": "7.3.54-exui-4309",
"engines": {
"node": ">=20.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,29 @@ describe('CaseEditPageComponent - all other tests', () => {
expect(comp.currentPage).toEqual(firstPage);
});

it('should clear stale validation errors on init', () => {
const staleValidationErrors = [{ id: 'field1', message: 'Stale validation error' }];
caseEditDataService.caseFormValidationErrors$.next(staleValidationErrors);
caseEditDataService.clearFormValidationErrors.and.callFake(() => {
caseEditDataService.caseFormValidationErrors$.next([]);
});

comp.validationErrors = staleValidationErrors;
comp.ngOnInit();

expect(comp.validationErrors).toEqual([]);
expect(caseEditDataService.clearFormValidationErrors).toHaveBeenCalled();
});

it('should clear validation errors when destroyed', () => {
comp.validationErrors = [{ id: 'field1', message: 'Stale validation error' }];

comp.ngOnDestroy();

expect(comp.validationErrors).toEqual([]);
expect(caseEditDataService.clearFormValidationErrors).toHaveBeenCalled();
});

it('should return true on hasPrevious check', () => {
const errorContext = {
ignoreWarning: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro

public ngOnInit(): void {
initDialog();
this.clearValidationErrors();
this.eventTrigger = this.caseEdit.eventTrigger;
this.editForm = this.caseEdit.form;
this.wizard = this.caseEdit.wizard;
Expand Down Expand Up @@ -197,6 +198,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
this.dialogRefAfterClosedSub?.unsubscribe();
this.saveDraftSub?.unsubscribe();
this.caseFormValidationErrorsSub?.unsubscribe();
this.clearValidationErrors();
this.multipageComponentStateService.reset();
}

Expand Down Expand Up @@ -225,7 +227,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
* EUI-3732 - Breathing space data not persisted on Previous button click with ExpUI Demo
*/
public toPreviousPage(): void {
this.caseEditDataService.clearFormValidationErrors();
this.clearValidationErrors();
const caseEventData: CaseEventData = this.buildCaseEventData(true);
caseEventData.data = caseEventData.event_data;
this.updateFormData(caseEventData);
Expand Down Expand Up @@ -393,7 +395,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
}
}

this.caseEditDataService.clearFormValidationErrors();
this.clearValidationErrors();
this.checkForStagesCompleted();
if (this.currentPageIsNotValid()) {
// The generateErrorMessage method filters out the hidden fields.
Expand Down Expand Up @@ -567,7 +569,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
this.caseEdit.cancelled.emit();
}

this.caseEditDataService.clearFormValidationErrors();
this.clearValidationErrors();
this.multipageComponentStateService.reset();
}

Expand Down Expand Up @@ -652,6 +654,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
}

private resetErrors(): void {
this.clearValidationErrors();
this.caseEdit.error = null;
this.caseEdit.ignoreWarning = false;
this.triggerText = this.getTriggerText();
Expand All @@ -660,6 +663,11 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
}
}

private clearValidationErrors(): void {
this.validationErrors = [];
this.caseEditDataService?.clearFormValidationErrors?.();
}

private saveDraft() {
if (this.eventTrigger.can_save_draft) {
const draftCaseEventData: CaseEventData = this.formValueService.sanitise(this.editForm.value) as CaseEventData;
Expand Down
Loading