use of io.imunity.furms.ui.components.administrators.UserContextMenuFactory in project furms by unity-idm.
the class SitesAdminsView method init.
private void init(String siteId) {
InviteUserComponent inviteUser = new InviteUserComponent(userService::getAllUsers, () -> siteService.findAllAdministrators(siteId));
MembershipChangerComponent membershipLayout = new MembershipChangerComponent(getTranslation("view.fenix-admin.sites.button.join"), getTranslation("view.fenix-admin.sites.button.demit"), () -> siteService.isCurrentUserAdminOf(siteId));
membershipLayout.addJoinButtonListener(event -> {
siteService.addAdmin(siteId, currentUserId);
gridReload();
inviteUser.reload();
});
membershipLayout.addDemitButtonListener(event -> {
if (siteService.findAllAdministrators(siteId).size() > 1) {
handleExceptions(() -> siteService.removeSiteUser(siteId, currentUserId));
gridReload();
} else {
showErrorNotification(getTranslation("component.administrators.error.validation.remove"));
}
inviteUser.reload();
membershipLayout.loadAppropriateButton();
});
inviteUser.addInviteAction(event -> doInviteAction(siteId, inviteUser, membershipLayout));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).withRemoveUserAction(userId -> siteService.removeSiteUser(siteId, userId)).withPostRemoveUserAction(userId -> {
membershipLayout.loadAppropriateButton();
inviteUser.reload();
}).withRemoveInvitationAction(invitationId -> {
siteService.removeInvitation(siteId, invitationId);
gridReload();
}).withResendInvitationAction(invitationId -> {
siteService.resendInvitation(siteId, invitationId);
gridReload();
}).build();
UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
grid = UsersGridComponent.defaultInit(() -> siteService.findAllAdministrators(siteId), () -> siteService.findSiteAdminInvitations(siteId), userGrid);
Site site = handleExceptions(() -> siteService.findById(siteId)).flatMap(identity()).orElseThrow(IllegalStateException::new);
ViewHeaderLayout viewHeaderLayout = new ViewHeaderLayout(getTranslation("view.sites.administrators.title", site.getName()), membershipLayout);
getContent().add(viewHeaderLayout, inviteUser, grid);
}
use of io.imunity.furms.ui.components.administrators.UserContextMenuFactory in project furms by unity-idm.
the class CommunityView method loadPage1Content.
private void loadPage1Content(String communityId, String communityName) {
InviteUserComponent inviteUser = new InviteUserComponent(userService::getAllUsers, () -> communityService.findAllAdmins(communityId));
MembershipChangerComponent membershipLayout = new MembershipChangerComponent(getTranslation("view.fenix-admin.community.button.join"), getTranslation("view.fenix-admin.community.button.demit"), () -> communityService.isAdmin(communityId));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).withRemoveUserAction(userId -> communityService.removeAdmin(communityId, userId)).withPostRemoveUserAction(userId -> {
membershipLayout.loadAppropriateButton();
inviteUser.reload();
}).withRemoveInvitationAction(invitationId -> {
communityService.removeInvitation(communityId, invitationId);
gridReload();
}).withResendInvitationAction(invitationId -> {
communityService.resendInvitation(communityId, invitationId);
gridReload();
}).build();
UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
grid = UsersGridComponent.defaultInit(() -> communityService.findAllAdmins(communityId), () -> communityService.findAllInvitations(communityId), userGrid);
membershipLayout.addJoinButtonListener(event -> {
communityService.addAdmin(communityId, currentUserId);
gridReload();
inviteUser.reload();
});
membershipLayout.addDemitButtonListener(event -> {
if (communityService.findAllAdmins(communityId).size() > 1) {
handleExceptions(() -> communityService.removeAdmin(communityId, currentUserId));
gridReload();
} else {
showErrorNotification(getTranslation("component.administrators.error.validation.remove"));
}
inviteUser.reload();
membershipLayout.loadAppropriateButton();
});
ViewHeaderLayout headerLayout = new ViewHeaderLayout(getTranslation("view.fenix-admin.community.page.header", communityName), membershipLayout);
inviteUser.addInviteAction(event -> doInviteAction(communityId, inviteUser, membershipLayout));
page1.add(headerLayout, inviteUser, grid);
}
use of io.imunity.furms.ui.components.administrators.UserContextMenuFactory 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 io.imunity.furms.ui.components.administrators.UserContextMenuFactory in project furms by unity-idm.
the class ProjectView method loadPage1Content.
private void loadPage1Content(Project project) {
InviteUserComponent inviteUser = new InviteUserComponent(() -> communityService.findAllUsers(project.getCommunityId()), () -> projectService.findAllAdmins(project.getCommunityId(), project.getId()));
MembershipChangerComponent membershipLayout = new MembershipChangerComponent(getTranslation("view.community-admin.project.button.join"), getTranslation("view.community-admin.project.button.demit"), () -> projectService.isAdmin(project.getId()));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).redirectOnCurrentUserRemoval().withRemoveUserAction(userId -> projectService.removeAdmin(project.getCommunityId(), project.getId(), userId)).withRemoveInvitationAction(invitationId -> {
projectService.removeInvitation(project.getId(), invitationId);
gridReload();
}).withResendInvitationAction(invitationId -> {
projectService.resendInvitation(project.getId(), invitationId);
gridReload();
}).withPostRemoveUserAction(userId -> {
membershipLayout.loadAppropriateButton();
inviteUser.reload();
}).build();
UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
grid = UsersGridComponent.defaultInit(() -> projectService.findAllAdmins(project.getCommunityId(), project.getId()), () -> projectService.findAllAdminsInvitations(project.getId()), userGrid);
membershipLayout.addJoinButtonListener(event -> {
projectService.addAdmin(project.getCommunityId(), project.getId(), currentUserId);
gridReload();
inviteUser.reload();
});
membershipLayout.addDemitButtonListener(event -> {
if (projectService.findAllAdmins(project.getCommunityId(), project.getId()).size() > 1) {
handleExceptions(() -> projectService.removeAdmin(project.getCommunityId(), project.getId(), currentUserId));
gridReload();
} else {
showErrorNotification(getTranslation("component.administrators.error.validation.remove"));
}
inviteUser.reload();
membershipLayout.loadAppropriateButton();
});
ViewHeaderLayout headerLayout = new ViewHeaderLayout(getTranslation("view.community-admin.project.page.header", project.getName()), membershipLayout);
inviteUser.addInviteAction(event -> doInviteAction(project, inviteUser, membershipLayout));
page1.add(headerLayout, inviteUser, grid);
}
use of io.imunity.furms.ui.components.administrators.UserContextMenuFactory in project furms by unity-idm.
the class GroupMembersView method fillPage.
private void fillPage(String communityId, GenericGroupId groupId, String groupName) {
getContent().removeAll();
ViewHeaderLayout viewHeaderLayout = new ViewHeaderLayout(groupName + " " + getTranslation("view.community-admin.groups.members.half.header"));
Supplier<List<FURMSUser>> fetchCurrentUsersAction = () -> genericGroupService.findAll(communityId, groupId).stream().map(x -> x.furmsUser).collect(Collectors.toList());
AddGroupComponent addGroupComponent = new AddGroupComponent(() -> communityService.findAllUsers(communityId).stream().filter(user -> user.fenixUserId.isPresent()).collect(Collectors.toList()), fetchCurrentUsersAction);
addGroupComponent.addAddingAction(event -> doAddAction(addGroupComponent, groupId));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().addCustomContextMenuItem(UserGroupGridItem -> new MenuButton(getTranslation("view.community-admin.groups.members.menu.delete"), TRASH), (UserGroupGridItem userGridItem) -> {
genericGroupService.deleteMembership(communityId, groupId, userGridItem.getFenixUserId().get());
addGroupComponent.reload();
grid.reloadGrid();
showSuccessNotification(getTranslation("group.membership.successful.removed"));
}).build();
UserGrid.Builder userGrid = UserGrid.builder().withFullNameColumn().withEmailColumn().withCustomColumn((UserGroupGridItem x) -> x.getMemberSince().format(dateTimeFormatter), getTranslation("view.community-admin.groups.members.member.since")).withContextMenuColumn(userContextMenuFactory);
grid = UsersGridComponent.init(() -> genericGroupService.findAll(communityId, groupId).stream().map(groupAssignmentWithUser -> new UserGroupGridItem(groupAssignmentWithUser.furmsUser, convertToZoneTime(groupAssignmentWithUser.membership.utcMemberSince, browserZoneId))).collect(Collectors.toList()), userGrid);
getContent().add(viewHeaderLayout, addGroupComponent, grid);
}
Aggregations