Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit e0acea4

Browse files
SORMAS-Foundation#2943 small cleanup
1 parent 73ee640 commit e0acea4

2 files changed

Lines changed: 36 additions & 52 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
import de.symeda.sormas.ui.UserProvider;
7979
import de.symeda.sormas.ui.utils.AbstractEditForm;
8080
import de.symeda.sormas.ui.utils.ButtonHelper;
81-
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.DoneListener;
8281
import de.symeda.sormas.ui.utils.ConfirmationComponent;
8382
import de.symeda.sormas.ui.utils.CssStyles;
8483
import de.symeda.sormas.ui.utils.FieldHelper;
@@ -277,9 +276,8 @@ protected void addFields() {
277276
style(epidField, ERROR_COLOR_PRIMARY);
278277

279278
// Button to automatically assign a new epid number
280-
Button assignNewEpidNumberButton = ButtonHelper.createButton(Captions.actionAssignNewEpidNumber, e -> {
281-
epidField.setValue(FacadeProvider.getCaseFacade().generateEpidNumber(getValue().toReference()));
282-
}, ValoTheme.BUTTON_DANGER, FORCE_CAPTION);
279+
Button assignNewEpidNumberButton = ButtonHelper.createButton(Captions.actionAssignNewEpidNumber,
280+
e -> epidField.setValue(FacadeProvider.getCaseFacade().generateEpidNumber(getValue().toReference())), ValoTheme.BUTTON_DANGER, FORCE_CAPTION);
283281

284282
getContent().addComponent(assignNewEpidNumberButton, ASSIGN_NEW_EPID_NUMBER_LOC);
285283
assignNewEpidNumberButton.setVisible(false);
@@ -291,7 +289,7 @@ protected void addFields() {
291289
addField(CaseDataDto.INVESTIGATION_STATUS, OptionGroup.class);
292290
addField(CaseDataDto.OUTCOME, OptionGroup.class);
293291
addField(CaseDataDto.SEQUELAE, OptionGroup.class);
294-
if (isConfiguredServer("de")) {
292+
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
295293
addField(CaseDataDto.REPORTING_TYPE);
296294
}
297295
addFields(CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.SEQUELAE_DETAILS);
@@ -309,7 +307,7 @@ protected void addFields() {
309307
quarantineFrom = addField(CaseDataDto.QUARANTINE_FROM, DateField.class);
310308
quarantineTo = addDateField(CaseDataDto.QUARANTINE_TO, DateField.class, -1);
311309

312-
if (isConfiguredServer("de")) {
310+
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
313311
final ComboBox cbCaseClassification = addField(CaseDataDto.CASE_CLASSIFICATION, ComboBox.class);
314312
cbCaseClassification.addValidator(
315313
new GermanCaseClassificationValidator(caseUuid, I18nProperties.getValidationError(Validations.caseClassificationInvalid)));
@@ -455,13 +453,12 @@ protected void addFields() {
455453
(FacilityType) facilityType.getValue(),
456454
facility);
457455
});
458-
community.addValueChangeListener(e -> {
459-
updateFacility(
460-
(DistrictReferenceDto) district.getValue(),
461-
(CommunityReferenceDto) community.getValue(),
462-
(FacilityType) facilityType.getValue(),
463-
facility);
464-
});
456+
community.addValueChangeListener(e -> updateFacility(
457+
(DistrictReferenceDto) district.getValue(),
458+
(CommunityReferenceDto) community.getValue(),
459+
(FacilityType) facilityType.getValue(),
460+
facility)
461+
);
465462
facilityOrHome.addValueChangeListener(e -> {
466463
FieldHelper.removeItems(facility);
467464
if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue())) {
@@ -495,19 +492,16 @@ protected void addFields() {
495492
}
496493
}
497494
});
498-
facilityTypeGroup.addValueChangeListener(e -> {
499-
FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
500-
});
501-
facilityType.addValueChangeListener(e -> {
502-
updateFacility(
503-
(DistrictReferenceDto) district.getValue(),
504-
(CommunityReferenceDto) community.getValue(),
505-
(FacilityType) facilityType.getValue(),
506-
facility);
507-
});
508-
facility.addValueChangeListener(e -> {
509-
updateFacilityDetails(facility, facilityDetails);
510-
});
495+
facilityTypeGroup.addValueChangeListener(e ->
496+
FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()))
497+
);
498+
facilityType.addValueChangeListener(e -> updateFacility(
499+
(DistrictReferenceDto) district.getValue(),
500+
(CommunityReferenceDto) community.getValue(),
501+
(FacilityType) facilityType.getValue(),
502+
facility)
503+
);
504+
facility.addValueChangeListener(e -> updateFacilityDetails(facility, facilityDetails));
511505
region.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
512506

