Search in sources :

Example 1 with TRASH

use of com.vaadin.flow.component.icon.VaadinIcon.TRASH 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);
}
Also used : ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) UTCTimeUtils.convertToZoneTime(io.imunity.furms.utils.UTCTimeUtils.convertToZoneTime) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) UserContextMenuFactory(io.imunity.furms.ui.components.administrators.UserContextMenuFactory) LoggerFactory(org.slf4j.LoggerFactory) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) Supplier(java.util.function.Supplier) Route(com.vaadin.flow.router.Route) UserGrid(io.imunity.furms.ui.components.administrators.UserGrid) GenericGroupService(io.imunity.furms.api.generic_groups.GenericGroupService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) UserNotPresentException(io.imunity.furms.api.validation.exceptions.UserNotPresentException) CommunityAdminMenu(io.imunity.furms.ui.views.community.CommunityAdminMenu) UsersGridComponent(io.imunity.furms.ui.components.administrators.UsersGridComponent) UIContext(io.imunity.furms.ui.user_context.UIContext) Logger(org.slf4j.Logger) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) MethodHandles(java.lang.invoke.MethodHandles) FURMSUser(io.imunity.furms.domain.users.FURMSUser) UserAlreadyIsInGroupError(io.imunity.furms.api.validation.exceptions.UserAlreadyIsInGroupError) Collectors(java.util.stream.Collectors) GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ZoneId(java.time.ZoneId) OptionalParameter(com.vaadin.flow.router.OptionalParameter) List(java.util.List) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) CommunityService(io.imunity.furms.api.communites.CommunityService) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) NotificationUtils.showSuccessNotification(io.imunity.furms.ui.utils.NotificationUtils.showSuccessNotification) UserGrid(io.imunity.furms.ui.components.administrators.UserGrid) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) MenuButton(io.imunity.furms.ui.components.MenuButton) List(java.util.List) UserContextMenuFactory(io.imunity.furms.ui.components.administrators.UserContextMenuFactory)

Aggregations

TRASH (com.vaadin.flow.component.icon.VaadinIcon.TRASH)1 BeforeEvent (com.vaadin.flow.router.BeforeEvent)1 OptionalParameter (com.vaadin.flow.router.OptionalParameter)1 Route (com.vaadin.flow.router.Route)1 CommunityService (io.imunity.furms.api.communites.CommunityService)1 GenericGroupService (io.imunity.furms.api.generic_groups.GenericGroupService)1 UserAlreadyIsInGroupError (io.imunity.furms.api.validation.exceptions.UserAlreadyIsInGroupError)1 UserNotPresentException (io.imunity.furms.api.validation.exceptions.UserNotPresentException)1 GenericGroup (io.imunity.furms.domain.generic_groups.GenericGroup)1 GenericGroupId (io.imunity.furms.domain.generic_groups.GenericGroupId)1 FURMSUser (io.imunity.furms.domain.users.FURMSUser)1 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)1 MenuButton (io.imunity.furms.ui.components.MenuButton)1 PageTitle (io.imunity.furms.ui.components.PageTitle)1 ViewHeaderLayout (io.imunity.furms.ui.components.ViewHeaderLayout)1 UserContextMenuFactory (io.imunity.furms.ui.components.administrators.UserContextMenuFactory)1 UserGrid (io.imunity.furms.ui.components.administrators.UserGrid)1 UsersGridComponent (io.imunity.furms.ui.components.administrators.UsersGridComponent)1 BreadCrumbParameter (io.imunity.furms.ui.components.layout.BreadCrumbParameter)1 UIContext (io.imunity.furms.ui.user_context.UIContext)1