Mercurial > hg > soundsoftware-site
diff app/controllers/projects_controller.rb @ 205:05f9a2a9c753 bug_67
Projects page: Sort and paginate table on the basis of root projects only; recurse to children (if any) after each root project is rendered. Fixes #67
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Tue, 08 Feb 2011 12:16:25 +0000 |
parents | 1890a968b404 |
children | 73ff0e6a11b1 ab672e427b9b |
line wrap: on
line diff
--- a/app/controllers/projects_controller.rb Mon Feb 07 14:13:20 2011 +0000 +++ b/app/controllers/projects_controller.rb Tue Feb 08 12:16:25 2011 +0000 @@ -46,19 +46,20 @@ include RepositoriesHelper include ProjectsHelper - # Lists visible projects + # Lists visible projects. Paginator is for top-level projects only + # (subprojects belong to them) def index respond_to do |format| format.html { - sort_init 'lft' - sort_update %w(lft title created_on updated_on) + sort_init 'name' + sort_update %w(name lft created_on updated_on) @limit = per_page_option - @project_count = Project.visible.count + @project_count = Project.visible_roots.count @project_pages = Paginator.new self, @project_count, @limit, params['page'] @offset ||= @project_pages.current.offset - @projects = Project.visible.all(:offset => @offset, :limit => @limit, :order => sort_clause) + @projects = Project.visible_roots.all(:offset => @offset, :limit => @limit, :order => sort_clause) if User.current.logged? - @user_projects = User.current.projects.sort_by(&:lft) + @user_projects = User.current.projects.sort_by(&:name) end render :template => 'projects/index.rhtml', :layout => !request.xhr? }