@@ -0,0 +1,9 | |||||
|
1 | <fieldset class="box"> | |||
|
2 | <legend><%= label_tag "user_search", l(:label_user_search) %></legend> | |||
|
3 | <p><%= text_field_tag 'user_search', nil %></p> | |||
|
4 | <%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %> | |||
|
5 | ||||
|
6 | <div id="users"> | |||
|
7 | <%= render_principals_for_new_group_users(@group) %> | |||
|
8 | </div> | |||
|
9 | </fieldset> |
@@ -0,0 +1,9 | |||||
|
1 | <h3 class="title"><%= l(:label_user_new) %></h3> | |||
|
2 | ||||
|
3 | <%= form_for(@group, :url => group_users_path(@group), :remote => true, :method => :post) do |f| %> | |||
|
4 | <%= render :partial => 'new_users_form' %> | |||
|
5 | <p class="buttons"> | |||
|
6 | <%= submit_tag l(:button_add) %> | |||
|
7 | <%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %> | |||
|
8 | </p> | |||
|
9 | <% end %> |
@@ -0,0 +1,6 | |||||
|
1 | <h2><%= l(:label_user_new) %></h2> | |||
|
2 | ||||
|
3 | <%= form_for(@group, :url => group_users_path(@group), :method => :post) do |f| %> | |||
|
4 | <%= render :partial => 'new_users_form' %> | |||
|
5 | <p><%= submit_tag l(:button_add) %></p> | |||
|
6 | <% end %> |
@@ -0,0 +1,2 | |||||
|
1 | $('#ajax-modal').html('<%= escape_javascript(render :partial => 'groups/new_users_modal') %>'); | |||
|
2 | showModal('ajax-modal', '700px'); |
@@ -95,6 +95,9 class GroupsController < ApplicationController | |||||
95 | end |
|
95 | end | |
96 | end |
|
96 | end | |
97 |
|
97 | |||
|
98 | def new_users | |||
|
99 | end | |||
|
100 | ||||
98 | def add_users |
|
101 | def add_users | |
99 | @users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a |
|
102 | @users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a | |
100 | @group.users << @users if request.post? |
|
103 | @group.users << @users if request.post? |
@@ -32,7 +32,10 module GroupsHelper | |||||
32 | principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page'] |
|
32 | principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page'] | |
33 | principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a |
|
33 | principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a | |
34 |
|
34 | |||
35 | s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals') |
|
35 | s = content_tag('div', | |
|
36 | content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals'), | |||
|
37 | :class => 'objects-selection' | |||
|
38 | ) | |||
36 |
|
39 | |||
37 | links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options| |
|
40 | links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options| | |
38 | link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true |
|
41 | link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true |
@@ -1,4 +1,5 | |||||
1 | <div class="splitcontentleft"> |
|
1 | <p><%= link_to l(:label_user_new), new_group_users_path(@group), :remote => true, :class => "icon icon-add" %></p> | |
|
2 | ||||
2 | <% if @group.users.any? %> |
|
3 | <% if @group.users.any? %> | |
3 | <table class="list users"> |
|
4 | <table class="list users"> | |
4 | <thead><tr> |
|
5 | <thead><tr> | |
@@ -19,21 +20,3 | |||||
19 | <% else %> |
|
20 | <% else %> | |
20 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
21 | <p class="nodata"><%= l(:label_no_data) %></p> | |
21 | <% end %> |
|
22 | <% end %> | |
22 | </div> |
|
|||
23 |
|
||||
24 | <div class="splitcontentright"> |
|
|||
25 | <%= form_for(@group, :remote => true, :url => group_users_path(@group), |
|
|||
26 | :html => {:method => :post}) do |f| %> |
|
|||
27 | <fieldset><legend><%=l(:label_user_new)%></legend> |
|
|||
28 |
|
||||
29 | <p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p> |
|
|||
30 | <%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %> |
|
|||
31 |
|
||||
32 | <div id="users"> |
|
|||
33 | <%= render_principals_for_new_group_users(@group) %> |
|
|||
34 | </div> |
|
|||
35 |
|
||||
36 | <p><%= submit_tag l(:button_add) %></p> |
|
|||
37 | </fieldset> |
|
|||
38 | <% end %> |
|
|||
39 | </div> |
|
@@ -1,3 +1,4 | |||||
|
1 | hideModal(); | |||
1 | $('#tab-content-users').html('<%= escape_javascript(render :partial => 'groups/users') %>'); |
|
2 | $('#tab-content-users').html('<%= escape_javascript(render :partial => 'groups/users') %>'); | |
2 | <% @users.each do |user| %> |
|
3 | <% @users.each do |user| %> | |
3 | $('#user-<%= user.id %>').effect("highlight"); |
|
4 | $('#user-<%= user.id %>').effect("highlight"); |
@@ -274,8 +274,9 Rails.application.routes.draw do | |||||
274 | end |
|
274 | end | |
275 | end |
|
275 | end | |
276 |
|
276 | |||
277 |
|
|
277 | get 'groups/:id/users/new', :to => 'groups#new_users', :id => /\d+/, :as => 'new_group_users' | |
278 |
|
|
278 | post 'groups/:id/users', :to => 'groups#add_users', :id => /\d+/, :as => 'group_users' | |
|
279 | delete 'groups/:id/users/:user_id', :to => 'groups#remove_user', :id => /\d+/, :as => 'group_user' | |||
279 |
|
280 | |||
280 | resources :trackers, :except => :show do |
|
281 | resources :trackers, :except => :show do | |
281 | collection do |
|
282 | collection do |
@@ -113,6 +113,18 class GroupsControllerTest < ActionController::TestCase | |||||
113 | assert_redirected_to '/groups' |
|
113 | assert_redirected_to '/groups' | |
114 | end |
|
114 | end | |
115 |
|
115 | |||
|
116 | def test_new_users | |||
|
117 | get :new_users, :id => 10 | |||
|
118 | assert_response :success | |||
|
119 | assert_template 'new_users' | |||
|
120 | end | |||
|
121 | ||||
|
122 | def test_xhr_new_users | |||
|
123 | xhr :get, :new_users, :id => 10 | |||
|
124 | assert_response :success | |||
|
125 | assert_equal 'text/javascript', response.content_type | |||
|
126 | end | |||
|
127 | ||||
116 | def test_add_users |
|
128 | def test_add_users | |
117 | assert_difference 'Group.find(10).users.count', 2 do |
|
129 | assert_difference 'Group.find(10).users.count', 2 do | |
118 | post :add_users, :id => 10, :user_ids => ['2', '3'] |
|
130 | post :add_users, :id => 10, :user_ids => ['2', '3'] |
@@ -79,6 +79,10 class RoutingGroupsTest < ActionDispatch::IntegrationTest | |||||
79 |
|
79 | |||
80 | def test_groups |
|
80 | def test_groups | |
81 | assert_routing( |
|
81 | assert_routing( | |
|
82 | { :method => 'get', :path => "/groups/567/users/new" }, | |||
|
83 | { :controller => 'groups', :action => 'new_users', :id => '567' } | |||
|
84 | ) | |||
|
85 | assert_routing( | |||
82 | { :method => 'post', :path => "/groups/567/users" }, |
|
86 | { :method => 'post', :path => "/groups/567/users" }, | |
83 | { :controller => 'groups', :action => 'add_users', :id => '567' } |
|
87 | { :controller => 'groups', :action => 'add_users', :id => '567' } | |
84 | ) |
|
88 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now