Add links to first and/or last page with kaminari

Also update Kaminari gem to the latest version
This commit is contained in:
Zeger-Jan van de Weg 2015-09-17 20:24:47 +02:00
parent fd6b5099fb
commit 3d177a818f
6 changed files with 14 additions and 7 deletions

View File

@ -19,6 +19,8 @@ v 8.0.1
v 8.0.0
- Fix Markdown links not showing up in dashboard activity feed (Stan Hu)
- Remove milestones from merge requests when milestones are deleted (Stan Hu)
v 8.0.0 (unreleased)
- Add first and last to pagination (Zeger-Jan van de Weg)
- Fix HTML link that was improperly escaped in new user e-mail (Stan Hu)
- Fix broken sort in merge request API (Stan Hu)
- Bump rouge to 1.10.1 to remove warning noise and fix other syntax highlighting bugs (Stan Hu)

View File

@ -77,7 +77,7 @@ gem "stamp", '~> 0.5.0'
gem 'enumerize', '~> 0.7.0'
# Pagination
gem "kaminari", "~> 0.15.1"
gem "kaminari", "~> 0.16.3"
# HAML
gem "haml-rails", '~> 0.5.3'

View File

@ -367,7 +367,7 @@ GEM
railties (>= 3.2.16)
json (1.8.3)
jwt (1.5.1)
kaminari (0.15.1)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.3)
@ -846,7 +846,7 @@ DEPENDENCIES
jquery-scrollto-rails (~> 1.4.3)
jquery-turbolinks (~> 2.0.1)
jquery-ui-rails (~> 4.2.1)
kaminari (~> 0.15.1)
kaminari (~> 0.16.3)
letter_opener (~> 1.1.2)
mail_room (~> 0.5.1)
minitest (~> 5.7.0)

View File

@ -5,5 +5,5 @@
-# num_pages: total number of pages
-# per_page: number of items to fetch per page
-# remote: data-remote
%span.first
%li.first
= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote

View File

@ -5,5 +5,5 @@
-# num_pages: total number of pages
-# per_page: number of items to fetch per page
-# remote: data-remote
%span.last
%li.last
= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {remote: remote}

View File

@ -8,10 +8,15 @@
= paginator.render do
%div.gl-pagination
%ul.pagination.clearfix
= prev_page_tag unless current_page.first?
- unless current_page.first?
= first_page_tag unless num_pages < 5 # As kaminari will always show the first 5 pages
= prev_page_tag
- each_page do |page|
- if page.left_outer? || page.right_outer? || page.inside_window?
= page_tag page
- elsif !page.was_truncated?
= gap_tag
= next_page_tag unless current_page.last?
- unless current_page.last?
= next_page_tag
= last_page_tag unless num_pages < 5