Search in sources :

Example 16 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class DistrictEditForm method addFields.

@Override
protected void addFields() {
    addField(DistrictDto.NAME, TextField.class);
    addField(DistrictDto.EPID_CODE, TextField.class);
    ComboBox region = addInfrastructureField(DistrictDto.REGION);
    addField(RegionDto.EXTERNAL_ID, TextField.class);
    // TextField growthRate = addField(DistrictDto.GROWTH_RATE, TextField.class);
    // growthRate.setConverter(new StringToFloatConverter());
    // growthRate.setConversionError(I18nProperties.getValidationError(Validations.onlyDecimalNumbersAllowed, growthRate.getCaption()));
    setRequired(true, DistrictDto.NAME, DistrictDto.EPID_CODE, DistrictDto.REGION);
    region.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
    // TODO: Workaround until cases and other data is properly transfered when infrastructure data changes
    if (!create) {
        region.setEnabled(false);
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Example 17 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class FacilityEditForm method addFields.

@Override
protected void addFields() {
    addField(FacilityDto.NAME, TextField.class);
    typeGroup = ComboBoxHelper.createComboBoxV7();
    typeGroup.setId("typeGroup");
    typeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
    typeGroup.addItems(FacilityTypeGroup.values());
    typeGroup.setWidth(100, Unit.PERCENTAGE);
    typeGroup.setEnabled(create);
    getContent().addComponent(typeGroup, TYPE_GROUP_LOC);
    ComboBox type = addField(FacilityDto.TYPE);
    type.removeAllItems();
    type.setEnabled(create);
    ComboBox region = addInfrastructureField(FacilityDto.REGION);
    ComboBox district = addInfrastructureField(FacilityDto.DISTRICT);
    ComboBox community = addInfrastructureField(FacilityDto.COMMUNITY);
    addField(FacilityDto.CITY, TextField.class);
    addField(FacilityDto.POSTAL_CODE, TextField.class);
    addField(FacilityDto.STREET, TextField.class);
    addField(FacilityDto.HOUSE_NUMBER, TextField.class);
    addField(FacilityDto.ADDITIONAL_INFORMATION, TextField.class);
    addField(FacilityDto.AREA_TYPE, ComboBox.class);
    addField(FacilityDto.CONTACT_PERSON_FIRST_NAME, TextField.class);
    addField(FacilityDto.CONTACT_PERSON_LAST_NAME, TextField.class);
    TextField contactPersonPhone = addField(FacilityDto.CONTACT_PERSON_PHONE, TextField.class);
    contactPersonPhone.addValidator(new PhoneNumberValidator(I18nProperties.getValidationError(Validations.validPhoneNumber, contactPersonPhone.getCaption())));
    TextField contactPersonEmail = addField(FacilityDto.CONTACT_PERSON_EMAIL, TextField.class);
    contactPersonEmail.addValidator(new EmailValidator(I18nProperties.getValidationError(Validations.validEmailAddress, contactPersonEmail.getCaption())));
    AccessibleTextField latitude = addField(FacilityDto.LATITUDE, AccessibleTextField.class);
    latitude.setConverter(new StringToAngularLocationConverter());
    latitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, latitude.getCaption()));
    AccessibleTextField longitude = addField(FacilityDto.LONGITUDE, AccessibleTextField.class);
    longitude.setConverter(new StringToAngularLocationConverter());
    longitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, longitude.getCaption()));
    addField(RegionDto.EXTERNAL_ID, TextField.class);
    setRequired(true, FacilityDto.NAME, TYPE_GROUP_LOC, FacilityDto.TYPE, FacilityDto.REGION, FacilityDto.DISTRICT);
    typeGroup.addValueChangeListener(e -> FieldHelper.updateEnumData(type, FacilityType.getTypes((FacilityTypeGroup) typeGroup.getValue())));
    type.addValueChangeListener(e -> {
        boolean notLab = !FacilityType.LABORATORY.equals(type.getValue());
        region.setRequired(notLab);
        district.setRequired(notLab);
        if (!create) {
            // Disable editing of region, etc. so case references stay correct
            region.setEnabled(false);
            district.setEnabled(false);
            community.setEnabled(false);
        }
    });
    region.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    district.addValueChangeListener(e -> {
        FieldHelper.removeItems(community);
        DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(community, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
    });
    community.addValueChangeListener(e -> {
        @SuppressWarnings("unused") CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue();
    });
    region.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
}
Also used : AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) EmailValidator(com.vaadin.v7.data.validator.EmailValidator) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) PhoneNumberValidator(de.symeda.sormas.ui.utils.PhoneNumberValidator) StringToAngularLocationConverter(de.symeda.sormas.ui.utils.StringToAngularLocationConverter) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) TextField(com.vaadin.v7.ui.TextField) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 18 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class CaseFilterForm method addMoreFilters.

