添加写project_status和user_status两表的方法,

在关注中写这2个表,
重构了tag的过滤方法,
拿掉了user_extension.rb.
This commit is contained in:
william 2013-08-27 11:27:25 +08:00
parent c7beefa556
commit 0c22d409fc
24 changed files with 222 additions and 161 deletions

View File

@ -14,71 +14,28 @@ class TagsController < ApplicationController
$selected_tags = Array.new $selected_tags = Array.new
$related_tags = Array.new $related_tags = Array.new
@@numbers = Setting.tags_show_search_results
def index def index
$selected_tags = [] $selected_tags = []
$related_tags = [] $related_tags = []
$selected_tags << params[:q] $selected_tags << params[:q]
@issues_tags_num = Issue.tag_counts.size @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num = get_tags_size
@projects_tags_num = Project.tag_counts.size
@users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
@users_results = nil
@projects_results = nil
@issues_results = nil
@bids_results = nil
@obj_pages = nil
@obj_id = params[:obj_id] @obj_id = params[:obj_id]
@obj_flag = params[:object_flag] @obj_flag = params[:object_flag]
@numbers = Setting.tags_show_search_results
# 获取搜索结果
case @obj_flag @obj,@obj_pages,@users_results,
when '1' then @projects_results,
@users_results = get_users_by_tag($selected_tags) @issues_results,
@obj = User.find_by_id(@obj_id) @bids_results,
@obj_pages = refresh_results(@obj_id,@obj_flag)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then
@projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
when '3' then
@issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
@bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all
else
@obj = nil
end
# 这里是做tag推荐用的 用来生产推荐的tag
unless @obj.nil? unless @obj.nil?
@tags = @obj.tag_list @tags = @obj.tag_list
$selected_tags.each do |i| $selected_tags.each do |i|
@ -91,35 +48,44 @@ class TagsController < ApplicationController
end end
# 增加已选的tag
def add_tag def add_tag
@tag = params[:tag] @tag = params[:tag]
@show_flag = params[:show_flag] @show_flag = params[:show_flag]
$selected_tags << @tag $selected_tags << @tag
$related_tags.delete(@tag) $related_tags.delete(@tag)
@obj_pages = nil # # 获取搜索结果
@numbers = Setting.tags_show_search_results # @obj,@obj_pages,@users_results,
# @projects_results,
# @issues_results,
# @bids_results,
# @obj_pages = refresh_results(@obj_id,@show_flag)
# @issues_results = get_issues_by_tag($selected_tags)
# @projects_results = get_projects_by_tag($selected_tags)
# @users_results = get_users_by_tag($selected_tags)
case @show_flag case @show_flag
when '1' then when '1' then
@users_results = get_users_by_tag($selected_tags) @users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id) @obj = User.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @users_results.count @project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@users_results = @users_results.offset(@offset).limit(@limit).all @users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then when '2' then
@projects_results = get_projects_by_tag($selected_tags) @projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id) @obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @projects_results.count @project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all @projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
@ -127,44 +93,49 @@ class TagsController < ApplicationController
@issues_results = get_issues_by_tag($selected_tags) @issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id) @obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @issues_results.count @project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all @issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
when '4' then
@bids_results = get_bids_by_tag($selected_tags) @bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id) @obj = Bid.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @bids_results.count @project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all @bids_results = @bids_results.offset(@offset).limit(@limit)
else else
@obj = nil @obj = nil
end end
end end
# 删除已选tag
def delete_tag def delete_tag
@tag = params[:tag] @tag = params[:tag]
@show_flag = params[:show_flag] @show_flag = params[:show_flag]
$related_tags << @tag $related_tags << @tag
$selected_tags.delete(@tag) $selected_tags.delete(@tag)
@obj_pages = nil @obj_pages = nil
@numbers = Setting.tags_show_search_results
# @issues_results = get_issues_by_tag($selected_tags)
# @projects_results = get_projects_by_tag($selected_tags)
# @users_results = get_users_by_tag($selected_tags)
case @show_flag case @show_flag
when '1' then when '1' then
@users_results = get_users_by_tag($selected_tags) @users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id) @obj = User.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @users_results.count @project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@ -173,7 +144,7 @@ class TagsController < ApplicationController
@projects_results = get_projects_by_tag($selected_tags) @projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id) @obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @projects_results.count @project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@ -183,20 +154,26 @@ class TagsController < ApplicationController
@issues_results = get_issues_by_tag($selected_tags) @issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id) @obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers}) @offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @issues_results.count @project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page'] @obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset @offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all @issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4' when '4'
@bids_results = get_bids_by_tag($selected_tags) @obj_pages,@bids_results = for_pagination(get_bids_by_tag($selected_tags))
# @bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id) @obj = Bid.find_by_id(@obj_id)
#
# @offset, @limit = api_offset_and_limit({:limit => @@numbers})
# @project_count = @bids_results.count
# @obj_pages = Paginator.new @project_count, @limit, params['page']
# @offset ||= @obj_pages.offset
# @bids_results = @bids_results.offset(@offset).limit(@limit).all
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all
else else
@obj = nil @obj = nil
@ -209,22 +186,13 @@ class TagsController < ApplicationController
def show_all def show_all
@tags = ActsAsTaggableOn::Tag.find(:all) @tags = ActsAsTaggableOn::Tag.find(:all)
end end
def for_pagination(results)
@offset, @limit = api_offset_and_limit({:limit => 2})
@project_count = results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
results = results.offset(@offset).limit(@limit).order('lft').all
end
#完全从数据库删除tag
def delete def delete
if params[:q] if params[:q]
@tag = ActsAsTaggableOn::Tag.find_by_id(params[:q]) @tag = ActsAsTaggableOn::Tag.find_by_id(params[:q])
@tag.delete @tag.delete
@taggings = ActsAsTaggableOn::Tagging.find_all_by_tag_id(@tag.id) @taggings = ActsAsTaggableOn::Tagging.find_all_by_tag_id(@tag.id)
@taggings.each do |tagging| @taggings.each do |tagging|
tagging.delete tagging.delete
end end
@ -238,4 +206,51 @@ private
end end
# 这里用来刷新搜索结果的区域
# 函数的返回值 前2字段用来处理获取其他tag和分页 另外4个返回值为过滤结果
def refresh_results(obj_id,obj_flag)
@users_results = nil
@projects_results = nil
@issues_results = nil
@bids_results = nil
@obj_pages = nil
@obj = nil
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
case obj_flag
when '1' then
@obj = User.find_by_id(obj_id)
@obj_pages,@users_results = for_pagination(get_users_by_tag($selected_tags))
when '2' then
@obj = Project.find_by_id(obj_id)
@obj_pages,@projects_results = for_pagination(get_projects_by_tag($selected_tags))
when '3' then
@obj = Issue.find_by_id(obj_id)
@obj_pages,@issues_results = for_pagination(get_issues_by_tag($selected_tags))
when '4' then
@obj_pages,@bids_results = for_pagination(get_bids_by_tag($selected_tags))
@obj = Bid.find_by_id(obj_id)
else
@obj = nil
end
return @obj,@obj_pages,@users_results,@projects_results,@issues_results,@bids_results
end
def for_pagination(results)
@offset, @limit = api_offset_and_limit({:limit => 3}) # 设置每页显示的个数
@results_count = results.count
@obj_pages = Paginator.new @results_count, @limit, params['page']
@offset ||= @obj_pages.offset
results = results.offset(@offset).limit(@limit).all # 这里默认设置为按时间排序
return @obj_pages,results
end
#获取有某类对象的tag总数
def get_tags_size
@issues_tags_num = Issue.tag_counts.size
@projects_tags_num = Project.tag_counts.size
@users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num
end
end end

