Skip to content

Commit

Permalink
Merge pull request #12789 from SORMAS-Foundation/fature-12463-fix-iss…
Browse files Browse the repository at this point in the history
…ues-found-by-qa

#12463 Allow users to send mails to case, contact, event participant …
  • Loading branch information
sergiupacurariu authored Nov 29, 2023
2 parents 3759224 + 9a5b918 commit f9d7f03
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion sormas-api/src/main/resources/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ messageRestoreNotPossibleAlreadyInEvent = Event participant can't be restored be
messageDuplicateEnvironmentFound = A similar environment already exists in the database (UUID: %s)
messageCasePersonHasNoEmail=Case person has no email address specified
messageContactPersonHasNoEmail=Contact person has no email address specified
messageEventParticipantPersonHasNoEmail=Event participantperson has no email address specified
messageEventParticipantPersonHasNoEmail=Event participant person has no email address specified
messageTravelEntryPersonHasNoEmail=Travel entry person has no email address specified
# Notifications
notificationCaseClassificationChanged = The classification of case %s has changed to %s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ protected void initView(String params) {
caze.toReference(),
caze.getPerson(),
Strings.messageCasePersonHasNoEmail,
isEditAllowed,
this::showUnsavedChangesPopup);
layout.addSidePanelComponent(new SideComponentLayout(externalEmailSideComponent), EXTERNAL_EMAILS_LOC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ protected void initView(String params) {
}

final String uuid = contactDto.getUuid();
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_REASSIGN_CASE) && isEditAllowed()) {
boolean editAllowed = isEditAllowed();
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_REASSIGN_CASE) && editAllowed) {
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setSpacing(true);

Expand Down Expand Up @@ -208,7 +209,7 @@ protected void initView(String params) {
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT)
&& UserProvider.getCurrent().hasUserRight(UserRight.TASK_VIEW)) {
TaskListComponent taskList =
new TaskListComponent(TaskContext.CONTACT, getContactRef(), contactDto.getDisease(), this::showUnsavedChangesPopup, isEditAllowed());
new TaskListComponent(TaskContext.CONTACT, getContactRef(), contactDto.getDisease(), this::showUnsavedChangesPopup, editAllowed);
taskList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addSidePanelComponent(taskList, TASKS_LOC);
}
Expand All @@ -217,7 +218,7 @@ protected void initView(String params) {
SampleListComponent sampleList = new SampleListComponent(
new SampleCriteria().contact(getContactRef()).disease(contactDto.getDisease()).sampleAssociationType(SampleAssociationType.CONTACT),
this::showUnsavedChangesPopup,
isEditAllowed());
editAllowed);
SampleListComponentLayout sampleListComponentLayout =
new SampleListComponentLayout(sampleList, I18nProperties.getString(Strings.infoCreateNewSampleDiscardsChangesContact));
layout.addSidePanelComponent(sampleListComponentLayout, SAMPLES_LOC);
Expand All @@ -229,7 +230,7 @@ protected void initView(String params) {
eventsLayout.setMargin(false);
eventsLayout.setSpacing(false);

EventListComponent eventList = new EventListComponent(getContactRef(), this::showUnsavedChangesPopup, isEditAllowed());
EventListComponent eventList = new EventListComponent(getContactRef(), this::showUnsavedChangesPopup, editAllowed);
eventList.addStyleName(CssStyles.SIDE_COMPONENT);
eventsLayout.addComponent(eventList);

Expand All @@ -243,7 +244,7 @@ protected void initView(String params) {
layout.addSidePanelComponent(new SideComponentLayout(new ImmunizationListComponent(() -> {
ContactDto refreshedContact = FacadeProvider.getContactFacade().getByUuid(getContactRef().getUuid());
return new ImmunizationListCriteria.Builder(refreshedContact.getPerson()).withDisease(refreshedContact.getDisease()).build();
}, null, this::showUnsavedChangesPopup, isEditAllowed())), IMMUNIZATION_LOC);
}, null, this::showUnsavedChangesPopup, editAllowed)), IMMUNIZATION_LOC);
} else {
layout.addSidePanelComponent(new SideComponentLayout(new VaccinationListComponent(() -> {
ContactDto refreshedContact = FacadeProvider.getContactFacade().getByUuid(getContactRef().getUuid());
Expand All @@ -257,7 +258,7 @@ protected void initView(String params) {
.contactReference(getContactRef())
.region(refreshedContact.getRegion() != null ? refreshedContact.getRegion() : refreshedCase.getResponsibleRegion())
.district(refreshedContact.getDistrict() != null ? refreshedContact.getDistrict() : refreshedCase.getResponsibleDistrict());
}, null, this::showUnsavedChangesPopup, isEditAllowed())), VACCINATIONS_LOC);
}, null, this::showUnsavedChangesPopup, editAllowed)), VACCINATIONS_LOC);
}
}

Expand All @@ -268,7 +269,7 @@ protected void initView(String params) {
sormasToSormasLocLayout.setMargin(false);
sormasToSormasLocLayout.setSpacing(false);

SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(contactDto, isEditAllowed());
SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(contactDto, editAllowed);
sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);

