socialforge/app/views/courses/_member.html.erb

60 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<% @members.each do |member| %>
<li >
<%#= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %>
<%= link_to "#{member.principal}#{member.principal.show_name}", user_path(member.principal), :class => "w150 linkBlue fl", :style=>"white-space: nowrap;overflow: hidden;text-overflow: ellipsis;", :title => "#{member.principal}#{member.principal.show_name}" %>
<span class="w150 fl">
<%= zh_course_role(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="ml45">
<%= 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? } %>
<label ><%= zh_course_role(h role) %></label>
</ul>
<!--<br/>-->
<% end %>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
<div class="ml45">
<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>
<% 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),
:remote => true,
: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? %>
<% end%>
</li>
<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>
<% end%>