Commit cd6f6c8d authored by jplang's avatar jplang

Don't display default watchers checkboxes on the new issue form when there are...

Don't display default watchers checkboxes on the new issue form when there are more than 20 members (#8562).

git-svn-id: https://svn.redmine.org/redmine/trunk@12673 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 6d9328ec
......@@ -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
......
......@@ -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
......@@ -17,11 +17,7 @@
:project_id => @project) }')" %>
<div id="users_for_watcher">
<%= principals_check_box_tags(
'watcher[user_ids][]',
(watched ?
watched.addable_watcher_users : User.active.limit(100).all)
) %>
<%= principals_check_box_tags('watcher[user_ids][]', users) %>
</div>
<p class="buttons">
......
$('#ajax-modal').html('<%= escape_javascript(render(:partial => 'watchers/new', :locals => {:watched => @watched})) %>');
$('#ajax-modal').html('<%= escape_javascript(render(:partial => 'watchers/new', :locals => {:watched => @watched, :users => @users})) %>');
$('#watchers').html('<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => @watched})) %>');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'watchers/new', :locals => {:watched => @watched}) %>');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'watchers/new', :locals => {:watched => @watched, :users => @users}) %>');
showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('new-watcher');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment