diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/finders/ProfileFinder.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/finders/ProfileFinder.java
new file mode 100644
index 000000000..01341d999
--- /dev/null
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/components/finders/ProfileFinder.java
@@ -0,0 +1,57 @@
+/*
+ * This file is part of ###PROJECT_NAME###
+ *
+ * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
+ * Desenvolvemento Tecnolóxico de Galicia
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package org.navalplanner.web.common.components.finders;
+
+import java.util.List;
+
+import org.navalplanner.business.users.daos.IProfileDAO;
+import org.navalplanner.business.users.entities.Profile;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+*
+* @author Jacobo Aragunde Perez
+*
+* Implements a {@link IFinder} class for providing {@link Profile}
+* elements
+*
+*/
+@Repository
+public class ProfileFinder extends Finder implements IFinder {
+
+ @Autowired
+ private IProfileDAO dao;
+
+ @Override
+ public String _toString(Object value) {
+ Profile profile = (Profile) value;
+ return (profile != null)? profile.getProfileName() : "";
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List getAll() {
+ return dao.list(Profile.class);
+ }
+
+}
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java
index bf6391fce..64f07f013 100644
--- a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java
@@ -104,4 +104,12 @@ public interface IUserModel {
*/
void removeProfile(Profile profile);
+ /**
+ * Adds a profile to the list of {@link Profile} objects associated
+ * with the current User.
+ *
+ * @param role The {@link Profile} object to be added.
+ */
+ void addProfile(Profile profile);
+
}
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java
index 10a642cf0..04a9bb6eb 100644
--- a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java
@@ -34,6 +34,7 @@ import org.navalplanner.web.common.Level;
import org.navalplanner.web.common.MessagesForUser;
import org.navalplanner.web.common.OnlyOneVisible;
import org.navalplanner.web.common.Util;
+import org.navalplanner.web.common.components.Autocomplete;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Combobox;
@@ -63,12 +64,15 @@ public class UserCRUDController extends GenericForwardComposer implements
private Combobox userRolesCombo;
+ private Autocomplete profileAutocomplete;
+
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setVariable("controller", this, true);
messagesForUser = new MessagesForUser(messagesContainer);
getVisibility().showOnly(listWindow);
+ profileAutocomplete = (Autocomplete) createWindow.getFellowIfAny("profileAutocomplete");
userRolesCombo = (Combobox) createWindow.getFellowIfAny("userRolesCombo");
appendAllUserRoles(userRolesCombo);
}
@@ -168,6 +172,18 @@ public class UserCRUDController extends GenericForwardComposer implements
return userModel.getProfiles();
}
+ public void addSelectedProfile() {
+ Comboitem comboItem = profileAutocomplete.getSelectedItem();
+ if(comboItem != null) {
+ addProfile((Profile)comboItem.getValue());
+ }
+ }
+
+ public void addProfile(Profile profile) {
+ userModel.addProfile(profile);
+ Util.reloadBindings(createWindow);
+ }
+
public void removeProfile(Profile profile) {
userModel.removeProfile(profile);
Util.reloadBindings(createWindow);
diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.java
index dbf713bb7..e692199e8 100644
--- a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.java
+++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.java
@@ -142,4 +142,9 @@ public class UserModel implements IUserModel {
public void removeProfile(Profile profile) {
user.removeProfile(profile);
}
+
+ @Override
+ public void addProfile(Profile profile) {
+ user.addProfile(profile);
+ }
}
diff --git a/navalplanner-webapp/src/main/webapp/users/_editUser.zul b/navalplanner-webapp/src/main/webapp/users/_editUser.zul
index c253514a9..dec4920e6 100644
--- a/navalplanner-webapp/src/main/webapp/users/_editUser.zul
+++ b/navalplanner-webapp/src/main/webapp/users/_editUser.zul
@@ -78,6 +78,13 @@
+
+
+
+