use of de.symeda.sormas.api.person.PersonContactDetailType in project SORMAS-Project by hzi-braunschweig.
the class PersonContactDetailEditForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
addField(PersonContactDetailDto.THIRD_PARTY, CheckBox.class).setCaption(I18nProperties.getCaption(Captions.personContactDetailThirdParty));
addField(PersonContactDetailDto.THIRD_PARTY_ROLE, TextField.class);
addField(PersonContactDetailDto.THIRD_PARTY_NAME, TextField.class);
addField(PersonContactDetailDto.PERSON_CONTACT_DETAILS_TYPE);
addField(PersonContactDetailDto.PHONE_NUMBER_TYPE);
addField(PersonContactDetailDto.DETAILS, TextField.class);
addField(PersonContactDetailDto.CONTACT_INFORMATION, TextField.class);
addField(PersonContactDetailDto.ADDITIONAL_INFORMATION, TextField.class);
addField(PersonContactDetailDto.PRIMARY_CONTACT, CheckBox.class);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(PersonContactDetailDto.THIRD_PARTY_ROLE, PersonContactDetailDto.THIRD_PARTY_NAME), PersonContactDetailDto.THIRD_PARTY, true, true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(PersonContactDetailDto.DETAILS), PersonContactDetailDto.PERSON_CONTACT_DETAILS_TYPE, PersonContactDetailType.OTHER, false);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(PersonContactDetailDto.DETAILS), PersonContactDetailDto.PHONE_NUMBER_TYPE, PhoneNumberType.OTHER, false);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(PersonContactDetailDto.PHONE_NUMBER_TYPE), PersonContactDetailDto.PERSON_CONTACT_DETAILS_TYPE, PersonContactDetailType.PHONE, false);
addFieldListeners(PersonContactDetailDto.PERSON_CONTACT_DETAILS_TYPE, e -> {
final Field<?> contactInformationField = getFieldGroup().getField(PersonContactDetailDto.CONTACT_INFORMATION);
final PersonContactDetailType value = (PersonContactDetailType) e.getProperty().getValue();
for (Validator validator : contactInformationField.getValidators()) {
contactInformationField.removeValidator(validator);
}
if (value == PersonContactDetailType.PHONE) {
contactInformationField.addValidator(new PhoneNumberValidator(I18nProperties.getValidationError(Validations.validPhoneNumber, contactInformationField.getCaption())));
} else if (value == PersonContactDetailType.EMAIL) {
contactInformationField.addValidator(new EmailValidator(I18nProperties.getValidationError(Validations.validEmailAddress, contactInformationField.getCaption())));
}
});
}
Aggregations