public void addMoreFilters(CustomLayout moreFiltersContainer) {
    ComboBox presentConditionField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseCriteria.PRESENT_CONDITION, 140));
    presentConditionField.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION));
    UserDto user = currentUserDto();
    ComboBox regionField = null;
    if (user.getRegion() == null) {
        regionField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.REGION, 140));
        regionField.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    }
    ComboBox districtField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.DISTRICT, 140));
    districtField.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
    addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.COMMUNITY, 140));
    if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
        ComboBox typeGroup = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseCriteria.FACILITY_TYPE_GROUP, 140));
        typeGroup.setInputPrompt(I18nProperties.getCaption(Captions.Facility_typeGroup));
        typeGroup.removeAllItems();
        FieldHelper.updateEnumData(typeGroup, FacilityTypeGroup.getAccomodationGroups());
        ComboBox type = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseCriteria.FACILITY_TYPE, 140));
        type.setInputPrompt(I18nProperties.getPrefixCaption(FacilityDto.I18N_PREFIX, FacilityDto.TYPE));
        type.removeAllItems();
        ComboBox facilityField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.HEALTH_FACILITY, 140));
        facilityField.setDescription(I18nProperties.getDescription(Descriptions.descFacilityFilter));
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) {
        ComboBox pointOfEntryField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.POINT_OF_ENTRY, 140));
        pointOfEntryField.setDescription(I18nProperties.getDescription(Descriptions.descPointOfEntryFilter));
    }
    ComboBox officerField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.SURVEILLANCE_OFFICER, 140));
    Disease selectedDisease = (Disease) getField(CaseIndexDto.DISEASE).getValue();
    officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(user.getRegion(), selectedDisease, UserRight.CASE_RESPONSIBLE));
    if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_FOLLOWUP)) {
        Field<?> followUpUntilTo = addField(moreFiltersContainer, FieldConfiguration.withCaptionAndPixelSized(CaseCriteria.FOLLOW_UP_UNTIL_TO, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.FOLLOW_UP_UNTIL), 200));
        followUpUntilTo.removeAllValidators();
        addField(moreFiltersContainer, FieldConfiguration.withCaptionAndPixelSized(CaseCriteria.SYMPTOM_JOURNAL_STATUS, I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SYMPTOM_JOURNAL_STATUS), 240));
    }
    addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseCriteria.VACCINATION_STATUS, 140));
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
        addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseCriteria.REINFECTION_STATUS, 140));
    }
    addField(moreFiltersContainer, FieldConfiguration.withCaptionAndPixelSized(CaseCriteria.REPORTING_USER_ROLE, I18nProperties.getString(Strings.reportedBy), 140));
    TextField reportingUserField = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseCriteria.REPORTING_USER_LIKE, 200));
    reportingUserField.setNullRepresentation("");
    reportingUserField.setInputPrompt(I18nProperties.getPrefixCaption(propertyI18nPrefix, CaseDataDto.REPORTING_USER));
    addField(moreFiltersContainer, FieldConfiguration.withCaptionAndPixelSized(CaseCriteria.QUARANTINE_TYPE, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.QUARANTINE), 200));
    Field<?> quarantineTo = addField(moreFiltersContainer, FieldConfiguration.pixelSized(CaseDataDto.QUARANTINE_TO, 200));
    quarantineTo.removeAllValidators();
    ComboBox birthDateYYYY = addField(moreFiltersContainer, CaseCriteria.BIRTHDATE_YYYY, ComboBox.class);
    birthDateYYYY.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_YYYY));
    birthDateYYYY.setWidth(140, Unit.PIXELS);
    birthDateYYYY.addItems(DateHelper.getYearsToNow());
    birthDateYYYY.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ID_TOSTRING);
    ComboBox birthDateMM = addField(moreFiltersContainer, CaseCriteria.BIRTHDATE_MM, ComboBox.class);
    birthDateMM.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_MM));
    birthDateMM.setWidth(140, Unit.PIXELS);
    birthDateMM.addItems(DateHelper.getMonthsInYear());
    ComboBox birthDateDD = addField(moreFiltersContainer, CaseCriteria.BIRTHDATE_DD, ComboBox.class);
    birthDateDD.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_DD));
    birthDateDD.setWidth(140, Unit.PIXELS);
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.MUST_HAVE_NO_GEO_COORDINATES, I18nProperties.getCaption(Captions.caseFilterWithoutGeo), I18nProperties.getDescription(Descriptions.descCaseFilterWithoutGeo), CssStyles.CHECKBOX_FILTER_INLINE));
    if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) {
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.MUST_BE_PORT_HEALTH_CASE_WITHOUT_FACILITY, I18nProperties.getCaption(Captions.caseFilterPortHealthWithoutFacility), I18nProperties.getDescription(Descriptions.descCaseFilterPortHealthWithoutFacility), CssStyles.CHECKBOX_FILTER_INLINE));
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.CLINICAL_COURSE_VIEW) || UserProvider.getCurrent().hasUserRight(UserRight.THERAPY_VIEW)) {
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.MUST_HAVE_CASE_MANAGEMENT_DATA, I18nProperties.getCaption(Captions.caseFilterCasesWithCaseManagementData), I18nProperties.getDescription(Descriptions.descCaseFilterCasesWithCaseManagementData), CssStyles.CHECKBOX_FILTER_INLINE));
    }
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.WITHOUT_RESPONSIBLE_OFFICER, I18nProperties.getCaption(Captions.caseFilterWithoutResponsibleUser), I18nProperties.getDescription(Descriptions.descCaseFilterWithoutResponsibleUser), CssStyles.CHECKBOX_FILTER_INLINE));
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.WITH_EXTENDED_QUARANTINE, I18nProperties.getCaption(Captions.caseFilterWithExtendedQuarantine), I18nProperties.getDescription(Descriptions.descCaseFilterWithExtendedQuarantine), CssStyles.CHECKBOX_FILTER_INLINE));
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.WITH_REDUCED_QUARANTINE, I18nProperties.getCaption(Captions.caseFilterWithReducedQuarantine), I18nProperties.getDescription(Descriptions.descCaseFilterWithReducedQuarantine), CssStyles.CHECKBOX_FILTER_INLINE));
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_QUARANTINE_HELP_NEEDED, I18nProperties.getCaption(Captions.caseFilterOnlyQuarantineHelpNeeded), null, CssStyles.CHECKBOX_FILTER_INLINE));
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_CASES_WITH_EVENTS, I18nProperties.getCaption(Captions.caseFilterRelatedToEvent), I18nProperties.getDescription(Descriptions.descCaseFilterRelatedToEvent), CssStyles.CHECKBOX_FILTER_INLINE));
    addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_CONTACTS_FROM_OTHER_INSTANCES, I18nProperties.getCaption(Captions.caseFilterOnlyFromOtherInstances), I18nProperties.getDescription(Descriptions.descCaseFilterOnlyFromOtherInstances), CssStyles.CHECKBOX_FILTER_INLINE));
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_CASES_WITH_REINFECTION, I18nProperties.getCaption(Captions.caseFilterCasesWithReinfection), I18nProperties.getDescription(Descriptions.descCaseFilterCasesWithReinfection), CssStyles.CHECKBOX_FILTER_INLINE));
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_SHOW_CASES_WITH_FULFILLED_REFERENCE_DEFINITION, I18nProperties.getCaption(Captions.caseFilterOnlyCasesWithFulfilledReferenceDefinition), I18nProperties.getDescription(Descriptions.descCaseFilterOnlyCasesWithFulfilledReferenceDefinition), CssStyles.CHECKBOX_FILTER_INLINE));
    }
    final JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
    if (userJurisdictionLevel != JurisdictionLevel.NATION && userJurisdictionLevel != JurisdictionLevel.NONE) {
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.INCLUDE_CASES_FROM_OTHER_JURISDICTIONS, I18nProperties.getCaption(Captions.caseFilterInludeCasesFromOtherJurisdictions), I18nProperties.getDescription(Descriptions.descCaseFilterIncludeCasesFromOtherJurisdictions), CssStyles.CHECKBOX_FILTER_INLINE));
    }
    boolean isExternalShareEnabled = FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled();
    if (isExternalShareEnabled) {
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_ENTITIES_NOT_SHARED_WITH_EXTERNAL_SURV_TOOL, I18nProperties.getCaption(Captions.caseFilterOnlyCasesNotSharedWithExternalSurvTool), null, CssStyles.CHECKBOX_FILTER_INLINE));
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_ENTITIES_SHARED_WITH_EXTERNAL_SURV_TOOL, I18nProperties.getCaption(Captions.caseFilterOnlyCasesSharedWithExternalSurvToo), null, CssStyles.CHECKBOX_FILTER_INLINE));
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_ENTITIES_CHANGED_SINCE_LAST_SHARED_WITH_EXTERNAL_SURV_TOOL, I18nProperties.getCaption(Captions.caseFilterOnlyCasesChangedSinceLastSharedWithExternalSurvTool), null, CssStyles.CHECKBOX_FILTER_INLINE));
        addField(moreFiltersContainer, CheckBox.class, FieldConfiguration.withCaptionAndStyle(CaseCriteria.ONLY_CASES_WITH_DONT_SHARE_WITH_EXTERNAL_SURV_TOOL, I18nProperties.getCaption(Captions.caseFilterOnlyCasesWithDontShareWithExternalSurvTool), null, CssStyles.CHECKBOX_FILTER_INLINE));
    }
    moreFiltersContainer.addComponent(buildWeekAndDateFilter(isExternalShareEnabled), WEEK_AND_DATE_FILTER);
}
Also used : Disease(de.symeda.sormas.api.Disease) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) TextField(com.vaadin.v7.ui.TextField)

Example 19 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class CaseFilterForm method applyDependenciesOnFieldChange.

@Override
protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueChangeEvent event) {
    super.applyDependenciesOnFieldChange(propertyId, event);
    final CaseCriteria criteria = getValue();
    final ComboBox regionField = getField(CaseDataDto.REGION);
    final ComboBox districtField = getField(CaseDataDto.DISTRICT);
    final ComboBox communityField = getField(CaseDataDto.COMMUNITY);
    final ComboBox facilityTypeGroupField = getField(CaseCriteria.FACILITY_TYPE_GROUP);
    final ComboBox facilityTypeField = getField(CaseCriteria.FACILITY_TYPE);
    final ComboBox facilityField = getField(CaseDataDto.HEALTH_FACILITY);
    final ComboBox pointOfEntryField = getField(CaseDataDto.POINT_OF_ENTRY);
    final ComboBox caseOriginField = getField(CaseDataDto.CASE_ORIGIN);
    final UserDto user = currentUserDto();
    final DistrictReferenceDto currentDistrict = user.getDistrict() != null ? user.getDistrict() : (DistrictReferenceDto) districtField.getValue();
    final CaseOrigin currentCaseOrigin = caseOriginField != null ? (CaseOrigin) getField(CaseDataDto.CASE_ORIGIN).getValue() : CaseOrigin.POINT_OF_ENTRY;
    switch(propertyId) {
        case CaseDataDto.REGION:
            {
                final RegionReferenceDto region = user.getRegion() != null ? user.getRegion() : (RegionReferenceDto) event.getProperty().getValue();
                if (!DataHelper.equal(region, criteria.getRegion())) {
                    final ComboBox officerField = getField(CaseDataDto.SURVEILLANCE_OFFICER);
                    officerField.removeAllItems();
                    if (region != null) {
                        enableFields(districtField);
                        FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
                        disableFields(pointOfEntryField);
                        clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField);
                        addOfficers(officerField, region);
                    } else {
                        clearAndDisableFields(districtField, communityField, facilityField, facilityTypeField, facilityTypeGroupField);
                        disableFields(pointOfEntryField);
                        addOfficers(officerField, user.getRegion());
                    }
                }
                break;
            }
        case CaseDataDto.DISTRICT:
            {
                final DistrictReferenceDto newDistrict = (DistrictReferenceDto) event.getProperty().getValue();
                if (!DataHelper.equal(newDistrict, criteria.getDistrict())) {
                    final ComboBox officerField = getField(CaseDataDto.SURVEILLANCE_OFFICER);
                    officerField.removeAllItems();
                    if (newDistrict != null) {
                        enableFields(communityField, facilityTypeGroupField);
                        clearAndDisableFields(facilityField);
                        if (facilityTypeGroupField != null) {
                            if (facilityTypeGroupField.getValue() != null && facilityTypeField.getValue() != null) {
                                FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(newDistrict, (FacilityType) facilityTypeField.getValue(), true, false));
                                enableFields(facilityField);
                            } else {
                                FieldHelper.updateEnumData(facilityTypeGroupField, FacilityTypeGroup.getAccomodationGroups());
                            }
                        }
                        FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(newDistrict.getUuid()));
                        if (pointOfEntryField != null && currentCaseOrigin == CaseOrigin.POINT_OF_ENTRY) {
                            pointOfEntryField.setEnabled(true);
                            FieldHelper.updateItems(pointOfEntryField, FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(newDistrict.getUuid(), true));
                        }
                        Disease selectedDisease = (Disease) getField(CaseIndexDto.DISEASE).getValue();
                        officerField.addItems(FacadeProvider.getUserFacade().getUserRefsByDistrict(newDistrict, selectedDisease, UserRight.CASE_RESPONSIBLE));
                    } else {
                        clearAndDisableFields(communityField, pointOfEntryField, facilityField, facilityTypeField, facilityTypeGroupField);
                        final RegionReferenceDto region = regionField != null ? (RegionReferenceDto) regionField.getValue() : null;
                        addOfficers(officerField, region != null ? region : user.getRegion());
                    }
                }
                break;
            }
        case CaseDataDto.COMMUNITY:
            {
                CommunityReferenceDto community = (CommunityReferenceDto) event.getProperty().getValue();
                if (!DataHelper.equal(community, criteria.getCommunity())) {
                    if (facilityField != null) {
                        facilityField.setValue(null);
                    }
                    final FacilityType facilityType = facilityTypeField != null ? (FacilityType) facilityTypeField.getValue() : null;
                    if (facilityType == null && facilityField != null) {
                        facilityField.removeAllItems();
                    } else if (facilityField != null) {
                        if (community == null) {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(currentDistrict, facilityType, true, false));
                        } else {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
                        }
                    }
                }
                break;
            }
        case CaseCriteria.FACILITY_TYPE_GROUP:
            {
                FacilityTypeGroup typeGroup = (FacilityTypeGroup) event.getProperty().getValue();
                if (!DataHelper.equal(typeGroup, criteria.getFacilityTypeGroup())) {
                    if (typeGroup != null) {
                        enableFields(CaseDataDto.FACILITY_TYPE);
                        FieldHelper.updateEnumData(facilityTypeField, FacilityType.getAccommodationTypes(typeGroup));
                        facilityField.setValue(null);
                    } else {
                        clearAndDisableFields(facilityTypeField, facilityField);
                    }
                }
                break;
            }
        case CaseCriteria.FACILITY_TYPE:
            {
                FacilityType facilityType = (FacilityType) event.getProperty().getValue();
                if (!DataHelper.equal(facilityType, criteria.getFacilityType())) {
                    if (facilityType == null) {
                        clearAndDisableFields(facilityField);
                    } else {
                        enableFields(facilityField);
                        facilityField.setValue(null);
                        CommunityReferenceDto community = (CommunityReferenceDto) communityField.getValue();
                        if (community != null) {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
                        } else if (currentDistrict != null) {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(currentDistrict, facilityType, true, false));
                        }
                    }
                }
                break;
            }
        case CaseCriteria.BIRTHDATE_MM:
            {
                Integer birthMM = (Integer) event.getProperty().getValue();
                ComboBox birthDayDD = getField(CaseCriteria.BIRTHDATE_DD);
                birthDayDD.setEnabled(birthMM != null);
                FieldHelper.updateItems(birthDayDD, DateHelper.getDaysInMonth((Integer) getField(CaseCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(CaseCriteria.BIRTHDATE_YYYY).getValue()));
                break;
            }
        case CaseDataDto.CASE_ORIGIN:
            {
                if (pointOfEntryField != null) {
                    CaseOrigin caseOrigin = (CaseOrigin) event.getProperty().getValue();
                    if (caseOrigin == CaseOrigin.POINT_OF_ENTRY && currentDistrict != null) {
                        pointOfEntryField.setEnabled(true);
                        FieldHelper.updateItems(pointOfEntryField, FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(currentDistrict.getUuid(), true));
                    } else {
                        clearAndDisableFields(CaseDataDto.POINT_OF_ENTRY);
                    }
                }
                break;
            }
        case CaseDataDto.DISEASE:
            {
                ComboBox diseaseVariantField = getField(CaseDataDto.DISEASE_VARIANT);
                ComboBox presentConditionField = getField(PersonDto.PRESENT_CONDITION);
                Disease disease = (Disease) event.getProperty().getValue();
                if (disease == null) {
                    FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
                    FieldHelper.setEnabled(false, diseaseVariantField);
                    FieldHelper.updateEnumData(presentConditionField, Arrays.asList(PresentCondition.values()));
                } else {
                    List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
                    FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
                    FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
                    FieldVisibilityCheckers fieldVisibilityCheckers = FieldVisibilityCheckers.withDisease(disease);
                    List<PresentCondition> validValues = Arrays.stream(PresentCondition.values()).filter(c -> fieldVisibilityCheckers.isVisible(PresentCondition.class, c.name())).collect(Collectors.toList());
                    PresentCondition currentValue = (PresentCondition) presentConditionField.getValue();
                    if (currentValue != null && !validValues.contains(currentValue)) {
                        validValues.add(currentValue);
                    }
                    FieldHelper.updateEnumData(presentConditionField, validValues);
                }
            }
    }
}
Also used : Disease(de.symeda.sormas.api.Disease) PresentCondition(de.symeda.sormas.api.person.PresentCondition) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) List(java.util.List) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin)

Example 20 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.

the class CaseFilterForm method setValue.

@Override
public void setValue(CaseCriteria newCriteria) throws ReadOnlyException, Converter.ConversionException {
    super.setValue(newCriteria);
    ComboBox typeField = getField(CaseCriteria.FACILITY_TYPE);
    if (newCriteria.getFacilityType() != null && typeField != null) {
        typeField.setValue(newCriteria.getFacilityType());
        ComboBox facilityField = getField(CaseDataDto.HEALTH_FACILITY);
        if (newCriteria.getHealthFacility() != null && facilityField != null) {
            facilityField.setValue(newCriteria.getHealthFacility());
        }
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)113 TextField (com.vaadin.v7.ui.TextField)43 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)31 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)28 Label (com.vaadin.ui.Label)24 Disease (de.symeda.sormas.api.Disease)24 TextArea (com.vaadin.v7.ui.TextArea)19 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 DateField (com.vaadin.v7.ui.DateField)18 List (java.util.List)18 CheckBox (com.vaadin.v7.ui.CheckBox)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)17 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)17 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)16 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)16 Field (com.vaadin.v7.ui.Field)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 Captions (de.symeda.sormas.api.i18n.Captions)14