summaryrefslogtreecommitdiffstats
path: root/app/controllers/watchers_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-01-19 10:01:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-01-19 10:01:14 +0000
commita525bc8e98f6e7c88a820ca42df54e58d92a5d1c (patch)
treec395fe1764af55f19374a3d43c65e1804072ece3 /app/controllers/watchers_controller.rb
parentb933cd7a65948f6d0b8b8359945342b04d273da2 (diff)
downloadredmine-a525bc8e98f6e7c88a820ca42df54e58d92a5d1c.tar.gz
redmine-a525bc8e98f6e7c88a820ca42df54e58d92a5d1c.zip
Don't display default watchers checkboxes on the new issue form when there are more than 20 members (#8562).
git-svn-id: http://svn.redmine.org/redmine/trunk@12673 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/watchers_controller.rb')
-rw-r--r--app/controllers/watchers_controller.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb
index 325e9e9f2..13f1f35c6 100644
--- a/app/controllers/watchers_controller.rb
+++ b/app/controllers/watchers_controller.rb
@@ -30,6 +30,7 @@ class WatchersController < ApplicationController
accept_api_auth :create, :destroy
def new
+ @users = users_for_new_watcher
end
def create
@@ -44,7 +45,7 @@ class WatchersController < ApplicationController
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
- format.js
+ format.js { @users = users_for_new_watcher }
format.api { render_api_ok }
end
end
@@ -66,10 +67,7 @@ class WatchersController < ApplicationController
end
def autocomplete_for_user
- @users = User.active.sorted.like(params[:q]).limit(100).all
- if @watched
- @users -= @watched.watcher_users
- end
+ @users = users_for_new_watcher
render :layout => false
end
@@ -106,4 +104,17 @@ class WatchersController < ApplicationController
format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => watchables} }
end
end
+
+ def users_for_new_watcher
+ users = []
+ if params[:q].blank? && @project.present?
+ users = @project.users.sorted
+ else
+ users = User.active.sorted.like(params[:q]).limit(100)
+ end
+ if @watched
+ users -= @watched.watcher_users
+ end
+ users
+ end
end