Bug #1486: Replace the widget used to select the roles with a Combobox.

We do this to have a consistent behaviour in similar widget inside the same
screen.

FEA: ItEr76S04BugFixing
This commit is contained in:
Jacobo Aragunde Pérez 2012-07-10 10:50:19 +02:00
parent 13ee4ff118
commit 7cef9c6c92
4 changed files with 30 additions and 7 deletions

View file

@ -132,4 +132,6 @@ public interface IUserModel {
void unboundResource();
List<Profile> getAllProfiles();
}

View file

@ -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<User> implements
private Groupbox boundResourceGroupbox;
private Autocomplete profileAutocomplete;
private Combobox profilesCombo;
private IURLHandlerRegistry URLHandlerRegistry;
@ -133,9 +132,10 @@ public class UserCRUDController extends BaseCRUDController<User> 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<User> implements
}
}
/**
* Appends the existing Profiles to the Combobox passed.
*
* @param combo
*/
private void appendAllProfiles(Combobox combo) {
List<Profile> profiles = userModel.getAllProfiles();
for (Profile profile : profiles) {
Comboitem item = combo.appendItem(profile.getProfileName());
item.setValue(profile);
}
}
public List<User> getUsers() {
return userModel.getUsers();
}
@ -205,7 +218,7 @@ public class UserCRUDController extends BaseCRUDController<User> implements
}
public void addSelectedProfile() {
Comboitem comboItem = profileAutocomplete.getSelectedItem();
Comboitem comboItem = profilesCombo.getSelectedItem();
if(comboItem != null) {
addProfile((Profile)comboItem.getValue());
}

View file

@ -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<Profile> getAllProfiles() {
return profileDAO.list(Profile.class);
}
}

View file

@ -149,9 +149,7 @@
<label value="${i18n:_('Profiles of LDAP users cannot be managed because LDAP roles are being used.')}" visible="@{controller.ldapUserRolesLdapConfiguration}" />
</vbox>
<hbox align="center">
<autocomplete id="profileAutocomplete"
autodrop="true" constraint=""
finder="ProfileFinder" />
<combobox id="profilesCombo" autodrop="true" />
<button label="${i18n:_('Add profile')}"
onClick="controller.addSelectedProfile()"
disabled="@{controller.areRolesAndProfilesDisabled}" />