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
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## RELEASE NOTES

### Version 7.3.54-exui-4675
**EXUI-4675** Able to bypass mandatory reasons which expand with radio buttons

### Version 7.3.54
**EXUI-4636** Revert CME-220 and EXUI-2111
**EXUI-4637** Revert EXUI-2645
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-4675",
"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-4675",
"engines": {
"node": ">=20.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { AfterViewInit, Component, EventEmitter, Input, OnDestroy, Output } from '@angular/core';
import { AfterViewInit, Component, EventEmitter, Input, OnDestroy, Output, QueryList, ViewChildren } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Subject, Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { CaseField } from '../../../domain/definition/case-field.model';
import { ConditionalShowFormDirective } from '../../../directives/conditional-show/conditional-show-form.directive';
import { FormValueService } from '../../../services/form/form-value.service';

@Component({
Expand All @@ -12,6 +13,9 @@ import { FormValueService } from '../../../services/form/form-value.service';
})
export class CaseEditFormComponent implements OnDestroy, AfterViewInit {

@ViewChildren(ConditionalShowFormDirective)
private readonly conditionalShowFormDirectives: QueryList<ConditionalShowFormDirective>;

@Input()
public fields: CaseField[] = [];
@Input()
Expand Down Expand Up @@ -71,4 +75,9 @@ export class CaseEditFormComponent implements OnDestroy, AfterViewInit {
const current = JSON.stringify(this.formValueService.sanitise(changes));
this.initial !== current ? this.valuesChanged.emit(true) : this.valuesChanged.emit(false);
}

// EXUI-4675 - needed for the race condition caused by the debounce in ConditionalShowFormDirective
public syncConditionalShowStates(): void {
this.conditionalShowFormDirectives?.forEach(directive => directive.evalAllShowHideConditions());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,40 @@ describe('CaseEditPageComponent - all other tests', () => {
expect(comp.editForm.controls.data.get('caseNameHmctsInternal')).toBeNull();
expect(comp.editForm.controls.data.get('caseLinksFlag')).toBeNull();
});

it('should call syncConditionalShowStates on each CaseEditFormComponent instance before form validation', () => {
const syncSpy = jasmine.createSpy('syncConditionalShowStates');
const mockFormComponent = { syncConditionalShowStates: syncSpy };
const forEachSpy = jasmine.createSpy('forEach').and.callFake((fn: Function) => fn(mockFormComponent));
(comp as any).caseEditFormComponents = { forEach: forEachSpy };

comp.eventTrigger = {
id: 'testEvent',
case_fields: [caseField1],
name: 'Test event trigger name',
can_save_draft: false,
event_token: 'test-token'
} as unknown as CaseEventTrigger;

comp.submit();

expect(forEachSpy).toHaveBeenCalled();
expect(syncSpy).toHaveBeenCalled();
});

it('should not throw when caseEditFormComponents is an empty QueryList during submit', () => {
(comp as any).caseEditFormComponents = { forEach: jasmine.createSpy('forEach') };

comp.eventTrigger = {
id: 'testEvent',
case_fields: [caseField1],
name: 'Test event trigger name',
can_save_draft: false,
event_token: 'test-token'
} as unknown as CaseEventTrigger;

expect(() => comp.submit()).not.toThrow();
});
});

describe('previous the form', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewChecked, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { AfterViewChecked, ChangeDetectorRef, Component, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core';
import { AbstractControl, FormArray, FormGroup } from '@angular/forms';
import { MatLegacyDialog as MatDialog, MatLegacyDialogConfig as MatDialogConfig} from '@angular/material/legacy-dialog';
import { ActivatedRoute } from '@angular/router';
Expand All @@ -18,6 +18,7 @@ import { SaveOrDiscardDialogComponent } from '../../dialogs/save-or-discard-dial
import { CallbackErrorsContext } from '../../error/domain/error-context';
import { initDialog } from '../../helpers';
import { CaseEditComponent } from '../case-edit/case-edit.component';
import { CaseEditFormComponent } from '../case-edit-form/case-edit-form.component';
import { WizardPage } from '../domain/wizard-page.model';
import { Wizard } from '../domain/wizard.model';
import { PageValidationService } from '../services/page-validation.service';
Expand Down Expand Up @@ -66,6 +67,9 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro
public saveDraftSub: Subscription;
public caseFormValidationErrorsSub: Subscription;

@ViewChildren(CaseEditFormComponent)
private readonly caseEditFormComponents: QueryList<CaseEditFormComponent>;

private static scrollToTop(): void {
window.scrollTo(0, 0);
}
Expand Down Expand Up @@ -395,6 +399,7 @@ export class CaseEditPageComponent implements OnInit, AfterViewChecked, OnDestro

this.caseEditDataService.clearFormValidationErrors();
this.checkForStagesCompleted();
this.caseEditFormComponents?.forEach(component => component.syncConditionalShowStates());
if (this.currentPageIsNotValid()) {
// The generateErrorMessage method filters out the hidden fields.
// The error message for LinkedCases journey will never get displayed because the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class ConditionalShowFormDirective implements OnInit, AfterViewInit, OnDe
}
}

private evalAllShowHideConditions(): void {
public evalAllShowHideConditions(): void {
this.getCurrentPagesReadOnlyAndFormFieldValues();
this.fieldsUtils.controlIterator(this.formGroup, this.handleFormArray, this.handleFormGroup, this.handleFormControl);
}
Expand Down
Loading