# HG changeset patch # User Chris Cannam # Date 1295284959 0 # Node ID 513e61d1b4daae123d18d931b3b872a647ab4efe # Parent db0caa9f0ff46bd671b52b22eb8cbb7e7fc3655f Start work on paginating and refining project list layout diff -r db0caa9f0ff4 -r 513e61d1b4da app/controllers/projects_controller.rb --- a/app/controllers/projects_controller.rb Mon Jan 17 14:47:09 2011 +0000 +++ b/app/controllers/projects_controller.rb Mon Jan 17 17:22:39 2011 +0000 @@ -45,12 +45,20 @@ helper :repositories include RepositoriesHelper include ProjectsHelper - + # Lists visible projects def index respond_to do |format| format.html { - @projects = Project.visible.find(:all, :order => 'lft') + @limit = per_page_option + @project_count = Project.visible.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 => 'lft') + if User.current.logged? + @user_projects = User.current.projects + end + render :template => 'projects/index.rhtml', :layout => !request.xhr? } format.xml { @projects = Project.visible.find(:all, :order => 'lft') diff -r db0caa9f0ff4 -r 513e61d1b4da app/views/projects/index.rhtml --- a/app/views/projects/index.rhtml Mon Jan 17 14:47:09 2011 +0000 +++ b/app/views/projects/index.rhtml Mon Jan 17 17:22:39 2011 +0000 @@ -8,18 +8,15 @@ <%= '| ' + link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> -<% if User.current.logged? %> +<% if @user_projects %> - <%= render_my_project_hierarchy(@projects)%> + <%= render_my_project_hierarchy(@user_projects)%> - <%= render_other_project_hierarchy(@projects)%> - -<% else %> - -

<%=l(:label_project_plural)%>

- <%= render_project_hierarchy(@projects)%> <% end %> +<%= render_other_project_hierarchy(@projects)%> + +

<%= pagination_links_full @project_pages, @project_count %>

<% other_formats_links do |f| %>