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

298 lines
13 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.

<%= 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_user_header member.principal, true %></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 },
{ :onchange=>"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' %>
<%
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="members_left">
<% if members.any? %>
<ul style=" border-bottom:none;">
<li><span class="w140_h f_b" ><%= l(:label_user) %></span><span class="w180_h f_b"><%= l(:label_role_plural) %></span><span></span></li>
<%= call_hook(:view_projects_settings_members_table_header, :project => @project) %>
<% members.each do |member| %>
<li >
<%= link_to_user_header member.principal, true, :class => "w140_h c_setting_blue fl" %>
<span class="w180_h fl">
<!--区分中英文角色显示的不同-->
<% 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 %>
<%= h zh_roles.sort.reverse.collect(&:to_s).join(', ') %>
<% else %>
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
<% end %>
<%= 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;" >
<%= 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? } %>
<!--编辑时候显示成员,中英文切换后面需从数据库的角度优化-->
<% if User.current.language == "zh" %>
<% if role.id == 3 %>
<label >管理人员</label>
<% elsif role.id == 4 %>
<label >开发人员</label>
<% else %>
<label >报告人员</label>
<% end %>
<% else %>
<label ><%= h role %></label>
<% end %>
</ul>
<!--<br/>-->
<% end %>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
<div class="pt5">
<a href="javascript:void(0)" class="project_member_btn" onclick="$('#member-<%= member.id%>-roles-form').submit();" style="margin-right: 10px;">
<%= l(:button_change)%>
</a>
<a href="javascript:void(0)" class="project_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.user_id == @project.user_id %>
<a href="javascript:void(0) " class="c_setting_blue ml30 fl" onclick="$('#member-<%= member.id%>-roles-form').show();$(this).parent().height(110);">编辑</a>
<%= delete_link membership_path(member),
:remote => true,
:class => "c_setting_blue ml15 fl",
: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%>
</li>
<% end%>
</ul>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
</div><!-- left -->
<!--right begin-->
<% if roles.any? %>
<div class="members_right">
<!-- applied -->
<div class="cl"></div>
<!-- add members -->
<p class="c_blue fb mt10 mb5"><%= l(:label_member_new) %></p>
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
<div class="member_search">
<input id="principal_search" class="member_search_input fl" type="text" placeholder="<%= "l(:label_invite_trustie_user_tips)"%>">
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
<div class="cl"></div>
<div id="principals_for_new_member">
<%= render_project_members(@project) %>
</div>
<div class="cl"></div>
<ul class="rolebox mb10 mt10">
<li class="fb">
<%= l(:label_role_plural) %>
</li>
<% roles.each do |role| %>
<li class="clear">
<%= radio_button_tag 'membership[role_ids][]', role.id, role.name == "报告人员" || role.name == "Reporter" %>
<% if User.current.language == "zh" %>
<% if role.id == 3 %>
<label >管理人员</label>
<% elsif role.id == 4 %>
<label >开发人员</label>
<% else %>
<label >报告人员</label>
<% end %>
<% else %>
<label ><%= h role %></label>
<% end %>
</li>
<% end %>
</ul>
<div class="cl mb10"></div>
<a href="javascript:void(0)" class="project_member_btn_right" onclick="$(this).parent().parent().submit();">
新增成员
</a>
</div>
<% end%>
</div><!-- 右边 end-->
<% end %>
<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>