use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class TaskEditForm method updateByTaskContext.
private void updateByTaskContext() {
TaskContext taskContext = (TaskContext) getFieldGroup().getField(TaskDto.TASK_CONTEXT).getValue();
// Task types depending on task context
ComboBox taskType = (ComboBox) getFieldGroup().getField(TaskDto.TASK_TYPE);
FieldHelper.updateItems(taskType, TaskType.getTaskTypes(taskContext), FieldVisibilityCheckers.withDisease(disease), TaskType.class);
// context reference depending on task context
ComboBox caseField = (ComboBox) getFieldGroup().getField(TaskDto.CAZE);
ComboBox eventField = (ComboBox) getFieldGroup().getField(TaskDto.EVENT);
ComboBox contactField = (ComboBox) getFieldGroup().getField(TaskDto.CONTACT);
if (taskContext != null) {
switch(taskContext) {
case CASE:
FieldHelper.setFirstVisibleClearOthers(caseField, eventField, contactField);
FieldHelper.setFirstRequired(caseField, eventField, contactField);
break;
case EVENT:
FieldHelper.setFirstVisibleClearOthers(eventField, caseField, contactField);
FieldHelper.setFirstRequired(eventField, caseField, contactField);
break;
case CONTACT:
FieldHelper.setFirstVisibleClearOthers(contactField, caseField, eventField);
FieldHelper.setFirstRequired(contactField, caseField, eventField);
break;
case GENERAL:
FieldHelper.setFirstVisibleClearOthers(null, caseField, contactField, eventField);
FieldHelper.setFirstRequired(null, caseField, contactField, eventField);
break;
}
} else {
FieldHelper.setFirstVisibleClearOthers(null, caseField, eventField, contactField);
FieldHelper.setFirstRequired(null, caseField, eventField, contactField);
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class UserEditForm method updateFieldsByUserRole.
@SuppressWarnings("unchecked")
private void updateFieldsByUserRole() {
final Field userRolesField = getFieldGroup().getField(UserDto.USER_ROLES);
final Set<UserRole> userRoles = (Set<UserRole>) userRolesField.getValue();
final JurisdictionLevel jurisdictionLevel = UserRole.getJurisdictionLevel(userRoles);
final boolean hasAssociatedOfficer = UserRole.hasAssociatedOfficer(userRoles);
final boolean hasOptionalHealthFacility = UserRole.hasOptionalHealthFacility(userRoles);
final boolean isPortHealthUser = UserRole.isPortHealthUser(userRoles);
final boolean usePointOfEntry = (isPortHealthUser && hasAssociatedOfficer) || jurisdictionLevel == JurisdictionLevel.POINT_OF_ENTRY;
final boolean useHealthFacility = jurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY;
final boolean useLaboratory = jurisdictionLevel == JurisdictionLevel.LABORATORY;
final boolean useCommunity = jurisdictionLevel == JurisdictionLevel.COMMUNITY;
final boolean useDistrict = hasAssociatedOfficer || jurisdictionLevel == JurisdictionLevel.DISTRICT || useCommunity || useHealthFacility || usePointOfEntry;
;
final boolean useRegion = jurisdictionLevel == JurisdictionLevel.REGION || useDistrict;
final ComboBox associatedOfficer = (ComboBox) getFieldGroup().getField(UserDto.ASSOCIATED_OFFICER);
associatedOfficer.setVisible(hasAssociatedOfficer);
setRequired(hasAssociatedOfficer && !isPortHealthUser, UserDto.ASSOCIATED_OFFICER);
if (!hasAssociatedOfficer) {
associatedOfficer.clear();
}
final ComboBox community = (ComboBox) getFieldGroup().getField(UserDto.COMMUNITY);
community.setVisible(useCommunity);
setRequired(useCommunity, UserDto.COMMUNITY);
if (!useCommunity) {
community.clear();
}
final ComboBox healthFacility = (ComboBox) getFieldGroup().getField(UserDto.HEALTH_FACILITY);
healthFacility.setVisible(hasOptionalHealthFacility || useHealthFacility);
setRequired(useHealthFacility, UserDto.HEALTH_FACILITY);
if (!healthFacility.isVisible()) {
healthFacility.clear();
}
final ComboBox laboratory = (ComboBox) getFieldGroup().getField(UserDto.LABORATORY);
laboratory.setVisible(useLaboratory);
setRequired(useLaboratory, UserDto.LABORATORY);
if (!useLaboratory) {
laboratory.clear();
}
final ComboBox pointOfEntry = (ComboBox) getFieldGroup().getField(UserDto.POINT_OF_ENTRY);
pointOfEntry.setVisible(usePointOfEntry);
setRequired(usePointOfEntry, UserDto.POINT_OF_ENTRY);
if (!usePointOfEntry) {
pointOfEntry.clear();
}
final ComboBox district = (ComboBox) getFieldGroup().getField(UserDto.DISTRICT);
district.setVisible(useDistrict);
setRequired(useDistrict, UserDto.DISTRICT);
if (!useDistrict) {
district.clear();
}
final ComboBox region = (ComboBox) getFieldGroup().getField(UserDto.REGION);
region.setVisible(useRegion);
setRequired(useRegion, UserDto.REGION);
if (!useRegion) {
region.clear();
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class UserEditForm method addFields.
@Override
protected void addFields() {
Label personDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingPersonData));
personDataHeadingLabel.addStyleName(H3);
getContent().addComponent(personDataHeadingLabel, PERSON_DATA_HEADING_LOC);
Label addressHeadingLabel = new Label(I18nProperties.getString(Strings.address));
addressHeadingLabel.addStyleName(H3);
getContent().addComponent(addressHeadingLabel, ADDRESS_HEADING_LOC);
Label userDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingUserData));
userDataHeadingLabel.addStyleName(H3);
getContent().addComponent(userDataHeadingLabel, USER_DATA_HEADING_LOC);
addField(UserDto.FIRST_NAME, TextField.class);
addField(UserDto.LAST_NAME, TextField.class);
addField(UserDto.USER_EMAIL, TextField.class);
TextField phone = addField(UserDto.PHONE, TextField.class);
phone.addValidator(new UserPhoneNumberValidator(I18nProperties.getValidationError(Validations.phoneNumberValidation)));
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AGGREGATE_REPORTING) || FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_SURVEILLANCE) || FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.WEEKLY_REPORTING) || FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.CASE_SURVEILANCE)) {
addDiseaseField(UserDto.LIMITED_DISEASE, false);
}
Label userEmailDesc = new Label(I18nProperties.getString(Strings.infoUserEmail));
getContent().addComponent(userEmailDesc, USER_EMAIL_DESC_LOC);
Label userPhoneDesc = new Label(I18nProperties.getString(Strings.infoUserPhoneNumber));
getContent().addComponent(userPhoneDesc, USER_PHONE_DESC_LOC);
ComboBox cbLanguage = addField(UserDto.LANGUAGE, ComboBox.class);
CssStyles.style(cbLanguage, CssStyles.COMBO_BOX_WITH_FLAG_ICON);
ControllerProvider.getUserController().setFlagIcons(cbLanguage);
addField(UserDto.ADDRESS, LocationEditForm.class).setCaption(null);
addField(UserDto.ACTIVE, CheckBox.class);
addField(UserDto.USER_NAME, TextField.class);
addField(UserDto.USER_ROLES, OptionGroup.class).addValidator(new UserRolesValidator());
OptionGroup userRoles = (OptionGroup) getFieldGroup().getField(UserDto.USER_ROLES);
userRoles.setMultiSelect(true);
ComboBox region = addInfrastructureField(UserDto.REGION);
ComboBox community = addInfrastructureField(UserDto.COMMUNITY);
ComboBox district = addInfrastructureField(UserDto.DISTRICT);
region.addValueChangeListener(e -> {
FieldHelper.removeItems(community);
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
// for informant
ComboBox associatedOfficer = addField(UserDto.ASSOCIATED_OFFICER, ComboBox.class);
ComboBox healthFacility = addInfrastructureField(UserDto.HEALTH_FACILITY);
ComboBox cbPointOfEntry = addInfrastructureField(UserDto.POINT_OF_ENTRY);
district.addValueChangeListener(e -> {
FieldHelper.removeItems(healthFacility);
FieldHelper.removeItems(associatedOfficer);
FieldHelper.removeItems(cbPointOfEntry);
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(community, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
FieldHelper.updateItems(healthFacility, districtDto != null ? FacadeProvider.getFacilityFacade().getActiveHospitalsByDistrict(districtDto, false) : null);
FieldHelper.updateItems(associatedOfficer, districtDto != null ? FacadeProvider.getUserFacade().getUserRefsByDistrict(districtDto, null, UserRight.CASE_RESPONSIBLE, UserRight.WEEKLYREPORT_CREATE) : null);
FieldHelper.updateItems(cbPointOfEntry, districtDto != null ? FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(districtDto.getUuid(), false) : null);
});
ComboBox laboratory = addInfrastructureField(UserDto.LABORATORY);
laboratory.addItems(FacadeProvider.getFacilityFacade().getAllActiveLaboratories(false));
region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
setRequired(true, UserDto.FIRST_NAME, UserDto.LAST_NAME, UserDto.USER_NAME, UserDto.USER_ROLES);
addValidators(UserDto.USER_NAME, new UserNameValidator());
addFieldListeners(UserDto.FIRST_NAME, e -> suggestUserName());
addFieldListeners(UserDto.LAST_NAME, e -> suggestUserName());
addFieldListeners(UserDto.USER_ROLES, e -> updateFieldsByUserRole());
updateFieldsByUserRole();
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class UserSettingsForm method addFields.
@Override
protected void addFields() {
ComboBox cbLanguage = addField(UserDto.LANGUAGE, ComboBox.class);
CssStyles.style(cbLanguage, CssStyles.COMBO_BOX_WITH_FLAG_ICON);
ControllerProvider.getUserController().setFlagIcons(cbLanguage);
String authenticationProvider = FacadeProvider.getConfigFacade().getAuthenticationProvider();
if (AuthProvider.KEYCLOAK.equals(authenticationProvider)) {
emailTf = addField(UserDto.USER_EMAIL, TextField.class);
emailTf.setCaption(I18nProperties.getCaption(Captions.User_userEmail));
emailTf.addValidator(new EmailValidator(I18nProperties.getValidationError(Validations.validEmailAddress, emailTf.getCaption())));
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class AbstractEditForm method addNonPrimaryDiseasesTo.
@SuppressWarnings("unchecked")
protected void addNonPrimaryDiseasesTo(ComboBox diseaseField) {
List<Disease> diseases = FacadeProvider.getDiseaseConfigurationFacade().getAllDiseases(true, false, true);
for (Disease disease : diseases) {
if (diseaseField.getItem(disease) != null) {
continue;
}
Item newItem = diseaseField.addItem(disease);
newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(disease.toString());
}
}
Aggregations