View File

@ -14,10 +14,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WatchersController < ApplicationController class WatchersController < ApplicationController
before_filter :require_login, :find_watchables, :only => [:watch, :unwatch] before_filter :require_login, :find_watchables, :only => [:watch, :unwatch]
def watch def watch
set_watcher(@watchables, User.current, true) set_watcher(@watchables, User.current, true)
end end
@ -86,7 +84,7 @@ class WatchersController < ApplicationController
end end
rescue rescue
render_404 render_404
end end
def find_watchables def find_watchables
klass = Object.const_get(params[:object_type].camelcase) rescue nil klass = Object.const_get(params[:object_type].camelcase) rescue nil
@ -100,7 +98,27 @@ class WatchersController < ApplicationController
def set_watcher(watchables, user, watching) def set_watcher(watchables, user, watching)
watchables.each do |watchable| watchables.each do |watchable|
watchable.set_watcher(user, watching) watchable.set_watcher(user, watching)
@user = watchable # added by william # @user = watchable # added by william
if watching
# 修改 user和project的状态
if watchable.instance_of?(User)
#写user_statuses表
watchable.user_status.update_watchers_count(1)
elsif watchable.instance_of?(Project)
#写project_statuese表
watchable.project_status.update_watchers_count(1)
end
else
# 修改 user和project的状态
if watchable.instance_of?(User)
#写user_statuses表
watchable.user_status.update_watchers_count(-1)
elsif watchable.instance_of?(Project)
#写project_statuese表 :project_status
watchable.project_status.update_watchers_count(-1)
end
end
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}

