Search in sources :

Example 1 with CHECK_CIRCLE

use of com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE in project furms by unity-idm.

the class PolicyDocumentAcceptanceView method fillPage.

private void fillPage() {
    getContent().removeAll();
    ViewHeaderLayout viewHeaderLayout = new ViewHeaderLayout(policyDocument.name + " " + getTranslation("view.site-admin.policy-documents-acceptance.half.header"));
    UserContextMenuFactory.Builder builder = UserContextMenuFactory.builder();
    if (policyDocument.workflow.equals(PolicyWorkflow.PAPER_BASED)) {
        builder.addCustomContextMenuItem(x -> new MenuButton(getTranslation("view.site-admin.policy-documents-acceptance.menu.accept"), CHECK_CIRCLE), (PolicyUserGridItem userGridItem) -> {
            PolicyAcceptance policyAcceptance = createPolicyAcceptance();
            policyDocumentService.addUserPolicyAcceptance(policyDocument.siteId, userGridItem.getFenixUserId().get(), policyAcceptance);
            grid.reloadGrid();
        }, policyUserGridItem -> !policyUserGridItem.isAccepted());
    }
    builder.addCustomContextMenuItem(x -> new MenuButton(getTranslation("view.site-admin.policy-documents-acceptance.menu.resend"), PAPERPLANE), (PolicyUserGridItem userGridItem) -> {
        policyDocumentService.resendPolicyInfo(policyDocument.siteId, userGridItem.getId().get(), policyDocument.id);
        grid.reloadGrid();
    }, policyUserGridItem -> !policyUserGridItem.isAccepted());
    UserContextMenuFactory userContextMenuFactory = builder.build();
    UserGrid.Builder userGrid = UserGrid.builder().withFullNameColumn().withEmailColumn().withCustomColumn((PolicyUserGridItem x) -> {
        if (x.isAccepted())
            return getTranslation("view.site-admin.policy-documents-acceptance.status.accepted");
        else if (x.getRevision() != 0)
            return getTranslation("view.site-admin.policy-documents-acceptance.status.accepted.old", x.getRevision());
        else
            return getTranslation("view.site-admin.policy-documents-acceptance.status.not.accepted");
    }, getTranslation("view.site-admin.policy-documents-acceptance.status")).withContextMenuColumn(userContextMenuFactory);
    grid = UsersGridComponent.init(() -> policyDocumentService.findAllUsersPolicyAcceptances(policyDocument.id, policyDocument.siteId).stream().filter(userPolicyAcceptances -> userPolicyAcceptances.user.fenixUserId.isPresent()).map(userPolicyAcceptances -> new PolicyUserGridItem(userPolicyAcceptances.user, userPolicyAcceptances.policyAcceptances.stream().filter(y -> y.policyDocumentId.equals(policyDocument.id)).mapToInt(y -> y.policyDocumentRevision).max().orElse(0), policyDocument.revision)).collect(Collectors.toList()), userGrid);
    getContent().add(viewHeaderLayout, grid);
}
Also used : PolicyId(io.imunity.furms.domain.policy_documents.PolicyId) PAPERPLANE(com.vaadin.flow.component.icon.VaadinIcon.PAPERPLANE) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) UserContextMenuFactory(io.imunity.furms.ui.components.administrators.UserContextMenuFactory) ZonedDateTime(java.time.ZonedDateTime) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Route(com.vaadin.flow.router.Route) UserGrid(io.imunity.furms.ui.components.administrators.UserGrid) PolicyAcceptanceStatus(io.imunity.furms.domain.policy_documents.PolicyAcceptanceStatus) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) PolicyWorkflow(io.imunity.furms.domain.policy_documents.PolicyWorkflow) ZoneOffset(java.time.ZoneOffset) UsersGridComponent(io.imunity.furms.ui.components.administrators.UsersGridComponent) SiteAdminMenu(io.imunity.furms.ui.views.site.SiteAdminMenu) PolicyDocument(io.imunity.furms.domain.policy_documents.PolicyDocument) Collectors(java.util.stream.Collectors) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ZoneId(java.time.ZoneId) OptionalParameter(com.vaadin.flow.router.OptionalParameter) UTCTimeUtils.convertToUTCTime(io.imunity.furms.utils.UTCTimeUtils.convertToUTCTime) PolicyAcceptance(io.imunity.furms.domain.policy_documents.PolicyAcceptance) Optional(java.util.Optional) CHECK_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE) PolicyDocumentService(io.imunity.furms.api.policy_documents.PolicyDocumentService) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) PolicyAcceptance(io.imunity.furms.domain.policy_documents.PolicyAcceptance) UserGrid(io.imunity.furms.ui.components.administrators.UserGrid) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) MenuButton(io.imunity.furms.ui.components.MenuButton) UserContextMenuFactory(io.imunity.furms.ui.components.administrators.UserContextMenuFactory)

