parent
8160cd02bd
commit
c3555b1728
|
@ -37,10 +37,18 @@ class AutoCompletesController < ApplicationController
|
||||||
if params[:remove_group_members].present?
|
if params[:remove_group_members].present?
|
||||||
@group = Group.find(params[:remove_group_members])
|
@group = Group.find(params[:remove_group_members])
|
||||||
@removed_users = @group.users
|
@removed_users = @group.users
|
||||||
else
|
|
||||||
@removed_users = []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:remove_watchers].present? && params[:klass].present?
|
||||||
|
watcher_class = params[:klass].constantize
|
||||||
|
if watcher_class.included_modules.include?(Redmine::Acts::Watchable) # check class is a watching class
|
||||||
|
@object = watcher_class.find(params[:remove_watchers])
|
||||||
|
@removed_users = @object.watcher_users
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@removed_users ||= []
|
||||||
|
|
||||||
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @removed_users
|
@users = User.active.like(params[:q]).find(:all, :limit => 100) - @removed_users
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
:object_id => watched},
|
:object_id => watched},
|
||||||
:method => :post,
|
:method => :post,
|
||||||
:html => {:id => 'new-watcher-form', :style => 'display:none;'}) do |f| %>
|
:html => {:id => 'new-watcher-form', :style => 'display:none;'}) do |f| %>
|
||||||
<% users = User.active.find(:all, :limit => 10) %>
|
<% users = User.active.find(:all, :limit => 25) - watched.watcher_users %>
|
||||||
<p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil, :style => "width:98%;" %></p>
|
<p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil, :style => "width:98%;" %></p>
|
||||||
<%= observe_field(:user_search,
|
<%= observe_field(:user_search,
|
||||||
:frequency => 0.5,
|
:frequency => 0.5,
|
||||||
:update => :users,
|
:update => :users,
|
||||||
:url => auto_complete_users_path,
|
:url => auto_complete_users_path(:remove_watchers => watched.id, :klass => watched.class),
|
||||||
:with => 'q')
|
:with => 'q')
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
|
@ -109,5 +109,23 @@ class AutoCompletesControllerTest < ActionController::TestCase
|
||||||
assert_select "input[type=checkbox][value=?]", @firstname.id, :count => 0
|
assert_select "input[type=checkbox][value=?]", @firstname.id, :count => 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "restrict by removing issue watchers" do
|
||||||
|
setup do
|
||||||
|
@issue = Issue.find(2)
|
||||||
|
@issue.add_watcher(@login)
|
||||||
|
@issue.add_watcher(@firstname)
|
||||||
|
get :users, :q => 'complete', :remove_watchers => @issue.id, :klass => 'Issue'
|
||||||
|
end
|
||||||
|
|
||||||
|
should_respond_with :success
|
||||||
|
|
||||||
|
should "not include existing watchers" do
|
||||||
|
assert_select "input[type=checkbox][value=?]", @lastname.id
|
||||||
|
|
||||||
|
assert_select "input[type=checkbox][value=?]", @login.id, :count => 0
|
||||||
|
assert_select "input[type=checkbox][value=?]", @firstname.id, :count => 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue