Project

General

Profile

Feature #1338 » issue_watchers_management.patch

Patch to add basic watch management to issues in redmine - Bradley Whittington, 2008-07-31 09:33

View differences:

app/views/issue_watchers/_form.rhtml (working copy)
1
<%= error_messages_for 'relation' %>
1
<%= error_messages_for 'watchers' %>
2
<p>
3
<% @user_list = @project.assignable_users
4
for @user in @issue.watchers.collect(&:user)
5
	@user_list.delete(@user)
6
end
2 7

  
3
<p><%= f.select :relation_type, collection_for_relation_type_select, {}, :onchange => "setPredecessorFieldsVisibility();" %>
4
<%= l(:label_issue) %> #<%= f.text_field :issue_to_id, :size => 6 %>
5
<span id="predecessor_fields" style="display:none;">
6
<%= l(:field_delay) %>: <%= f.text_field :delay, :size => 3 %> <%= l(:label_day_plural) %>
7
</span>
8
%>
9
<%= f.select :watcher_id, (@user_list.collect {|m| [m.name, m.id]}), :include_blank => true %>
8 10
<%= submit_tag l(:button_add) %>
9
<%= toggle_link l(:button_cancel), 'new-relation-form'%>
11
<%= toggle_link l(:button_cancel), 'new-watcher-form'%>
10 12
</p>
11

  
12
<%= javascript_tag "setPredecessorFieldsVisibility();" %>
app/views/issues/_watchers.rhtml (revision 0)
1
<div id="watchers">
2
	<%  watchers = @issue.watchers.collect(&:user).uniq
3
	    for user in watchers %>
4
	                        <span class="user"><%= link_to_user(user)%>, </span>
5
	<% end %>
6
	<% remote_form_for(:watchers, @watchers, 
7
	                 :url => {:controller => 'watchers', :action => 'add_user', :object_type => 'issue', :object_id => @issue, :issue => @issue},
8
	                 :method => :post,
9
	                 :html => {:id => 'new-watcher-form', :style => (@watchers ? '' : 'display: none;')}) do |f| %>
10
	<%= render :partial => 'issue_watchers/form', :locals => {:f => f}%>
11
	<% end %>
12
</div>
13

  
app/views/issues/show.rhtml (working copy)
43 43
    <% end %>
44 44
</tr>
45 45
<tr>
46
	<td valign="top"><b><%=l(:field_watchers)%> :</b> <%= show_and_goto_link(l(:button_add_watcher), 'new-watcher-form', :class => 'icon icon-add', :accesskey => accesskey(:watchers)) %></td>
47
	<td colspan=2>
48
		<%= render :partial => 'watchers' %>
49
	</td>
50
</tr>
51
<tr>
46 52
<% n = 0
47 53
for custom_value in @custom_values %>
48 54
    <td valign="top"><b><%= custom_value.custom_field.name %> :</b></td><td valign="top"><%= simple_format(h(show_value(custom_value))) %></td>
app/controllers/watchers_controller.rb (working copy)
27 27
      format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
28 28
    end
29 29
  end
30

  
31
  def add_user
32
    @issue = Issue.find(params[:object_id])
33
    @user = User.find(params[:watchers][:watcher_id])
34
    @watched.add_watcher(@user)
35
    respond_to do |format|
36
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
37
      format.js do
38
        render :update do |page|
39
          page.replace_html "watchers", :partial => 'issues/watchers'
40
        end
41
      end
42
    end
43
  end
30 44
  
31 45
  def remove
32 46
    user = User.current
lang/en.yml (working copy)
179 179
field_searchable: Searchable
180 180
field_default_value: Default value
181 181
field_comments_sorting: Display comments
182
field_watchers: Watchers
182 183

  
183 184
setting_app_title: Application title
184 185
setting_app_subtitle: Application subtitle
......
548 549
button_annotate: Annotate
549 550
button_update: Update
550 551
button_configure: Configure
552
button_add_watcher: Add
551 553

  
552 554
status_active: active
553 555
status_registered: registered
(1-1/2)