diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 64a50fd7a..a068fe398 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -50,7 +50,7 @@ class ProjectsController < ApplicationController helper :members helper :activities helper :documents - helper :watchers + helper :watchers # Lists visible projects diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 264b5870c..052c3fd25 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -30,9 +30,11 @@ module WatchersHelper objects = Array.wrap(objects) watched = objects.any? {|object| object.watched_by?(user)} - css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid))) + css = @watch_flag ? ([watcher_css(objects), watched ? 'icon' : 'icon'].join(' ')) : + ([watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')) - text = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid))) ? + text = @watch_flag ? (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) url = watch_path( @@ -40,7 +42,7 @@ module WatchersHelper :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) ) method = watched ? 'delete' : 'post' - + link_to text, url, :remote => true, :method => method, :class => css end diff --git a/app/models/project.rb b/app/models/project.rb index 7cc3100e7..6c1be04af 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -79,7 +79,7 @@ class Project < ActiveRecord::Base ############################added by william acts_as_taggable - ###################added by liuping 关注 + ###################added by liuping 关注 acts_as_watchable attr_protected :status diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index 6cc8282e8..6cd867f83 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -84,13 +84,7 @@ <% end -%> - - - - - - - +