AAE-22944 Disable form rules form read only form (#9775)

This commit is contained in:
Bartosz Sekula
2024-06-06 12:04:39 +02:00
committed by GitHub
parent ad0d2c80a5
commit 00b714a57a
3 changed files with 21 additions and 2 deletions

View File

@@ -710,6 +710,17 @@ describe('Form Renderer Component', () => {
expect(rulesManager.initialize).toHaveBeenCalledWith(formModel);
});
it('should NOT call the Form Rules Manager init when the form is read only', () => {
spyOn(rulesManager, 'initialize');
const formModel = formService.parseForm(customWidgetFormWithVisibility.formRepresentation.formDefinition);
formRendererComponent.formDefinition = formModel;
formRendererComponent.readOnly = true;
formRendererComponent.ngOnInit();
expect(rulesManager.initialize).not.toHaveBeenCalled();
});
it('should call the Form Rules Manager destroy on component destruction', () => {
spyOn(rulesManager, 'destroy');

View File

@@ -66,6 +66,9 @@ export class FormRendererComponent<T> implements OnInit, OnDestroy {
@Input()
formDefinition: FormModel;
@Input()
readOnly = false;
debugMode: boolean;
fields: FormFieldModel[];
@@ -79,7 +82,9 @@ export class FormRendererComponent<T> implements OnInit, OnDestroy {
ngOnInit(): void {
this.runMiddlewareServices();
this.formRulesManager.initialize(this.formDefinition);
if (!this.readOnly) {
this.formRulesManager.initialize(this.formDefinition);
}
}
ngOnDestroy() {