mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Moved new group user to its own action GroupsController#new_users.
git-svn-id: http://svn.redmine.org/redmine/trunk@13602 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
67835aa74d
commit
1508cd7b8b
@ -95,6 +95,9 @@ class GroupsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_users
|
||||||
|
end
|
||||||
|
|
||||||
def add_users
|
def add_users
|
||||||
@users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a
|
@users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a
|
||||||
@group.users << @users if request.post?
|
@group.users << @users if request.post?
|
||||||
|
|||||||
@ -32,7 +32,10 @@ module GroupsHelper
|
|||||||
principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
|
principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
|
||||||
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
|
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
|
||||||
|
|
||||||
s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
|
s = content_tag('div',
|
||||||
|
content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals'),
|
||||||
|
:class => 'objects-selection'
|
||||||
|
)
|
||||||
|
|
||||||
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
||||||
link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
|
link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
|
||||||
|
|||||||
9
app/views/groups/_new_users_form.html.erb
Normal file
9
app/views/groups/_new_users_form.html.erb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<fieldset class="box">
|
||||||
|
<legend><%= label_tag "user_search", l(:label_user_search) %></legend>
|
||||||
|
<p><%= text_field_tag 'user_search', nil %></p>
|
||||||
|
<%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %>
|
||||||
|
|
||||||
|
<div id="users">
|
||||||
|
<%= render_principals_for_new_group_users(@group) %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
9
app/views/groups/_new_users_modal.html.erb
Normal file
9
app/views/groups/_new_users_modal.html.erb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<h3 class="title"><%= l(:label_user_new) %></h3>
|
||||||
|
|
||||||
|
<%= form_for(@group, :url => group_users_path(@group), :remote => true, :method => :post) do |f| %>
|
||||||
|
<%= render :partial => 'new_users_form' %>
|
||||||
|
<p class="buttons">
|
||||||
|
<%= submit_tag l(:button_add) %>
|
||||||
|
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
@ -1,4 +1,5 @@
|
|||||||
<div class="splitcontentleft">
|
<p><%= link_to l(:label_user_new), new_group_users_path(@group), :remote => true, :class => "icon icon-add" %></p>
|
||||||
|
|
||||||
<% if @group.users.any? %>
|
<% if @group.users.any? %>
|
||||||
<table class="list users">
|
<table class="list users">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
@ -19,21 +20,3 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="splitcontentright">
|
|
||||||
<%= form_for(@group, :remote => true, :url => group_users_path(@group),
|
|
||||||
:html => {:method => :post}) do |f| %>
|
|
||||||
<fieldset><legend><%=l(:label_user_new)%></legend>
|
|
||||||
|
|
||||||
<p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
|
|
||||||
<%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %>
|
|
||||||
|
|
||||||
<div id="users">
|
|
||||||
<%= render_principals_for_new_group_users(@group) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p><%= submit_tag l(:button_add) %></p>
|
|
||||||
</fieldset>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
hideModal();
|
||||||
$('#tab-content-users').html('<%= escape_javascript(render :partial => 'groups/users') %>');
|
$('#tab-content-users').html('<%= escape_javascript(render :partial => 'groups/users') %>');
|
||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
$('#user-<%= user.id %>').effect("highlight");
|
$('#user-<%= user.id %>').effect("highlight");
|
||||||
|
|||||||
6
app/views/groups/new_users.html.erb
Normal file
6
app/views/groups/new_users.html.erb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<h2><%= l(:label_user_new) %></h2>
|
||||||
|
|
||||||
|
<%= form_for(@group, :url => group_users_path(@group), :method => :post) do |f| %>
|
||||||
|
<%= render :partial => 'new_users_form' %>
|
||||||
|
<p><%= submit_tag l(:button_add) %></p>
|
||||||
|
<% end %>
|
||||||
2
app/views/groups/new_users.js.erb
Normal file
2
app/views/groups/new_users.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'groups/new_users_modal') %>');
|
||||||
|
showModal('ajax-modal', '700px');
|
||||||
@ -274,8 +274,9 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
|
get 'groups/:id/users/new', :to => 'groups#new_users', :id => /\d+/, :as => 'new_group_users'
|
||||||
match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
|
post 'groups/:id/users', :to => 'groups#add_users', :id => /\d+/, :as => 'group_users'
|
||||||
|
delete 'groups/:id/users/:user_id', :to => 'groups#remove_user', :id => /\d+/, :as => 'group_user'
|
||||||
|
|
||||||
resources :trackers, :except => :show do
|
resources :trackers, :except => :show do
|
||||||
collection do
|
collection do
|
||||||
|
|||||||
@ -113,6 +113,18 @@ class GroupsControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to '/groups'
|
assert_redirected_to '/groups'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_users
|
||||||
|
get :new_users, :id => 10
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'new_users'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_xhr_new_users
|
||||||
|
xhr :get, :new_users, :id => 10
|
||||||
|
assert_response :success
|
||||||
|
assert_equal 'text/javascript', response.content_type
|
||||||
|
end
|
||||||
|
|
||||||
def test_add_users
|
def test_add_users
|
||||||
assert_difference 'Group.find(10).users.count', 2 do
|
assert_difference 'Group.find(10).users.count', 2 do
|
||||||
post :add_users, :id => 10, :user_ids => ['2', '3']
|
post :add_users, :id => 10, :user_ids => ['2', '3']
|
||||||
|
|||||||
@ -78,6 +78,10 @@ class RoutingGroupsTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_groups
|
def test_groups
|
||||||
|
assert_routing(
|
||||||
|
{ :method => 'get', :path => "/groups/567/users/new" },
|
||||||
|
{ :controller => 'groups', :action => 'new_users', :id => '567' }
|
||||||
|
)
|
||||||
assert_routing(
|
assert_routing(
|
||||||
{ :method => 'post', :path => "/groups/567/users" },
|
{ :method => 'post', :path => "/groups/567/users" },
|
||||||
{ :controller => 'groups', :action => 'add_users', :id => '567' }
|
{ :controller => 'groups', :action => 'add_users', :id => '567' }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user