diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-03-27 18:10:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-03-27 18:10:36 +0000 |
commit | 90810c0741bb4ef589ea9ea7c8fd7e353d939500 (patch) | |
tree | 1f922070a6212c671d62e41036ed8c2bc10dd292 /app | |
parent | c77806738adaf718642c93c1db1be3dab2bc6e37 (diff) | |
download | redmine-90810c0741bb4ef589ea9ea7c8fd7e353d939500.tar.gz redmine-90810c0741bb4ef589ea9ea7c8fd7e353d939500.zip |
Ability to add multiple project members in a single action (#1556).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2635 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/members_controller.rb | 20 | ||||
-rw-r--r-- | app/views/projects/settings/_members.rhtml | 21 |
2 files changed, 33 insertions, 8 deletions
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 130b56c80..fcc65ba0f 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -21,10 +21,26 @@ class MembersController < ApplicationController before_filter :authorize def new - @project.members << Member.new(params[:member]) if request.post? + members = [] + if params[:member] && request.post? + attrs = params[:member].dup + if (user_ids = attrs.delete(:user_ids)) + user_ids.each do |user_id| + members << Member.new(attrs.merge(:user_id => user_id)) + end + else + members << Member.new(attrs) + end + @project.members << members + end respond_to do |format| format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } - format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } + format.js { + render(:update) {|page| + page.replace_html "tab-content-members", :partial => 'projects/settings/members' + members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") } + } + } end end diff --git a/app/views/projects/settings/_members.rhtml b/app/views/projects/settings/_members.rhtml index 20806fe2d..79ddeded5 100644 --- a/app/views/projects/settings/_members.rhtml +++ b/app/views/projects/settings/_members.rhtml @@ -3,7 +3,8 @@ <% users = User.active.find(:all).sort - @project.users %> <% # members sorted by role position members = @project.members.find(:all, :include => [:role, :user]).sort %> - + +<div class="splitcontentleft"> <% if members.any? %> <table class="list"> <thead> @@ -15,7 +16,7 @@ <tbody> <% members.each do |member| %> <% next if member.new_record? %> - <tr class="<%= cycle 'odd', 'even' %>"> + <tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %>"> <td><%= member.name %></td> <td align="center"> <% if authorize_for('members', 'edit') %> @@ -39,12 +40,20 @@ <% else %> <p class="nodata"><%= l(:label_no_data) %></p> <% end %> +</div> -<% if authorize_for('members', 'new') && !users.empty? %> +<div class="splitcontentright"> +<% if !users.empty? %> <% remote_form_for(:member, @member, :url => {:controller => 'members', :action => 'new', :id => @project}, :method => :post) do |f| %> - <p><label for="member_user_id"><%=l(:label_member_new)%></label><br /> - <%= f.select :user_id, users.collect{|user| [user.name, user.id]} %> - <%= l(:label_role) %>: <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, :selected => nil %> + <fieldset><legend><%=l(:label_member_new)%></legend> + <div> + <% users.each do |user| -%> + <label><%= check_box_tag 'member[user_ids][]', user.id, false %> <%= user %></label> + <% end -%> + </div> + <p><%= l(:label_role) %>: <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, :selected => nil %> <%= submit_tag l(:button_add) %></p> + </fieldset> <% end %> <% end %> +</div> |