diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-01-19 10:01:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-01-19 10:01:14 +0000 |
commit | a525bc8e98f6e7c88a820ca42df54e58d92a5d1c (patch) | |
tree | c395fe1764af55f19374a3d43c65e1804072ece3 /app/controllers | |
parent | b933cd7a65948f6d0b8b8359945342b04d273da2 (diff) | |
download | redmine-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')
-rw-r--r-- | app/controllers/issues_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/watchers_controller.rb | 21 |
2 files changed, 20 insertions, 6 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f89298c4c..7f40be7d7 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -428,7 +428,10 @@ class IssuesController < ApplicationController @priorities = IssuePriority.active @allowed_statuses = @issue.new_statuses_allowed_to(User.current, @issue.new_record?) - @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq + @available_watchers = @issue.watcher_users + if @issue.project.users.count <= 20 + @available_watchers = (@available_watchers + @issue.project.users.sort).uniq + end end def check_for_default_issue_status 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 |