From 52d8ed9e4f716f7bf89bc544aa38a810a007f244 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 22 Mar 2012 00:09:57 +0200 Subject: [PATCH] Pagination for Merge Requests. Fixed for issues --- app/assets/stylesheets/common.scss | 15 +++++++-------- app/controllers/issues_controller.rb | 4 ++-- app/controllers/merge_requests_controller.rb | 2 +- app/views/issues/_issues.html.haml | 11 ++++++++--- app/views/kaminari/gitlab/_paginator.html.haml | 2 -- app/views/merge_requests/index.html.haml | 7 ++++++- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index a729dfe09ec..d6750d3a9df 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -476,8 +476,7 @@ img.lil_av { } } - &.bottom { - padding: 0 10px; + .bottom { background:#f5f5f5; border-top: 1px solid #eee; @include round-borders-bottom(4px); @@ -1029,11 +1028,11 @@ p.time { } .gitlab_pagination { - span { - padding:0 10px; - - a { - color:$link_color; - } + span a { color:$link_color; } + .prev, .next, .current, .page a { + padding:10px; + } + .current { + border-bottom:2px solid $style_color; } } diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 1fc59d989c9..4070f899a12 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -28,9 +28,9 @@ class IssuesController < ApplicationController when 2 then @project.issues.closed when 3 then @project.issues.opened.assigned(current_user) else @project.issues.opened - end.page(params[:page]).per(10) + end.page(params[:page]).per(20) - @issues = @issues.includes(:author, :project) + @issues = @issues.includes(:author, :project).order("critical, updated_at") respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 3a3143cb15f..f882028fcab 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -28,7 +28,7 @@ class MergeRequestsController < ApplicationController when 2 then @merge_requests.closed when 3 then @merge_requests.opened.assigned(current_user) else @merge_requests.opened - end + end.page(params[:page]).per(20) @merge_requests = @merge_requests.includes(:author, :project).order("created_at desc") end diff --git a/app/views/issues/_issues.html.haml b/app/views/issues/_issues.html.haml index f18cbe209a8..f82aee94a8f 100644 --- a/app/views/issues/_issues.html.haml +++ b/app/views/issues/_issues.html.haml @@ -1,7 +1,12 @@ -- @issues.critical.each do |issue| +- @issues.select(&:critical).each do |issue| = render(:partial => 'issues/show', :locals => {:issue => issue}) -- @issues.non_critical.each do |issue| +- @issues.reject(&:critical).each do |issue| = render(:partial => 'issues/show', :locals => {:issue => issue}) -%li= paginate @issues, :remote => true, :theme => "gitlab" +- if @issues.present? + %li.bottom + .row + .span10= paginate @issues, :remote => true, :theme => "gitlab" + .span4.right + %span.cgray.right #{@issues.total_count} issues for this filter diff --git a/app/views/kaminari/gitlab/_paginator.html.haml b/app/views/kaminari/gitlab/_paginator.html.haml index 858fe9c5e33..6dd5a5782a2 100644 --- a/app/views/kaminari/gitlab/_paginator.html.haml +++ b/app/views/kaminari/gitlab/_paginator.html.haml @@ -7,7 +7,6 @@ -# paginator: the paginator that renders the pagination tags inside = paginator.render do %nav.gitlab_pagination - -#= first_page_tag unless current_page.first? = prev_page_tag - each_page do |page| - if page.left_outer? || page.right_outer? || page.inside_window? @@ -15,4 +14,3 @@ - elsif !page.was_truncated? = gap_tag = next_page_tag - -#= last_page_tag unless current_page.last? diff --git a/app/views/merge_requests/index.html.haml b/app/views/merge_requests/index.html.haml index 468eaf33179..9a03d195e88 100644 --- a/app/views/merge_requests/index.html.haml +++ b/app/views/merge_requests/index.html.haml @@ -27,5 +27,10 @@ - if @merge_requests.blank? %li %p.padded Nothing to show here - + - if @merge_requests.present? + %li.bottom + .row + .span10= paginate @merge_requests, :theme => "gitlab" + .span4.right + %span.cgray.right #{@merge_requests.total_count} merge requests for this filter