summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-08-30 20:10:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-08-30 20:10:56 +0000
commitdaab32923d85c86723ebdf23990f82f424cface2 (patch)
tree236a7cf137fe012db325e679601248dfc3be8e0c /app
parent3b7d651bbbeae5883a1f6d346507793672cba8c9 (diff)
downloadredmine-daab32923d85c86723ebdf23990f82f424cface2.tar.gz
redmine-daab32923d85c86723ebdf23990f82f424cface2.zip
Adds pagination to admin project list.
git-svn-id: http://svn.redmine.org/redmine/trunk@15755 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_controller.rb5
-rw-r--r--app/controllers/projects_controller.rb4
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/models/project.rb5
-rw-r--r--app/views/admin/projects.html.erb3
5 files changed, 14 insertions, 7 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 811845713..9842ec0e1 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -34,7 +34,10 @@ class AdminController < ApplicationController
scope = Project.status(@status).sorted
scope = scope.like(params[:name]) if params[:name].present?
- @projects = scope.to_a
+
+ @project_count = scope.count
+ @project_pages = Paginator.new @project_count, per_page_option, params['page']
+ @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a
render :action => "projects", :layout => false if request.xhr?
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 07d664e5e..52243884f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -192,14 +192,14 @@ class ProjectsController < ApplicationController
unless @project.archive
flash[:error] = l(:error_can_not_archive_project)
end
- redirect_to admin_projects_path(:status => params[:status])
+ redirect_to_referer_or admin_projects_path(:status => params[:status])
end
def unarchive
unless @project.active?
@project.unarchive
end
- redirect_to admin_projects_path(:status => params[:status])
+ redirect_to_referer_or admin_projects_path(:status => params[:status])
end
def close
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1b3273838..4a421b1b8 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -371,8 +371,8 @@ module ApplicationHelper
# Yields the given block for each project with its level in the tree
#
# Wrapper for Project#project_tree
- def project_tree(projects, &block)
- Project.project_tree(projects, &block)
+ def project_tree(projects, options={}, &block)
+ Project.project_tree(projects, options, &block)
end
def principals_check_box_tags(name, principals)
diff --git a/app/models/project.rb b/app/models/project.rb
index 2fc35ec4d..c35a86780 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -816,8 +816,11 @@ class Project < ActiveRecord::Base
end
# Yields the given block for each project with its level in the tree
- def self.project_tree(projects, &block)
+ def self.project_tree(projects, options={}, &block)
ancestors = []
+ if options[:init_level] && projects.first
+ ancestors = projects.first.ancestors.to_a
+ end
projects.sort_by(&:lft).each do |project|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb
index 0437f9e28..91d1cc785 100644
--- a/app/views/admin/projects.html.erb
+++ b/app/views/admin/projects.html.erb
@@ -25,7 +25,7 @@
<th></th>
</tr></thead>
<tbody>
-<% project_tree(@projects) do |project, level| %>
+<% project_tree(@projects, :init_level => true) do |project, level| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
<td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td>
<td><%= checked_image project.is_public? %></td>
@@ -41,3 +41,4 @@
</tbody>
</table>
</div>
+<span class="pagination"><%= pagination_links_full @project_pages, @project_count %></span> \ No newline at end of file