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);
}
}
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;
}
}
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));
}
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);
}
}
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);
}
Aggregations