View File

@ -34,7 +34,7 @@ module BidsHelper
# this method is used to get all projects that tagged one tag # this method is used to get all projects that tagged one tag
# added by william # added by william
def get_bids_by_tag(tag_name) def get_bids_by_tag(tag_name)
Bid.tagged_with(tag_name) Bid.tagged_with(tag_name).order('updated_on desc')
end end
end end

View File

@ -33,7 +33,7 @@ module GroupsHelper
s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals') s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options| links = pagination_links_full(principal_pages, principal_count, :per_page_links => false){|text, parameters, options|
link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
} }

View File

@ -377,7 +377,7 @@ module IssuesHelper
# this method is used to get all projects that tagged one tag # this method is used to get all projects that tagged one tag
# added by william # added by william
def get_issues_by_tag(tag_name) def get_issues_by_tag(tag_name)
Issue.tagged_with(tag_name) Issue.tagged_with(tag_name).order('updated_on desc')
end end
end end

View File

@ -21,7 +21,7 @@ module MembersHelper
def render_principals_for_new_members(project) def render_principals_for_new_members(project)
scope = Principal.active.sorted.not_member_of(project).like(params[:q]) scope = Principal.active.sorted.not_member_of(project).like(params[:q])
principal_count = scope.count principal_count = scope.count
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']#by young principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
s = content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals') s = content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals')

View File

@ -85,7 +85,7 @@ module ProjectsHelper
# this method is used to get all projects that tagged one tag # this method is used to get all projects that tagged one tag
# added by william # added by william
def get_projects_by_tag(tag_name) def get_projects_by_tag(tag_name)
Project.tagged_with(tag_name) Project.tagged_with(tag_name).order('updated_on desc')
end end
end end

View File

@ -58,7 +58,7 @@ module UsersHelper
# this method is used to get all projects that tagged one tag # this method is used to get all projects that tagged one tag
# added by william # added by william
def get_users_by_tag(tag_name) def get_users_by_tag(tag_name)
User.tagged_with(tag_name) User.tagged_with(tag_name).order('updated_on desc')
end end
# added by fq # added by fq

View File

@ -56,6 +56,8 @@ class Project < ActiveRecord::Base
# end # end
#ADDED BY NIE #ADDED BY NIE
has_many :project_infos, :dependent => :destroy has_many :project_infos, :dependent => :destroy
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
#end #end
has_one :wiki, :dependent => :destroy has_one :wiki, :dependent => :destroy
# Custom field for the project issues # Custom field for the project issues
@ -81,10 +83,10 @@ class Project < ActiveRecord::Base
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}}, :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
:author => nil :author => nil
############################added by william ############################added by william
acts_as_taggable acts_as_taggable
scope :by_join_date, order("created_at DESC") scope :by_join_date, order("created_on DESC")
###################added by liuping 关注 ###################added by liuping 关注
acts_as_watchable acts_as_watchable
attr_protected :status attr_protected :status

View File

@ -0,0 +1,21 @@
class ProjectStatus < ActiveRecord::Base
attr_accessible :changesets_count, :watchers_count, :project_id
belongs_to :projects
belongs_to :watchers
belongs_to :changesets
validates_presence_of :project_id
validates_uniqueness_of :project_id
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
# 删除用户时 此表创建人员未作相应删除动作
def update_watchers_count(num)
if self.watchers_count >= 0
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
end
end
end

View File