Example 2 with CHECK_CIRCLE

use of com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE in project furms by unity-idm.

the class UsersView method loadPageContent.

private void loadPageContent() {
    String projectId = getCurrentResourceId();
    project = projectService.findById(projectId).orElseThrow(() -> new IllegalStateException("Project not found: " + getCurrentResourceId()));
    currentUserId = authzService.getCurrentUserId();
    InviteUserComponent inviteUser = new InviteUserComponent(() -> projectService.findAllAdmins(project.getCommunityId(), project.getId()).stream().filter(IS_ELIGIBLE_FOR_PROJECT_MEMBERSHIP).collect(Collectors.toList()), () -> projectService.findAllUsers(project.getCommunityId(), project.getId()));
    membershipLayout = new MembershipChangerComponent(getTranslation("view.project-admin.users.button.join"), getTranslation("view.project-admin.users.button.demit"), () -> projectService.isUser(project.getId()));
    userService.findById(currentUserId).ifPresent(user -> membershipLayout.setEnabled(IS_ELIGIBLE_FOR_PROJECT_MEMBERSHIP.test(user)));
    UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).allowRemovalOfLastUser().withConfirmRemovalMessageKey("view.project-admin.users.remove.confirm").withConfirmSelfRemovalMessageKey("view.project-admin.users.remove.yourself.confirm").withRemoveInvitationAction(invitationId -> {
        projectService.removeInvitation(projectId, invitationId);
        gridReload();
    }).withResendInvitationAction(invitationId -> {
        projectService.resendInvitation(projectId, invitationId);
        gridReload();
    }).withRemoveUserAction(userId -> {
        try {
            projectService.removeUser(project.getCommunityId(), project.getId(), userId);
        } catch (UserInstallationOnSiteIsNotTerminalException e) {
            showErrorNotification(getTranslation("user.currently.de-installing"));
        }
    }).withPostRemoveUserAction(userId -> {
        membershipLayout.loadAppropriateButton();
        inviteUser.reload();
    }).addCustomContextMenuItem((UserGridItem userGridItem) -> new MenuButton(getTranslation("view.project-admin.users.requested.accept"), CHECK_CIRCLE), userGridItem -> {
        try {
            projectApplicationsService.accept(projectId, userGridItem.getFenixUserId().get());
            showSuccessNotification(getTranslation("view.project-admin.users.application.accept"));
        } catch (ApplicationNotExistingException e) {
            showErrorNotification(getTranslation("application.already.not.existing"));
        }
        grid.reloadGrid();
    }, userGridItem -> UserUIStatus.ACCESS_REQUESTED.equals(userGridItem.getStatus())).addCustomContextMenuItem((UserGridItem userGridItem) -> new MenuButton(getTranslation("view.project-admin.users.requested.reject"), CLOSE_CIRCLE), userGridItem -> {
        try {
            projectApplicationsService.remove(projectId, userGridItem.getFenixUserId().get());
            showSuccessNotification(getTranslation("view.project-admin.users.application.reject"));
        } catch (ApplicationNotExistingException e) {
            showErrorNotification(getTranslation("application.already.not.existing"));
        }
        grid.reloadGrid();
    }, userGridItem -> UserUIStatus.ACCESS_REQUESTED.equals(userGridItem.getStatus())).build();
    UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
    grid = UsersGridComponent.defaultInit(() -> projectService.findAllUsers(project.getCommunityId(), project.getId()), () -> projectService.findAllUsersInvitations(projectId), () -> projectApplicationsService.findAllApplyingUsers(projectId), userGrid);
    membershipLayout.addJoinButtonListener(event -> {
        projectService.addUser(project.getCommunityId(), project.getId(), currentUserId);
        grid.reloadGrid();
        inviteUser.reload();
    });
    membershipLayout.addDemitButtonListener(event -> {
        projectService.removeUser(project.getCommunityId(), project.getId(), currentUserId);
        grid.reloadGrid();
        inviteUser.reload();
        membershipLayout.loadAppropriateButton();
    });
    inviteUser.addInviteAction(event -> doInviteAction(inviteUser, projectId));
    ViewHeaderLayout headerLayout = new ViewHeaderLayout(getTranslation("view.project-admin.users.header", project.getName()), membershipLayout);
    getContent().add(headerLayout, inviteUser, grid);
}
Also used : Project(io.imunity.furms.domain.projects.Project) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) UserContextMenuFactory(io.imunity.furms.ui.components.administrators.UserContextMenuFactory) LoggerFactory(org.slf4j.LoggerFactory) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) MembershipChangerComponent(io.imunity.furms.ui.components.MembershipChangerComponent) DuplicatedInvitationError(io.imunity.furms.api.validation.exceptions.DuplicatedInvitationError) UserAlreadyAppliedForMembershipException(io.imunity.furms.api.validation.exceptions.UserAlreadyAppliedForMembershipException) UserGrid(io.imunity.furms.ui.components.administrators.UserGrid) UserUIStatus(io.imunity.furms.ui.components.administrators.UserUIStatus) UserService(io.imunity.furms.api.users.UserService) PROJECT_BASE_LANDING_PAGE(io.imunity.furms.domain.constant.RoutesConst.PROJECT_BASE_LANDING_PAGE) UsersGridComponent(io.imunity.furms.ui.components.administrators.UsersGridComponent) ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) PersistentId(io.imunity.furms.domain.users.PersistentId) Logger(org.slf4j.Logger) ApplicationNotExistingException(io.imunity.furms.api.validation.exceptions.ApplicationNotExistingException) Predicate(java.util.function.Predicate) MethodHandles(java.lang.invoke.MethodHandles) ProjectApplicationsService(io.imunity.furms.api.applications.ProjectApplicationsService) FURMSUser(io.imunity.furms.domain.users.FURMSUser) Collectors(java.util.stream.Collectors) UserAlreadyHasRoleError(io.imunity.furms.api.validation.exceptions.UserAlreadyHasRoleError) AuthzService(io.imunity.furms.api.authz.AuthzService) AfterNavigationEvent(com.vaadin.flow.router.AfterNavigationEvent) InviteUserComponent(io.imunity.furms.ui.components.InviteUserComponent) UserInstallationOnSiteIsNotTerminalException(io.imunity.furms.api.validation.exceptions.UserInstallationOnSiteIsNotTerminalException) ProjectService(io.imunity.furms.api.projects.ProjectService) CLOSE_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE) CHECK_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE) UserGridItem(io.imunity.furms.ui.components.administrators.UserGridItem) FurmsLandingViewComponent(io.imunity.furms.ui.components.FurmsLandingViewComponent) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) NotificationUtils.showSuccessNotification(io.imunity.furms.ui.utils.NotificationUtils.showSuccessNotification) UserGrid(io.imunity.furms.ui.components.administrators.UserGrid) ApplicationNotExistingException(io.imunity.furms.api.validation.exceptions.ApplicationNotExistingException) MembershipChangerComponent(io.imunity.furms.ui.components.MembershipChangerComponent) MenuButton(io.imunity.furms.ui.components.MenuButton) UserInstallationOnSiteIsNotTerminalException(io.imunity.furms.api.validation.exceptions.UserInstallationOnSiteIsNotTerminalException) UserContextMenuFactory(io.imunity.furms.ui.components.administrators.UserContextMenuFactory) UserGridItem(io.imunity.furms.ui.components.administrators.UserGridItem) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) InviteUserComponent(io.imunity.furms.ui.components.InviteUserComponent)

Example 3 with CHECK_CIRCLE

use of com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE 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

CHECK_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE)3 Route (com.vaadin.flow.router.Route)3 MenuButton (io.imunity.furms.ui.components.MenuButton)3 PageTitle (io.imunity.furms.ui.components.PageTitle)3 ViewHeaderLayout (io.imunity.furms.ui.components.ViewHeaderLayout)3 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)3 Collectors (java.util.stream.Collectors)3 CLOSE_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE)2 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)2 MethodHandles (java.lang.invoke.MethodHandles)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 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 PAPERPLANE (com.vaadin.flow.component.icon.VaadinIcon.PAPERPLANE)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1