Remove ROLE_BOUND_USER from roles list in user and profile edition
If a user has this role the remove button will appear disabled. FEA: ItEr76S30PermissionsEnhancements
This commit is contained in:
parent
081d70d0c7
commit
6e9b96b77a
4 changed files with 20 additions and 25 deletions
|
|
@ -60,11 +60,6 @@ public interface IProfileModel {
|
|||
*/
|
||||
void confirmSave() throws ValidationException;
|
||||
|
||||
/**
|
||||
* Returns a list of the available user roles in the system.
|
||||
*/
|
||||
List<UserRole> getAllRoles();
|
||||
|
||||
/**
|
||||
* Gets the current {@link Profile}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ package org.libreplan.web.users;
|
|||
|
||||
import static org.libreplan.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
|
@ -61,15 +63,19 @@ public class ProfileCRUDController extends BaseCRUDController<Profile> {
|
|||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
userRolesCombo = (Combobox) editWindow.getFellowIfAny("userRolesCombo");
|
||||
appendAllUserRoles(userRolesCombo);
|
||||
appendAllUserRolesExceptRoleBoundUser(userRolesCombo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the existing UserRoles to the Combobox passed.
|
||||
* @param combo
|
||||
*/
|
||||
private void appendAllUserRoles(Combobox combo) {
|
||||
for(UserRole role : getAllRoles()) {
|
||||
private void appendAllUserRolesExceptRoleBoundUser(Combobox combo) {
|
||||
List<UserRole> roles = new ArrayList<UserRole>(Arrays.asList(UserRole
|
||||
.values()));
|
||||
roles.remove(UserRole.ROLE_BOUND_USER);
|
||||
|
||||
for (UserRole role : roles) {
|
||||
Comboitem item = combo.appendItem(_(role.getDisplayName()));
|
||||
item.setValue(role);
|
||||
}
|
||||
|
|
@ -87,10 +93,6 @@ public class ProfileCRUDController extends BaseCRUDController<Profile> {
|
|||
return profileModel.getProfile();
|
||||
}
|
||||
|
||||
public List<UserRole> getAllRoles() {
|
||||
return profileModel.getAllRoles();
|
||||
}
|
||||
|
||||
public void addSelectedRole() {
|
||||
Comboitem comboItem = userRolesCombo.getSelectedItem();
|
||||
if(comboItem != null) {
|
||||
|
|
|
|||
|
|
@ -100,15 +100,6 @@ public class ProfileModel implements IProfileModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRole> getAllRoles() {
|
||||
List<UserRole> list = new ArrayList<UserRole>();
|
||||
for(UserRole role : UserRole.values()) {
|
||||
list.add(role);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRole(UserRole role) {
|
||||
profile.addRole(role);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ package org.libreplan.web.users;
|
|||
|
||||
import static org.libreplan.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -121,7 +123,7 @@ public class UserCRUDController extends BaseCRUDController<User> implements
|
|||
passwordConfirmationBox = (Textbox) editWindow.getFellowIfAny("passwordConfirmation");
|
||||
profileAutocomplete = (Autocomplete) editWindow.getFellowIfAny("profileAutocomplete");
|
||||
userRolesCombo = (Combobox) editWindow.getFellowIfAny("userRolesCombo");
|
||||
appendAllUserRoles(userRolesCombo);
|
||||
appendAllUserRolesExceptRoleBoundUser(userRolesCombo);
|
||||
boundResourceGroupbox = (Groupbox) editWindow
|
||||
.getFellowIfAny("boundResourceGroupbox");
|
||||
|
||||
|
|
@ -134,8 +136,12 @@ public class UserCRUDController extends BaseCRUDController<User> implements
|
|||
* Appends the existing UserRoles to the Combobox passed.
|
||||
* @param combo
|
||||
*/
|
||||
private void appendAllUserRoles(Combobox combo) {
|
||||
for(UserRole role : UserRole.values()) {
|
||||
private void appendAllUserRolesExceptRoleBoundUser(Combobox combo) {
|
||||
List<UserRole> roles = new ArrayList<UserRole>(Arrays.asList(UserRole
|
||||
.values()));
|
||||
roles.remove(UserRole.ROLE_BOUND_USER);
|
||||
|
||||
for (UserRole role : roles) {
|
||||
Comboitem item = combo.appendItem(_(role.getDisplayName()));
|
||||
item.setValue(role);
|
||||
}
|
||||
|
|
@ -313,7 +319,8 @@ public class UserCRUDController extends BaseCRUDController<User> implements
|
|||
removeRole(role);
|
||||
}
|
||||
});
|
||||
removeButton.setDisabled(getLdapUserRolesLdapConfiguration());
|
||||
removeButton.setDisabled(getLdapUserRolesLdapConfiguration()
|
||||
|| role.equals(UserRole.ROLE_BOUND_USER));
|
||||
row.appendChild(removeButton);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue