use of de.catma.user.Member in project catma by forTEXT.
the class ResourcePermissionView method initData.
private void initData(TreeData<Resource> resourceData, Collection<TagsetDefinition> tagsets) {
try {
permissionGrid.removeAllColumns();
permissionGrid.addColumn(resource -> resource.getIcon(), new HtmlRenderer()).setWidth(70);
permissionGrid.addColumn(resource -> resource.getName()).setWidth(250).setCaption("Resource");
TreeData<Resource> items = new TreeData<Resource>();
for (Resource documentResource : resourceData.getRootItems()) {
Set<Member> documentMembers = project.getResourceMembers(documentResource.getResourceId());
documentMembers.forEach(member -> permissionMatrix.put(documentResource, member, member.getRole()));
items.addItem(null, documentResource);
Collection<Resource> collectionResources = resourceData.getChildren(documentResource);
for (Resource collectionResource : collectionResources) {
Set<Member> collectionMembers = project.getResourceMembers(collectionResource.getResourceId());
collectionMembers.forEach(member -> permissionMatrix.put(collectionResource, member, member.getRole()));
items.addItem(documentResource, collectionResource);
}
}
for (TagsetDefinition tagset : tagsets) {
Set<Member> tagsetMembers = project.getResourceMembers(tagset.getUuid());
TagsetResource tagsetResource = new TagsetResource(tagset, project.getProjectId());
tagsetMembers.forEach(member -> permissionMatrix.put(tagsetResource, member, member.getRole()));
items.addItem(null, tagsetResource);
}
for (Member member : permissionMatrix.columnKeySet()) {
Column<Resource, String> memberColumn = permissionGrid.addColumn(resource -> {
RBACRole role = permissionMatrix.get(resource, member);
return role == null ? "" : role.getRoleName();
}).setWidth(120).setCaption(member.getName()).setDescriptionGenerator(resource -> member.preciseName());
// only reporter and lower can be upgraded for specific resources
if (member.getRole().getAccessLevel() <= RBACRole.REPORTER.getAccessLevel()) {
memberColumn.setEditorBinding(createRoleEditor(member));
} else {
memberColumn.setHidable(true);
memberColumn.setHidden(true);
}
}
permissionDataProvider = new TreeDataProvider<>(items);
permissionGrid.setDataProvider(permissionDataProvider);
permissionGrid.expand(resourceData.getRootItems());
} catch (IOException e) {
errorHandler.showAndLogError("Failed to fetch permissions", e);
}
}
use of de.catma.user.Member in project catma by forTEXT.
the class ProjectView method initTeamContent.
private Component initTeamContent() {
HorizontalFlexLayout teamContent = new HorizontalFlexLayout();
teamGrid = new Grid<>();
teamGrid.setHeaderVisible(false);
// $NON-NLS-1$
teamGrid.setWidth("402px");
teamGrid.addColumn((user) -> VaadinIcons.USER.getHtml(), new HtmlRenderer());
teamGrid.addColumn(User::getName).setWidth(200).setComparator((r1, r2) -> String.CASE_INSENSITIVE_ORDER.compare(r1.getName(), r2.getName())).setDescriptionGenerator(User::preciseName);
teamGrid.addColumn(Member::getRole).setExpandRatio(1);
Label membersAnnotations = new Label("Members");
ActionGridComponent<Grid<Member>> membersGridComponent = new ActionGridComponent<>(membersAnnotations, teamGrid);
// $NON-NLS-1$
membersGridComponent.addStyleName("project-view-action-grid");
ContextMenu addContextMenu = membersGridComponent.getActionGridBar().getBtnAddContextMenu();
addContextMenu.addItem("Add Member", (click) -> new AddMemberDialog(project::assignOnProject, // $NON-NLS-1$
(query) -> project.findUser(query.getFilter().isPresent() ? query.getFilter().get() : "", query.getOffset(), query.getLimit()), (evt) -> eventBus.post(new MembersChangedEvent())).show());
ContextMenu moreOptionsContextMenu = membersGridComponent.getActionGridBar().getBtnMoreOptionsContextMenu();
moreOptionsContextMenu.addItem("Edit Members", (click) -> handleEditMembers());
moreOptionsContextMenu.addItem("Remove Members", (click) -> handleRemoveMembers());
miInvite = moreOptionsContextMenu.addItem("Invite someone to the Project", click -> handleProjectInvitationRequest());
MenuItem editResBtn = moreOptionsContextMenu.addItem("Resource permissions", click -> {
@SuppressWarnings("unchecked") TreeDataProvider<Resource> resourceDataProvider = (TreeDataProvider<Resource>) documentGrid.getDataProvider();
TreeData<Resource> resourceData = resourceDataProvider.getTreeData();
if (!resourceData.getRootItems().isEmpty()) {
new ResourcePermissionView(resourceData, tagsetData.getItems(), this.project).show();
} else {
Notification.show("Info", "You do not have any Documents yet, please add a Document first!", Type.HUMANIZED_MESSAGE);
}
});
editResBtn.setEnabled(false);
rbacEnforcer.register(RBACConstraint.ifAuthorized(role -> (project.hasPermission(role, RBACPermission.PROJECT_MEMBERS_EDIT)), () -> editResBtn.setEnabled(true)));
teamContent.addComponent(membersGridComponent);
return teamContent;
}
use of de.catma.user.Member in project catma by forTEXT.
the class ProjectView method handleRemoveMembers.
private void handleRemoveMembers() {
if (teamGrid.getSelectedItems().isEmpty()) {
Notification.show("Info", "Please select one or more members first!", Type.HUMANIZED_MESSAGE);
} else {
if (teamGrid.getSelectedItems().stream().map(User::getUserId).filter(id -> id.equals(project.getUser().getUserId())).findFirst().isPresent()) {
HTMLNotification.show("Info", "You cannot remove yourself from the Project. " + "Please use the 'Leave Project' button on the Project card on the Dashboard instead!" + "<br><br> If your are the owner of the Project, " + "please contact the Administrator to request an transfer of ownership.", Type.ERROR_MESSAGE);
}
Set<Member> members = teamGrid.getSelectedItems().stream().filter(member -> !member.getUserId().equals(project.getUser().getUserId())).collect(Collectors.toSet());
members.remove(project.getUser());
if (!members.isEmpty()) {
new RemoveMemberDialog(project::unassignFromProject, teamGrid.getSelectedItems(), evt -> eventBus.post(new MembersChangedEvent())).show();
}
}
}
Aggregations