项目配置页面冗余代码清理

This commit is contained in:
huang 2016-10-24 15:42:57 +08:00
parent d385123a93
commit 38d30c1cca
4 changed files with 5 additions and 223 deletions

View File

@ -133,143 +133,6 @@
<%= error_messages_for 'member' %> <%= 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"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
var collection=$("#principals_for_new_member").children("#principals").children("label"); var collection=$("#principals_for_new_member").children("#principals").children("label");

View File

@ -8,7 +8,6 @@
</li> </li>
<% end %> <% end %>
<li class="clear "> <li class="clear ">
<input class="fl mt8" type="checkbox">
<p class="fl ml5"><%= check_all_links('modules-form').html_safe %></p> <p class="fl ml5"><%= check_all_links('modules-form').html_safe %></p>
</li> </li>
<% end %> <% end %>

View File

@ -8,89 +8,6 @@
$("#pro_st_edit_ban").toggle(); $("#pro_st_edit_ban").toggle();
} }
</script> </script>
<% if @project.shared_versions.any? %>
<table class="pro_table">
<tbody>
<tr class="pro_table_tit">
<td class="w150"><%= l(:label_version) %></td>
<td class="w90" > <%= l(:field_effective_date) %></td>
<td class="w150"><%= l(:field_description) %> </td>
<td class="w90"><%= l(:field_status) %></td>
<!--<td class="w90"><%#= l(:field_sharing) %></td>-->
<!--<td class="w150"><%#= l(:label_wiki_page) %></td>-->
<td class="w150"></td>
</tr>
<% for version in @project.shared_versions.sort %>
<tr class="<%= cycle 'pro_table_on', '' %>">
<td class="tl">
<a class="c_blue02"><%= 'shared' if version.project != @project %> <%= link_to_version version %></a>
</td>
<td class=""><%= format_date(version.effective_date) %></td>
<td class="tl" style="word-break:break-all;"><%=h version.description %></td>
<td class="status"><%= l("version_status_#{version.status}") %></td>
<!--<td class="sharing"><%#=h format_version_sharing(version.sharing) %></td>-->
<!--<td class="tl" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="">-->
<%#= link_to_if_authorized(h(truncate(version.wiki_page_title,:length=>20)), {:controller => 'wiki',
# :action => 'show',
# :project_id => version.project,
:id => Wiki.titleize(version.wiki_page_title)},:class=>"c_blue02") || h(version.wiki_page_title) unless version.wiki_page_title.blank? || version.project.wiki.nil? %>
<!--</td>-->
<td >
<% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %>
<%= link_to l(:button_edit), edit_version_path(version), :class => 'c_purple' %></a>
<a href="/versions/1" class=" c_purple" data-confirm="您确定要删除吗?" ><%= delete_link_version version_path(version) %></a>
<% end %>
</td>
</tr>
<% end; reset_cycle %>
</tbody>
<% else %>
<p class="nodata">
<%= l(:label_no_data) %>
</p>
<% end %>
</table>
<% if @project.versions.any? %>
<%= link_to l(:label_close_versions), close_completed_project_versions_path(@project), :method => :put, :class =>"c_orange fr" %>
<% end %>
<a href="javascript:viod(0)" class="pic_add fl mr5" onclick="pro_st_show_ban();"></a>
<%= link_to l(:label_version_new),"#", :class => 'c_blue fl',:onclick=>"pro_st_show_ban();" if User.current.allowed_to?(:manage_versions, @project) %>
<div class="cl"></div>
<%= form_for :version, :url => project_versions_path(@project),:html=>{:id=>"new_project_version_form"} do |f| %>
<div id="pro_st_edit_ban" class="pro_st_edit_ban">
<ul>
<li >
<label class="label02"><span class="c_red">*</span><%=l(:field_name)%></label>
<%= f.text_field :name, :maxlength => 60 %>
</li>
<li >
<label class="label02"><%=l(:label_version_description)%></label>
<%= f.text_field :description, :maxlength => 60 %>
</li>
<li >
<label class="label02"><%=l(:field_status)%></label>
<%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]} %>
</li>
<!--<li >-->
<!--<label class="label02"><%#=l(:label_wiki_page)%></label>-->
<!--<%#= f.text_field :wiki_page_title, :size =>60, :label => :label_wiki_page, :disabled => @project.wiki.nil? %>-->
<!--</li>-->
<li >
<label class="label02"><%=l(:field_deadline)%></label>
<%= f.text_field :effective_date, :size => 10, :readonly => true,:class=>" fl" %>
<%= calendar_for('version_effective_date') %>
</li>
<div class="cl mb10"></div>
<!--<li >-->
<!--<label class="label02"><%#=l(:field_sharing)%></label>-->
<!--<%#= f.select :sharing, @project.versions.build.allowed_sharings.collect {|v| [format_version_sharing(v), v]} %>-->
<!--</li>-->
<a href="#" onclick="$('#new_project_version_form').submit();" class="blue_btn ml110"><%=l(:button_save)%></a>
</ul>
</div>
<% end %>
<% if @project.shared_versions.empty? %> <% if @project.shared_versions.empty? %>
<div class="pro_new_prompt ml15 mr15 mb10"><p><%= l(:milestone_no_data) %></p></div> <div class="pro_new_prompt ml15 mr15 mb10"><p><%= l(:milestone_no_data) %></p></div>

View File

@ -2,8 +2,11 @@
<div class="clear new_roadmap_listbox"> <div class="clear new_roadmap_listbox">
<div class="clear"> <div class="clear">
<h4 class="fl new_roadmap_listtitle"><%= link_to_version version, :name => version_anchor(version) %></h4><span class="fl <%= get_version_type(version.status) %> mt3 ml5"></span> <h4 class="fl new_roadmap_listtitle"><%= link_to_version version, :name => version_anchor(version) %></h4><span class="fl <%= get_version_type(version.status) %> mt3 ml5"></span>
<%= link_to "导出", version_path(version, :format => 'xls'), :class => "btn_newpro_grey fr" %> <%= link_to "导出Issue", version_path(version, :format => 'xls'), :class => "btn_newpro_grey fr" %>
<a href="javascript:void(0);" class="roadmap_icons_del fr mt5 mr5" alt="删除"></a> <%= delete_version_link version_path(version, :back_url => url_for(:controller => 'versions',
:action => 'index',
:project_id => version.project)),
:class=>'roadmap_icons_del fr mt5 mr5' if User.current.allowed_to?(:manage_versions, version.project) %>
<a href="javascript:void(0);" class="roadmap_icons_edit fr mt5 " alt="编辑"></a> <a href="javascript:void(0);" class="roadmap_icons_edit fr mt5 " alt="编辑"></a>
</div> </div>
<ul class="new_roadmap_list_txt clear mb5"> <ul class="new_roadmap_list_txt clear mb5">