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