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