513507
if (!FacadeProvider.getFeatureConfigurationFacade().isFeatureDisabled(FeatureType.NATIONAL_CASE_SHARING)) {
@@ -578,12 +572,10 @@ protected void addFields() {
578572
CaseDataDto.VACCINATION_DATE);
579573

580574
// Set initial visibilities & accesses
581-
582575
initializeVisibilitiesAndAllowedVisibilities();
583576
initializeAccessAndAllowedAccesses();
584577

585578
// Set requirements that don't need visibility changes and read only status
586-
587579
setRequired(
588580
true,
589581
CaseDataDto.REPORT_DATE,
@@ -640,7 +632,6 @@ protected void addFields() {
640632

641633
// Set conditional visibilities - ALWAYS call isVisibleAllowed before
642634
// dynamically setting the visibility
643-
644635
if (isVisibleAllowed(CaseDataDto.PREGNANT)) {
645636
setVisible(person.getSex() == Sex.FEMALE, CaseDataDto.PREGNANT, CaseDataDto.POSTPARTUM);
646637
}
@@ -769,7 +760,6 @@ protected void addFields() {
769760
}
770761

771762
// Other initializations
772-
773763
if (disease == Disease.MONKEYPOX) {
774764
Image smallpoxVaccinationScarImg = new Image(null, new ThemeResource("img/smallpox-vaccination-scar.jpg"));
775765
style(smallpoxVaccinationScarImg, VSPACE_3);
@@ -780,9 +770,9 @@ protected void addFields() {
780770
.setVisible(getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).getValue() == YesNoUnknown.YES);
781771

782772
// Set up image visibility listener
783-
getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).addValueChangeListener(e -> {
784-
getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(e.getProperty().getValue() == YesNoUnknown.YES);
785-
});
773+
getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).addValueChangeListener(e ->
774+
getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(e.getProperty().getValue() == YesNoUnknown.YES)
775+
);
786776
}
787777

788778
List<String> medicalInformationFields =
@@ -804,9 +794,8 @@ protected void addFields() {
804794
// Automatic case classification rules button - invisible for other diseases
805795
DiseaseClassificationCriteriaDto diseaseClassificationCriteria = FacadeProvider.getCaseClassificationFacade().getByDisease(disease);
806796
if (disease != Disease.OTHER && diseaseClassificationCriteria != null) {
807-
Button classificationRulesButton = ButtonHelper.createIconButton(Captions.info, VaadinIcons.INFO_CIRCLE, e -> {
808-
ControllerProvider.getCaseController().openClassificationRulesPopup(diseaseClassificationCriteria);
809-
}, ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
797+
Button classificationRulesButton = ButtonHelper.createIconButton(Captions.info, VaadinIcons.INFO_CIRCLE, e ->
798+
ControllerProvider.getCaseController().openClassificationRulesPopup(diseaseClassificationCriteria), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
810799

811800
getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC);
812801
}
@@ -888,7 +877,7 @@ protected void addFields() {
888877
setVisible(false, CaseDataDto.CASE_ORIGIN);
889878
}
890879

891-
if (isConfiguredServer("de")) {
880+
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
892881
setVisible(false, CaseDataDto.EPID_NUMBER);
893882
} else {
894883
setVisible(false, CaseDataDto.EXTERNAL_ID);
@@ -1096,7 +1085,7 @@ public void setValue(CaseDataDto newFieldValue) throws ReadOnlyException, Conver
10961085
super.setValue(newFieldValue);
10971086

10981087
// HACK: Binding to the fields will call field listeners that may clear/modify the values of other fields.
1099-
// this hopefully resets everything to it's correct value
1088+
// this hopefully resets everything to its correct value
11001089
discard();
11011090
}
11021091

@@ -1158,7 +1147,7 @@ protected String createHtmlLayout() {
11581147
}
11591148

11601149
private void setEpidNumberError(TextField epidField, Button assignNewEpidNumberButton, Label epidNumberWarningLabel, String fieldValue) {
1161-
if (!isConfiguredServer("de")
1150+
if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)
11621151
&& FacadeProvider.getCaseFacade().doesEpidNumberExist(fieldValue, getValue().getUuid(), getValue().getDisease())) {
11631152
epidField.setComponentError(new UserError(I18nProperties.getValidationError(Validations.duplicateEpidNumber)));
11641153
assignNewEpidNumberButton.setVisible(true);
@@ -1167,7 +1156,7 @@ private void setEpidNumberError(TextField epidField, Button assignNewEpidNumberB
11671156
epidField.setComponentError(null);
11681157
getContent().removeComponent(epidNumberWarningLabel);
11691158
assignNewEpidNumberButton
1170-
.setVisible(!isConfiguredServer("de") && !CaseLogic.isEpidNumberPrefix(fieldValue) && !CaseLogic.isCompleteEpidNumber(fieldValue));
1159+
.setVisible(!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) && !CaseLogic.isEpidNumberPrefix(fieldValue) && !CaseLogic.isCompleteEpidNumber(fieldValue));
11711160
}
11721161
}
11731162

@@ -1208,12 +1197,9 @@ protected void onCancel() {
12081197
Window popupWindow = VaadinUiUtil.showPopupWindow(confirmDiseaseChangeComponent);
12091198
CloseListener closeListener = ce -> diseaseField.setValue(currentDisease);
12101199
popupWindow.addCloseListener(closeListener);
1211-
confirmDiseaseChangeComponent.addDoneListener(new DoneListener() {
1212-
1213-
public void onDone() {
1214-
popupWindow.removeCloseListener(closeListener);
1215-
popupWindow.close();
1216-
}
1200+
confirmDiseaseChangeComponent.addDoneListener(() -> {
1201+
popupWindow.removeCloseListener(closeListener);
1202+
popupWindow.close();
12171203
});
12181204
popupWindow.setCaption(I18nProperties.getString(Strings.headingChangeCaseDisease));
12191205
}

sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactDataForm.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ protected void addFields() {
195195
tracingAppDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
196196
// tracingApp.setVisible(false);
197197
// tracingAppDetails.setVisible(false);
198-
if (isConfiguredServer("de")) {
198+
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
199199
FieldHelper.setVisibleWhen(
200200
getFieldGroup(),
201201
ContactDto.CONTACT_IDENTIFICATION_SOURCE_DETAILS,
@@ -213,7 +213,7 @@ protected void addFields() {
213213
}
214214
contactProximity = addField(ContactDto.CONTACT_PROXIMITY, OptionGroup.class);
215215
contactProximity.removeStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
216-
if (isConfiguredServer("de")) {
216+
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
217217
addField(ContactDto.CONTACT_PROXIMITY_DETAILS, TextField.class);
218218
contactCategory = addField(ContactDto.CONTACT_CATEGORY, OptionGroup.class);
219219

@@ -371,9 +371,7 @@ protected void addFields() {
371371
addField(ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE_DETAILS, TextField.class);
372372
OptionGroup ogCareForPeopleOver60 = addField(ContactDto.CARE_FOR_PEOPLE_OVER_60, OptionGroup.class);
373373

374-
cbDisease.addValueChangeListener(e -> {
375-
updateDiseaseConfiguration((Disease) e.getProperty().getValue());
376-
});
374+
cbDisease.addValueChangeListener(e -> updateDiseaseConfiguration((Disease) e.getProperty().getValue()));
377375

378376
HealthConditionsForm clinicalCourseForm = addField(ContactDto.HEALTH_CONDITIONS, HealthConditionsForm.class);
379377
clinicalCourseForm.setCaption(null);
@@ -469,7 +467,7 @@ protected void addFields() {
469467
}
470468
}
471469

472-
if (!isConfiguredServer("de")) {
470+
if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
473471
setVisible(
474472
false,
475473
ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE,

0 commit comments

Comments
 (0)