Ability to add non-member watchers on issue creation (#5159).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9254 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang committed 2012-03-24 12:57:28 +00:00
1 parent e2bb8721d9
commit fae5250e52
12 files changed
+98 -14

No files matched your search

+1
View File
@@ -407,6 +407,7 @@ private
@priorities = IssuePriority.active
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
end
def check_for_default_issue_status
+29 -5
View File
@@ -64,6 +64,23 @@ class WatchersController < ApplicationController
render :text => 'Watcher added.', :layout => true
end
def append
if params[:watcher].is_a?(Hash)
user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
users = User.active.find_all_by_id(user_ids)
respond_to do |format|
format.js do
render :update do |page|
users.each do |user|
page.select("#issue_watcher_user_ids_#{user.id}").each(&:hide)
end
page.insert_html :bottom, 'watchers_inputs', :text => watchers_checkboxes(nil, users, true)
end
end
end
end
end
def destroy
@watched.set_watcher(User.find(params[:user_id]), false) if request.post?
respond_to do |format|
@@ -77,16 +94,23 @@ class WatchersController < ApplicationController
end
def autocomplete_for_user
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @watched.watcher_users
@users = User.active.like(params[:q]).find(:all, :limit => 100)
if @watched
@user -= @watched.watcher_users
end
render :layout => false
end
private
def find_project
klass = Object.const_get(params[:object_type].camelcase)
return false unless klass.respond_to?('watched_by')
@watched = klass.find(params[:object_id])
@project = @watched.project
if params[:object_type] && params[:object_id]
klass = Object.const_get(params[:object_type].camelcase)
return false unless klass.respond_to?('watched_by')
@watched = klass.find(params[:object_id])
@project = @watched.project
elsif params[:project_id]
@project = Project.visible.find(params[:project_id])
end
rescue
render_404
end
+8
View File
@@ -63,4 +63,12 @@ module WatchersHelper
end
(lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>").html_safe
end
def watchers_checkboxes(object, users, checked=nil)
users.map do |user|
c = checked.nil? ? object.watched_by?(user) : checked
tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil
content_tag 'label', "#{tag} #{h(user)}", :id => "issue_watcher_user_ids_#{user.id}", :class => "floating"
end.join
end
end
+2 -3
View File
@@ -14,6 +14,5 @@
<%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
</span>
</span>
<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</small>
<span class="add_attachment"><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;', :class => 'add_attachment' %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</span>
+9 -4
View File
@@ -22,10 +22,15 @@
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
<p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
<% @issue.project.users.sort.each do |user| -%>
<label class="floating"><%= check_box_tag 'issue[watcher_user_ids][]', user.id, @issue.watched_by?(user), :id => nil %> <%=h user %></label>
<% end -%>
</p>
<span id="watchers_inputs">
<%= watchers_checkboxes(@issue, @available_watchers) %>
</span>
<span class="search_for_watchers">
<%= link_to_remote l(:label_search_for_watchers),
:url => {:controller => 'watchers', :action => 'new', :project_id => @issue.project},
:method => 'get' %>
</span>
</p>
<% end %>
</div>
+2 -2
View File
@@ -1,7 +1,7 @@
<h3 class="title"><%= l(:permission_add_issue_watchers) %></h3>
<% form_remote_tag :url => {:controller => 'watchers',
:action => 'create',
:action => (watched ? 'create' : 'append'),
:object_type => watched.class.name.underscore,
:object_id => watched},
:method => :post,
@@ -22,7 +22,7 @@
:with => 'q') %>
<div id="users_for_watcher">
<%= principals_check_box_tags 'watcher[user_ids][]', watched.addable_watcher_users %>
<%= principals_check_box_tags 'watcher[user_ids][]', (watched ? watched.addable_watcher_users : User.active.all(:limit => 100)) %>
</div>
<p class="buttons">