项目资源统计代码优化

This commit is contained in:
huang 2015-05-27 10:43:03 +08:00
parent 1919292c58
commit 5af284e8a4
5 changed files with 56 additions and 64 deletions

View File

@ -130,7 +130,7 @@ class IssuesController < ApplicationController
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
respond_to do |format|
respond_to do |format|``
format.html {
retrieve_previous_and_next_issue_ids
render :template => 'issues/show', :layout => @project_base_tag#by young

View File

@ -18,54 +18,7 @@
<!-- page specific tags -->
<%= yield :header_tags -%>
<!--项目的三种类型-->
<script type="text/javascript">
function click_ok(url)
{
$('#light').css('display','none');
$('#fade').css('display','none');
//ajax处理请求
var project_type;
if($("#development_group").attr("checked") == "checked"){
project_type = 1;
}
else if($("#research_group").attr("checked") == "checked"){
project_type = 2;
}
else if($("#friend_organization").attr("checked") == "checked"){
project_type = 3;
}
$.get(
url,
{ project_type: project_type},
function (data) {
if(data == 1)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_development_team), 1))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/development_group')) %>');
$("#close_light").attr("onClick","close_window('development_group');");
}
else if(data == 2)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_research_group), 2))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/research_team')) %>');
$("#close_light").attr("onClick","close_window('research_group');");
}
else if(data == 3)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_friend_organization), 3))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/friend_group')) %>');
$("#close_light").attr("onClick","close_window('friend_organization');");
}
else
{
alert("服务器异常,请与管理员联系");
}
}
);
}
</script>
</head>
<!--add by huang-->
<body>
@ -83,13 +36,7 @@
</h2>
<p class="hidden">
<%= l(:label_user_location) %> :
<%= link_to l(:field_homepage), home_path %>
>
<a href="http://<%= Setting.host_name %>">
<%=l(:label_project_hosting_platform) %>
</a>
>
<%= link_to @project.name, project_path(@project.id) %>
<%= link_to l(:field_homepage), home_path %> > <a href="http://<%= Setting.host_name %>"><%=l(:label_project_hosting_platform) %> </a>><%= link_to @project.name, project_path(@project.id) %>
</p>
</div>
<div class="search fl">
@ -144,10 +91,11 @@
<%= l(:label_member) %><%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue' %>
<span>|&nbsp;</span>
<%= l(:label_user_watcher) %><%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'info_foot_num c_blue' %>
<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<span>|&nbsp;</span>
<%= l(:project_module_attachments) %>
<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
<% attaments_num %>
<%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue' %></span>
<% end %>
</div>
@ -166,14 +114,14 @@
</ul>
<% end %><!--end-->
<!--menu 左侧工具栏 -->
<!--project_new_type: 1为开发组2为科研组3为朋友圈子-->
<%#--project_new_type: 1为开发组2为科研组3为朋友圈子--%>
<div id="project_memu_list">
<% if @project.project_new_type == 1 || @project.project_new_type.nil? %>
<%= render :partial => 'projects/development_group', :locals => {:project => @project}%>
<%= render :partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num} %>
<% elsif @project.project_new_type == 2 %>
<%= render :partial => 'projects/research_team', :locals => {:project => @project}%>
<%= render :partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num} %>
<% else %>
<%= render :partial => 'projects/friend_group', :locals => {:project => @project}%>
<%= render :partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num} %>
<% end %>
</div>
<!-- end -->
@ -232,8 +180,55 @@
<li><input type="radio" name="project_type" <%= @project.project_new_type == 3 ? 'checked' : ''%> id="friend_organization"/><label class="f14">&nbsp;&nbsp;圈子模式:<span class="f12 ml5 c_grey">为朋友圈提供简洁的交流和分享工具。</span></label></li>
</ul>
<a href="javascript:void(0)" class="orange_btn" onclick="click_ok('<%= change_project_type_project_path @project%>');" >确定</a>
</div>
<!--项目的三种类型-->
<script type="text/javascript">
function click_ok(url)
{
$('#light').css('display','none');
$('#fade').css('display','none');
//ajax处理请求
var project_type;
if($("#development_group").attr("checked") == "checked"){
project_type = 1;
}
else if($("#research_group").attr("checked") == "checked"){
project_type = 2;
}
else if($("#friend_organization").attr("checked") == "checked"){
project_type = 3;
}
$.get(
url,
{ project_type: project_type},
function (data) {
if(data == 1)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_development_team), 1))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num})) %>');
$("#close_light").attr("onClick","close_window('development_group');");
}
else if(data == 2)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_research_group), 2))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num})) %>');
$("#close_light").attr("onClick","close_window('research_group');");
}
else if(data == 3)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_friend_organization), 3))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num})) %>');
$("#close_light").attr("onClick","close_window('friend_organization');");
}
else
{
alert("服务器异常,请与管理员联系");
}
}
);
}
</script>
</div>
<div id="fade" class="black_overlay">123</div>
<%= render :partial => 'layouts/new_feedback' %>

View File

@ -1,4 +1,3 @@
<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>

View File

@ -1,4 +1,3 @@
<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>

View File

@ -1,4 +1,3 @@
<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>