Search in sources :

Example 6 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorHelperTest method testGetFormField.

@Test
public void testGetFormField() {
    when(formDefinition.getFieldById(anyString())).thenReturn(nameField);
    content.setDefinition(formDefinition);
    FieldDefinition formField = formEditorHelper.getFormField(nameField.getId());
    assertEquals(formField, nameField);
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) Test(org.junit.Test)

Example 7 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorHelperTest method testUnboundField.

void testUnboundField(Pair<EditorFieldLayoutComponent, FieldDefinition> pair) {
    FieldDefinition expectedField = pair.getK2();
    Assertions.assertThat(expectedField).isNotNull();
    FieldDefinition resultField = formEditorHelper.getFormField(expectedField.getId());
    formEditorHelper.saveFormField(expectedField, resultField);
    Assertions.assertThat(resultField).isNotNull().isEqualTo(expectedField);
    Assertions.assertThat(resultField.getFieldType().getTypeName()).isEqualTo(resultField.getLabel());
    Assertions.assertThat(content.getDefinition().getFieldById(resultField.getId())).isNotNull();
    Assertions.assertThat(formEditorHelper.getUnbindedFields().get(resultField.getId())).isNull();
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)

Example 8 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorHelperTest method testSwitchToNullBinding.

@Test
public void testSwitchToNullBinding() {
    FieldDefinition result = formEditorHelper.switchToField(nameField, null);
    Assertions.assertThat(result.getId()).isNotEqualTo(nameField.getId());
    Assertions.assertThat(result.getName()).isNotEqualTo(nameField.getName());
    Assertions.assertThat(result.getBinding()).isNullOrEmpty();
    Assertions.assertThat(result.getBinding()).isNotEqualTo(nameField.getBinding());
    Assertions.assertThat(result.getStandaloneClassName()).isEqualTo(nameField.getStandaloneClassName());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) Test(org.junit.Test)

Example 9 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorPresenterTest method testRemoveFields.

protected void testRemoveFields(boolean checkAvailable) {
    int formFields = editorHelper.getFormDefinition().getFields().size();
    assertTrue("Form should have fields.", formFields > 0);
    assertEquals("Form should contain '" + employeeFields.size() + "' fields.", formFields, employeeFields.size());
    int availableFields = editorHelper.getAvailableFields().size();
    assertTrue("There should not exist available fields.", availableFields == 0);
    List<FieldDefinition> formFieldsList = new ArrayList<>(editorHelper.getFormDefinition().getFields());
    for (FieldDefinition field : formFieldsList) {
        presenter.onRemoveComponent(createComponentRemovedEvent(editorHelper.getFormDefinition(), field));
        availableFields++;
        formFields--;
        checkExpectedFields(availableFields, formFields, checkAvailable);
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) ArrayList(java.util.ArrayList)

Example 10 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorPresenterTest method testRemoveEventWhenMovingFieldOnLayout.

@Test
public void testRemoveEventWhenMovingFieldOnLayout() {
    loadContent();
    loadAvailableFields();
    addAllFields();
    FormEditorPresenter presenterSpy = spy(presenter);
    FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
    ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), true);
    presenterSpy.onRemoveComponent(event);
    assertNotNull(editorHelper.getFormDefinition().getFieldById(field.getId()));
    verify(presenterSpy, never()).onSyncPalette(anyString());
    verify(editorHelper, never()).removeField(anyString(), anyBoolean());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) ComponentRemovedEvent(org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent) Test(org.junit.Test)

Aggregations

FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)85 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)42 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)29 Test (org.junit.Test)27 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)24 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)22 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)21 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)20 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)18 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)17 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)14 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)13 ArrayList (java.util.ArrayList)11 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)8 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)7 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)7 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)7 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)7 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)7