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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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() {

View File

@ -63,7 +63,10 @@
</mat-card-title>
</mat-card-header>
<mat-card-content class="adf-form-container-card-content">
<adf-form-renderer [formDefinition]="form">
<adf-form-renderer
[formDefinition]="form"
[readOnly]="readOnly"
>
</adf-form-renderer>
</mat-card-content>
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions">