##// END OF EJS Templates
remove trailing white-spaces from app/helpers/watchers_helper.rb....
Toshi MARUYAMA -
r6800:42aac56a5582
parent child
Show More
@@ -1,64 +1,64
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module WatchersHelper
18 module WatchersHelper
19
19
20 def watcher_tag(object, user, options={})
20 def watcher_tag(object, user, options={})
21 content_tag("span", watcher_link(object, user), :class => watcher_css(object))
21 content_tag("span", watcher_link(object, user), :class => watcher_css(object))
22 end
22 end
23
23
24 def watcher_link(object, user)
24 def watcher_link(object, user)
25 return '' unless user && user.logged? && object.respond_to?('watched_by?')
25 return '' unless user && user.logged? && object.respond_to?('watched_by?')
26 watched = object.watched_by?(user)
26 watched = object.watched_by?(user)
27 url = {:controller => 'watchers',
27 url = {:controller => 'watchers',
28 :action => (watched ? 'unwatch' : 'watch'),
28 :action => (watched ? 'unwatch' : 'watch'),
29 :object_type => object.class.to_s.underscore,
29 :object_type => object.class.to_s.underscore,
30 :object_id => object.id}
30 :object_id => object.id}
31 link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
31 link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)),
32 {:url => url},
32 {:url => url},
33 :href => url_for(url),
33 :href => url_for(url),
34 :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
34 :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off'))
35
35
36 end
36 end
37
37
38 # Returns the css class used to identify watch links for a given +object+
38 # Returns the css class used to identify watch links for a given +object+
39 def watcher_css(object)
39 def watcher_css(object)
40 "#{object.class.to_s.underscore}-#{object.id}-watcher"
40 "#{object.class.to_s.underscore}-#{object.id}-watcher"
41 end
41 end
42
42
43 # Returns a comma separated list of users watching the given object
43 # Returns a comma separated list of users watching the given object
44 def watchers_list(object)
44 def watchers_list(object)
45 remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
45 remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
46 lis = object.watcher_users.collect do |user|
46 lis = object.watcher_users.collect do |user|
47 s = avatar(user, :size => "16").to_s + link_to_user(user, :class => 'user').to_s
47 s = avatar(user, :size => "16").to_s + link_to_user(user, :class => 'user').to_s
48 if remove_allowed
48 if remove_allowed
49 url = {:controller => 'watchers',
49 url = {:controller => 'watchers',
50 :action => 'destroy',
50 :action => 'destroy',
51 :object_type => object.class.to_s.underscore,
51 :object_type => object.class.to_s.underscore,
52 :object_id => object.id,
52 :object_id => object.id,
53 :user_id => user}
53 :user_id => user}
54 s += ' ' + link_to_remote(image_tag('delete.png'),
54 s += ' ' + link_to_remote(image_tag('delete.png'),
55 {:url => url},
55 {:url => url},
56 :href => url_for(url),
56 :href => url_for(url),
57 :style => "vertical-align: middle",
57 :style => "vertical-align: middle",
58 :class => "delete")
58 :class => "delete")
59 end
59 end
60 "<li>#{ s }</li>"
60 "<li>#{ s }</li>"
61 end
61 end
62 lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>"
62 lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>"
63 end
63 end
64 end
64 end
General Comments 0
You need to be logged in to leave comments. Login now