Mercurial > hg > soundsoftware-site
changeset 123:605adf7e1735 cannam
Start work on paginating and refining project list layout
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Mon, 17 Jan 2011 17:22:39 +0000 |
parents | 7c628fc7e91d |
children | bc91f2025d05 |
files | app/controllers/projects_controller.rb app/views/projects/index.rhtml |
diffstat | 2 files changed, 15 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ -42,12 +42,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.api { @offset, @limit = api_offset_and_limit
--- 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) %> </div> -<% if User.current.logged? %> +<% if @user_projects %> - <%= render_my_project_hierarchy(@projects)%> + <%= render_my_project_hierarchy(@user_projects)%> - <%= render_other_project_hierarchy(@projects)%> - -<% else %> - - <h2><%=l(:label_project_plural)%></h2> - <%= render_project_hierarchy(@projects)%> <% end %> +<%= render_other_project_hierarchy(@projects)%> + +<p class="pagination"><%= pagination_links_full @project_pages, @project_count %></p> <% other_formats_links do |f| %>