mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Adds pagination to admin project list.
git-svn-id: http://svn.redmine.org/redmine/trunk@15755 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3b7d651bbb
commit
daab32923d
@ -34,7 +34,10 @@ class AdminController < ApplicationController
|
|||||||
|
|
||||||
scope = Project.status(@status).sorted
|
scope = Project.status(@status).sorted
|
||||||
scope = scope.like(params[:name]) if params[:name].present?
|
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?
|
render :action => "projects", :layout => false if request.xhr?
|
||||||
end
|
end
|
||||||
|
|||||||
@ -192,14 +192,14 @@ class ProjectsController < ApplicationController
|
|||||||
unless @project.archive
|
unless @project.archive
|
||||||
flash[:error] = l(:error_can_not_archive_project)
|
flash[:error] = l(:error_can_not_archive_project)
|
||||||
end
|
end
|
||||||
redirect_to admin_projects_path(:status => params[:status])
|
redirect_to_referer_or admin_projects_path(:status => params[:status])
|
||||||
end
|
end
|
||||||
|
|
||||||
def unarchive
|
def unarchive
|
||||||
unless @project.active?
|
unless @project.active?
|
||||||
@project.unarchive
|
@project.unarchive
|
||||||
end
|
end
|
||||||
redirect_to admin_projects_path(:status => params[:status])
|
redirect_to_referer_or admin_projects_path(:status => params[:status])
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
|||||||
@ -371,8 +371,8 @@ module ApplicationHelper
|
|||||||
# Yields the given block for each project with its level in the tree
|
# Yields the given block for each project with its level in the tree
|
||||||
#
|
#
|
||||||
# Wrapper for Project#project_tree
|
# Wrapper for Project#project_tree
|
||||||
def project_tree(projects, &block)
|
def project_tree(projects, options={}, &block)
|
||||||
Project.project_tree(projects, &block)
|
Project.project_tree(projects, options, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def principals_check_box_tags(name, principals)
|
def principals_check_box_tags(name, principals)
|
||||||
|
|||||||
@ -816,8 +816,11 @@ class Project < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Yields the given block for each project with its level in the tree
|
# 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 = []
|
ancestors = []
|
||||||
|
if options[:init_level] && projects.first
|
||||||
|
ancestors = projects.first.ancestors.to_a
|
||||||
|
end
|
||||||
projects.sort_by(&:lft).each do |project|
|
projects.sort_by(&:lft).each do |project|
|
||||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody>
|
<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 %>">
|
<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 class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td>
|
||||||
<td><%= checked_image project.is_public? %></td>
|
<td><%= checked_image project.is_public? %></td>
|
||||||
@ -41,3 +41,4 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="pagination"><%= pagination_links_full @project_pages, @project_count %></span>
|
||||||
Loading…
x
Reference in New Issue
Block a user