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

178 lines
8.2 KiB
Plaintext
Raw Normal View History

2015-04-14 10:23:49 +08:00
<%= 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
2015-04-14 10:23:49 +08:00
else
roles = roles[0..2]
end
members = @project.member_principals.includes(:roles, :principal).all.sort
%>
<div class="members_left">
2015-04-14 10:23:49 +08:00
<% if members.any? %>
2015-04-17 13:49:40 +08:00
<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>
2015-04-14 10:23:49 +08:00
<%= call_hook(:view_projects_settings_members_table_header, :project => @project) %>
<% members.each do |member| %>
2015-04-14 11:47:47 +08:00
<li >
<%= link_to_user_header member.principal,false,:class => "w140_h c_setting_blue fl" %>
<span class="w180_h fl">
2015-05-08 09:12:27 +08:00
<!--区分中英文角色显示的不同-->
<% 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 %>
2015-04-29 16:46:34 +08:00
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
2015-04-17 13:49:40 +08:00
) do |f| %>
2015-04-29 16:46:34 +08:00
<% roles.each do |role| %>
<ul style="text-align: left;" >
<%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
2015-04-14 11:47:47 +08:00
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %>
2015-05-08 09:12:27 +08:00
<!--编辑时候显示成员,中英文切换后面需从数据库的角度优化-->
<% 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 %>
2015-04-14 10:23:49 +08:00
</ul>
<!--<br/>-->
2015-04-29 16:46:34 +08:00
<% end %>
2015-04-17 13:49:40 +08:00
<%= 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;">
2015-04-17 13:49:40 +08:00
<%= 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)">
2015-04-17 13:49:40 +08:00
<%= l(:button_cancel)%>
</a>
</div>
2015-04-14 10:23:49 +08:00
<% end %>
2015-04-29 16:46:34 +08:00
</span>
2015-04-17 13:49:40 +08:00
<% 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>
2015-04-17 13:49:40 +08:00
<%= delete_link membership_path(member),
:remote => true,
:class => "c_setting_blue ml15 fl",
2015-04-17 13:49:40 +08:00
: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>
2015-04-14 11:47:47 +08:00
<% end%>
2015-04-17 13:49:40 +08:00
</ul>
2015-04-14 10:23:49 +08:00
<% else %>
2015-04-17 13:49:40 +08:00
<p class="nodata"><%= l(:label_no_data) %></p>
2015-04-14 10:23:49 +08:00
<% end %>
</div><!-- left -->
<!--right begin-->
<% if roles.any? %>
2015-04-17 13:49:40 +08:00
<div class="members_right">
<!-- applied -->
<% if @project.applied_projects.any? %>
<div class="members_jion">
<p class="c_blue mb10 fb"><%= l(:label_apply_project) %></p>
<%= form_for(@applied_members, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
<div id="principals_for_applied_member">
<%= render_principals_for_applied_members_new(@project) %>
</div>
<ul class="mb10">
<li><%= l(:label_role_plural) %>:</li>
<% roles.each do |role| %>
<li>
<%= check_box_tag 'membership[role_ids][]', role.id %>
<label ><%= h role %></label >
2015-04-17 13:49:40 +08:00
</li>
<% end %>
</ul>
<a remote="true" href="javascript:void(0)" class="blue_btn fl" onclick="$('#new_membership').submit();">
<%= l(:label_approve) %>
</a>
<a remote="true" href="javascript:void(0)" class="grey_btn fl ml10" onclick="refusal_applied_member();">
<%= l(:label_refusal) %>
</a>
<% end %>
<div class="cl"></div>
</div>
<% end %><!--members_jion end-->
<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">
2015-05-06 15:01:26 +08:00
<input id="principal_search" class="member_search_input fl" type="text" placeholder="<%= l(:label_invite_trustie_user_tips)%>">
2015-04-17 13:49:40 +08:00
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
<div class="cl"></div>
2015-04-14 11:47:47 +08:00
2015-04-17 13:49:40 +08:00
<div id="principals_for_new_member">
<%= render_project_members(@project) %>
2015-04-17 13:49:40 +08:00
</div>
<div class="cl"></div>
2015-04-14 11:47:47 +08:00
2015-04-17 13:49:40 +08:00
<ul class="rolebox mb10 mt10">
<li class="fb">
<%= l(:label_role_plural) %>
2015-04-14 11:47:47 +08:00
</li>
2015-04-17 13:49:40 +08:00
<% roles.each do |role| %>
<li>
<%= radio_button_tag 'membership[role_ids][]', role.id %>
2015-05-08 09:12:27 +08:00
<% if User.current.language == "zh" %>
<% if role.id == 3 %>
2015-05-08 09:28:01 +08:00
<label >管理人员</label>
2015-05-08 09:12:27 +08:00
<% elsif role.id == 4 %>
<label >开发人员</label>
<% else %>
<label >报告人员</label>
<% end %>
<% else %>
<label ><%= h role %></label>
<% end %>
2015-04-17 13:49:40 +08:00
</li>
<% end %>
</ul>
<div class="cl mb10"></div>
<a href="javascript:void(0)" class="project_member_btn_right" onclick="$(this).parent().parent().submit();">
2015-04-17 13:49:40 +08:00
新增成员
</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);
}
});
</script>