Search in sources :

Example 6 with FormField

use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.

the class CheckboxTemplate method create.

@Override
public FormField create() {
    List<EnumItem> values = Lists.newArrayList();
    values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(1)));
    values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(2)));
    FormField field = new FormField(ResourceId.generateFieldId(EnumType.TYPE_CLASS));
    field.setLabel(I18N.CONSTANTS.defaultCheckboxFieldLabel());
    field.setType(new EnumType(Cardinality.MULTIPLE, values));
    return field;
}
Also used : EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem) FormField(org.activityinfo.model.form.FormField)

Example 7 with FormField

use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.

the class RelevanceRow method onFieldChanged.

@UiHandler("fieldListBox")
public void onFieldChanged(ChangeEvent event) {
    FormField field = getSelectedField();
    if (field != null) {
        updateOperators(field, getSelectedOperator());
        updateOperandChoices(field, getValue());
    }
}
Also used : FormField(org.activityinfo.model.form.FormField) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 8 with FormField

use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.

the class FieldEditor method validateCode.

/**
 * Returns whether code is valid.
 *
 * @return whether code is valid
 */
private boolean validateCode(FieldWidgetContainer fieldWidgetContainer) {
    codeGroup.setShowValidationMessage(false);
    String codeString = this.code.getValue();
    if (Strings.isNullOrEmpty(codeString)) {
        return true;
    }
    if (!FormField.isValidCode(codeString)) {
        codeGroup.showValidationMessage(I18N.CONSTANTS.invalidCodeMessage());
        return false;
    } else {
        // check whether code is unique
        List<FormField> formFields = fieldWidgetContainer.getFormDesigner().getModel().getAllFormsFields();
        formFields.remove(fieldWidgetContainer.getFormField());
        for (FormField field : formFields) {
            if (codeString.equals(field.getCode())) {
                codeGroup.showValidationMessage(I18N.CONSTANTS.duplicateCodeMessage());
                return false;
            }
        }
        return true;
    }
}
Also used : FormField(org.activityinfo.model.form.FormField)

Example 9 with FormField

use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.

the class RelevancePanelPresenter method fieldList.

private List<FormField> fieldList(FieldWidgetContainer container) {
    ResourceId thisFieldId = container.getFormField().getId();
    FormClass formClass = container.getFormDesigner().getModel().getFormClassByElementId(thisFieldId);
    List<FormField> formFields = new ArrayList<>();
    for (FormField formField : formClass.getFields()) {
        if (!formField.getId().equals(thisFieldId)) {
            formFields.add(formField);
        }
    }
    return formFields;
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FormClass(org.activityinfo.model.form.FormClass) ArrayList(java.util.ArrayList) FormField(org.activityinfo.model.form.FormField)

Example 10 with FormField

use of org.activityinfo.model.form.FormField in project activityinfo by bedatadriven.

the class RadioButtonTemplate method create.

@Override
public FormField create() {
    List<EnumItem> values = Lists.newArrayList();
    values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(1)));
    values.add(new EnumItem(EnumItem.generateId(), I18N.MESSAGES.defaultEnumItem(2)));
    FormField field = new FormField(ResourceId.generateFieldId(EnumType.TYPE_CLASS));
    field.setLabel(I18N.CONSTANTS.defaultRadioFieldLabel());
    field.setType(new EnumType(Cardinality.SINGLE, values));
    return field;
}
Also used : EnumType(org.activityinfo.model.type.enumerated.EnumType) EnumItem(org.activityinfo.model.type.enumerated.EnumItem) FormField(org.activityinfo.model.form.FormField)

Aggregations

FormField (org.activityinfo.model.form.FormField)119 FormClass (org.activityinfo.model.form.FormClass)48 ResourceId (org.activityinfo.model.resource.ResourceId)32 Test (org.junit.Test)30 QuantityType (org.activityinfo.model.type.number.QuantityType)18 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)17 ReferenceType (org.activityinfo.model.type.ReferenceType)16 EnumType (org.activityinfo.model.type.enumerated.EnumType)14 FieldValue (org.activityinfo.model.type.FieldValue)12 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)11 JsonValue (org.activityinfo.json.JsonValue)9 FormTree (org.activityinfo.model.formTree.FormTree)9 FormInstance (org.activityinfo.model.form.FormInstance)8 CalculatedFieldType (org.activityinfo.model.type.expr.CalculatedFieldType)8 ColumnSet (org.activityinfo.model.query.ColumnSet)6 QueryModel (org.activityinfo.model.query.QueryModel)6 KeyGenerator (org.activityinfo.model.legacy.KeyGenerator)5 Quantity (org.activityinfo.model.type.number.Quantity)5 TypedRecordUpdate (org.activityinfo.store.spi.TypedRecordUpdate)5 ArrayList (java.util.ArrayList)4