summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-18 17:57:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-18 17:57:16 +0000
commit1257f1960ff6d59b2f3f7890777d3481f1800430 (patch)
tree6be67b6fc92cb8a408ed002fc6fe219ea566bb9a /app
parent10c96dba8b79822e1d54ef58bb8139851cf30c80 (diff)
downloadredmine-1257f1960ff6d59b2f3f7890777d3481f1800430.tar.gz
redmine-1257f1960ff6d59b2f3f7890777d3481f1800430.zip
Adds pagination to users list when adding project or group members (#9549).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11200 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/groups_controller.rb5
-rw-r--r--app/controllers/members_controller.rb5
-rw-r--r--app/controllers/projects_controller.rb1
-rw-r--r--app/helpers/groups_helper.rb15
-rw-r--r--app/helpers/members_helper.rb14
-rw-r--r--app/views/groups/_users.html.erb8
-rw-r--r--app/views/groups/autocomplete_for_user.html.erb1
-rw-r--r--app/views/groups/autocomplete_for_user.js.erb1
-rw-r--r--app/views/members/autocomplete.html.erb1
-rw-r--r--app/views/members/autocomplete.js.erb1
-rw-r--r--app/views/projects/settings/_members.html.erb10
11 files changed, 44 insertions, 18 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index d0a9dad09..b2f9d6af5 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -109,8 +109,9 @@ class GroupsController < ApplicationController
end
def autocomplete_for_user
- @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
- render :layout => false
+ respond_to do |format|
+ format.js
+ end
end
def edit_membership
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index 54b3a5cbe..c46b62879 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -112,8 +112,9 @@ class MembersController < ApplicationController
end
def autocomplete
- @principals = Principal.active.not_member_of(@project).like(params[:q]).all(:limit => 100)
- render :layout => false
+ respond_to do |format|
+ format.js
+ end
end
private
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 054b8bb47..a3527a550 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -43,6 +43,7 @@ class ProjectsController < ApplicationController
helper :repositories
include RepositoriesHelper
include ProjectsHelper
+ helper :members
# Lists visible projects
def index
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index 91cbb803f..5e6b1f7aa 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -24,4 +24,19 @@ module GroupsHelper
{:name => 'memberships', :partial => 'groups/memberships', :label => :label_project_plural}
]
end
+
+ def render_principals_for_new_group_users(group)
+ scope = User.active.not_in_group(group).like(params[:q])
+ principal_count = scope.count
+ principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
+ principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
+
+ s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
+
+ 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
+ }
+
+ s + content_tag('p', links, :class => 'pagination')
+ end
end
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index d56fc6179..eb06a3977 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -18,4 +18,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module MembersHelper
+ def render_principals_for_new_members(project)
+ scope = Principal.active.not_member_of(project).like(params[:q]).order('type, login, lastname ASC')
+ principal_count = scope.count
+ principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
+ principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
+
+ s = content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals')
+
+ links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
+ link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
+ }
+
+ s + content_tag('p', links, :class => 'pagination')
+ end
end
diff --git a/app/views/groups/_users.html.erb b/app/views/groups/_users.html.erb
index 8bd76e90e..a0f89d76f 100644
--- a/app/views/groups/_users.html.erb
+++ b/app/views/groups/_users.html.erb
@@ -22,22 +22,18 @@
</div>
<div class="splitcontentright">
-<% users = User.active.not_in_group(@group).all(:limit => 100) %>
-<% if users.any? %>
<%= 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', 'users', '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %>
+ <%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %>
<div id="users">
- <%= principals_check_box_tags 'user_ids[]', users %>
+ <%= render_principals_for_new_group_users(@group) %>
</div>
<p><%= submit_tag l(:button_add) %></p>
</fieldset>
<% end %>
-<% end %>
-
</div>
diff --git a/app/views/groups/autocomplete_for_user.html.erb b/app/views/groups/autocomplete_for_user.html.erb
deleted file mode 100644
index de1b0073a..000000000
--- a/app/views/groups/autocomplete_for_user.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= principals_check_box_tags 'user_ids[]', @users %>
diff --git a/app/views/groups/autocomplete_for_user.js.erb b/app/views/groups/autocomplete_for_user.js.erb
new file mode 100644
index 000000000..9bb569ea1
--- /dev/null
+++ b/app/views/groups/autocomplete_for_user.js.erb
@@ -0,0 +1 @@
+$('#users').html('<%= escape_javascript(render_principals_for_new_group_users(@group)) %>');
diff --git a/app/views/members/autocomplete.html.erb b/app/views/members/autocomplete.html.erb
deleted file mode 100644
index a3ae74a0b..000000000
--- a/app/views/members/autocomplete.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= principals_check_box_tags 'membership[user_ids][]', @principals %>
diff --git a/app/views/members/autocomplete.js.erb b/app/views/members/autocomplete.js.erb
new file mode 100644
index 000000000..ba98983d3
--- /dev/null
+++ b/app/views/members/autocomplete.js.erb
@@ -0,0 +1 @@
+$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>');
diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb
index 7b2eaac87..87c8f8be3 100644
--- a/app/views/projects/settings/_members.html.erb
+++ b/app/views/projects/settings/_members.html.erb
@@ -51,18 +51,16 @@
<% end %>
</div>
-<% principals = Principal.active.not_member_of(@project).all(:limit => 100, :order => 'type, login, lastname ASC') %>
-
<div class="splitcontentright">
-<% if roles.any? && principals.any? %>
+<% if roles.any? %>
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
<fieldset><legend><%=l(:label_member_new)%></legend>
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
- <%= javascript_tag "observeSearchfield('principal_search', 'principals', '#{ escape_javascript autocomplete_project_memberships_path(@project) }')" %>
+ <%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
- <div id="principals">
- <%= principals_check_box_tags 'membership[user_ids][]', principals %>
+ <div id="principals_for_new_member">
+ <%= render_principals_for_new_members(@project) %>
</div>
<p><%= l(:label_role_plural) %>: