Search in sources :

Example 31 with ComboBox

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

the class PersonFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(PersonCriteria criteria) {
    final UserDto user = currentUserDto();
    final JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
    final ComboBox districtFilter = getField(PersonCriteria.DISTRICT);
    final ComboBox communityFilter = getField(PersonCriteria.COMMUNITY);
    // Get initial field values according to user and criteria
    final RegionReferenceDto region = user.getRegion() == null ? criteria.getRegion() : user.getRegion();
    final DistrictReferenceDto district = user.getDistrict() == null ? criteria.getDistrict() : user.getDistrict();
    final CommunityReferenceDto community = user.getCommunity() == null ? criteria.getCommunity() : user.getCommunity();
    // district
    if (region != null) {
        enableFields(districtFilter);
        districtFilter.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        // community
        if (district != null) {
            districtFilter.setValue(district);
            communityFilter.addItems(FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
            enableFields(communityFilter);
            if (community != null) {
                communityFilter.setValue(community);
            }
        } else {
            clearAndDisableFields(communityFilter);
        }
    } else {
        clearAndDisableFields(districtFilter, communityFilter);
    }
    // Disable fields according to user & jurisdiction
    if (userJurisdictionLevel == JurisdictionLevel.DISTRICT) {
        clearAndDisableFields(districtFilter);
    } else if (userJurisdictionLevel == JurisdictionLevel.COMMUNITY) {
        clearAndDisableFields(districtFilter, communityFilter);
    } else if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
        clearAndDisableFields(districtFilter, communityFilter);
    }
    ComboBox birthDateDD = getField(PersonCriteria.BIRTHDATE_DD);
    if (getField(PersonCriteria.BIRTHDATE_YYYY).getValue() != null && getField(PersonCriteria.BIRTHDATE_MM).getValue() != null) {
        birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(PersonCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(PersonCriteria.BIRTHDATE_YYYY).getValue()));
        birthDateDD.setEnabled(true);
    } else {
        birthDateDD.clear();
        birthDateDD.setEnabled(false);
    }
}
Also used : CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 32 with ComboBox

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

the class PersonFilterForm method applyDependenciesOnFieldChange.

@Override
protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueChangeEvent event) {
    super.applyDependenciesOnFieldChange(propertyId, event);
    final ComboBox districtFilter = getField(PersonCriteria.DISTRICT);
    final ComboBox communityFilter = getField(PersonCriteria.COMMUNITY);
    switch(propertyId) {
        case PersonCriteria.BIRTHDATE_MM:
            {
                Integer birthMM = (Integer) event.getProperty().getValue();
                ComboBox birthDayDD = getField(PersonCriteria.BIRTHDATE_DD);
                birthDayDD.setEnabled(birthMM != null);
                FieldHelper.updateItems(birthDayDD, DateHelper.getDaysInMonth((Integer) getField(PersonCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(PersonCriteria.BIRTHDATE_YYYY).getValue()));
                break;
            }
        case PersonCriteria.REGION:
            RegionReferenceDto region = (RegionReferenceDto) event.getProperty().getValue();
            if (region != null) {
                enableFields(districtFilter);
                districtFilter.removeAllItems();
                districtFilter.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
            } else {
                districtFilter.removeAllItems();
                districtFilter.clear();
            }
            clearAndDisableFields(communityFilter);
            break;
        case PersonCriteria.DISTRICT:
            DistrictReferenceDto district = (DistrictReferenceDto) event.getProperty().getValue();
            if (district != null) {
                enableFields(communityFilter);
                communityFilter.removeAllItems();
                communityFilter.addItems(FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
            } else {
                communityFilter.removeAllItems();
                communityFilter.clear();
            }
            break;
    }
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 33 with ComboBox

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

the class PersonFilterForm method addFields.

@Override
protected void addFields() {
    final ComboBox birthDateYYYY = addField(getContent(), PersonCriteria.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);
    final ComboBox birthDateMM = addField(getContent(), PersonCriteria.BIRTHDATE_MM, ComboBox.class);
    birthDateMM.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_MM));
    birthDateMM.setWidth(140, Unit.PIXELS);
    birthDateMM.addItems(DateHelper.getMonthsInYear());
    final ComboBox birthDateDD = addField(getContent(), PersonCriteria.BIRTHDATE_DD, ComboBox.class);
    birthDateDD.setInputPrompt(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE_DD));
    birthDateDD.setWidth(140, Unit.PIXELS);
    final TextField searchField = addField(FieldConfiguration.withCaptionAndPixelSized(PersonCriteria.NAME_ADDRESS_PHONE_EMAIL_LIKE, I18nProperties.getString(Strings.promptPersonsSearchField), 200));
    searchField.setNullRepresentation("");
    final ComboBox presentConditionField = addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.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(getContent(), FieldConfiguration.pixelSized(PersonCriteria.REGION, 140));
        regionField.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    }
    final ComboBox districtFilter = addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.DISTRICT, 140));
    districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
    addField(getContent(), FieldConfiguration.pixelSized(PersonCriteria.COMMUNITY, 140));
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) TextField(com.vaadin.v7.ui.TextField)