Expand All @@ -286,7 +287,7 @@ protected void initView(String params) {
getContactRef(),
UserRight.CONTACT_EDIT,
contactDto.isPseudonymized(),
isEditAllowed(),
editAllowed,
isDocumentDeleteAllowed);
layout.addSidePanelComponent(new SideComponentLayout(documentList), DOCUMENTS_LOC);
}
Expand All @@ -300,6 +301,7 @@ protected void initView(String params) {
contactDto.toReference(),
contactDto.getPerson(),
Strings.messageContactPersonHasNoEmail,
editAllowed,
this::showUnsavedChangesPopup);
layout.addSidePanelComponent(new SideComponentLayout(externalEmailSideComponent), EXTERNAL_EMAILS_LOC);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.ui.email;

import org.apache.commons.lang3.StringUtils;

import com.vaadin.server.Sizeable;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Window;
Expand Down Expand Up @@ -48,7 +47,11 @@ public void sendEmail(
ExternalEmailOptionsForm optionsForm = new ExternalEmailOptionsForm(documentWorkflow, person);

ExternalEmailOptionsDto defaultValue = new ExternalEmailOptionsDto(documentWorkflow, rootEntityType, rootEntityReference);
defaultValue.setRecipientEmail(person.getEmailAddress(true));
String presonPrimaryEmail = person.getEmailAddress(true);
if (StringUtils.isNotBlank(presonPrimaryEmail)) {
defaultValue.setRecipientEmail(presonPrimaryEmail);
}

optionsForm.setValue(defaultValue);

CommitDiscardWrapperComponent<ExternalEmailOptionsForm> optionsCommitDiscard =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.ui.email;
Expand All @@ -22,6 +19,8 @@

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.vaadin.v7.ui.ComboBox;

import de.symeda.sormas.api.FacadeProvider;
Expand All @@ -48,6 +47,7 @@ protected ExternalEmailOptionsForm(DocumentWorkflow documentWorkflow, PersonDto
this.person = person;

addFields();
hideValidationUntilNextCommit();
}

@Override
Expand All @@ -67,6 +67,9 @@ protected void addFields() {
List<String> recipientEmails = person.getAllEmailAddresses();
FieldHelper.updateItems(recipientEmailCombo, recipientEmails);
String primaryEmailAddress = person.getEmailAddress(true);
recipientEmailCombo.setItemCaption(primaryEmailAddress, primaryEmailAddress + " (" + I18nProperties.getCaption(Captions.primarySuffix) + ")");
if (StringUtils.isNotBlank(primaryEmailAddress)) {
recipientEmailCombo
.setItemCaption(primaryEmailAddress, primaryEmailAddress + " (" + I18nProperties.getCaption(Captions.primarySuffix) + ")");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2023 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.ui.email;
Expand All @@ -38,19 +35,23 @@
import de.symeda.sormas.ui.utils.components.sidecomponent.SideComponent;

public class ExternalEmailSideComponent extends SideComponent {

public ExternalEmailSideComponent(
DocumentWorkflow documentWorkflow,
RootEntityType rootEntityType,
ReferenceDto rootEntityReference,
PersonReferenceDto personRef,
String noRecipientStringKey,
boolean isEditAllowed,
Consumer<Runnable> actionCallback) {
super(I18nProperties.getCaption(Captions.messagesEmails), actionCallback);

addCreateButton(
I18nProperties.getCaption(Captions.messagesSendEmail),
() -> ControllerProvider.getExternalEmailController().sendEmail(documentWorkflow, rootEntityType, rootEntityReference, personRef),
UserRight.EXTERNAL_EMAIL_SEND);
if (isEditAllowed) {
addCreateButton(
I18nProperties.getCaption(Captions.messagesSendEmail),
() -> ControllerProvider.getExternalEmailController().sendEmail(documentWorkflow, rootEntityType, rootEntityReference, personRef),
UserRight.EXTERNAL_EMAIL_SEND);
}

PersonDto person = FacadeProvider.getPersonFacade().getByUuid(personRef.getUuid());
if (CollectionUtils.isEmpty(person.getAllEmailAddresses())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ protected void initView(String params) {
eventParticipantRef,
eventParticipant.getPerson().toReference(),
Strings.messageEventParticipantPersonHasNoEmail,
editAllowed,
this::showUnsavedChangesPopup);
layout.addSidePanelComponent(new SideComponentLayout(externalEmailSideComponent), EXTERNAL_EMAILS_LOC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ protected void initView(String params) {
travelEntryDto.toReference(),
travelEntryDto.getPerson(),
Strings.messageTravelEntryPersonHasNoEmail,
editAllowed,
this::showUnsavedChangesPopup);
layout.addSidePanelComponent(new SideComponentLayout(externalEmailSideComponent), EXTERNAL_EMAILS_LOC);
}
Expand Down

0 comments on commit f9d7f03

Please sign in to comment.