Преглед на файлове

Adds pagination to admin project list.

git-svn-id: http://svn.redmine.org/redmine/trunk@15755 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang преди 7 години
родител
ревизия
daab32923d

+ 4
- 1
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

+ 2
- 2
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

+ 2
- 2
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)

+ 4
- 1
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

+ 2
- 1
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>

Loading…
Отказ
Запис