Members management in project settings is now AJAXified
git-svn-id: http://redmine.rubyforge.org/svn/trunk@508 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a6a181c70c
commit
3eed7e622c
|
@ -21,15 +21,19 @@ class MembersController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
if request.post? and @member.update_attributes(params[:member])
|
if request.post? and @member.update_attributes(params[:member])
|
||||||
flash[:notice] = l(:notice_successful_update)
|
respond_to do |format|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@member.destroy
|
@member.destroy
|
||||||
flash[:notice] = l(:notice_successful_delete)
|
respond_to do |format|
|
||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project
|
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
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -96,8 +96,6 @@ class ProjectsController < ApplicationController
|
||||||
@custom_fields = IssueCustomField.find(:all)
|
@custom_fields = IssueCustomField.find(:all)
|
||||||
@issue_category ||= IssueCategory.new
|
@issue_category ||= IssueCategory.new
|
||||||
@member ||= @project.members.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) }
|
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -172,16 +170,16 @@ class ProjectsController < ApplicationController
|
||||||
# Add a new member to @project
|
# Add a new member to @project
|
||||||
def add_member
|
def add_member
|
||||||
@member = @project.members.build(params[:member])
|
@member = @project.members.build(params[:member])
|
||||||
if request.post?
|
if request.post? && @member.save
|
||||||
if @member.save
|
respond_to do |format|
|
||||||
flash[:notice] = l(:notice_successful_create)
|
format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
|
||||||
redirect_to :action => 'settings', :tab => 'members', :id => @project
|
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
settings
|
settings
|
||||||
render :action => 'settings'
|
render :action => 'settings'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Show members list of @project
|
# Show members list of @project
|
||||||
def list_members
|
def list_members
|
||||||
|
|
|
@ -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 %>
|
|
@ -19,44 +19,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="tab-content-members" class="tab-content" style="display:none;">
|
<div id="tab-content-members" class="tab-content" style="display:none;">
|
||||||
<%= error_messages_for 'member' %>
|
<%= render :partial => 'members' %>
|
||||||
<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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="tab-content-versions" class="tab-content" style="display:none;">
|
<div id="tab-content-versions" class="tab-content" style="display:none;">
|
||||||
|
@ -68,8 +31,8 @@
|
||||||
<td><%=h version.name %></td>
|
<td><%=h version.name %></td>
|
||||||
<td align="center"><%= format_date(version.effective_date) %></td>
|
<td align="center"><%= format_date(version.effective_date) %></td>
|
||||||
<td><%=h version.description %></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"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></small></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_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end; reset_cycle %>
|
<% end; reset_cycle %>
|
||||||
|
@ -94,7 +57,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td align="center">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -242,7 +242,7 @@ text-decoration:none;
|
||||||
|
|
||||||
form {display: inline;}
|
form {display: inline;}
|
||||||
blockquote {padding-left: 6px; border-left: 2px solid #ccc;}
|
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;}
|
input.button-small {font-size: 0.8em;}
|
||||||
textarea.wiki-edit { width: 99.5%; }
|
textarea.wiki-edit { width: 99.5%; }
|
||||||
|
|
Loading…
Reference in New Issue