use of de.catma.ui.events.MembersChangedEvent in project catma by forTEXT.
the class ProjectInvitationDialog method close.
@Override
public void close() {
super.close();
eventBus.post(new MembersChangedEvent());
}
use of de.catma.ui.events.MembersChangedEvent 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.ui.events.MembersChangedEvent 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