修改成员角色

This commit is contained in:
sw 2015-03-30 15:57:10 +08:00
parent 2af071a92e
commit ed02959e00
5 changed files with 44 additions and 14 deletions

View File

@ -250,6 +250,8 @@ class MembersController < ApplicationController
end end
end end
end end
@roles = Role.givable.all[3..5]
@members = @course.member_principals.includes(:roles, :principal).all.sort
end end
saved = @member.save saved = @member.save

View File

@ -35,13 +35,13 @@
</li> </li>
<% @roles.each do |role| %> <% @roles.each do |role| %>
<li> <li>
<%= check_box_tag 'membership[role_ids][]', role.id %> <%= radio_button_tag 'membership[role_ids][]', role.id %>
<label ><%= h role %></label> <label ><%= h role %></label>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<div class="cl mb10"></div> <div class="cl mb10"></div>
<a href="#" class="member_btn" onclick="$('#new_membership').submit();"> <a href="javascript:void(0)" class="member_btn" onclick="$('#new_membership').submit();">
新增成员 新增成员
</a> </a>
</div> </div>

View File

@ -3,11 +3,35 @@
<%= link_to_user_header member.principal,false,:class => "w150 c_orange fl" %> <%= link_to_user_header member.principal,false,:class => "w150 c_orange fl" %>
<span class="w150 fl"> <span class="w150 fl">
<%= h member.roles.sort.collect(&:to_s).join(', ') %> <%= h member.roles.sort.collect(&:to_s).join(', ') %>
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
) do |f| %>
<% @roles.each do |role| %>
<ul style="text-align: left;" class="ml20">
<%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %>
<label ><%= h role %></label>
</ul>
<!--<br/>-->
<% end %>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
<div class="ml20">
<a href="javascript:void(0)" class="member_btn" onclick="$('#member-<%= member.id%>-roles-form').submit();" style="margin-right: 10px;">
<%= l(:button_change)%>
</a>
<a href="javascript:void(0)" class="member_btn" onclick="$('#member-<%= member.id%>-roles-form').hide();$(this).parent().parent().parent().parent().height(30)">
<%= l(:button_cancel)%>
</a>
</div>
<% end %>
</span> </span>
<a href="#" class="c_dblue w40 fl">编辑</a> <% unless member.roles.first.to_s == "Manager"%>
<a href="javascript:void(0) " class="c_dblue w40 fl" onclick="$('#member-<%= member.id%>-roles-form').show();$(this).parent().height(110);">编辑</a>
<%= delete_link membership_path(member), <%= delete_link membership_path(member),
:remote => true, :remote => true,
:class => "c_dblue w40 fl", :class => "c_dblue w40 fl",
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %> :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %>
<% end%>
</li> </li>
<% end%> <% end%>

View File

@ -1,7 +1,10 @@
<%if @project%> <%if @project%>
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>'); $('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
<%elsif @course%>
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>');
<%end%>
hideOnLoad();
$("#member-<%= @member.id %>").effect("highlight"); $("#member-<%= @member.id %>").effect("highlight");
hideOnLoad();
<%elsif @course%>
$('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/course_members') %>');
hideOnLoad();
<%end%>

View File

@ -272,8 +272,9 @@ a:hover.tijiao{ background:#0f99a9;}
.member_search_input{ border:1px solid #15bccf; background:#fff; width:170px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;} .member_search_input{ border:1px solid #15bccf; background:#fff; width:170px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;}
.member_search_btn{ background:#15bccf; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #15bccf; padding-top:2px; cursor:pointer;} .member_search_btn{ background:#15bccf; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #15bccf; padding-top:2px; cursor:pointer;}
.member_search_btn:hover{ background:#0da1b2; border:1px solid #0da1b2;} .member_search_btn:hover{ background:#0da1b2; border:1px solid #0da1b2;}
a.member_btn{ padding:5px; background:#15bccf; color:#fff;} a.member_btn{ padding: 3px 5px; background:#15bccf; color:#fff;}
a:hover.member_btn{ background:#329cbd;} a:hover.member_btn{ background:#329cbd;}
.hol{display: none;}
/* 新建项目 */ /* 新建项目 */
.pro_new{ } .pro_new{ }