3939import com .vaadin .v7 .data .util .converter .Converter ;
4040import com .vaadin .v7 .ui .AbstractSelect .ItemCaptionMode ;
4141import com .vaadin .v7 .ui .ComboBox ;
42- import com .vaadin .v7 .ui .Field ;
4342import com .vaadin .v7 .ui .OptionGroup ;
4443import com .vaadin .v7 .ui .TextArea ;
4544import com .vaadin .v7 .ui .TextField ;
6665import de .symeda .sormas .api .exposure .ExposureSetting ;
6766import de .symeda .sormas .api .exposure .ExposureSubSetting ;
6867import de .symeda .sormas .api .exposure .FomiteTransmissionLocation ;
68+ import de .symeda .sormas .api .exposure .TypeOfAnimal ;
6969import de .symeda .sormas .api .i18n .Captions ;
7070import de .symeda .sormas .api .i18n .I18nProperties ;
7171import de .symeda .sormas .api .i18n .Strings ;
@@ -109,6 +109,7 @@ public class ExposureForm extends AbstractEditForm<ExposureDto> {
109109 ExposureDto .SUB_SETTINGS ,
110110 ExposureDto .CONDITION_OF_ANIMAL ,
111111 ExposureDto .ANIMAL_CATEGORY ,
112+ ExposureDto .TYPE_OF_ANIMAL ,
112113 ExposureDto .FOMITE_TRANSMISSION_LOCATION
113114 )),
114115 fluidColumn (4 , 0 , locs (
@@ -173,6 +174,7 @@ public class ExposureForm extends AbstractEditForm<ExposureDto> {
173174 private TextField protectiveMeasureDetailsField ;
174175 private NullableOptionGroup conditionOfAnimalField ;
175176 private NullableOptionGroup animalCategoryField ;
177+ private ComboBox typeOfAnimalField ;
176178 private TextField animalCategoryDetailsField ;
177179 private NullableOptionGroup fomiteTransmissionLocationField ;
178180
@@ -314,6 +316,9 @@ private void addBasicFields() {
314316 animalCategoryField = addField (exposureDetailsLayout , ExposureDto .ANIMAL_CATEGORY , NullableOptionGroup .class );
315317 animalCategoryField .setVisible (false );
316318
319+ typeOfAnimalField = addField (exposureDetailsLayout , ExposureDto .TYPE_OF_ANIMAL , ComboBox .class );
320+ typeOfAnimalField .setVisible (false );
321+
317322 animalCategoryDetailsField = addField (exposureDetailsLayout , ExposureDto .ANIMAL_CATEGORY_DETAILS , TextField .class );
318323 animalCategoryDetailsField .setVisible (false );
319324
@@ -400,6 +405,9 @@ private void addBasicFields() {
400405 // Clear dependent fields when conditionOfAnimal becomes null
401406 if (!hasValue ) {
402407 animalCategoryField .setValue (null );
408+
409+ typeOfAnimalField .setValue (null );
410+ typeOfAnimalField .setVisible (false );
403411 animalCategoryDetailsField .setValue (null );
404412 animalCategoryDetailsField .setVisible (false );
405413 }
@@ -409,11 +417,13 @@ private void addBasicFields() {
409417 Object value = e .getProperty ().getValue ();
410418 boolean hasValue = value != null ;
411419
412- // Show/hide animalCategoryDetailsField
420+ // Show/hide typeOfAnimal, animalCategoryDetailsField
421+ typeOfAnimalField .setVisible (hasValue );
413422 animalCategoryDetailsField .setVisible (hasValue );
414423
415424 // Clear details field when animalCategory becomes null
416425 if (!hasValue ) {
426+ typeOfAnimalField .setValue (null );
417427 animalCategoryDetailsField .setValue (null );
418428 }
419429 });
@@ -541,6 +551,9 @@ private void updateAnimalContactFields(ExposureCategory category) {
541551 animalCategoryField .setValue (null );
542552 animalCategoryField .setVisible (false );
543553 animalCategoryField .setRequired (false );
554+
555+ typeOfAnimalField .setValue (null );
556+ typeOfAnimalField .setVisible (false );
544557 animalCategoryDetailsField .setValue (null );
545558 animalCategoryDetailsField .setVisible (false );
546559 }
@@ -579,6 +592,7 @@ public void setValue(ExposureDto newFieldValue) throws ReadOnlyException, Conver
579592 String protectiveMeasureDetails = newFieldValue .getProtectiveMeasureDetails ();
580593 AnimalCondition conditionOfAnimal = newFieldValue .getConditionOfAnimal ();
581594 AnimalCategory animalCategory = newFieldValue .getAnimalCategory ();
595+ TypeOfAnimal typeOfAnimal = newFieldValue .getTypeOfAnimal ();
582596 String animalCategoryDetails = newFieldValue .getAnimalCategoryDetails ();
583597 FomiteTransmissionLocation fomiteTransmissionLocation = newFieldValue .getFomiteTransmissionLocation ();
584598
@@ -640,6 +654,12 @@ public void setValue(ExposureDto newFieldValue) throws ReadOnlyException, Conver
640654 }
641655
642656 boolean hasAnimalCategory = animalCategory != null ;
657+
658+ typeOfAnimalField .setVisible (isAnimalContact && hasConditionOfAnimal && hasAnimalCategory );
659+ if (isAnimalContact && hasConditionOfAnimal && hasAnimalCategory && typeOfAnimal != null ) {
660+ typeOfAnimalField .setValue (typeOfAnimal );
661+ }
662+
643663 animalCategoryDetailsField .setVisible (isAnimalContact && hasConditionOfAnimal && hasAnimalCategory );
644664 if (isAnimalContact && hasConditionOfAnimal && hasAnimalCategory && animalCategoryDetails != null ) {
645665 animalCategoryDetailsField .setValue (animalCategoryDetails );
@@ -689,20 +709,6 @@ private void populateExposureCategories(ExposureDto exposure) {
689709 FieldHelper .updateItems (categoryField , new ArrayList <>(categories ));
690710 }
691711
692- private void addFieldsToLayout (CustomLayout layout , String ... propertyIds ) {
693- for (String propertyId : propertyIds ) {
694- addField (layout , propertyId );
695- }
696- }
697-
698- private void addFieldsWithCssToLayout (CustomLayout layout , Class <? extends Field > fieldType , List <String > propertyIds , String ... styles ) {
699-
700- for (String propertyId : propertyIds ) {
701- Field <?> field = addField (layout , propertyId , fieldType );
702- CssStyles .style (field , styles );
703- }
704- }
705-
706712 public Map <CustomizableFieldMetadataDto , CustomizableFieldValueDto > collectCurrentFieldValues () {
707713 Map <CustomizableFieldMetadataDto , CustomizableFieldValueDto > result = new HashMap <>();
708714 for (CustomizableFieldsGroup panel : new CustomizableFieldsGroup [] {
0 commit comments