summaryrefslogtreecommitdiffstats
path: root/app/helpers/watchers_helper.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-04-05 12:09:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-04-05 12:09:15 +0000
commite3dae9ddbf46353df67a1cc155de6b05a58bfa35 (patch)
tree2b9ceda31b34dac2d53743c2eb405a503e68306a /app/helpers/watchers_helper.rb
parent1af6527e427bcfeba189eac10c3642fa177dfa6e (diff)
downloadredmine-e3dae9ddbf46353df67a1cc155de6b05a58bfa35.tar.gz
redmine-e3dae9ddbf46353df67a1cc155de6b05a58bfa35.zip
Cleaner way to handle the replacement of watch links (#8071).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5320 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/watchers_helper.rb')
-rw-r--r--app/helpers/watchers_helper.rb29
1 files changed, 12 insertions, 17 deletions
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 2695ce9f6..e0010d834 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006-2007 Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -16,28 +16,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module WatchersHelper
-
- # Valid options
- # * :id - the element id
- # * :replace - a string or array of element ids that will be
- # replaced
- def watcher_tag(object, user, options={:replace => 'watcher'})
- id = options[:id]
- id ||= options[:replace] if options[:replace].is_a? String
- content_tag("span", watcher_link(object, user, options), :id => id)
+
+ def watcher_tag(object, user, options={})
+ content_tag("span", watcher_link(object, user), :class => watcher_css(object))
end
- # Valid options
- # * :replace - a string or array of element ids that will be
- # replaced
- def watcher_link(object, user, options={:replace => 'watcher'})
+ def watcher_link(object, user)
return '' unless user && user.logged? && object.respond_to?('watched_by?')
watched = object.watched_by?(user)
url = {:controller => 'watchers',
:action => (watched ? 'unwatch' : 'watch'),
:object_type => object.class.to_s.underscore,
- :object_id => object.id,
- :replace => options[:replace]}
+ :object_id => object.id}
link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
{:url => url},
:href => url_for(url),
@@ -45,6 +35,11 @@ module WatchersHelper
end
+ # Returns the css class used to identify watch links for a given +object+
+ def watcher_css(object)
+ "#{object.class.to_s.underscore}-#{object.id}-watcher"
+ end
+
# Returns a comma separated list of users watching the given object
def watchers_list(object)
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)