@@ -34,7 +34,10 class AdminController < ApplicationController | |||
|
34 | 34 | |
|
35 | 35 | scope = Project.status(@status).sorted |
|
36 | 36 | scope = scope.like(params[:name]) if params[:name].present? |
|
37 | @projects = scope.to_a | |
|
37 | ||
|
38 | @project_count = scope.count | |
|
39 | @project_pages = Paginator.new @project_count, per_page_option, params['page'] | |
|
40 | @projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a | |
|
38 | 41 | |
|
39 | 42 | render :action => "projects", :layout => false if request.xhr? |
|
40 | 43 | end |
@@ -192,14 +192,14 class ProjectsController < ApplicationController | |||
|
192 | 192 | unless @project.archive |
|
193 | 193 | flash[:error] = l(:error_can_not_archive_project) |
|
194 | 194 | end |
|
195 | redirect_to admin_projects_path(:status => params[:status]) | |
|
195 | redirect_to_referer_or admin_projects_path(:status => params[:status]) | |
|
196 | 196 | end |
|
197 | 197 | |
|
198 | 198 | def unarchive |
|
199 | 199 | unless @project.active? |
|
200 | 200 | @project.unarchive |
|
201 | 201 | end |
|
202 | redirect_to admin_projects_path(:status => params[:status]) | |
|
202 | redirect_to_referer_or admin_projects_path(:status => params[:status]) | |
|
203 | 203 | end |
|
204 | 204 | |
|
205 | 205 | def close |
@@ -371,8 +371,8 module ApplicationHelper | |||
|
371 | 371 | # Yields the given block for each project with its level in the tree |
|
372 | 372 | # |
|
373 | 373 | # Wrapper for Project#project_tree |
|
374 | def project_tree(projects, &block) | |
|
375 | Project.project_tree(projects, &block) | |
|
374 | def project_tree(projects, options={}, &block) | |
|
375 | Project.project_tree(projects, options, &block) | |
|
376 | 376 | end |
|
377 | 377 | |
|
378 | 378 | def principals_check_box_tags(name, principals) |
@@ -816,8 +816,11 class Project < ActiveRecord::Base | |||
|
816 | 816 | end |
|
817 | 817 | |
|
818 | 818 | # Yields the given block for each project with its level in the tree |
|
819 | def self.project_tree(projects, &block) | |
|
819 | def self.project_tree(projects, options={}, &block) | |
|
820 | 820 | ancestors = [] |
|
821 | if options[:init_level] && projects.first | |
|
822 | ancestors = projects.first.ancestors.to_a | |
|
823 | end | |
|
821 | 824 | projects.sort_by(&:lft).each do |project| |
|
822 | 825 | while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) |
|
823 | 826 | ancestors.pop |
@@ -25,7 +25,7 | |||
|
25 | 25 | <th></th> |
|
26 | 26 | </tr></thead> |
|
27 | 27 | <tbody> |
|
28 | <% project_tree(@projects) do |project, level| %> | |
|
28 | <% project_tree(@projects, :init_level => true) do |project, level| %> | |
|
29 | 29 | <tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> |
|
30 | 30 | <td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td> |
|
31 | 31 | <td><%= checked_image project.is_public? %></td> |
@@ -41,3 +41,4 | |||
|
41 | 41 | </tbody> |
|
42 | 42 | </table> |
|
43 | 43 | </div> |
|
44 | <span class="pagination"><%= pagination_links_full @project_pages, @project_count %></span> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now