diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractEditForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractEditForm.java index ecc6ea80b00..fb3e4203bac 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractEditForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractEditForm.java @@ -15,6 +15,8 @@ package de.symeda.sormas.ui.utils; +import static com.vaadin.v7.data.fieldgroup.DefaultFieldGroupFieldFactory.CAPTION_PROPERTY_ID; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -221,6 +223,11 @@ protected ComboBox addDiseaseField( diseaseField = addField(fieldId, ComboBox.class); this.setServerDiseaseAsDefault = setServerDiseaseAsDefault; + + if (hideFollowUpDisabledDiseases) { + removeFollowUpDisabledDiseases(diseaseField); + } + if (showNonPrimaryDiseases) { addNonPrimaryDiseasesTo(diseaseField); } @@ -234,15 +241,10 @@ protected ComboBox addDiseaseField( Object value = e.getProperty().getValue(); if (value != null && !diseaseField.containsId(value)) { Item newItem = diseaseField.addItem(value); - newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(value.toString()); + newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(value.toString()); } }); - // - if (hideFollowUpDisabledDiseases) { - removeFollowUpDisabledDiseases(diseaseField); - } - return diseaseField; } @@ -509,17 +511,16 @@ protected void addNonPrimaryDiseasesTo(ComboBox diseaseField) { } Item newItem = diseaseField.addItem(disease); - newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(disease.toString()); + newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(disease.toString()); } } protected void removeFollowUpDisabledDiseases(ComboBox diseaseField) { - List allActiveDiseases = FacadeProvider.getDiseaseConfigurationFacade().getAllActiveDiseases(); - - for (Disease disease : allActiveDiseases) { - if (diseaseField.getItem(disease) != null && !disease.isDefaultFollowUpEnabled()) { - diseaseField.removeItem(disease); - } + List allDiseasesWithFollowUp = FacadeProvider.getDiseaseConfigurationFacade().getAllDiseasesWithFollowUp(true, true, true); + diseaseField.removeAllItems(); + for (Object r : allDiseasesWithFollowUp) { + Item newItem = diseaseField.addItem(r); + newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString()); } }