diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/IUserModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/IUserModel.java index f2b4a3e50..86023176e 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/IUserModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/IUserModel.java @@ -132,4 +132,6 @@ public interface IUserModel { void unboundResource(); + List getAllProfiles(); + } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java index 4ed3f8542..686ca9b47 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java @@ -40,7 +40,6 @@ import org.libreplan.business.users.entities.User; import org.libreplan.business.users.entities.UserRole; import org.libreplan.web.common.BaseCRUDController; import org.libreplan.web.common.Util; -import org.libreplan.web.common.components.Autocomplete; import org.libreplan.web.common.entrypoints.EntryPointsHandler; import org.libreplan.web.common.entrypoints.IURLHandlerRegistry; import org.libreplan.web.resources.worker.IWorkerCRUDControllerEntryPoints; @@ -86,7 +85,7 @@ public class UserCRUDController extends BaseCRUDController implements private Groupbox boundResourceGroupbox; - private Autocomplete profileAutocomplete; + private Combobox profilesCombo; private IURLHandlerRegistry URLHandlerRegistry; @@ -133,9 +132,10 @@ public class UserCRUDController extends BaseCRUDController implements passwordBox = (Textbox) editWindow.getFellowIfAny("password"); passwordConfirmationBox = (Textbox) editWindow.getFellowIfAny("passwordConfirmation"); - profileAutocomplete = (Autocomplete) editWindow.getFellowIfAny("profileAutocomplete"); + profilesCombo = (Combobox) editWindow.getFellowIfAny("profilesCombo"); userRolesCombo = (Combobox) editWindow.getFellowIfAny("userRolesCombo"); appendAllUserRolesExceptRoleBoundUser(userRolesCombo); + appendAllProfiles(profilesCombo); boundResourceGroupbox = (Groupbox) editWindow .getFellowIfAny("boundResourceGroupbox"); @@ -166,6 +166,19 @@ public class UserCRUDController extends BaseCRUDController implements } } + /** + * Appends the existing Profiles to the Combobox passed. + * + * @param combo + */ + private void appendAllProfiles(Combobox combo) { + List profiles = userModel.getAllProfiles(); + for (Profile profile : profiles) { + Comboitem item = combo.appendItem(profile.getProfileName()); + item.setValue(profile); + } + } + public List getUsers() { return userModel.getUsers(); } @@ -205,7 +218,7 @@ public class UserCRUDController extends BaseCRUDController implements } public void addSelectedProfile() { - Comboitem comboItem = profileAutocomplete.getSelectedItem(); + Comboitem comboItem = profilesCombo.getSelectedItem(); if(comboItem != null) { addProfile((Profile)comboItem.getValue()); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserModel.java index 401c15e1b..72036c49c 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserModel.java @@ -31,6 +31,7 @@ import org.libreplan.business.common.exceptions.InstanceNotFoundException; import org.libreplan.business.common.exceptions.ValidationException; import org.libreplan.business.resources.daos.IWorkerDAO; import org.libreplan.business.resources.entities.Worker; +import org.libreplan.business.users.daos.IProfileDAO; import org.libreplan.business.users.daos.IUserDAO; import org.libreplan.business.users.entities.Profile; import org.libreplan.business.users.entities.User; @@ -67,6 +68,9 @@ public class UserModel implements IUserModel { @Autowired private IWorkerDAO workerDAO; + @Autowired + private IProfileDAO profileDAO; + private User user; private String clearNewPassword; @@ -265,4 +269,10 @@ public class UserModel implements IUserModel { user.setWorker(null); } + @Override + @Transactional(readOnly = true) + public List getAllProfiles() { + return profileDAO.list(Profile.class); + } + } diff --git a/libreplan-webapp/src/main/webapp/users/_editUser.zul b/libreplan-webapp/src/main/webapp/users/_editUser.zul index 8201b4da6..2f12f278d 100644 --- a/libreplan-webapp/src/main/webapp/users/_editUser.zul +++ b/libreplan-webapp/src/main/webapp/users/_editUser.zul @@ -149,9 +149,7 @@