调整了参赛应用列表布局显示样式
This commit is contained in:
parent
484d334c3c
commit
6421f02ac8
|
@ -11,6 +11,7 @@ class TagsController < ApplicationController
|
|||
include BidsHelper
|
||||
include ForumsHelper
|
||||
include AttachmentsHelper
|
||||
include ContestsHelper
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
helper :projects
|
||||
include TagsHelper
|
||||
|
@ -30,7 +31,7 @@ class TagsController < ApplicationController
|
|||
# 最后是2个过滤何种数据,显示结果的控制参数params[:obj_id],params[:object_falg]
|
||||
# 0代表删除tag 1代表增加tag
|
||||
def index
|
||||
|
||||
|
||||
@obj_id = params[:obj_id]
|
||||
@obj_flag = params[:object_flag]
|
||||
|
||||
|
@ -44,28 +45,29 @@ class TagsController < ApplicationController
|
|||
@tag = params[:tag]
|
||||
@selected_tags = params[:current_selected_tags]
|
||||
@selected_tags = @selected_tags.nil? ? Array.new : @selected_tags
|
||||
|
||||
|
||||
case @do_what
|
||||
when '0' then
|
||||
@selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop
|
||||
@selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop
|
||||
when '1' then
|
||||
# 判断是否已存在该tag 主要用来处理分页的情况
|
||||
unless @selected_tags.include? @tag
|
||||
@selected_tags << @tag
|
||||
end
|
||||
# 判断是否已存在该tag 主要用来处理分页的情况
|
||||
unless @selected_tags.include? @tag
|
||||
@selected_tags << @tag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num,
|
||||
|
||||
@users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num,@contests_tags_num,
|
||||
@forum_tags_num, @attachments_tags_num = get_tags_size
|
||||
|
||||
|
||||
# 获取搜索结果
|
||||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
@attachments_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
@attachments_results,
|
||||
@contests_tags = refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
|
||||
# 这里是做tag推荐用的, 用来生产推荐的tags
|
||||
unless @obj.nil?
|
||||
|
@ -74,13 +76,13 @@ class TagsController < ApplicationController
|
|||
# @selected_tags.each do |i|
|
||||
# @tags.delete(i)
|
||||
# end
|
||||
@related_tags = @tags
|
||||
@related_tags = @tags
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
# 增加已选的tag
|
||||
def add_tag
|
||||
@tag = params[:tag]
|
||||
|
@ -90,11 +92,13 @@ class TagsController < ApplicationController
|
|||
$related_tags.delete(@tag)
|
||||
|
||||
# 获取搜索结果
|
||||
@obj,@obj_pages,@users_results,
|
||||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results = refresh_results(@obj_id,@show_flag)
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results = refresh_results(@obj_id,@show_flag)
|
||||
end
|
||||
|
||||
# 删除已选tag
|
||||
|
@ -110,13 +114,15 @@ class TagsController < ApplicationController
|
|||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results = refresh_results(@obj_id,@show_flag)
|
||||
@forums_results,
|
||||
@attachments_results,
|
||||
@contests_results = refresh_results(@obj_id,@show_flag)
|
||||
end
|
||||
|
||||
def show_all
|
||||
@tags = ActsAsTaggableOn::Tag.find(:all)
|
||||
@tags = ActsAsTaggableOn::Tag.find(:all)
|
||||
end
|
||||
|
||||
|
||||
# 完全从数据库删除tag
|
||||
# 这种删除方式是针对 印有该 tag所有对象来做删除的
|
||||
# 这样是从整个系统数据库中把该tag删除了
|
||||
|
@ -149,24 +155,24 @@ class TagsController < ApplicationController
|
|||
|
||||
# if can_remove_tag?(User.current,@taggable_id,@taggable_type)
|
||||
|
||||
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
|
||||
|
||||
unless @taggings.nil?
|
||||
@taggings.delete
|
||||
end
|
||||
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
|
||||
|
||||
unless @taggings.nil?
|
||||
@taggings.delete
|
||||
end
|
||||
|
||||
# 是否还有其他记录 引用了 tag_id
|
||||
@tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
|
||||
@tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
|
||||
# 如果taggings表中记录已经不存在 ,那么检查tags表 作删除动作
|
||||
if @tagging.nil?
|
||||
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
|
||||
@tag.delete unless @tag.nil?
|
||||
end
|
||||
if @tagging.nil?
|
||||
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
|
||||
@tag.delete unless @tag.nil?
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
# 这里用来刷新搜索结果的区域
|
||||
# 函数的返回值 前2字段用来处理获取其他tag和分页 ,另外4个返回值为过滤结果
|
||||
def refresh_results(obj_id,obj_flag,selected_tags)
|
||||
|
@ -174,11 +180,12 @@ private
|
|||
@projects_results = nil
|
||||
@issues_results = nil
|
||||
@bids_results = nil
|
||||
@contests_results = nil
|
||||
@forums_results = nil
|
||||
attachments_results = nil
|
||||
@obj_pages = nil
|
||||
@obj = nil
|
||||
|
||||
|
||||
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
||||
case obj_flag
|
||||
when '1' then
|
||||
|
@ -199,10 +206,22 @@ private
|
|||
when '6'
|
||||
@obj = Attachment.find_by_id(obj_id)
|
||||
@obj_pages, attachments_results, @results_count = for_pagination(get_attachments_by_tag(selected_tags))
|
||||
when '7'
|
||||
@obj = Contest.find_by_id(obj_id)
|
||||
@obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags))
|
||||
else
|
||||
@obj = nil
|
||||
@obj = nil
|
||||
end
|
||||
return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results,@forums_results, attachments_results
|
||||
return [@obj,
|
||||
@obj_pages,
|
||||
@results_count,
|
||||
@users_results,
|
||||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results,
|
||||
@forums_results,
|
||||
attachments_results,
|
||||
@contests_results]
|
||||
end
|
||||
|
||||
def for_pagination(results)
|
||||
|
@ -222,7 +241,8 @@ private
|
|||
@bids_tags_num = Bid.tag_counts.size
|
||||
forum_tags_num = Forum.tag_counts.size
|
||||
attachment_tags_num = Attachment.tag_counts.size
|
||||
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num
|
||||
@contests_tags_num = Contest.tag_counts.size
|
||||
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num
|
||||
end
|
||||
|
||||
# 通过数字 来转换出对象的类型
|
||||
|
@ -243,6 +263,8 @@ private
|
|||
return 'Forum'
|
||||
when '6'
|
||||
return 'Attachment'
|
||||
when '7'
|
||||
return 'Contest'
|
||||
else
|
||||
render_error :message => e.message
|
||||
return
|
||||
|
|
|
@ -653,6 +653,8 @@ class UsersController < ApplicationController
|
|||
@obj = Forum.find_by_id(@obj_id)
|
||||
when '6'
|
||||
@obj = Attachment.find_by_id(@obj_id)
|
||||
when '7' then
|
||||
@obj = Contest.find_by_id(@obj_id)
|
||||
else
|
||||
@obj = nil
|
||||
end
|
||||
|
|
|
@ -5,15 +5,17 @@ module TagsHelper
|
|||
@obj = nil
|
||||
case obj_type
|
||||
when '1'
|
||||
@obj = User.find_by_id(obj_id)
|
||||
@obj = User.find_by_id(obj_id)
|
||||
when '2'
|
||||
@obj = Project.find_by_id(obj_id)
|
||||
when '3'
|
||||
@obj = Issue.find_by_id(obj_id)
|
||||
when '4'
|
||||
@obj = Bid.find_by_id(obj_id)
|
||||
@obj = Bid.find_by_id(obj_id)
|
||||
when '6'
|
||||
@obj = Attachment.find_by_id(obj_id)
|
||||
when '7'
|
||||
@obj= Contest.find_by_id(obj_id)
|
||||
else
|
||||
raise Exception, '[TagsHelper] ===> tag type unknow.'
|
||||
end
|
||||
|
@ -40,6 +42,10 @@ module TagsHelper
|
|||
if user.id == obj_id
|
||||
@result = true
|
||||
end
|
||||
when '7'
|
||||
if user.id == obj_id
|
||||
@result = true
|
||||
end
|
||||
end
|
||||
return @result
|
||||
end
|
||||
|
|
|
@ -1,41 +1,35 @@
|
|||
|
||||
<% contesting_softapplication.each do |c_softapplication|%>
|
||||
<% if c_softapplication.softapplication %>
|
||||
<table width="90%" border="0" align='center'>
|
||||
<div style="padding-left: 18px">
|
||||
<div style="font-size: 15px">
|
||||
<tr>
|
||||
<td><strong>应用软件:</strong></td>
|
||||
<td>
|
||||
<%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
|
||||
</td>
|
||||
</tr></br>
|
||||
</div>
|
||||
<div style="padding-left: 68px">
|
||||
<tr>
|
||||
<td>简介:</td>
|
||||
<td>
|
||||
<table width="660px" border="0" align='center'>
|
||||
<tr>
|
||||
|
||||
<td width="65%" valign="top">
|
||||
<table width="100%" valign="top" align="left">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50%">
|
||||
<strong>
|
||||
<%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
|
||||
</strong>
|
||||
<span class="font_lighter"><%= l(:label_joined_contest)%></span>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="50%" style=" word-wrap: break-word; word-break: break-all"><%= c_softapplication.softapplication.description %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><span class="font_lighter">
|
||||
<%=format_time c_softapplication.created_at %>
|
||||
</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<%= c_softapplication.softapplication.description %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</tr></br>
|
||||
</div>
|
||||
<div style="padding-left: 68px; padding-bottom: 8px">
|
||||
<tr>
|
||||
<td>发布时间:</td>
|
||||
<td>
|
||||
<%=format_time c_softapplication.created_at %>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="underline-contests_three"></div>
|
||||
<% end %>
|
||||
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<td width="85%">
|
||||
<div class='icon icon-add'> <!--标注我要参加及添加图标-->
|
||||
|
||||
<%= link_to(l(:button_contesting_as_application), {:controller => 'softapplications', :action => 'new'}) %>
|
||||
<%= link_to l(:button_contesting_as_application), "javascript:void(0);", onclick: "$('#put-bid-form').toggle();" %>
|
||||
</div>
|
||||
</td>
|
||||
<% end %>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<% if User.current.logged? %>
|
||||
<!--我要以发布应用的形式参加竞赛-弹出框-->
|
||||
<div id = 'flash' style="float:left; width: 100%; display: nonea" ></div>
|
||||
<div id="put-bid-form" style="display: nonea">
|
||||
<div id="put-bid-form" style="display: none">
|
||||
<%= form_for "contest_for_save", :remote=>true, :url => {:controller => 'contests', :action => 'add_softapplication'}, :update => "contesting_softapplication_list", :complete => '$("#put-bid-form").hide();' do |f| %>
|
||||
<table id="contesting_table" border="0" width="100%" style="margin-left: 40px;"> <!--该table为点击我要参加后弹出的-->
|
||||
<tr>
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
<table style="font-family:微软雅黑">
|
||||
<tr>
|
||||
<td>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @contest, :object_flag => "4"}%>
|
||||
<%= render :partial => 'tags/tag', :locals => {:obj => @contest, :object_flag => "7"}%>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
<div class="underline-contests_one"></div>
|
||||
|
||||
<div style="height: 120px">
|
||||
<div style="height: 50px">
|
||||
<div style="font-size: 15px"><strong>软件评论:</strong></div>
|
||||
<div></div>
|
||||
</div>
|
||||
|
@ -78,6 +78,5 @@
|
|||
|
||||
|
||||
<div>
|
||||
<%= link_to 'Edit', edit_softapplication_path(@softapplication) %> |
|
||||
<%= link_to 'Back', softapplications_path %>
|
||||
<%#= link_to '返回竞赛页面', show_softapplication_contest_path(contest)) %>
|
||||
</div>
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
(<%= Bid.tagged_with("#{sg}").size %>)
|
||||
<% when '5' then %>
|
||||
(<%= Forum.tagged_with("#{sg}").size %>)
|
||||
|
||||
<% when '6' then %>
|
||||
(<%= Attachment.tagged_with("#{sg}").size %>)
|
||||
<% end %>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
4 代表是bid类型
|
||||
5 代表是forum类型
|
||||
6 代表是Attachment类型
|
||||
|
||||
7 代表是contest类型
|
||||
#end%>
|
||||
<!-- 3 代表的是issue 当是issue是 处理方式与前2个对象不同 -->
|
||||
<% if object_flag == '3' %>
|
||||
|
|
|
@ -79,6 +79,13 @@
|
|||
<span class='del'> <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag,
|
||||
:taggable_id => obj.id,:taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
<% when '7'%>
|
||||
<% if obj.author_id == User.current.id %>
|
||||
|
||||
<span class='del'> <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag,
|
||||
:taggable_id => obj.id,:taggable_type => object_flag %> </span>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
<% when show_flag == '6'%>
|
||||
<strong><%= l(:label_attachment)%>(<%= @results_count %>)</strong>
|
||||
<%= render :partial => "show_attachments",:locals => {:attachments_results => attachments_results}%>
|
||||
<% when show_flag == '7'%>
|
||||
<strong><%= l(:label_contest_innovate)%>(<%= @results_count %>)</strong>
|
||||
<%= render :partial => "show_contests",:locals => {:contests_results => contests_results}%>
|
||||
<% else %>
|
||||
<strong><%= l(:label_tags_all_objects)%></strong>
|
||||
<!-- 这里为显示搜有过滤结果预留了默认设置 -->
|
||||
|
@ -26,6 +29,7 @@
|
|||
<%= render :partial => "show_users",:locals => {:users_results => users_results }%>
|
||||
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
|
||||
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
|
||||
<%= render :partial => "show_contests",:locals => {:contests_results => contests_results}%>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
|
|
|
@ -5,6 +5,6 @@ $('#related_tags').html('<%= j(render :partial => "related_tags",
|
|||
|
||||
$('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
||||
:projects_results => @projects_results,:users_results => @users_results,
|
||||
:bids_results => @bids_results ,:show_flag => @show_flag,:obj_pages => @obj_pages })%>')
|
||||
:bids_results => @bids_results,:contests_results => @contests_results,:show_flag => @show_flag,:obj_pages => @obj_pages })%>')
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@ $('#related_tags').html('<%= j(render :partial => "related_tags",
|
|||
|
||||
$('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
||||
:projects_results => @projects_results,:users_results => @users_results,
|
||||
:bids_results => @bids_results ,:show_flag => @show_flag ,:obj_pages => @obj_pages })%>')
|
||||
:bids_results => @bids_results ,:contests_results => @contests_results ,:show_flag => @show_flag ,:obj_pages => @obj_pages })%>')
|
||||
|
||||
|
||||
|
|
|
@ -23,12 +23,20 @@
|
|||
<%= l(:label_user_plural) %>(<%= @users_tags_num %>) |
|
||||
<%= l(:label_tags_call)%>(<%= @bids_tags_num %>) |
|
||||
<%= l(:field_filename)%>(<%= @attachments_tags_num %>)
|
||||
<%= l(:label_tags_contest)%>(<%= @contests_tags_num %>) |
|
||||
</div>
|
||||
<div id="show_results">
|
||||
<%# 求工厂模式重构 %>
|
||||
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
||||
:projects_results => @projects_results,:users_results => @users_results ,
|
||||
:bids_results=>@bids_results,:forums_results => @forums_results, :attachments_results => @attachments_results, :show_flag => @obj_flag}%>
|
||||
<%= render :partial => "tag_search_results",
|
||||
:locals => {:issues_results => @issues_results,
|
||||
:projects_results => @projects_results,
|
||||
:users_results => @users_results,
|
||||
:bids_results => @bids_results,
|
||||
:forums_results => @forums_results,
|
||||
:attachments_results=> @attachments_results,
|
||||
:contests_results => @contests_results,
|
||||
:show_flag => @obj_flag}
|
||||
%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1844,4 +1844,8 @@ zh:
|
|||
label_contest_description_no: 暂无描述。
|
||||
label_no_contest_softapplication: 暂无参赛应用
|
||||
label_button_ok: 确定
|
||||
label_tags_contest: 竞赛标签
|
||||
label_tags_contest: 竞赛名称
|
||||
label_tags_contest_description: 竞赛描述
|
||||
|
||||
|
|
@ -2721,7 +2721,11 @@ div.repos_explain{
|
|||
border-bottom: 1px dashed rgb(204, 204, 204);
|
||||
width: 660px;
|
||||
}
|
||||
|
||||
.underline-contests_three{
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px dashed rgb(204, 204, 204);
|
||||
width: 688px;
|
||||
}
|
||||
.contest-star{
|
||||
color: #bb0000;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue