CCM NG/ccm-core: Creating, editing and deleting roles in the Vaadin prototype
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4753 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
c840580599
commit
1daadd865a
|
|
@ -42,6 +42,8 @@ import org.libreccm.l10n.GlobalizationHelper;
|
||||||
import org.libreccm.security.GroupManager;
|
import org.libreccm.security.GroupManager;
|
||||||
import org.libreccm.security.GroupRepository;
|
import org.libreccm.security.GroupRepository;
|
||||||
import org.libreccm.security.PermissionChecker;
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.libreccm.security.RoleManager;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
import org.libreccm.security.UserManager;
|
import org.libreccm.security.UserManager;
|
||||||
import org.libreccm.security.UserRepository;
|
import org.libreccm.security.UserRepository;
|
||||||
|
|
||||||
|
|
@ -88,6 +90,12 @@ public class AdminView extends CustomComponent implements View {
|
||||||
@Inject
|
@Inject
|
||||||
private GroupManager groupManager;
|
private GroupManager groupManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RoleRepository roleRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RoleManager roleManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private UsersTableDataProvider usersTableDataProvider;
|
private UsersTableDataProvider usersTableDataProvider;
|
||||||
|
|
||||||
|
|
@ -214,4 +222,12 @@ public class AdminView extends CustomComponent implements View {
|
||||||
return groupManager;
|
return groupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RoleRepository getRoleRepository() {
|
||||||
|
return roleRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleManager getRoleManager() {
|
||||||
|
return roleManager;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ public class GroupEditor extends Window {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
groupName.setValue(group.getName());
|
groupName.setValue(group.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
setContent(panel);
|
setContent(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,9 +138,9 @@ public class GroupEditor extends Window {
|
||||||
|
|
||||||
if (dataHasChanged) {
|
if (dataHasChanged) {
|
||||||
final ResourceBundle bundle = ResourceBundle
|
final ResourceBundle bundle = ResourceBundle
|
||||||
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
UI.getCurrent().getLocale());
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
final ConfirmDiscardDialog dialog = new ConfirmDiscardDialog(
|
final ConfirmDiscardDialog dialog = new ConfirmDiscardDialog(
|
||||||
this,
|
this,
|
||||||
bundle.getString("ui.admin.group_edit.discard_confirm"));
|
bundle.getString("ui.admin.group_edit.discard_confirm"));
|
||||||
|
|
@ -150,44 +150,44 @@ public class GroupEditor extends Window {
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void saveGroup() {
|
protected void saveGroup() {
|
||||||
|
|
||||||
final ResourceBundle bundle = ResourceBundle
|
final ResourceBundle bundle = ResourceBundle
|
||||||
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
UI.getCurrent().getLocale());
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
boolean valid = true;
|
boolean valid = true;
|
||||||
|
|
||||||
if (groupName.getValue() == null
|
if (groupName.getValue() == null
|
||||||
|| groupName.getValue().trim().isEmpty()) {
|
|| groupName.getValue().trim().isEmpty()) {
|
||||||
|
|
||||||
groupName.setComponentError(new UserError(
|
groupName.setComponentError(new UserError(
|
||||||
bundle.getString("")));
|
bundle.getString("ui.admin.group_edit.groupname.error.notempty")));
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Group currentGroup;
|
final Group currentGroup;
|
||||||
final String notificationText;
|
final String notificationText;
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
|
|
||||||
currentGroup = new Group();
|
currentGroup = new Group();
|
||||||
currentGroup.setName(groupName.getValue());
|
currentGroup.setName(groupName.getValue());
|
||||||
notificationText = String.format("Created new group %s",
|
notificationText = String.format("Created new group %s",
|
||||||
currentGroup.getName());
|
currentGroup.getName());
|
||||||
} else {
|
} else {
|
||||||
currentGroup = group;
|
currentGroup = group;
|
||||||
group.setName(groupName.getValue());
|
group.setName(groupName.getValue());
|
||||||
notificationText = String.format("Saved changes to group %s",
|
notificationText = String.format("Saved changes to group %s",
|
||||||
currentGroup.getName());
|
currentGroup.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
groupRepo.save(currentGroup);
|
groupRepo.save(currentGroup);
|
||||||
|
|
||||||
dataHasChanged = false;
|
dataHasChanged = false;
|
||||||
if (usersGroupsRoles != null) {
|
if (usersGroupsRoles != null) {
|
||||||
usersGroupsRoles.refreshGroups();
|
usersGroupsRoles.refreshGroups();
|
||||||
|
|
@ -196,8 +196,8 @@ public class GroupEditor extends Window {
|
||||||
new Notification(notificationText, Notification.Type.TRAY_NOTIFICATION)
|
new Notification(notificationText, Notification.Type.TRAY_NOTIFICATION)
|
||||||
.show(Page.getCurrent());
|
.show(Page.getCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DataHasChangedListener
|
private class DataHasChangedListener
|
||||||
implements HasValue.ValueChangeListener<String> {
|
implements HasValue.ValueChangeListener<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1410903365203533072L;
|
private static final long serialVersionUID = -1410903365203533072L;
|
||||||
|
|
@ -206,6 +206,7 @@ public class GroupEditor extends Window {
|
||||||
public void valueChange(final HasValue.ValueChangeEvent<String> event) {
|
public void valueChange(final HasValue.ValueChangeEvent<String> event) {
|
||||||
dataHasChanged = true;
|
dataHasChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Grid;
|
import com.vaadin.ui.Grid;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Panel;
|
|
||||||
import com.vaadin.ui.TextField;
|
import com.vaadin.ui.TextField;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,216 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.admin.ui.usersgroupsroles;
|
||||||
|
|
||||||
|
import com.arsdigita.ui.admin.AdminUiConstants;
|
||||||
|
|
||||||
|
import com.vaadin.data.HasValue;
|
||||||
|
import com.vaadin.server.UserError;
|
||||||
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.FormLayout;
|
||||||
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
|
import com.vaadin.ui.TextArea;
|
||||||
|
import com.vaadin.ui.TextField;
|
||||||
|
import com.vaadin.ui.UI;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
import com.vaadin.ui.Window;
|
||||||
|
import org.libreccm.admin.ui.ConfirmDiscardDialog;
|
||||||
|
import org.libreccm.security.Role;
|
||||||
|
import org.libreccm.security.RoleManager;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
|
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class RoleEditor extends Window {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2982855646090602847L;
|
||||||
|
|
||||||
|
private final UsersGroupsRoles usersGroupsRoles;
|
||||||
|
private final Role role;
|
||||||
|
private final RoleRepository roleRepo;
|
||||||
|
private final RoleManager roleManager;
|
||||||
|
|
||||||
|
private boolean dataHasChanged = false;
|
||||||
|
|
||||||
|
private TextField roleName;
|
||||||
|
private TextArea roleDescription;
|
||||||
|
|
||||||
|
public RoleEditor(final UsersGroupsRoles usersGroupsRoles,
|
||||||
|
final RoleRepository roleRepo,
|
||||||
|
final RoleManager roleManager) {
|
||||||
|
|
||||||
|
super("Create new role");
|
||||||
|
|
||||||
|
this.usersGroupsRoles = usersGroupsRoles;
|
||||||
|
role = null;
|
||||||
|
this.roleRepo = roleRepo;
|
||||||
|
this.roleManager = roleManager;
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleEditor(final Role role,
|
||||||
|
final UsersGroupsRoles usersGroupsRoles,
|
||||||
|
final RoleRepository roleRepo,
|
||||||
|
final RoleManager roleManager) {
|
||||||
|
|
||||||
|
super(String.format("Edit role %s", role.getName()));
|
||||||
|
|
||||||
|
this.role = role;
|
||||||
|
this.usersGroupsRoles = usersGroupsRoles;
|
||||||
|
this.roleRepo = roleRepo;
|
||||||
|
this.roleManager = roleManager;
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addWidgets() {
|
||||||
|
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
|
final DataHasChangedListener dataHasChangedListener
|
||||||
|
= new DataHasChangedListener();
|
||||||
|
|
||||||
|
roleName = new TextField(bundle
|
||||||
|
.getString("ui.admin.role_edit.rolename.label"));
|
||||||
|
roleName.setRequiredIndicatorVisible(true);
|
||||||
|
roleName.addValueChangeListener(dataHasChangedListener);
|
||||||
|
|
||||||
|
roleDescription = new TextArea(bundle
|
||||||
|
.getString("ui.admin.role_edit.roledescription.label"));
|
||||||
|
roleDescription.addValueChangeListener(dataHasChangedListener);
|
||||||
|
|
||||||
|
final Button submit = new Button();
|
||||||
|
if (role == null) {
|
||||||
|
submit.setCaption(bundle
|
||||||
|
.getString("ui.admin.role.createpanel.header"));
|
||||||
|
} else {
|
||||||
|
submit.setCaption(bundle.getString("ui.admin.save"));
|
||||||
|
}
|
||||||
|
submit.addClickListener(event -> saveRole());
|
||||||
|
|
||||||
|
final Button cancel = new Button(bundle.getString("ui.admin.cancel"));
|
||||||
|
cancel.addClickListener(event -> close());
|
||||||
|
|
||||||
|
final HorizontalLayout buttons = new HorizontalLayout(submit, cancel);
|
||||||
|
|
||||||
|
final FormLayout formLayout = new FormLayout(roleName,
|
||||||
|
roleDescription);
|
||||||
|
|
||||||
|
final VerticalLayout layout = new VerticalLayout(formLayout, buttons);
|
||||||
|
|
||||||
|
// final Panel panel = new Panel(layout);
|
||||||
|
// if (role == null) {
|
||||||
|
// panel.setCaption(bundle
|
||||||
|
// .getString("ui.admin.group.createpanel.header"));
|
||||||
|
// } else {
|
||||||
|
// panel.setCaption(bundle
|
||||||
|
// .getString("ui.admin.group_details.edit"));
|
||||||
|
// }
|
||||||
|
if (role != null) {
|
||||||
|
roleName.setValue(role.getName());
|
||||||
|
roleDescription.setValue(role
|
||||||
|
.getDescription()
|
||||||
|
.getValue(UI.getCurrent().getLocale()));
|
||||||
|
}
|
||||||
|
|
||||||
|
setContent(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
if (dataHasChanged) {
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
|
final ConfirmDiscardDialog dialog = new ConfirmDiscardDialog(
|
||||||
|
this,
|
||||||
|
bundle.getString("ui.admin.role_edit.discard_confirm"));
|
||||||
|
dialog.setModal(true);
|
||||||
|
UI.getCurrent().addWindow(dialog);
|
||||||
|
} else {
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void saveRole() {
|
||||||
|
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
|
boolean valid = true;
|
||||||
|
|
||||||
|
if (roleName.getValue() == null
|
||||||
|
|| roleName.getValue().trim().isEmpty()) {
|
||||||
|
|
||||||
|
roleName.setComponentError(new UserError(
|
||||||
|
bundle.getString("ui.admin.role_edit.rolename.error.notempty")));
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Role currentRole;
|
||||||
|
if (role == null) {
|
||||||
|
currentRole = new Role();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
currentRole = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentRole.setName(roleName.getValue());
|
||||||
|
if (roleDescription.getValue() != null
|
||||||
|
&& !roleDescription.getValue().trim().isEmpty()) {
|
||||||
|
currentRole.getDescription().addValue(UI.getCurrent().getLocale(),
|
||||||
|
roleDescription.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
roleRepo.save(currentRole);
|
||||||
|
|
||||||
|
dataHasChanged = false;
|
||||||
|
if (usersGroupsRoles != null) {
|
||||||
|
usersGroupsRoles.refreshRoles();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DataHasChangedListener
|
||||||
|
implements HasValue.ValueChangeListener<String> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1410903365203533072L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChange(final HasValue.ValueChangeEvent<String> event) {
|
||||||
|
dataHasChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -24,15 +24,20 @@ import com.vaadin.icons.VaadinIcons;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Grid;
|
import com.vaadin.ui.Grid;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.TextField;
|
import com.vaadin.ui.TextField;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
import com.vaadin.ui.Window;
|
||||||
import com.vaadin.ui.components.grid.HeaderCell;
|
import com.vaadin.ui.components.grid.HeaderCell;
|
||||||
import com.vaadin.ui.components.grid.HeaderRow;
|
import com.vaadin.ui.components.grid.HeaderRow;
|
||||||
import com.vaadin.ui.renderers.ButtonRenderer;
|
import com.vaadin.ui.renderers.ButtonRenderer;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
import org.libreccm.admin.ui.AdminView;
|
import org.libreccm.admin.ui.AdminView;
|
||||||
import org.libreccm.security.Role;
|
import org.libreccm.security.Role;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
@ -54,7 +59,7 @@ public class RolesTable extends Grid<Role> {
|
||||||
private final Button clearFiltersButton;
|
private final Button clearFiltersButton;
|
||||||
private final Button createRoleButton;
|
private final Button createRoleButton;
|
||||||
|
|
||||||
public RolesTable(final AdminView adminView,
|
public RolesTable(final AdminView view,
|
||||||
final UsersGroupsRoles usersGroupsRoles) {
|
final UsersGroupsRoles usersGroupsRoles) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
@ -80,7 +85,7 @@ public class RolesTable extends Grid<Role> {
|
||||||
})
|
})
|
||||||
.findFirst();
|
.findFirst();
|
||||||
if (locale.isPresent()) {
|
if (locale.isPresent()) {
|
||||||
return role.getDescription().getValue(locale.get());
|
return role.getDescription().getValue(locale.get());
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -91,12 +96,24 @@ public class RolesTable extends Grid<Role> {
|
||||||
.setCaption("Description");
|
.setCaption("Description");
|
||||||
addColumn(user -> bundle.getString("ui.admin.roles.table.edit"),
|
addColumn(user -> bundle.getString("ui.admin.roles.table.edit"),
|
||||||
new ButtonRenderer<>(event -> {
|
new ButtonRenderer<>(event -> {
|
||||||
//ToDo Open GroupEditor window
|
final RoleEditor roleEditor = new RoleEditor(
|
||||||
|
event.getItem(),
|
||||||
|
usersGroupsRoles,
|
||||||
|
view.getRoleRepository(),
|
||||||
|
view.getRoleManager());
|
||||||
|
roleEditor.center();
|
||||||
|
UI.getCurrent().addWindow(roleEditor);
|
||||||
}))
|
}))
|
||||||
.setId(COL_EDIT);
|
.setId(COL_EDIT);
|
||||||
addColumn(user -> bundle.getString("ui.admin.roles.table.delete"),
|
addColumn(user -> bundle.getString("ui.admin.roles.table.delete"),
|
||||||
new ButtonRenderer<>(event -> {
|
new ButtonRenderer<>(event -> {
|
||||||
//ToDo Display Confirm dialog
|
final ConfirmDeleteDialog dialog
|
||||||
|
= new ConfirmDeleteDialog(
|
||||||
|
event.getItem(),
|
||||||
|
usersGroupsRoles,
|
||||||
|
view.getRoleRepository());
|
||||||
|
dialog.center();
|
||||||
|
UI.getCurrent().addWindow(dialog);
|
||||||
}))
|
}))
|
||||||
.setId(COL_DELETE);
|
.setId(COL_DELETE);
|
||||||
|
|
||||||
|
|
@ -129,7 +146,12 @@ public class RolesTable extends Grid<Role> {
|
||||||
createRoleButton.setStyleName(ValoTheme.BUTTON_TINY);
|
createRoleButton.setStyleName(ValoTheme.BUTTON_TINY);
|
||||||
createRoleButton.setIcon(VaadinIcons.PLUS);
|
createRoleButton.setIcon(VaadinIcons.PLUS);
|
||||||
createRoleButton.addClickListener(event -> {
|
createRoleButton.addClickListener(event -> {
|
||||||
//ToDo Open GroupEditor
|
final RoleEditor roleEditor = new RoleEditor(
|
||||||
|
usersGroupsRoles,
|
||||||
|
view.getRoleRepository(),
|
||||||
|
view.getRoleManager());
|
||||||
|
roleEditor.center();
|
||||||
|
UI.getCurrent().addWindow(roleEditor);
|
||||||
});
|
});
|
||||||
final HorizontalLayout actionsLayout = new HorizontalLayout(
|
final HorizontalLayout actionsLayout = new HorizontalLayout(
|
||||||
clearFiltersButton,
|
clearFiltersButton,
|
||||||
|
|
@ -160,4 +182,55 @@ public class RolesTable extends Grid<Role> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ConfirmDeleteDialog extends Window {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1315311220464298282L;
|
||||||
|
|
||||||
|
private final Role role;
|
||||||
|
private final UsersGroupsRoles usersGroupsRoles;
|
||||||
|
private final RoleRepository roleRepo;
|
||||||
|
|
||||||
|
public ConfirmDeleteDialog(final Role role,
|
||||||
|
final UsersGroupsRoles usersGroupsRoles,
|
||||||
|
final RoleRepository roleRepo) {
|
||||||
|
this.role = role;
|
||||||
|
this.usersGroupsRoles = usersGroupsRoles;
|
||||||
|
this.roleRepo = roleRepo;
|
||||||
|
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
|
final MessageFormat messageFormat = new MessageFormat(
|
||||||
|
bundle.getString("ui.admin.roles.delete.confirm"));
|
||||||
|
|
||||||
|
final Label text = new Label(messageFormat
|
||||||
|
.format(new Object[]{role.getName()}));
|
||||||
|
|
||||||
|
final Button yesButton
|
||||||
|
= new Button(bundle.getString("ui.admin.yes"));
|
||||||
|
yesButton.addClickListener(event -> deleteRole());
|
||||||
|
|
||||||
|
final Button noButton = new Button(bundle.getString("ui.admin.no"));
|
||||||
|
noButton.addClickListener(event -> close());
|
||||||
|
|
||||||
|
final HorizontalLayout buttons = new HorizontalLayout(yesButton,
|
||||||
|
noButton);
|
||||||
|
|
||||||
|
final VerticalLayout layout = new VerticalLayout(text, buttons);
|
||||||
|
|
||||||
|
// final Panel panel = new Panel(
|
||||||
|
// bundle.getString("ui.admin.groups.delete.confirm.title"),
|
||||||
|
// layout);
|
||||||
|
setContent(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteRole() {
|
||||||
|
roleRepo.delete(role);
|
||||||
|
usersGroupsRoles.refreshRoles();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.arsdigita.ui.admin.AdminUiConstants;
|
||||||
import com.vaadin.ui.CustomComponent;
|
import com.vaadin.ui.CustomComponent;
|
||||||
import com.vaadin.ui.TabSheet;
|
import com.vaadin.ui.TabSheet;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import org.libreccm.admin.ui.AdminView;
|
import org.libreccm.admin.ui.AdminView;
|
||||||
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
@ -172,7 +173,8 @@ public class UsersGroupsRoles extends CustomComponent {
|
||||||
|
|
||||||
rolesTable = new RolesTable(view, this);
|
rolesTable = new RolesTable(view, this);
|
||||||
rolesTable.setWidth("100%");
|
rolesTable.setWidth("100%");
|
||||||
|
rolesTable.setHeight("100%");
|
||||||
|
|
||||||
tabSheet.addTab(usersTable, "Users");
|
tabSheet.addTab(usersTable, "Users");
|
||||||
tabSheet.addTab(groupsTable, "Groups");
|
tabSheet.addTab(groupsTable, "Groups");
|
||||||
tabSheet.addTab(rolesTable, "Roles");
|
tabSheet.addTab(rolesTable, "Roles");
|
||||||
|
|
|
||||||
|
|
@ -586,3 +586,9 @@ ui.admin.group.createpanel.header=Create a new group
|
||||||
ui.admin.group_details.edit=Edit group
|
ui.admin.group_details.edit=Edit group
|
||||||
ui.admin.group_edit.groupname.error.not_empty=The name of a group can't be empty.
|
ui.admin.group_edit.groupname.error.not_empty=The name of a group can't be empty.
|
||||||
ui.admin.group_edit.discard_confirm=Are you sure to discard all changes made to this group?
|
ui.admin.group_edit.discard_confirm=Are you sure to discard all changes made to this group?
|
||||||
|
ui.admin.group_edit.groupname.error.notempty=The name of a group can't be empty.
|
||||||
|
ui.admin.role_edit.rolename.label=Name
|
||||||
|
ui.admin.role_edit.roledescription.label=Description
|
||||||
|
ui.admin.role.createpanel.header=Create new role
|
||||||
|
ui.admin.role_edit.discard_confirm=Are you sure to discard all changes made to this role?
|
||||||
|
ui.admin.role_edit.rolename.error.notempty=The name of a role can't be empty.
|
||||||
|
|
|
||||||
|
|
@ -590,3 +590,9 @@ ui.admin.group.createpanel.header=Neue Gruppe anlegen
|
||||||
ui.admin.group_details.edit=Gruppe bearbeiten
|
ui.admin.group_details.edit=Gruppe bearbeiten
|
||||||
ui.admin.group_edit.groupname.error.not_empty=Der Name einer Gruppe darf nicht leer sein.
|
ui.admin.group_edit.groupname.error.not_empty=Der Name einer Gruppe darf nicht leer sein.
|
||||||
ui.admin.group_edit.discard_confirm=Sind Sie icher, dass die alle an der Gruppe vorgenommenen \u00c4nderungen verwerfen wollen?
|
ui.admin.group_edit.discard_confirm=Sind Sie icher, dass die alle an der Gruppe vorgenommenen \u00c4nderungen verwerfen wollen?
|
||||||
|
ui.admin.group_edit.groupname.error.notempty=Der Name einer Gruppe darf nicht leer sein.
|
||||||
|
ui.admin.role_edit.rolename.label=Name
|
||||||
|
ui.admin.role_edit.roledescription.label=Beschreibung
|
||||||
|
ui.admin.role.createpanel.header=Neue Rolle anlegen
|
||||||
|
ui.admin.role_edit.discard_confirm=Sind Sie sicher, dass Sie alle an dieser Rolle vorgenommenden \u00c4nderungen verwerfen wollen?
|
||||||
|
ui.admin.role_edit.rolename.error.notempty=Der Name einer Rolle kann nicht leer sein.
|
||||||
|
|
|
||||||
|
|
@ -583,3 +583,9 @@ ui.admin.group.createpanel.header=Create a new group
|
||||||
ui.admin.group_details.edit=Edit group
|
ui.admin.group_details.edit=Edit group
|
||||||
ui.admin.group_edit.groupname.error.not_empty=The name of a group can't be empty.
|
ui.admin.group_edit.groupname.error.not_empty=The name of a group can't be empty.
|
||||||
ui.admin.group_edit.discard_confirm=Are you sure to discard all changes made to this group?
|
ui.admin.group_edit.discard_confirm=Are you sure to discard all changes made to this group?
|
||||||
|
ui.admin.group_edit.groupname.error.notempty=The name of a group can't be empty.
|
||||||
|
ui.admin.role_edit.rolename.label=Name
|
||||||
|
ui.admin.role_edit.roledescription.label=Description
|
||||||
|
ui.admin.role.createpanel.header=Create new role
|
||||||
|
ui.admin.role_edit.discard_confirm=Are you sure to discard all changes made to this role?
|
||||||
|
ui.admin.role_edit.rolename.error.notempty=The name of a role can't be empty.
|
||||||
|
|
|
||||||
|
|
@ -574,3 +574,9 @@ ui.admin.group.createpanel.header=Create a new group
|
||||||
ui.admin.group_details.edit=Edit group
|
ui.admin.group_details.edit=Edit group
|
||||||
ui.admin.group_edit.groupname.error.not_empty=The name of a group can't be empty.
|
ui.admin.group_edit.groupname.error.not_empty=The name of a group can't be empty.
|
||||||
ui.admin.group_edit.discard_confirm=Are you sure to discard all changes made to this group?
|
ui.admin.group_edit.discard_confirm=Are you sure to discard all changes made to this group?
|
||||||
|
ui.admin.group_edit.groupname.error.notempty=The name of a group can't be empty.
|
||||||
|
ui.admin.role_edit.rolename.label=Name
|
||||||
|
ui.admin.role_edit.roledescription.label=Description
|
||||||
|
ui.admin.role.createpanel.header=Create new role
|
||||||
|
ui.admin.role_edit.discard_confirm=Are you sure to discard all changes made to this role?
|
||||||
|
ui.admin.role_edit.rolename.error.notempty=The name of a role can't be empty.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue