点击tag之后的索引功能.
This commit is contained in:
parent
344e51105a
commit
825b1e7fd7
|
@ -8,6 +8,7 @@ class TagsController < ApplicationController
|
|||
include IssuesHelper
|
||||
include UsersHelper
|
||||
include BidsHelper
|
||||
include ForumsHelper
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
helper :projects
|
||||
include TagsHelper
|
||||
|
@ -56,7 +57,8 @@ class TagsController < ApplicationController
|
|||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
@bids_results,
|
||||
@forums_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
|
||||
|
||||
# 这里是做tag推荐用的, 用来生产推荐的tags
|
||||
unless @obj.nil?
|
||||
|
@ -83,7 +85,8 @@ class TagsController < ApplicationController
|
|||
@obj,@obj_pages,@users_results,
|
||||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results = refresh_results(@obj_id,@show_flag)
|
||||
@bids_results,
|
||||
@forums_results = refresh_results(@obj_id,@show_flag)
|
||||
end
|
||||
|
||||
# 删除已选tag
|
||||
|
@ -98,7 +101,8 @@ class TagsController < ApplicationController
|
|||
@obj,@obj_pages,@results_count,@users_results,
|
||||
@projects_results,
|
||||
@issues_results,
|
||||
@bids_results = refresh_results(@obj_id,@show_flag)
|
||||
@bids_results,
|
||||
@forums_results = refresh_results(@obj_id,@show_flag)
|
||||
end
|
||||
|
||||
def show_all
|
||||
|
@ -161,6 +165,7 @@ private
|
|||
@projects_results = nil
|
||||
@issues_results = nil
|
||||
@bids_results = nil
|
||||
@forums_results = nil
|
||||
@obj_pages = nil
|
||||
@obj = nil
|
||||
|
||||
|
@ -176,12 +181,15 @@ private
|
|||
@obj = Issue.find_by_id(obj_id)
|
||||
@obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags))
|
||||
when '4' then
|
||||
@obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
|
||||
@obj = Bid.find_by_id(obj_id)
|
||||
@obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
|
||||
@obj = Bid.find_by_id(obj_id)
|
||||
when '5'
|
||||
@obj = Forum.find_by_id(obj_id)
|
||||
@obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags))
|
||||
else
|
||||
@obj = nil
|
||||
end
|
||||
return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results
|
||||
return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results,@forums_results
|
||||
end
|
||||
|
||||
def for_pagination(results)
|
||||
|
|
|
@ -1,128 +1,128 @@
|
|||
#enconding:utf-8
|
||||
# fq
|
||||
module BidsHelper
|
||||
|
||||
def render_notes(bid, journal, options={})
|
||||
content = ''
|
||||
removable = User.current == journal.user || User.current == bid.author
|
||||
links = []
|
||||
if !journal.notes.blank?
|
||||
links << link_to(image_tag('comment.png'),
|
||||
{:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal},
|
||||
:remote => true,
|
||||
:method => 'post',
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
if removable
|
||||
url = {:controller => 'bids',
|
||||
:action => 'destroy',
|
||||
:object_id => journal,
|
||||
:id => bid}
|
||||
links << ' '
|
||||
links << link_to(image_tag('delete.png'), url,
|
||||
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
|
||||
end
|
||||
end
|
||||
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||
content << textilizable(journal.notes)
|
||||
css_classes = "wiki"
|
||||
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||
end
|
||||
|
||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
||||
link_to text, '#', options.merge(:onclick => onclick)
|
||||
end
|
||||
|
||||
# this method is used to get all projects that tagged one tag
|
||||
# added by william
|
||||
def get_bids_by_tag(tag_name)
|
||||
Bid.tagged_with(tag_name).order('updated_on desc')
|
||||
end
|
||||
|
||||
#added by huang
|
||||
def sort_bid_enterprise(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs_enterprise")
|
||||
end
|
||||
#end
|
||||
|
||||
def sort_bid(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
|
||||
#huang
|
||||
def sort_contest(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1')))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0')))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
#end
|
||||
|
||||
def course_options_for_select(courses)
|
||||
# <option value = '0'>#{l(:label_choose_reward)}</option>
|
||||
html = ''
|
||||
courses.each do |course|
|
||||
html << "<option value = #{course.id}>"
|
||||
html << course.name
|
||||
html << "</option>"
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
# used to get the reward and handle the value which can be used to display in views
|
||||
# added by william
|
||||
def get_prize(b_project)
|
||||
b_project.get_reward
|
||||
end
|
||||
|
||||
def count_bid_project
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@projects = []
|
||||
for bid in bids
|
||||
@projects += bid.biding_projects
|
||||
end
|
||||
@projects.count
|
||||
end
|
||||
|
||||
def count_bid_user
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@users = []
|
||||
for bid in bids
|
||||
for project in bid.projects
|
||||
@users += project.users
|
||||
end
|
||||
end
|
||||
@users.count
|
||||
end
|
||||
#enconding:utf-8
|
||||
# fq
|
||||
module BidsHelper
|
||||
|
||||
def render_notes(bid, journal, options={})
|
||||
content = ''
|
||||
removable = User.current == journal.user || User.current == bid.author
|
||||
links = []
|
||||
if !journal.notes.blank?
|
||||
links << link_to(image_tag('comment.png'),
|
||||
{:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal},
|
||||
:remote => true,
|
||||
:method => 'post',
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
if removable
|
||||
url = {:controller => 'bids',
|
||||
:action => 'destroy',
|
||||
:object_id => journal,
|
||||
:id => bid}
|
||||
links << ' '
|
||||
links << link_to(image_tag('delete.png'), url,
|
||||
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
|
||||
end
|
||||
end
|
||||
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||
content << textilizable(journal.notes)
|
||||
css_classes = "wiki"
|
||||
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||
end
|
||||
|
||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
||||
link_to text, '#', options.merge(:onclick => onclick)
|
||||
end
|
||||
|
||||
# this method is used to get all projects that tagged one tag
|
||||
# added by william
|
||||
def get_bids_by_tag(tag_name)
|
||||
Bid.tagged_with(tag_name).order('updated_on desc')
|
||||
end
|
||||
|
||||
#added by huang
|
||||
def sort_bid_enterprise(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs_enterprise")
|
||||
end
|
||||
#end
|
||||
|
||||
def sort_bid(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
|
||||
#huang
|
||||
def sort_contest(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1')))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0')))
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
#end
|
||||
|
||||
def course_options_for_select(courses)
|
||||
# <option value = '0'>#{l(:label_choose_reward)}</option>
|
||||
html = ''
|
||||
courses.each do |course|
|
||||
html << "<option value = #{course.id}>"
|
||||
html << course.name
|
||||
html << "</option>"
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
|
||||
# used to get the reward and handle the value which can be used to display in views
|
||||
# added by william
|
||||
def get_prize(b_project)
|
||||
b_project.get_reward
|
||||
end
|
||||
|
||||
def count_bid_project
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@projects = []
|
||||
for bid in bids
|
||||
@projects += bid.biding_projects
|
||||
end
|
||||
@projects.count
|
||||
end
|
||||
|
||||
def count_bid_user
|
||||
bids = Bid.where('parent_id = ?', @bid.id)
|
||||
@users = []
|
||||
for bid in bids
|
||||
for project in bid.projects
|
||||
@users += project.users
|
||||
end
|
||||
end
|
||||
@users.count
|
||||
end
|
||||
end
|
|
@ -19,4 +19,10 @@ module ForumsHelper
|
|||
end
|
||||
options
|
||||
end
|
||||
|
||||
# this method is used to get all projects that tagged one tag
|
||||
# added by william
|
||||
def get_forums_by_tag(tag_name)
|
||||
Forum.tagged_with(tag_name).order('updated_at desc')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div id="issues">
|
||||
<% if forums_results.size > 0 %>
|
||||
<hr />
|
||||
<% forums_results.each do |forum| %>
|
||||
<p class="font_description2">
|
||||
<strong><%= l(:label_tags_forum) %>:<%= link_to "#{forum.name}",
|
||||
:controller => "forums",:action => "show",:id => forum.id %></strong>
|
||||
<br />
|
||||
<strong><%= l(:label_tags_forum_description) %>:</strong><%= forum.description %>
|
||||
<%= forum.updated_at %>
|
||||
</p>
|
||||
<div class="line_under"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -7,4 +7,6 @@
|
|||
(<%= Issue.tagged_with("#{sg}").size %>)
|
||||
<% when '4' then %>
|
||||
(<%= Bid.tagged_with("#{sg}").size %>)
|
||||
<% when '5' then %>
|
||||
(<%= Forum.tagged_with("#{sg}").size %>)
|
||||
<% end %>
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<% when show_flag == '4'%>
|
||||
<strong><%= l(:label_requirement)%>(<%= @results_count %>)</strong>
|
||||
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
|
||||
<% when show_flag == '5'%>
|
||||
<strong><%= l(:label_forum)%>(<%= @results_count %>)</strong>
|
||||
<%= render :partial => "show_forums",:locals => {:forums_results => forums_results}%>
|
||||
<% else %>
|
||||
<strong><%= l(:label_tags_all_objects)%></strong>
|
||||
<!-- 这里为显示搜有过滤结果预留了默认设置 -->
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<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,:show_flag => @obj_flag}%>
|
||||
:bids_results=>@bids_results,:forums_results => @forums_results, :show_flag => @obj_flag}%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1571,6 +1571,9 @@ en:
|
|||
label_memo_new: new memo
|
||||
label_memo_edit: edit memo
|
||||
label_project_module_forums: Forums
|
||||
label_forum: Forum
|
||||
label_tags_forum_description: Forum description
|
||||
label_tags_forum: Call forum
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1735,3 +1735,6 @@ zh:
|
|||
label_borad_project: 项目讨论区
|
||||
label_borad_course: 课程讨论区
|
||||
label_memo_new_from_forum: 发布帖子
|
||||
label_forum: 讨论区
|
||||
label_tags_forum_description: 讨论区描述
|
||||
label_tags_forum: 讨论区名称
|
||||
|
|
Loading…
Reference in New Issue