[AAE-15522] Fix - Dropdown variable error messages are displayed at modeling level (#8730)

This commit is contained in:
Tomasz Gnyp
2023-07-04 09:37:08 +02:00
committed by GitHub
parent 3b3fd5ab9a
commit a933070fc3
9 changed files with 101 additions and 7 deletions

View File

@@ -103,6 +103,29 @@ describe('FormFieldComponent', () => {
});
});
it('should set field preview state', () => {
const field = new FormFieldModel(form, {
type: FormFieldTypes.DROPDOWN,
id: 'FAKE-DROPDOWN-WIDGET'
});
component.field = field;
component.preview = true;
fixture.detectChanges();
expect(component.field.preview).toBe(true);
});
it('should field preview state be false as default', () => {
const field = new FormFieldModel(form, {
type: FormFieldTypes.DROPDOWN,
id: 'FAKE-DROPDOWN-WIDGET'
});
component.field = field;
fixture.detectChanges();
expect(component.field.preview).toBe(false);
});
it('should hide the field when it is not visible', (done) => {
const field = new FormFieldModel(form, {
type: FormFieldTypes.TEXT,

View File

@@ -63,6 +63,9 @@ export class FormFieldComponent implements OnInit, OnDestroy {
@Input()
field: FormFieldModel = null;
@Input()
preview: boolean = false;
componentRef: ComponentRef<any>;
focus: boolean = false;
@@ -80,6 +83,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
}
const originalField = this.getField();
if (originalField) {
this.setFieldPreviewState();
const customTemplate = this.field.form.customFieldTemplates[originalField.type];
if (customTemplate && this.hasController(originalField.type)) {
const factory = this.getComponentFactorySync(originalField.type, customTemplate);
@@ -154,6 +158,10 @@ export class FormFieldComponent implements OnInit, OnDestroy {
return module.componentFactories.find((x) => x.componentType === decoratedCmp);
}
private setFieldPreviewState(): void {
this.field.preview = this.preview;
}
focusToggle() {
setTimeout(() => {
this.focus = !this.focus;

View File

@@ -83,6 +83,7 @@ export class FormFieldModel extends FormWidgetModel {
groupsRestriction: string[];
leftLabels: boolean = false;
variableConfig: VariableConfig;
preview: boolean = false;
// container model members
numberOfColumns: number = 1;

View File

@@ -90,6 +90,7 @@ export class FormModel implements ProcessFormModel {
isValid = true;
processVariables: ProcessVariableModel[] = [];
variables: FormVariableModel[] = [];
preview: boolean = false;
constructor(
json?: any,