socialforge/app/views/projects/settings/_new_members.html.erb

161 lines
6.3 KiB
Plaintext

<%= error_messages_for 'member' %>
<%
roles = Role.givable.all
if @project.project_type == Project::ProjectType_course
if User.current.language == "zh"
roles = ["管理人员","开发者","报告人员"]
else
roles = ["管理人员","开发者","报告人员"]
# roles = roles[3..5]
end
else
roles = roles[0..2]
end
members = @project.member_principals.includes(:roles, :principal).all.sort
%>
<div class=" clear ml15 mr15" >
<% if roles.any? %>
<a href="javascript:void(0);" class="fr sy_btn_green mb10" onclick="add_member();">添加成员</a>
<% end %>
<div class="cl"></div>
<div class=" sy_new_tchbox clear ml10 mr10 undis" id="add_members_id">
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
<div class="hw_search_box mb10">
<input id="principal_search" class="sy_new_search" placeholder="支持姓名、邮箱、登录名搜索" type="text">
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
</div>
<ul class="pro_new_idlist fl">
<div class="clear mb10" id="principals_for_new_member">
<%= render_project_members(@project) %>
</div>
</ul>
<ul class="fl pro_new_idbox">
<% roles.each do |role| %>
<li class="clear ">
<%= radio_button_tag 'membership[role_ids][]', role.id, role.name == "报告人员" || role.name == "Reporter", :class=>"fl" %>
<% if User.current.language == "zh" %>
<% if role.id == 3 %>
<div class="fl ml5" style="height:30px">管理人员</div>
<% elsif role.id == 4 %>
<div class="fl ml5" style="height:30px">开发人员</div>
<% else %>
<div class="fl ml5" style="height:30px">报告人员</div>
<% end %>
<% else %>
<div class="fl ml5" style="height:30px"><%= h role %></div>
<% end %>
</li>
<% end %>
</ul>
<div class="cl mb10"></div>
<a href="javascript:void(0);" class="fr sy_btn_grey " onclick="hidden_add_member();">取消</a>
<a href="javascript:void(0);" class="fr sy_btn_blue mr5" onclick="$(this).parent().submit();">保存</a>
<%end%>
</div>
<% if members.any? %>
<table class="sy_new_table clear mb15" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>序号</th>
<th >用户</th>
<th>角色</th>
<th class="sy_new_namebox">操作</th>
</tr>
<%= call_hook(:view_projects_settings_members_table_header, :project => @project) %>
</thead>
<tbody>
<% i = 0 %>
<% members.each do |member| %>
<tr>
<th><%= i += 1 %></th>
<th><%= link_to member.principal.show_name, user_path(member.principal) %></th>
<th>
<% if User.current.language == "zh" %>
<% zh_roles = [] %>
<% member.roles.each do |role| %>
<% if role.id == 3
zh_roles << "管理人员"
elsif role.id == 4
zh_roles << "开发人员"
else
zh_roles << "报告人员"
end
%>
<% end %>
<label style="text-align:center;" id="members_<%= member.id %>_role_show"><%= h zh_roles.sort.reverse.collect(&:to_s).join(', ') %></label>
<% else %>
<label style="text-align:center;" id="members_<%= member.id %>_role_show"> <%= h member.roles.sort.collect(&:to_s).join(', ') %></label>
<% end %>
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "members-#{member.id}-roles-form", :class => 'undis'}}
) do |f| %>
<%= select( :membership, :roles, [["管理人员",3],["开发人员",4],["报告人员",5]],
{ :include_blank => false, :selected => member.roles[0].id ? member.roles[0].id : 0 },
{ :onblur => "remote_function('#members-#{member.id}-roles-form');", :id =>"membership[role_ids][]", :name => "membership[role_ids][]", :style => "border:1px solid #e5e5e5;"}) %>
<% end %>
</th>
<th>
<% unless member.user_id == @project.user_id %>
<a href="javascript:void(0);" class=" sy_btn_blue mr5 " onclick="$('#members-<%= member.id%>-roles-form').show();$('#members_<%= member.id %>_role_show').hide();">编辑</a>
<%= delete_link membership_path(member),
:remote => true,
:class => "sy_btn_grey mr5",
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_for_project_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %>
<% end %>
</th>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
</div>
<%= error_messages_for 'member' %>
<script type="text/javascript">
$(document).ready(function () {
var collection=$("#principals_for_new_member").children("#principals").children("label");
collection.css("text-overflow","ellipsis");
collection.css("white-space","nowrap");
collection.css("width","200px");
collection.css("overflow","hidden");
for(i=0;i<collection.length;i++){ //增加悬浮显示
var label=collection[i];
var text=$(label).text();
$(label).attr("title",text);
}
});
function add_member(){
$("#add_members_id").show();
}
function hidden_add_member(){
$("#add_members_id").hide();
}
function add_members_submit(){
$("#new_membership").submit();
}
function remote_function(id) {
$(id).submit();
}
</script>