项目配置成员界面

This commit is contained in:
daiao 2016-10-13 16:57:43 +08:00
parent 07b98bae5e
commit 5ae89613ec
4 changed files with 131 additions and 6 deletions

View File

@ -998,7 +998,7 @@ module ApplicationHelper
def project_member_check_box_tags_ex name, principals
s = ''
principals.each do |principal|
s << "<li>#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_url_in_org( principal.id)}</li>\n"
s << "<li class='mb5'>#{ check_box_tag name, principal.id, false, :id => nil} #{h link_to principal.userInfo, user_url_in_org( principal.id)}</li>\n"
end
s.html_safe
end

View File

@ -38,9 +38,9 @@ module MembersHelper
scope = []
end
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'pro_new_idlist fl', :id => 'principals')
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js', :class=>"fl pro_new_idname")), :remote => true
}
s + content_tag('ul', links,:class => 'wlist', :id => "course_member_pagination_links" )
end

View File

@ -1,3 +1,122 @@
<%= 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 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 %>
<%= h zh_roles.sort.reverse.collect(&:to_s).join(', ') %>
<% else %>
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
<% end %></th>
<th>
<% unless member.user_id == @project.user_id %>
<a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</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 %>
<% if roles.any? %>
<a href="javascript:void(0);" class="fl sy_btn_green mb10" onclick="add_member();">添加成员</a>
<% end %>
</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>
<div class="clear mb10" id="principals_for_new_member">
<ul class="pro_new_idlist fl">
<%= render_project_members(@project) %>
</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>
<a href="javascript:void(0);" class="fr sy_btn_grey ">取消</a>
<a href="javascript:void(0);" class="fr sy_btn_blue mr5" onclick="add_members_submit()">保存</a>
<%end%>
</div>
<%= error_messages_for 'member' %>
<%
roles = Role.givable.all
@ -97,7 +216,7 @@
<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)%>">
<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>
@ -149,4 +268,10 @@
$(label).attr("title",text);
}
});
function add_member(){
$("#add_members_id").show();
}
function add_members_submit(){
$("#new_membership").submit();
}
</script>

View File

@ -885,7 +885,7 @@ a:hover.btn_newpro_grey,a:active.btn_newpro_grey{ background: #eaeaea;}
.pro_new_setting_leftnav ul li a{ display: block; height: 40px; line-height: 40px; border-bottom:3px solid #fff; text-align: center; width:162px;}
.pro_new_setting_leftnav ul li a:hover,.pro_new_setting_leftnav .active{ color: #3b94d6; background: #f3faff; }
.pro_new_setting_conbox{ background: #fff; width: 818px; border:1px solid #ddd; padding-top: 15px;}
.pro_new_setting_conbox input,.pro_new_setting_conbox select{ border:1px solid #c8c8c8; height: 28px; color: #888;}
.pro_new_setting_conbox input,.pro_new_setting_conbox select{ border:1px solid #c8c8c8; color: #888;}
.pro_new_setting_conbox label{width: 100px; text-align: right; display: inline-block;}
.w690{width: 690px; }
.pro_new_upimg{ width: 60px; height: 58px; border:1px solid #ddd; padding:1px;}
@ -911,4 +911,4 @@ a:hover.btn_newpro_grey,a:active.btn_newpro_grey{ background: #eaeaea;}
.pro_newsetting_con p,.pro_newsetting_con { line-height: 30px;}
.w650{ width: 650px;}
.pro_new_prompt{ border:1px solid #f6d0b1; padding:10px; background: #fff9e9; color: #ee4a20; text-align: center;}
p.pro_new_grey{ line-height: 1.9; }
p.pro_new_grey{ line-height: 1.9; }