use of com.vaadin.flow.component.icon.VaadinIcon.MINUS_CIRCLE in project furms by unity-idm.
the class SitesView method fillGrid.
private void fillGrid() {
grid.addHierarchyColumn(model -> Optional.ofNullable(model.siteName).orElse("")).setHeader(getTranslation("view.project-admin.sites.grid.1")).setSortable(true).setFlexGrow(25);
grid.addComponentColumn(model -> new StatusLayout(model.status, model.message, getContent())).setHeader(getTranslation("view.project-admin.sites.grid.2")).setSortable(true).setFlexGrow(6);
grid.addColumn(model -> model.userName).setHeader(getTranslation("view.project-admin.sites.grid.3")).setSortable(true).setFlexGrow(25);
grid.addColumn(model -> model.userEmail).setHeader(getTranslation("view.project-admin.sites.grid.4")).setSortable(true).setFlexGrow(25);
grid.addColumn(model -> Optional.ofNullable(model.userAccessStatus).map(status -> status.status.isEnabled() ? getTranslation("view.project-admin.sites.enabled") : getTranslation("view.project-admin.sites.disabled")).orElse("")).setHeader(getTranslation("view.project-admin.sites.grid.5")).setSortable(true).setFlexGrow(25);
grid.addComponentColumn(model -> Optional.ofNullable(model.userAccessStatus).map(status -> (Component) new StatusLayout(getTranslation("view.project-admin.sites." + status.status.name()), status.message, getContent())).orElse(new Div())).setHeader(getTranslation("view.project-admin.sites.grid.6")).setSortable(true).setFlexGrow(25);
grid.addComponentColumn(resourceAccessModel -> {
if (resourceAccessModel.userAccessStatus == null || resourceAccessModel.userAccessStatus.status.isPending()) {
IconButton iconButton = new IconButton(REFRESH.create());
iconButton.addClickListener(event -> loadGridContent());
return iconButton;
} else {
GridActionMenu contextMenu = new GridActionMenu();
if (resourceAccessModel.userAccessStatus.status.isInstalled()) {
contextMenu.addItem(new MenuButton(getTranslation("view.project-admin.sites.revoke"), MINUS_CIRCLE), event -> {
userSiteAccessService.removeAccess(resourceAccessModel.siteId, projectId, resourceAccessModel.userId);
loadGridContent();
});
} else {
contextMenu.addItem(new MenuButton(getTranslation("view.project-admin.sites.grant"), PLUS_CIRCLE), event -> {
userSiteAccessService.addAccess(resourceAccessModel.siteId, projectId, resourceAccessModel.userId);
loadGridContent();
});
}
return new GridActionsButtonLayout(contextMenu.getTarget());
}
}).setHeader(getTranslation("view.project-admin.sites.grid.7")).setTextAlign(ColumnTextAlign.END);
grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
loadGridContent();
}
Aggregations