Search in sources :

Example 1 with InviteeService

use of io.imunity.furms.api.invitations.InviteeService in project furms by unity-idm.

the class InvitationsView method createMainContextMenu.

private Component createMainContextMenu(InviteeService inviteeService, Map<InvitationId, Checkbox> checkboxes) {
    GridActionMenu contextMenu = new GridActionMenu();
    contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.confirm"), CHECK_CIRCLE), event -> {
        try {
            checkboxes.entrySet().stream().filter(x -> x.getValue().getValue()).forEach(x -> inviteeService.acceptBy(x.getKey()));
        } catch (InvitationNotExistingException e) {
            showErrorNotification(getTranslation("invitation.already.removed"));
        } catch (Exception e) {
            LOG.warn("Could not accept Invitations. ", e);
            showErrorNotification(getTranslation("base.error.message"));
        }
        loadGrid();
    });
    contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.reject"), CLOSE_CIRCLE), event -> {
        if (checkboxes.entrySet().stream().anyMatch(x -> x.getValue().getValue()))
            createMainConfirmDialog(checkboxes).open();
    });
    return contextMenu.getTarget();
}
Also used : UTCTimeUtils.convertToZoneTime(io.imunity.furms.utils.UTCTimeUtils.convertToZoneTime) Component(com.vaadin.flow.component.Component) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) LoggerFactory(org.slf4j.LoggerFactory) Label(com.vaadin.flow.component.html.Label) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) HashMap(java.util.HashMap) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) DenseGrid(io.imunity.furms.ui.components.DenseGrid) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Map(java.util.Map) UserSettingsMenu(io.imunity.furms.ui.views.user_settings.UserSettingsMenu) Grid(com.vaadin.flow.component.grid.Grid) UIContext(io.imunity.furms.ui.user_context.UIContext) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) Set(java.util.Set) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) DateTimeFormatter(java.time.format.DateTimeFormatter) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Optional(java.util.Optional) CLOSE_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE) CHECK_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE) Dialog(com.vaadin.flow.component.dialog.Dialog) InviteeService(io.imunity.furms.api.invitations.InviteeService) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) MenuButton(io.imunity.furms.ui.components.MenuButton) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException)

Aggregations

Component (com.vaadin.flow.component.Component)1 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1 Dialog (com.vaadin.flow.component.dialog.Dialog)1 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)1 Grid (com.vaadin.flow.component.grid.Grid)1 Label (com.vaadin.flow.component.html.Label)1 CHECK_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE)1 CLOSE_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 Route (com.vaadin.flow.router.Route)1 InviteeService (io.imunity.furms.api.invitations.InviteeService)1 InvitationNotExistingException (io.imunity.furms.api.validation.exceptions.InvitationNotExistingException)1 InvitationId (io.imunity.furms.domain.invitations.InvitationId)1 DenseGrid (io.imunity.furms.ui.components.DenseGrid)1 FurmsDialog (io.imunity.furms.ui.components.FurmsDialog)1 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)1 GridActionMenu (io.imunity.furms.ui.components.GridActionMenu)1 MenuButton (io.imunity.furms.ui.components.MenuButton)1 PageTitle (io.imunity.furms.ui.components.PageTitle)1 ViewHeaderLayout (io.imunity.furms.ui.components.ViewHeaderLayout)1