@ -89,6 +89,7 @@ class User < Principal
######added by nie ######added by nie
has_many :project_infos, :dependent => :destroy has_many :project_infos, :dependent => :destroy
has_one :user_status, :dependent => :destroy
##### #####
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") } scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
@ -99,10 +100,10 @@ class User < Principal
acts_as_customizable acts_as_customizable
############################added by william ############################added by william
acts_as_taggable acts_as_taggable
scope :by_join_date, order("created_at DESC") scope :by_join_date, order("created_on DESC")
############################# added by liuping 关注 ############################# added by liuping 关注
acts_as_watchable acts_as_watchable
has_one :user_extensions has_one :user_extensions,:dependent => :destroy
## end ## end
attr_accessor :password, :password_confirmation attr_accessor :password, :password_confirmation

View File

@ -1,11 +0,0 @@
class UserExtension < ActiveRecord::Base
attr_accessible :birthday, :brief_introduction, :fans_num, :finish_project_num, :follow_num, :gender, :good_num, :location, :occupation, :publish_requirement_num, :user_id, :work_experience, :zip_code
belongs_to :user
validate :validate_user
def validate_user
errors.add :user_id, :invalid if user.nil? || !user.active? || User.current != user_id
end
end

20
app/models/user_status.rb Normal file
View File

@ -0,0 +1,20 @@
class UserStatus < ActiveRecord::Base
attr_accessible :changesets_count, :user_id, :watchers_count
belongs_to :users
belongs_to :watchers
belongs_to :changesets
validates_presence_of :user_id
validates_uniqueness_of :user_id
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
# 删除用户时 此表创建人员未作相应删除动作
def update_watchers_count(num)
if self.watchers_count >= 0
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
end
end
end

View File

@ -69,7 +69,7 @@
<%= render :partial => 'users/preferences' %></div> <%= render :partial => 'users/preferences' %></div>
</fieldset> </fieldset>
<!-- added by william --> <!-- added by william -->
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;display: none;"> <fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;display: none">
<legend onclick="toggleFieldset(this);"> <legend onclick="toggleFieldset(this);">
<%= l(:label_user_extensions)%> <%= l(:label_user_extensions)%>
</legend> </legend>

View File

@ -6,10 +6,7 @@
<span id="tag"> <span id="tag">
<%= rt %> <%= rt %>
</span> </span>
<% @issue_size = Issue.tagged_with("#{rt}").size %> <%= render :partial => 'sidebar_tags',:locals => {:show_flag => show_flag,:sg => rt }%>
<% @project_size = Project.tagged_with(rt).size %>
<% @user_size = User.tagged_with("#{rt}").size %>
(<%= @user_size + @project_size + @issue_size %>)
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -2,12 +2,10 @@
<ul style="list-style-type: none"> <ul style="list-style-type: none">
<% for sg in selected_tags %> <% for sg in selected_tags %>
<li> <li>
<%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",:remote=>true,:tag => sg,:show_flag => show_flag %> <%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",
:remote=>true,:tag => sg,:show_flag => show_flag %>
<span id="tag"><%= sg %> </span> <span id="tag"><%= sg %> </span>
<% @issue_size = Issue.tagged_with("#{sg}").size %> <%= render :partial => 'sidebar_tags',:locals => {:show_flag => show_flag,:sg => sg }%>
<% @project_size = Project.tagged_with(sg).size %>
<% @user_size = User.tagged_with("#{sg}").size %>
(<%= @user_size + @project_size + @issue_size %>)
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -6,6 +6,7 @@
<strong><%= l(:label_tags_bid) %>:<%= link_to "#{bid.name}",:controller => "bids",:action => "show",:id => bid.id %></strong> <strong><%= l(:label_tags_bid) %>:<%= link_to "#{bid.name}",:controller => "bids",:action => "show",:id => bid.id %></strong>
<br /> <br />
<strong><%= l(:label_tags_bid_description) %>:</strong><%= bid.description %> <strong><%= l(:label_tags_bid_description) %>:</strong><%= bid.description %>
<%= bid.updated_on %>
</p> </p>
<div class="line_under"></div> <div class="line_under"></div>
<% end %> <% end %>

View File

