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

Commit 64e1a1b

Browse files
SORMAS-Foundation#4082 - Made button only visible for clusters
1 parent b22385f commit 64e1a1b

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventController.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.HashSet;
2323
import java.util.List;
2424
import java.util.Set;
25+
import java.util.function.Consumer;
2526

2627
import org.apache.commons.lang3.StringUtils;
2728

@@ -50,6 +51,7 @@
5051
import de.symeda.sormas.api.event.EventParticipantDto;
5152
import de.symeda.sormas.api.event.EventParticipantReferenceDto;
5253
import de.symeda.sormas.api.event.EventReferenceDto;
54+
import de.symeda.sormas.api.event.EventStatus;
5355
import de.symeda.sormas.api.i18n.Captions;
5456
import de.symeda.sormas.api.i18n.I18nProperties;
5557
import de.symeda.sormas.api.i18n.Strings;
@@ -269,15 +271,17 @@ public boolean linkCaseToEvent(EventReferenceDto eventReferenceDto, CaseDataDto
269271
final PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(caseDataDto.getPerson().getUuid());
270272
final EventParticipantDto eventParticipantDto =
271273
new EventParticipantDto().buildFromCase(caseRef, personDto, eventReferenceDto, UserProvider.getCurrent().getUserReference());
272-
ControllerProvider.getEventParticipantController().createEventParticipant(eventReferenceDto, r -> {}, eventParticipantDto);
274+
ControllerProvider.getEventParticipantController().createEventParticipant(eventReferenceDto, r -> {
275+
}, eventParticipantDto);
273276
return false;
274277
}
275278

276279
public void createEventParticipantWithContact(EventReferenceDto eventReferenceDto, ContactDto contact) {
277280
final PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(contact.getPerson().getUuid());
278281
final EventParticipantDto eventParticipantDto =
279282
new EventParticipantDto().buildFromPerson(personDto, eventReferenceDto, UserProvider.getCurrent().getUserReference());
280-
ControllerProvider.getEventParticipantController().createEventParticipant(eventReferenceDto, r -> {}, eventParticipantDto);
283+
ControllerProvider.getEventParticipantController().createEventParticipant(eventReferenceDto, r -> {
284+
}, eventParticipantDto);
281285
}
282286

283287
public void navigateToIndex() {
@@ -426,7 +430,7 @@ public CommitDiscardWrapperComponent<EventDataForm> getEventCreateComponent(
426430
return component;
427431
}
428432

429-
public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(final String eventUuid) {
433+
public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(final String eventUuid, Consumer<EventStatus> saveCallback) {
430434

431435
EventDto event = findEvent(eventUuid);
432436
EventDataForm eventEditForm = new EventDataForm(false, event.isPseudonymized());
@@ -442,6 +446,10 @@ public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(fi
442446
eventDto = FacadeProvider.getEventFacade().saveEvent(eventDto);
443447
Notification.show(I18nProperties.getString(Strings.messageEventSaved), Type.WARNING_MESSAGE);
444448
SormasUI.refreshView();
449+
450+
if (saveCallback != null) {
451+
saveCallback.accept(eventDto.getEventStatus());
452+
}
445453
}
446454
});
447455

sormas-ui/src/main/java/de/symeda/sormas/ui/events/EventDataView.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import de.symeda.sormas.api.contact.ContactCriteria;
2828
import de.symeda.sormas.api.document.DocumentRelatedEntityType;
2929
import de.symeda.sormas.api.event.EventDto;
30+
import de.symeda.sormas.api.event.EventStatus;
3031
import de.symeda.sormas.api.feature.FeatureType;
3132
import de.symeda.sormas.api.i18n.Captions;
3233
import de.symeda.sormas.api.i18n.I18nProperties;
@@ -62,6 +63,7 @@ public class EventDataView extends AbstractEventView {
6263
public static final String SUPERORDINATE_EVENT_LOC = "superordinate-event";
6364

6465
private CommitDiscardWrapperComponent<?> editComponent;
66+
private HorizontalLayout survNetLayout;
6567

6668
public EventDataView() {
6769
super(VIEW_NAME);
@@ -95,7 +97,10 @@ protected void initView(String params) {
9597
layout.setHeightUndefined();
9698
container.addComponent(layout);
9799

98-
editComponent = ControllerProvider.getEventController().getEventDataEditComponent(getEventRef().getUuid());
100+
survNetLayout = SurvnetGateway.addComponentToLayout(layout, SurvnetGatewayType.EVENTS, () -> Collections.singletonList(event.getUuid()));
101+
setSurvNetLayoutVisibility(event.getEventStatus());
102+
103+
editComponent = ControllerProvider.getEventController().getEventDataEditComponent(getEventRef().getUuid(), this::setSurvNetLayoutVisibility);
99104
editComponent.setMargin(false);
100105
editComponent.setWidth(100, Unit.PERCENTAGE);
101106
editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
@@ -149,10 +154,14 @@ protected void initView(String params) {
149154
shortcutLinksLayout.addComponent(seeEventContactsBtn);
150155
}
151156

152-
SurvnetGateway.addComponentToLayout(layout, SurvnetGatewayType.EVENTS, () -> Collections.singletonList(event.getUuid()));
153-
154157
layout.addComponent(shortcutLinksLayout, SHORTCUT_LINKS_LOC);
155158

156159
setEventEditPermission(container);
157160
}
161+
162+
private void setSurvNetLayoutVisibility(EventStatus eventStatus) {
163+
if (survNetLayout != null) {
164+
survNetLayout.setVisible(eventStatus == EventStatus.CLUSTER);
165+
}
166+
}
158167
}

sormas-ui/src/main/java/de/symeda/sormas/ui/survnet/SurvnetGateway.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ private SurvnetGateway() {
3333
//NOOP
3434
}
3535

36-
public static void addComponentToLayout(CustomLayout targetLayout, SurvnetGatewayType gatewayType, Supplier<List<String>> uuids) {
36+
public static HorizontalLayout addComponentToLayout(CustomLayout targetLayout, SurvnetGatewayType gatewayType, Supplier<List<String>> uuids) {
3737
if (!FacadeProvider.getSurvnetGatewayFacade().isFeatureEnabled()) {
38-
return;
38+
return null;
3939
}
4040

4141
Label header = new Label(I18nProperties.getCaption(Captions.SurvnetGateway_title));
@@ -55,6 +55,8 @@ public static void addComponentToLayout(CustomLayout targetLayout, SurvnetGatewa
5555

5656
layout.addStyleNames(CssStyles.SIDE_COMPONENT);
5757
targetLayout.addComponent(layout, SURVNET_GATEWAY_LOC);
58+
59+
return layout;
5860
}
5961

6062
public static void sendToSurvnet(SurvnetGatewayType gatewayType, List<String> uuids) {

0 commit comments

Comments
 (0)