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 diff --git a/app/views/watchers/_new.html.erb b/app/views/watchers/_new.html.erb index e3443a1cd..6282d59aa 100644 --- a/app/views/watchers/_new.html.erb +++ b/app/views/watchers/_new.html.erb @@ -17,11 +17,7 @@ :project_id => @project) }')" %>