@ -39,7 +39,5 @@
<% else %> <% else %>
<div><%= l(:label_tags_no) %></div> <div><%= l(:label_tags_no) %></div>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -15,16 +15,14 @@
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%> <%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% else %> <% else %>
<strong><%= l(:label_tags_all_objects)%></strong> <strong><%= l(:label_tags_all_objects)%></strong>
<!-- 这里为显示搜有过滤结果预留了默认设置 -->
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%> <%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
<%= render :partial => "show_users",:locals => {:users_results => users_results }%> <%= render :partial => "show_users",:locals => {:users_results => users_results }%>
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%> <%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% end %> <% end %>
<% else %> <% else %>
<span>no data.</span> <span>no data.</span>
<% end %> <% end %>
</ul> </ul>
<div class="pagination" style="float:right;">
<ul>
<%= pagination_links_full @obj_pages %>
<ul>
</div>

View File

@ -4,6 +4,7 @@ $('#related_tags').html('<%= j(render :partial => "related_tags",
:locals => {:related_tags => $related_tags ,:show_flag => @show_flag })%>') :locals => {:related_tags => $related_tags ,:show_flag => @show_flag })%>')
$('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results, $('#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 })%>') :projects_results => @projects_results,:users_results => @users_results,
:bids_results => @bids_results ,:show_flag => @show_flag,:obj_pages => @obj_pages })%>')

View File

@ -4,5 +4,7 @@ $('#related_tags').html('<%= j(render :partial => "related_tags",
:locals => {:related_tags => $related_tags,:show_flag => @show_flag })%>') :locals => {:related_tags => $related_tags,:show_flag => @show_flag })%>')
$('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results, $('#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 })%>') :projects_results => @projects_results,:users_results => @users_results,
:bids_results => @bids_results ,:show_flag => @show_flag ,:obj_pages => @obj_pages })%>')

View File

@ -1,14 +1,14 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<div> <div>
<h3><strong><%= l(:label_tags_selected) %></strong></h3> <h3><strong><%= l(:label_tags_selected) %></strong></h3>
<div id="selected_tags"> <div id="selected_tags">
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%> <%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
</div> </div>
<h3><strong><%= l(:label_tags_related) %></strong></h3> <h3><strong><%= l(:label_tags_related) %></strong></h3>
<div id="related_tags"> <div id="related_tags">
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%> <%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
</div> </div>
</div> </div>
<% end %> <% end %>
<% content_for :content do %> <% content_for :content do %>
@ -16,15 +16,18 @@
<h3><strong><%= l(:label_tags_search_result) %></strong></h3> <h3><strong><%= l(:label_tags_search_result) %></strong></h3>
<div align="right"> <div align="right">
<%= l(:label_tags_numbers) %> <%= l(:label_tags_numbers) %>
<%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)| <%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)|
<%= l(:label_project_plural) %>(<%= @projects_tags_num %>)| <%= l(:label_project_plural) %>(<%= @projects_tags_num %>)|
<%= l(:label_user_plural) %>(<%= @users_tags_num %>)| <%= l(:label_user_plural) %>(<%= @users_tags_num %>)|
<%= l(:label_tags_call)%>(<%= @bids_tags_num %>) <%= l(:label_tags_call)%>(<%= @bids_tags_num %>)
</div> </div>
<div id="show_results"> <div id="show_results">
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_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}%> :projects_results => @projects_results,:users_results => @users_results ,
</div> :bids_results=>@bids_results,:show_flag => @obj_flag}%>
</div>
</div> </div>
<%= render :partial => "pagination",:locals => {:obj_pages => @obj_pages}%>
<% end %> <% end %>

View File

@ -5,7 +5,7 @@
<div id="show_all_tags"> <div id="show_all_tags">
<% for tag in @tags %> <% for tag in @tags %>
<span id="tag" class="tag<%= tag.id %>"> <span id="tag" class="tag<%= tag.id %>">
<%= link_to tag.name,:remote=>true,:action=>"delete",:q => tag.id%> <%= link_to tag.name,:remote=>true,:action=>"delete",:q => tag.id,:confirm => "Are you Sure?"%>
</span> </span>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,5 +1,2 @@
<% selector = ".#{watcher_css(watched)}" %> <% selector = ".#{watcher_css(watched)}" %>
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")}); $("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
$('#fans_num').html('<%= j(render :partial => "/watchers/fans_num",:locals => {:fans_num => get_fans_num(@user) }
) %>');