diff options
-rw-r--r-- | app/controllers/members_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 16 | ||||
-rw-r--r-- | app/views/projects/_members.rhtml | 43 | ||||
-rw-r--r-- | app/views/projects/settings.rhtml | 45 | ||||
-rw-r--r-- | public/stylesheets/application.css | 2 |
5 files changed, 63 insertions, 55 deletions
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index ad9e44ff9..dfaad7fa3 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -21,15 +21,19 @@ class MembersController < ApplicationController def edit if request.post? and @member.update_attributes(params[:member]) - flash[:notice] = l(:notice_successful_update) - redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project + 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/members'} } + end end end def destroy @member.destroy - flash[:notice] = l(:notice_successful_delete) - redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project + 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/members'} } + end end private diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d3a71478b..a870cca2a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -96,8 +96,6 @@ class ProjectsController < ApplicationController @custom_fields = IssueCustomField.find(:all) @issue_category ||= IssueCategory.new @member ||= @project.members.new - @roles = Role.find(:all, :order => 'position') - @users = User.find_active(:all) - @project.users @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } end @@ -172,14 +170,14 @@ class ProjectsController < ApplicationController # Add a new member to @project def add_member @member = @project.members.build(params[:member]) - if request.post? - if @member.save - flash[:notice] = l(:notice_successful_create) - redirect_to :action => 'settings', :tab => 'members', :id => @project - else - settings - render :action => 'settings' + if request.post? && @member.save + respond_to do |format| + format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project } + format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} } end + else + settings + render :action => 'settings' end end diff --git a/app/views/projects/_members.rhtml b/app/views/projects/_members.rhtml new file mode 100644 index 000000000..4283b2ef8 --- /dev/null +++ b/app/views/projects/_members.rhtml @@ -0,0 +1,43 @@ +<%= error_messages_for 'member' %> +<% roles = Role.find(:all, :order => 'position') %> +<% users = User.find_active(:all) - @project.users %> + +<table class="list"> + <thead> + <th><%= l(:label_user) %></th> + <th><%= l(:label_role) %></th> + <th></th> + </thead> + <tbody> + <% @project.members.find(:all, :include => [:role, :user]).sort{|x,y| x.role.position <=> y.role.position}.each do |member| %> + <% next if member.new_record? %> + <tr class="<%= cycle 'odd', 'even' %>"> + <td><%= member.user.display_name %></td> + <td align="center"> + <% if authorize_for('members', 'edit') %> + <% remote_form_for(:member, member, :url => {:controller => 'members', :action => 'edit', :id => member}, :method => :post) do |f| %> + <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, {}, :class => "small" %> + <%= submit_tag l(:button_change), :class => "small" %> + <% end %> + <% end %> + </td> + <td align="center"> + <small><%= link_to_remote l(:button_delete), { :url => {:controller => 'members', :action => 'destroy', :id => member}, + :method => :post + }, :title => l(:button_delete), + :class => 'icon icon-del' %></small> + </td> + </tr> + </tbody> +<% end; reset_cycle %> +</table> + + +<% if authorize_for('projects', 'add_member') && !users.empty? %> + <p><label for="member_user_id"><%=l(:label_member_new)%></label></p> + <% remote_form_for(:member, @member, :url => {:controller => 'projects', :action => 'add_member', :tab => 'members', :id => @project}, :method => :post) do |f| %> + <%= 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 %> + <%= submit_tag l(:button_add) %> + <% end %> +<% end %> diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml index aaa4e6522..69d26d299 100644 --- a/app/views/projects/settings.rhtml +++ b/app/views/projects/settings.rhtml @@ -19,44 +19,7 @@ </div> <div id="tab-content-members" class="tab-content" style="display:none;"> -<%= error_messages_for 'member' %> -<table class="list"> - <thead><th><%= l(:label_user) %></th><th><%= l(:label_role) %></th><th></th></thead> - <tbody> - <% @project.members.find(:all, :include => [:role, :user]).sort{|x,y| x.role.position <=> y.role.position}.each do |member| %> - <% unless member.new_record? %> - <tr class="<%= cycle 'odd', 'even' %>"> - <td><%= member.user.display_name %></td> - <td align="center"> - <% if authorize_for('members', 'edit') %> - <% form_tag({:controller => 'members', :action => 'edit', :id => member}) do %> - <select name="member[role_id]"> - <%= options_from_collection_for_select @roles, "id", "name", member.role_id %> - </select> - <%= submit_tag l(:button_change), :class => "button-small" %> - <% end %> - <% end %> - </td> - <td align="center"> - <%= link_to_if_authorized l(:button_delete), {:controller => 'members', :action => 'destroy', :id => member}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> - </td> - </tr> - <% end %> - </tbody> -<% end; reset_cycle %> -</table> -<% if authorize_for('projects', 'add_member') %> - <label><%=l(:label_member_new)%></label><br/> - <% form_tag({:controller => 'projects', :action => 'add_member', :tab => 'members', :id => @project}) do %> - <select name="member[user_id]"> - <%= options_from_collection_for_select @users, "id", "display_name", @member.user_id %> - </select> - <select name="member[role_id]"> - <%= options_from_collection_for_select @roles, "id", "name", @member.role_id %> - </select> - <%= submit_tag l(:button_add) %> - <% end %> -<% end %> + <%= render :partial => 'members' %> </div> <div id="tab-content-versions" class="tab-content" style="display:none;"> @@ -68,8 +31,8 @@ <td><%=h version.name %></td> <td align="center"><%= format_date(version.effective_date) %></td> <td><%=h version.description %></td> - <td align="center"><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></td> - <td align="center"><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></td> + <td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></small></td> + <td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td> </td> </tr> <% end; reset_cycle %> @@ -94,7 +57,7 @@ <% end %> </td> <td align="center"> - <%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => @category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> + <small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => @category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small> </td> </tr> <% end %> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 2555b61f7..7cc0f3d86 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -242,7 +242,7 @@ text-decoration:none; form {display: inline;} blockquote {padding-left: 6px; border-left: 2px solid #ccc;} -input, select {vertical-align: middle; margin-bottom: 4px;} +input, select {vertical-align: middle; margin-top: 1px; margin-bottom: 1px;} input.button-small {font-size: 0.8em;} textarea.wiki-edit { width: 99.5%; } |