diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 250ed8ce8..0fe1755eb 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -23,6 +23,20 @@ module UsersHelper [l(:status_locked), 3]], selected) end + # Options for the new membership projects combo-box + def projects_options_for_select(projects) + options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---") + projects_by_root = projects.group_by(&:root) + projects_by_root.keys.sort.each do |root| + options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root))) + projects_by_root[root].sort.each do |project| + next if project == root + options << content_tag('option', '» ' + h(project.name), :value => project.id) + end + end + options + end + def change_status_link(user) url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]} diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml index 2499ba387..44d74ef7b 100644 --- a/app/views/users/_memberships.rhtml +++ b/app/views/users/_memberships.rhtml @@ -13,17 +13,17 @@
<% end %> <% end %> + +<% if @projects.any? %>
<% form_tag({ :action => 'edit_membership', :id => @user }) do %>
-
-
+<%= select_tag 'membership[project_id]', projects_options_for_select(@projects) %>
+<%= l(:label_role) %>:
+<%= select_tag 'membership[role_id]', options_from_collection_for_select(@roles, "id", "name") %>
<%= submit_tag l(:button_add) %>
<% end %>