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