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);
}
Aggregations