Skip to content

Commit 59fe672

Browse files
authored
Merge pull request #13371 from SORMAS-Foundation/change-13364-changes_ui_for_notified_by
#13364 - Fixes the UI for the "Notified by" field in case notifier si…
2 parents 557428c + 911bf1e commit 59fe672

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/notifier/CaseNotifierSideViewComponent.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
package de.symeda.sormas.ui.caze.notifier;
1717

1818
import com.vaadin.icons.VaadinIcons;
19+
import com.vaadin.server.Sizeable.Unit;
1920
import com.vaadin.ui.Button;
2021
import com.vaadin.ui.Label;
2122
import com.vaadin.ui.themes.ValoTheme;
2223

24+
import de.symeda.sormas.api.FacadeProvider;
2325
import de.symeda.sormas.api.caze.CaseDataDto;
2426
import de.symeda.sormas.api.i18n.Captions;
2527
import de.symeda.sormas.api.i18n.I18nProperties;
@@ -49,12 +51,22 @@ public CaseNotifierSideViewComponent(CaseDataDto caze) {
4951
setSpacing(false);
5052

5153
if (caze.getNotifier() != null) {
52-
var component = ControllerProvider.getCaseNotifierSideViewController().getNotifierComponent(caze);
54+
final var component = ControllerProvider.getCaseNotifierSideViewController().getNotifierComponent(caze);
5355
addComponent(component);
54-
Button notficationButton = ButtonHelper.createIconButton(Captions.Notifier_notification, VaadinIcons.BOOK, e -> {
56+
57+
Button notificationButton = ButtonHelper.createIconButton(Captions.Notifier_notification, VaadinIcons.BOOK, e -> {
58+
final var oldestReport = ControllerProvider.getCaseNotifierSideViewController().getOldestReport(caze);
59+
if (oldestReport == null) {
60+
return;
61+
}
62+
final var externalMessage = FacadeProvider.getExternalMessageFacade().getForSurveillanceReport(oldestReport.toReference());
63+
if (externalMessage == null) {
64+
return;
65+
}
66+
ControllerProvider.getExternalMessageController().showExternalMessage(externalMessage.getUuid(), false, null);
5567
}, ValoTheme.BUTTON_PRIMARY);
5668

57-
addCreateButton(notficationButton);
69+
addCreateButton(notificationButton);
5870
} else {
5971
addComponent(new Label(I18nProperties.getCaption(Captions.Notification_noNotification)));
6072
}

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/notifier/CaseNotifierSideViewContent.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,31 @@ private void buildNotifierDetails() {
114114
// Full name
115115
Label fullNameLabel = new Label(notifier.getFirstName() + " " + notifier.getLastName());
116116
CssStyles.style(fullNameLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
117+
addComponent(fullNameLabel);
117118

118119
// Registration number
119120
Label registrationNumberLabel = new Label(notifier.getRegistrationNumber());
120121
CssStyles.style(registrationNumberLabel, CssStyles.LABEL_BOLD);
122+
addComponent(registrationNumberLabel);
121123

122-
// Spacer before phone label
123-
Label spacerBeforePhone = new Label();
124-
spacerBeforePhone.setHeight("0.05rem");
124+
// Spacer before contact label
125+
if ((notifier.getPhone() != null && !notifier.getPhone().isEmpty()) || (notifier.getEmail() != null && !notifier.getEmail().isEmpty())) {
126+
Label spacerBeforeContact = new Label();
127+
spacerBeforeContact.setHeight("0.1rem");
128+
addComponent(spacerBeforeContact);
129+
}
125130

126131
// Phone
127-
Label phoneLabel = new Label(notifier.getPhone());
132+
if (notifier.getPhone() != null && !notifier.getPhone().isEmpty()) {
133+
Label phoneLabel = new Label(notifier.getPhone());
134+
addComponent(phoneLabel);
135+
}
128136

129137
// Email
130-
Label emailLabel = new Label(notifier.getEmail());
138+
if (notifier.getEmail() != null && !notifier.getEmail().isEmpty()) {
139+
Label emailLabel = new Label(notifier.getEmail());
140+
addComponent(emailLabel);
141+
}
131142

132143
// Spacer before email label
133144
Label spacerDates = new Label();
@@ -147,22 +158,10 @@ private void buildNotifierDetails() {
147158
HorizontalLayout dateFieldsLayout = new HorizontalLayout(notificationDateField, diagnosticDateField);
148159
dateFieldsLayout.setSpacing(true);
149160
dateFieldsLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
150-
151-
// Spacer before treatment group
152-
Label spacerBeforeTreatment = new Label();
153-
spacerBeforeTreatment.setHeight("0.05rem");
154-
155-
RadioButtonGroup<TreatmentOption> treatmentGroup = buildTreatmentOptions();
156-
157-
// Add components to the layout
158-
addComponent(fullNameLabel);
159-
addComponent(registrationNumberLabel);
160-
addComponent(spacerBeforePhone);
161-
addComponent(phoneLabel);
162-
addComponent(emailLabel);
163161
addComponent(spacerDates);
164162
addComponent(dateFieldsLayout);
165-
addComponent(spacerBeforeTreatment);
163+
164+
RadioButtonGroup<TreatmentOption> treatmentGroup = buildTreatmentOptions();
166165
addComponent(treatmentGroup);
167166

168167
}

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/notifier/CaseNotifierSideViewController.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,39 @@ public class CaseNotifierSideViewController {
4040
/**
4141
* Retrieves the notifier component for a given case.
4242
*
43-
* @param caze The case data for which the notifier component is to be retrieved.
43+
* @param caze
44+
* The case data for which the notifier component is to be retrieved.
4445
* @return A {@link CaseNotifierSideViewContent} object containing the notifier, oldest report, and treatment details.
4546
*/
4647
public CaseNotifierSideViewContent getNotifierComponent(CaseDataDto caze) {
4748

4849
NotifierDto notifier =
4950
FacadeProvider.getNotifierFacade().getByUuidAndTime(caze.getNotifier().getUuid(), caze.getNotifier().getVersionDate().toInstant());
5051

52+
return new CaseNotifierSideViewContent(caze, notifier, getOldestReport(caze), getTreatment(caze.getTherapy()), true);
53+
}
54+
55+
/**
56+
* Retrieves the oldest surveillance report for a given case.
57+
*
58+
* @param caze
59+
* The case
60+
* @return The oldest {@link SurveillanceReportDto} for the case, or null if no reports are found.
61+
*/
62+
public SurveillanceReportDto getOldestReport(CaseDataDto caze) {
5163
CaseReferenceDto cazeRef = new CaseReferenceDto();
5264
cazeRef.setUuid(caze.getUuid());
53-
54-
return new CaseNotifierSideViewContent(caze, notifier, getOldestReport(cazeRef), getTreatment(caze.getTherapy()), true);
65+
return getOldestReport(cazeRef);
5566
}
5667

5768
/**
5869
* Retrieves the oldest surveillance report for a given case reference.
5970
*
60-
* @param caze The reference to the case for which the oldest report is to be retrieved.
71+
* @param caze
72+
* The reference to the case for which the oldest report is to be retrieved.
6173
* @return The oldest {@link SurveillanceReportDto} for the case, or null if no reports are found.
6274
*/
63-
protected SurveillanceReportDto getOldestReport(CaseReferenceDto caze) {
75+
public SurveillanceReportDto getOldestReport(CaseReferenceDto caze) {
6476

6577
SurveillanceReportCriteria criteria = new SurveillanceReportCriteria();
6678
criteria.caze(caze);
@@ -77,7 +89,8 @@ protected SurveillanceReportDto getOldestReport(CaseReferenceDto caze) {
7789
/**
7890
* Retrieves the treatment details for a given therapy.
7991
*
80-
* @param therapy The therapy for which the treatment details are to be retrieved.
92+
* @param therapy
93+
* The therapy for which the treatment details are to be retrieved.
8194
* @return A {@link TreatmentDto} object containing the treatment details, or null if no treatment is found.
8295
*/
8396
protected TreatmentDto getTreatment(TherapyDto therapy) {

0 commit comments

Comments
 (0)