@@ -25,6 +25,8 class BoardsController < ApplicationController | |||||
25 | include MessagesHelper |
|
25 | include MessagesHelper | |
26 | helper :sort |
|
26 | helper :sort | |
27 | include SortHelper |
|
27 | include SortHelper | |
|
28 | helper :watchers | |||
|
29 | include WatchersHelper | |||
28 |
|
30 | |||
29 | def index |
|
31 | def index | |
30 | @boards = @project.boards |
|
32 | @boards = @project.boards |
@@ -27,6 +27,8 class IssuesController < ApplicationController | |||||
27 | include IfpdfHelper |
|
27 | include IfpdfHelper | |
28 | helper :issue_relations |
|
28 | helper :issue_relations | |
29 | include IssueRelationsHelper |
|
29 | include IssueRelationsHelper | |
|
30 | helper :watchers | |||
|
31 | include WatchersHelper | |||
30 |
|
32 | |||
31 | def show |
|
33 | def show | |
32 | @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user |
|
34 | @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user |
@@ -20,19 +20,30 class WatchersController < ApplicationController | |||||
20 | before_filter :require_login, :find_project, :check_project_privacy |
|
20 | before_filter :require_login, :find_project, :check_project_privacy | |
21 |
|
21 | |||
22 | def add |
|
22 | def add | |
23 |
|
|
23 | user = logged_in_user | |
24 | redirect_to :controller => 'issues', :action => 'show', :id => @issue |
|
24 | @watched.add_watcher(user) | |
|
25 | respond_to do |format| | |||
|
26 | format.html { render :text => 'Watcher added.', :layout => true } | |||
|
27 | format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} } | |||
|
28 | end | |||
25 | end |
|
29 | end | |
26 |
|
30 | |||
27 | def remove |
|
31 | def remove | |
28 |
|
|
32 | user = logged_in_user | |
29 | redirect_to :controller => 'issues', :action => 'show', :id => @issue |
|
33 | @watched.remove_watcher(user) | |
|
34 | respond_to do |format| | |||
|
35 | format.html { render :text => 'Watcher removed.', :layout => true } | |||
|
36 | format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} } | |||
|
37 | end | |||
30 | end |
|
38 | end | |
31 |
|
39 | |||
32 | private |
|
40 | private | |
33 |
|
||||
34 | def find_project |
|
41 | def find_project | |
35 | @issue = Issue.find(params[:issue_id]) |
|
42 | klass = Object.const_get(params[:object_type].camelcase) | |
36 | @project = @issue.project |
|
43 | return false unless klass.respond_to?('watched_by') | |
|
44 | @watched = klass.find(params[:object_id]) | |||
|
45 | @project = @watched.project | |||
|
46 | rescue | |||
|
47 | render_404 | |||
37 | end |
|
48 | end | |
38 | end |
|
49 | end |
@@ -16,4 +16,21 | |||||
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 | def watcher_tag(object, user) | |||
|
20 | content_tag("span", watcher_link(object, user), :id => 'watcher') | |||
|
21 | end | |||
|
22 | ||||
|
23 | def watcher_link(object, user) | |||
|
24 | return '' unless user && object.respond_to?('watched_by?') | |||
|
25 | watched = object.watched_by?(user) | |||
|
26 | url = {:controller => 'watchers', | |||
|
27 | :action => (watched ? 'remove' : 'add'), | |||
|
28 | :object_type => object.class.to_s.underscore, | |||
|
29 | :object_id => object.id} | |||
|
30 | link_to_remote((watched ? l(:button_unwatch) : l(:button_watch)), | |||
|
31 | {:url => url}, | |||
|
32 | :href => url_for(url), | |||
|
33 | :class => (watched ? 'icon icon-fav' : 'icon icon-fav-off')) | |||
|
34 | ||||
|
35 | end | |||
19 | end |
|
36 | end |
@@ -21,6 +21,7 class Board < ActiveRecord::Base | |||||
21 | has_many :messages, :dependent => :delete_all, :order => "#{Message.table_name}.created_on DESC" |
|
21 | has_many :messages, :dependent => :delete_all, :order => "#{Message.table_name}.created_on DESC" | |
22 | belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id |
|
22 | belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id | |
23 | acts_as_list :scope => :project_id |
|
23 | acts_as_list :scope => :project_id | |
|
24 | acts_as_watchable | |||
24 |
|
25 | |||
25 | validates_presence_of :name, :description |
|
26 | validates_presence_of :name, :description | |
26 | validates_length_of :name, :maximum => 30 |
|
27 | validates_length_of :name, :maximum => 30 |
@@ -1,5 +1,6 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to l(:label_message_new), {:controller => 'messages', :action => 'new', :board_id => @board}, :class => "icon icon-add" %> |
|
2 | <%= link_to l(:label_message_new), {:controller => 'messages', :action => 'new', :board_id => @board}, :class => "icon icon-add" %> | |
|
3 | <%= watcher_tag(@board, @logged_in_user) %> | |||
3 | </div> |
|
4 | </div> | |
4 |
|
5 | |||
5 | <h2><%=h @board.name %></h2> |
|
6 | <h2><%=h @board.name %></h2> |
@@ -58,13 +58,7 end %> | |||||
58 | <div class="contextual"> |
|
58 | <div class="contextual"> | |
59 | <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %> |
|
59 | <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %> | |
60 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %> |
|
60 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %> | |
61 |
<% |
|
61 | <%= watcher_tag(@issue, @logged_in_user) %> | |
62 | <% if @issue.watched_by?(@logged_in_user) %> |
|
|||
63 | <%= link_to l(:button_unwatch), {:controller => 'watchers', :action => 'remove', :issue_id => @issue}, :class => 'icon icon-fav' %> |
|
|||
64 | <% else %> |
|
|||
65 | <%= link_to l(:button_watch), {:controller => 'watchers', :action => 'add', :issue_id => @issue}, :class => 'icon icon-fav-off' %> |
|
|||
66 | <% end %> |
|
|||
67 | <% end %> |
|
|||
68 | <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %> |
|
62 | <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %> | |
69 | <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
63 | <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
70 | </div> |
|
64 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now