diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-10 10:31:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-02-10 10:31:12 +0000 |
commit | 856ef810b4854c5524843f7f4f69157b6223bfc7 (patch) | |
tree | 7a70dadf59232d6f1ba565033b9f20ef937527be /app/helpers | |
parent | 7303cc416c4e60658b6ea9af7d620c3f6c24066b (diff) | |
download | redmine-856ef810b4854c5524843f7f4f69157b6223bfc7.tar.gz redmine-856ef810b4854c5524843f7f4f69157b6223bfc7.zip |
Bulk watch/unwatch issues from the context menu (#7159).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11339 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/watchers_helper.rb | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 5b3b1b7b4..3c27fc02d 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -24,21 +24,28 @@ module WatchersHelper watcher_link(object, user) end - def watcher_link(object, user) - return '' unless user && user.logged? && object.respond_to?('watched_by?') - watched = object.watched_by?(user) - css = [watcher_css(object), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') - url = {:controller => 'watchers', - :action => (watched ? 'unwatch' : 'watch'), - :object_type => object.class.to_s.underscore, - :object_id => object.id} - link_to((watched ? l(:button_unwatch) : l(:button_watch)), url, - :remote => true, :method => 'post', :class => css) + def watcher_link(objects, user) + return '' unless user && user.logged? + 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(' ') + text = watched ? l(:button_unwatch) : l(:button_watch) + url = { + :controller => 'watchers', + :action => (watched ? 'unwatch' : 'watch'), + :object_type => objects.first.class.to_s.underscore, + :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) + } + + link_to text, url, :remote => true, :method => 'post', :class => css 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" + def watcher_css(objects) + objects = Array.wrap(objects) + id = (objects.size == 1 ? objects.first.id : 'bulk') + "#{objects.first.class.to_s.underscore}-#{id}-watcher" end # Returns a comma separated list of users watching the given object |