112 lines
6.0 KiB
Plaintext
112 lines
6.0 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.school ? member.user.user_extensions.school.name : '--' %></span>
|
|
</td>
|
|
<td style="width: 200px">
|
|
<span id="member_role_<%=member.id %>"><%= zh_contest_role(h member.roles.sort.collect(&:to_s).join(', ')) %></span>
|
|
<%= form_for(member, {:as => :membership, :remote => true, :url => contest_member_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 %>_13").on('click', function(){
|
|
if($("#edit_member_role_<%=member.id %>_13").is(":checked") || $("#edit_member_role_<%=member.id %>_14").is(":checked")) {
|
|
$("#edit_member_role_<%=member.id %>_15").attr('checked', false);
|
|
$("#edit_member_role_<%=member.id %>_15").attr('disabled', 'disabled');
|
|
} else {
|
|
$("#edit_member_role_<%=member.id %>_15").removeAttr('disabled');
|
|
}
|
|
});
|
|
$("#edit_member_role_<%=member.id %>_14").on('click', function(){
|
|
if($("#edit_member_role_<%=member.id %>_13").is(":checked") || $("#edit_member_role_<%=member.id %>_14").is(":checked")) {
|
|
$("#edit_member_role_<%=member.id %>_15").attr('checked', false);
|
|
$("#contest_contestant").attr('disabled', 'disabled');
|
|
} else {
|
|
$("#edit_member_role_<%=member.id %>_15").removeAttr('disabled');
|
|
}
|
|
});
|
|
$("#edit_member_role_<%=member.id %>_15").on('click', function(){
|
|
if($("#edit_member_role_<%=member.id %>_15").is(":checked")) {
|
|
$("#edit_member_role_<%=member.id %>_13").attr('checked', false);
|
|
$("#edit_member_role_<%=member.id %>_14").attr('checked', false);
|
|
$("#edit_member_role_<%=member.id %>_13").attr('disabled', 'disabled');
|
|
$("#edit_member_role_<%=member.id %>_14").attr('disabled', 'disabled');
|
|
} else {
|
|
$("#edit_member_role_<%=member.id %>_13").removeAttr('disabled');
|
|
$("#edit_member_role_<%=member.id %>_14").removeAttr('disabled');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<% @roles.each do |role| %>
|
|
<% if (member.user == @contest.user && role.id != 15) || member.user != @contest.user %>
|
|
<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.user == @contest.user && role.id == 13, :class => "mt6 fl h28" %>
|
|
<% if member.user == @contest.user && role.id == 13 %>
|
|
<%= hidden_field_tag 'membership[role_ids][]', '13' %>
|
|
<% end %>
|
|
<p class="fl ml5"> <%= zh_contest_role(h role) %></p>
|
|
<!--</label>-->
|
|
</li>
|
|
<% end %>
|
|
<% end %>
|
|
</ul>
|
|
<% end %>
|
|
</td>
|
|
<td>
|
|
<% if User.current.admin_of_contest?(@contest) %>
|
|
<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>
|
|
<% unless member.user == @contest.user %>
|
|
<a href="javascript:void(0)" class="sy_btn_grey mr5" id="delete_member_<%=member.id %>" onclick="delete_confirm_box_2('<%=contest_member_path(member) %>', '<%= l(:label_delete_confirm)%>')">删除</a>
|
|
<%#= delete_link contest_member_path(member),
|
|
:remote => true,
|
|
:class => "sy_btn_grey mr5",
|
|
:id => "delete_member_#{member.id}",
|
|
:data => ({confirm: l(:label_delete_confirm)}) %>
|
|
<% end %>
|
|
<% 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();
|
|
}
|
|
</script> |