socialforge/app/views/courses/settings/_course_member.html.erb

98 lines
4.8 KiB
Plaintext

<table class="sy_new_table clearfix mb15" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th style="width: 35px;">序号</th>
<th style="width:180px;">姓名</th>
<th style="width:140px;">学号</th>
<th>角色</th>
<th class="sy_new_namebox">操作</th>
</tr>
</thead>
<tbody>
<% @members.each_with_index do |member, index| %>
<tr>
<td><%= index + 1 %></td>
<td>
<%= link_to member.user.show_name, user_path(member.user), :class => "pro_new_idname ml10 mr10", :title => "#{member.user.show_name}" %>
</td>
<td>
<span class="pro_new_school_name ml5 mr5"><%=member.user.user_extensions.student_id %></span>
</td>
<td style="width: 200px">
<span id="member_role_<%=member.id %>"><%= zh_course_role(h member.roles.sort.collect(&:to_s).join(', ')) %></span>
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
) do |f| %>
<ul class="clear ml15">
<script>
$(function() {
$("#edit_member_role_<%=member.id %>_7").on('click', function(){
if($("#edit_member_role_<%=member.id %>_7").is(":checked")) {
$("#edit_member_role_<%=member.id %>_9").attr("checked",false);
$("#edit_member_role_<%=member.id %>_9").attr('disabled', 'disabled');
} else {
$("#edit_member_role_<%=member.id %>_9").removeAttr('disabled');
}
});
$("#edit_member_role_<%=member.id %>_9").on('click', function(){
if($("#edit_member_role_<%=member.id %>_9").is(":checked")) {
$("#edit_member_role_<%=member.id %>_7").attr('disabled', 'disabled');
$("#edit_member_role_<%=member.id %>_7").attr("checked",false);
} else {
$("#edit_member_role_<%=member.id %>_7").removeAttr('disabled');
}
});
});
</script>
<% @roles.each do |role| %>
<li class="fl mr5">
<!--<label style="width: 54px;">-->
<%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role), :id => "edit_member_role_#{member.id}_#{role.id}",
:disabled => member.member_roles.detect {|mr| mr.role_id == role.id && !mr.inherited_from.nil?}, :class => "mt6 fl h28" %>
<p class="fl ml5"><%= zh_course_role(h role) %></p>
<!--</label>-->
</li>
<% end %>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
</ul>
<% end %>
</td>
<td>
<% if member.user == @course.teacher %>
<% if User.current == @course.teacher %>
<a href="javascript:void(0)" class="sy_btn_green" onclick="change_manager();">更换管理员</a>
<% end %>
<% else %>
<a href="javascript:void(0)" class="sy_btn_blue mr5" onclick="edit_member($(this), <%=member.id %>);">编辑</a>
<a href="javascript:void(0)" class="sy_btn_blue mr5" style="display: none;" onclick="$('#member-<%= member.id%>-roles-form').submit();">保存</a>
<a href="javascript:void(0)" class="sy_btn_grey mr5" style="display: none;" onclick="cancel_edit($(this), <%=member.id %>);">取消</a>
<a href="javascript:void(0)" class="sy_btn_grey mr5" id="delete_member_<%=member.id %>" onclick="delete_confirm_box_2('<%=membership_path(member) %>', '<%= l(:label_delete_confirm)%>')">删除</a>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<script>
function edit_member(div, id){
$('#member_role_' + id).hide();
$('#member-' + id + '-roles-form').show();
$(div).next().show();
$(div).next().next().show();
$('#delete_member_' + id).hide();
$(div).hide();
}
function cancel_edit(div, id){
$('#member_role_' + id).show();
$('#member-' + id + '-roles-form').hide();
$(div).prev().hide();
$(div).prev().prev().show();
$('#delete_member_' + id).show();
$(div).hide();
}
function change_manager(){
var htmlvalue = "<%= escape_javascript(render :partial => 'courses/settings/change_manager') %>";
pop_box_new(htmlvalue, 424, 366);
}
</script>