Search in sources :

Example 1 with EventGroupSelectionField

use of de.symeda.sormas.ui.events.groups.EventGroupSelectionField in project SORMAS-Project by hzi-braunschweig.

the class EventGroupController method selectOrCreate.

public void selectOrCreate(List<EventReferenceDto> eventReferences, Runnable callback) {
    Set<String> excludedEventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(eventReferences).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
    EventGroupSelectionField selectionField = new EventGroupSelectionField(excludedEventGroupUuids);
    selectionField.setWidth(1024, Sizeable.Unit.PIXELS);
    final CommitDiscardWrapperComponent<EventGroupSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
    component.addCommitListener(() -> {
        EventGroupIndexDto selectedEventGroup = selectionField.getValue();
        if (selectedEventGroup != null) {
            FacadeProvider.getEventGroupFacade().linkEventsToGroup(eventReferences, selectedEventGroup.toReference());
            FacadeProvider.getEventGroupFacade().notifyEventAddedToEventGroup(selectedEventGroup.toReference(), eventReferences);
            Notification.show(I18nProperties.getString(Strings.messageEventLinkedToGroup), Type.TRAY_NOTIFICATION);
            if (callback != null) {
                callback.run();
            } else {
                SormasUI.refreshView();
            }
        } else {
            create(eventReferences, callback);
        }
    });
    selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
    VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEventGroup));
}
Also used : EventGroupSelectionField(de.symeda.sormas.ui.events.groups.EventGroupSelectionField) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventGroupIndexDto(de.symeda.sormas.api.event.EventGroupIndexDto)

Example 2 with EventGroupSelectionField

use of de.symeda.sormas.ui.events.groups.EventGroupSelectionField in project SORMAS-Project by hzi-braunschweig.

the class EventGroupController method select.

public void select(List<EventReferenceDto> eventReferences, Runnable callback) {
    Set<String> excludedEventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(eventReferences).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
    EventGroupSelectionField selectionField = new EventGroupSelectionField(excludedEventGroupUuids);
    selectionField.setWidth(1024, Sizeable.Unit.PIXELS);
    final CommitDiscardWrapperComponent<EventGroupSelectionField> component = new CommitDiscardWrapperComponent<>(selectionField);
    component.addCommitListener(() -> {
        EventGroupIndexDto selectedEventGroup = selectionField.getValue();
        if (selectedEventGroup != null) {
            FacadeProvider.getEventGroupFacade().linkEventsToGroup(eventReferences, selectedEventGroup.toReference());
            FacadeProvider.getEventGroupFacade().notifyEventAddedToEventGroup(selectedEventGroup.toReference(), eventReferences);
            Notification.show(I18nProperties.getString(Strings.messageEventLinkedToGroup), Type.TRAY_NOTIFICATION);
            if (callback != null) {
                callback.run();
            } else {
                SormasUI.refreshView();
            }
        }
    });
    selectionField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
    VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEventGroup));
}
Also used : EventGroupSelectionField(de.symeda.sormas.ui.events.groups.EventGroupSelectionField) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventGroupIndexDto(de.symeda.sormas.api.event.EventGroupIndexDto)

Aggregations

EventGroupIndexDto (de.symeda.sormas.api.event.EventGroupIndexDto)2 EventGroupSelectionField (de.symeda.sormas.ui.events.groups.EventGroupSelectionField)2 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)2