Search in sources :

Example 1 with PAPERPLANE

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

Aggregations

CHECK_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE)1 PAPERPLANE (com.vaadin.flow.component.icon.VaadinIcon.PAPERPLANE)1 BeforeEvent (com.vaadin.flow.router.BeforeEvent)1 OptionalParameter (com.vaadin.flow.router.OptionalParameter)1 Route (com.vaadin.flow.router.Route)1 PolicyDocumentService (io.imunity.furms.api.policy_documents.PolicyDocumentService)1 PolicyAcceptance (io.imunity.furms.domain.policy_documents.PolicyAcceptance)1 PolicyAcceptanceStatus (io.imunity.furms.domain.policy_documents.PolicyAcceptanceStatus)1 PolicyDocument (io.imunity.furms.domain.policy_documents.PolicyDocument)1 PolicyId (io.imunity.furms.domain.policy_documents.PolicyId)1 PolicyWorkflow (io.imunity.furms.domain.policy_documents.PolicyWorkflow)1 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)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 UserContextMenuFactory (io.imunity.furms.ui.components.administrators.UserContextMenuFactory)1 UserGrid (io.imunity.furms.ui.components.administrators.UserGrid)1 UsersGridComponent (io.imunity.furms.ui.components.administrators.UsersGridComponent)1 BreadCrumbParameter (io.imunity.furms.ui.components.layout.BreadCrumbParameter)1 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)1