Mercurial > hg > soundsoftware-site
diff app/helpers/.svn/text-base/watchers_helper.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 513646585e45 |
children |
line wrap: on
line diff
--- a/app/helpers/.svn/text-base/watchers_helper.rb.svn-base Thu Mar 03 11:42:28 2011 +0000 +++ b/app/helpers/.svn/text-base/watchers_helper.rb.svn-base Mon Jun 06 14:24:13 2011 +0100 @@ -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 @@ 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)