Example 34 with ComboBox

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

the class EventGroupsFilterForm method applyDistrictDependency.

@Override
protected void applyDistrictDependency(DistrictReferenceDto district, String communityFieldId) {
    final ComboBox communityField = getField(communityFieldId);
    if (district != null) {
        FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
        communityField.setEnabled(true);
    } else {
        communityField.setEnabled(false);
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Example 35 with ComboBox

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

the class EventParticipantEditForm method addFields.

@Override
protected void addFields() {
    if (event == null) {
        // workaround to stop initialization until event is set
        return;
    }
    if (searchPerson) {
        searchPersonButton = createPersonSearchButton(PERSON_SEARCH_LOC);
        searchPersonButton.setCaption(I18nProperties.getString(Strings.infoSearchPersonOnDependentForm));
        getContent().addComponent(searchPersonButton, PERSON_SEARCH_LOC);
    }
    pef = new PersonEditForm(PersonContext.EVENT_PARTICIPANT, event.getDisease(), event.getDiseaseDetails(), null, isPersonPseudonymized);
    pef.setWidth(100, Unit.PERCENTAGE);
    pef.setImmediate(true);
    getFieldGroup().bind(pef, EventParticipantDto.PERSON);
    getContent().addComponent(pef, EventParticipantDto.PERSON);
    addField(EventParticipantDto.INVOLVEMENT_DESCRIPTION, TextField.class);
    ComboBox region = addInfrastructureField(EventParticipantDto.REGION);
    region.setDescription(I18nProperties.getPrefixDescription(EventParticipantDto.I18N_PREFIX, EventParticipantDto.REGION));
    ComboBox district = addInfrastructureField(EventParticipantDto.DISTRICT);
    district.setDescription(I18nProperties.getPrefixDescription(EventParticipantDto.I18N_PREFIX, EventParticipantDto.DISTRICT));
    region.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    LocationDto locationDto = event.getEventLocation();
    boolean shouldBeRequired = locationDto.getRegion() == null || locationDto.getDistrict() == null;
    region.setRequired(shouldBeRequired);
    district.setRequired(shouldBeRequired);
    addField(EventParticipantDto.REPORTING_USER, ComboBox.class);
    setReadOnly(true, EventParticipantDto.REPORTING_USER);
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    addField(EventParticipantDto.VACCINATION_STATUS);
    addField(EventParticipantDto.DELETION_REASON);
    addField(EventParticipantDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, EventParticipantDto.DELETION_REASON, EventParticipantDto.OTHER_DELETION_REASON);
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) PersonEditForm(de.symeda.sormas.ui.person.PersonEditForm) LocationDto(de.symeda.sormas.api.location.LocationDto)

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