Search in sources :

Example 1 with ControlPropertyField

use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.

the class ConfirmationInputDialog method initializeContentView.

@Override
protected void initializeContentView(ViewDataBinding rootBinding, ViewDataBinding buttonPanelBinding) {
    getPositiveButton().setEnabled(false);
    ((ControlTextEditField) getRoot().findViewById(R.id.confirmation_input)).addValueChangedListener(new ValueChangeListener() {

        @Override
        public void onChange(ControlPropertyField field) {
            if (field.getValue() != null) {
                getPositiveButton().setEnabled(wordToType.compareToIgnoreCase(field.getValue().toString()) == 0);
            } else {
                getPositiveButton().setEnabled(false);
            }
        }
    });
}
Also used : ValueChangeListener(de.symeda.sormas.app.component.controls.ValueChangeListener) ControlTextEditField(de.symeda.sormas.app.component.controls.ControlTextEditField) ControlPropertyField(de.symeda.sormas.app.component.controls.ControlPropertyField)

Example 2 with ControlPropertyField

use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.

the class BaseActivity method extendHelpString.

private void extendHelpString(StringBuilder sb, ViewGroup parent) {
    if (parent == null)
        return;
    for (int i = 0; i < parent.getChildCount(); i++) {
        View child = parent.getChildAt(i);
        if (child instanceof ControlPropertyField && child.getVisibility() == View.VISIBLE) {
            ControlPropertyField propertyField = (ControlPropertyField) child;
            if (propertyField.getCaption() != null) {
                sb.append("<b>").append(Html.escapeHtml(propertyField.getCaption())).append("</b>").append("<br>");
                if (!StringUtils.isEmpty(propertyField.getDescription())) {
                    sb.append(Html.escapeHtml(propertyField.getDescription()));
                } else {
                    sb.append(Html.escapeHtml("-"));
                }
                sb.append("<br><br>");
            }
        } else if (child instanceof ViewGroup) {
            extendHelpString(sb, (ViewGroup) child);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ControlPropertyField(de.symeda.sormas.app.component.controls.ControlPropertyField) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) NavigationView(com.google.android.material.navigation.NavigationView)

Example 3 with ControlPropertyField

use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.

the class SymptomsEditFragment method initOnsetSymptomField.

private void initOnsetSymptomField(FragmentSymptomsEditLayoutBinding contentBinding) {
    final ControlSpinnerField onsetSymptomField = contentBinding.symptomsOnsetSymptom;
    final ControlDateField onsetDateField = contentBinding.symptomsOnsetDate;
    List<Item> initialSpinnerItems = new ArrayList<>();
    for (ControlSwitchField symptomField : symptomFields) {
        symptomField.addValueChangedListener(new ValueChangeListener() {

            @Override
            public void onChange(ControlPropertyField field) {
                Item item = new Item(field.getCaption(), field.getCaption());
                int position = onsetSymptomField.getPositionOf(item);
                if (SymptomState.YES.equals(field.getValue())) {
                    if (position == -1) {
                        onsetSymptomField.getAdapter().add(item);
                    }
                    onsetDateField.setEnabled(true);
                } else {
                    if (position != -1) {
                        onsetSymptomField.getAdapter().remove(onsetSymptomField.getAdapter().getItem(position));
                    }
                    onsetDateField.setEnabled(isAnySymptomSetToYes());
                }
                // first is "empty item"
                onsetSymptomField.setEnabled(onsetSymptomField.getAdapter().getCount() > 1);
            }
        });
        if (SymptomState.YES.equals(symptomField.getValue())) {
            initialSpinnerItems.add(new Item(symptomField.getCaption(), symptomField.getCaption()));
        }
    }
    onsetSymptomField.initializeSpinner(DataUtils.addEmptyItem(initialSpinnerItems));
    // first is "empty item"
    onsetSymptomField.setEnabled(onsetSymptomField.getAdapter().getCount() > 1);
    onsetDateField.setEnabled(isAnySymptomSetToYes());
}
Also used : Item(de.symeda.sormas.app.component.Item) ControlSpinnerField(de.symeda.sormas.app.component.controls.ControlSpinnerField) ValueChangeListener(de.symeda.sormas.app.component.controls.ValueChangeListener) ArrayList(java.util.ArrayList) ControlDateField(de.symeda.sormas.app.component.controls.ControlDateField) ControlPropertyField(de.symeda.sormas.app.component.controls.ControlPropertyField) ControlSwitchField(de.symeda.sormas.app.component.controls.ControlSwitchField)

Example 4 with ControlPropertyField

use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.

the class CampaignFormDataFragmentUtils method handleDependingOn.

public static void handleDependingOn(Map<String, ControlPropertyField> fieldMap, CampaignFormElement campaignFormElement, ControlPropertyField dynamicField) {
    final String dependingOn = campaignFormElement.getDependingOn();
    final String[] dependingOnValues = campaignFormElement.getDependingOnValues();
    if (dependingOn != null && dependingOnValues != null) {
        ControlPropertyField controlPropertyField = fieldMap.get(dependingOn);
        setVisibilityDependency(dynamicField, dependingOnValues, controlPropertyField.getValue());
        final ControlPropertyField finalDynamicField = dynamicField;
        controlPropertyField.addValueChangedListener(field -> setVisibilityDependency(finalDynamicField, dependingOnValues, field.getValue()));
    }
}
Also used : ControlPropertyField(de.symeda.sormas.app.component.controls.ControlPropertyField)

Example 5 with ControlPropertyField

use of de.symeda.sormas.app.component.controls.ControlPropertyField in project SORMAS-Project by hzi-braunschweig.

the class FieldVisibilityAndAccessHelper method setFieldVisibilitiesAndAccesses.

public static void setFieldVisibilitiesAndAccesses(Class<?> dtoClass, ViewGroup viewGroup, FieldVisibilityCheckers visibilityCheckers, UiFieldAccessCheckers accessCheckers) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View child = viewGroup.getChildAt(i);
        if (child instanceof ControlPropertyField) {
            String propertyId = ((ControlPropertyField) child).getSubPropertyId();
            boolean visibleAllowed = isVisibleAllowed(dtoClass, propertyId, visibilityCheckers);
            child.setVisibility(visibleAllowed && child.getVisibility() == VISIBLE ? VISIBLE : GONE);
            if (child.isEnabled() && !isFieldAccessible(dtoClass, propertyId, accessCheckers)) {
                setFieldInaccessibleValue(child);
            }
        } else if (child instanceof ViewGroup) {
            setFieldVisibilitiesAndAccesses(dtoClass, (ViewGroup) child, visibilityCheckers, accessCheckers);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ControlPropertyField(de.symeda.sormas.app.component.controls.ControlPropertyField) View(android.view.View)

Aggregations

ControlPropertyField (de.symeda.sormas.app.component.controls.ControlPropertyField)17 ValueChangeListener (de.symeda.sormas.app.component.controls.ValueChangeListener)10 View (android.view.View)6 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 LinearLayout (android.widget.LinearLayout)3 Disease (de.symeda.sormas.api.Disease)3 CampaignFormDataEntry (de.symeda.sormas.api.campaign.data.CampaignFormDataEntry)3 CampaignFormElement (de.symeda.sormas.api.campaign.form.CampaignFormElement)3 CampaignFormElementType (de.symeda.sormas.api.campaign.form.CampaignFormElementType)3 CampaignFormMeta (de.symeda.sormas.app.backend.campaign.form.CampaignFormMeta)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 ViewGroup (android.view.ViewGroup)2 Facility (de.symeda.sormas.app.backend.facility.Facility)2 CampaignFormDataFragmentUtils.getOrCreateCampaignFormDataEntry (de.symeda.sormas.app.campaign.CampaignFormDataFragmentUtils.getOrCreateCampaignFormDataEntry)2 Item (de.symeda.sormas.app.component.Item)2 ControlSwitchField (de.symeda.sormas.app.component.controls.ControlSwitchField)2 ConfirmationDialog (de.symeda.sormas.app.component.dialog.ConfirmationDialog)2 FragmentActivity (androidx.fragment.app.FragmentActivity)1