mirror of
https://github.com/Evolix/chexpire.git
synced 2024-06-14 13:34:29 +02:00
[GEM] +kaminari for pagination.
This commit is contained in:
parent
c619d39bde
commit
3ef8e6322a
1
Gemfile
1
Gemfile
|
@ -42,6 +42,7 @@ gem 'whenever', require: false
|
||||||
|
|
||||||
|
|
||||||
gem 'octicons'
|
gem 'octicons'
|
||||||
|
gem 'kaminari'
|
||||||
|
|
||||||
# Reduces boot times through caching; required in config/boot.rb
|
# Reduces boot times through caching; required in config/boot.rb
|
||||||
gem 'bootsnap', '>= 1.1.0', require: false
|
gem 'bootsnap', '>= 1.1.0', require: false
|
||||||
|
|
13
Gemfile.lock
13
Gemfile.lock
|
@ -138,6 +138,18 @@ GEM
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
multi_json (>= 1.2)
|
multi_json (>= 1.2)
|
||||||
json (2.1.0)
|
json (2.1.0)
|
||||||
|
kaminari (1.1.1)
|
||||||
|
activesupport (>= 4.1.0)
|
||||||
|
kaminari-actionview (= 1.1.1)
|
||||||
|
kaminari-activerecord (= 1.1.1)
|
||||||
|
kaminari-core (= 1.1.1)
|
||||||
|
kaminari-actionview (1.1.1)
|
||||||
|
actionview
|
||||||
|
kaminari-core (= 1.1.1)
|
||||||
|
kaminari-activerecord (1.1.1)
|
||||||
|
activerecord
|
||||||
|
kaminari-core (= 1.1.1)
|
||||||
|
kaminari-core (1.1.1)
|
||||||
launchy (2.4.3)
|
launchy (2.4.3)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
letter_opener (1.6.0)
|
letter_opener (1.6.0)
|
||||||
|
@ -339,6 +351,7 @@ DEPENDENCIES
|
||||||
guard
|
guard
|
||||||
guard-minitest
|
guard-minitest
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
|
kaminari
|
||||||
launchy
|
launchy
|
||||||
letter_opener_web
|
letter_opener_web
|
||||||
listen (>= 3.0.5, < 3.2)
|
listen (>= 3.0.5, < 3.2)
|
||||||
|
|
11
app/views/kaminari/_first_page.html.erb
Normal file
11
app/views/kaminari/_first_page.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<%# Link to the "First" page
|
||||||
|
- available local variables
|
||||||
|
url: url to the first page
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
-%>
|
||||||
|
<li class="page-item <%= 'active' if current_page.first? %>">
|
||||||
|
<%= link_to t('views.pagination.first').html_safe, url, remote: remote, class: "page-link" %>
|
||||||
|
</li>
|
10
app/views/kaminari/_gap.html.erb
Normal file
10
app/views/kaminari/_gap.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<%# Non-link tag that stands for skipped pages...
|
||||||
|
- available local variables
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
-%>
|
||||||
|
<li class="page-item">
|
||||||
|
<span class="page-link"><%= t('views.pagination.truncate').html_safe %></span>
|
||||||
|
</li>
|
11
app/views/kaminari/_last_page.html.erb
Normal file
11
app/views/kaminari/_last_page.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<%# Link to the "Last" page
|
||||||
|
- available local variables
|
||||||
|
url: url to the last page
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
-%>
|
||||||
|
<li class="page-item <%= 'active' if current_page.last? %>">
|
||||||
|
<%= link_to t('views.pagination.last').html_safe, url, remote: remote, class: "page-link" %>
|
||||||
|
</li>
|
11
app/views/kaminari/_next_page.html.erb
Normal file
11
app/views/kaminari/_next_page.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<%# Link to the "Next" page
|
||||||
|
- available local variables
|
||||||
|
url: url to the next page
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
-%>
|
||||||
|
<li class="page-item <%= 'active' if current_page.last? %>">
|
||||||
|
<%= link_to t('views.pagination.next').html_safe, url, rel: 'next', remote: remote, class: "page-link" %>
|
||||||
|
</li>
|
15
app/views/kaminari/_page.html.erb
Normal file
15
app/views/kaminari/_page.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<%# Link showing page number
|
||||||
|
- available local variables
|
||||||
|
page: a page object for "this" page
|
||||||
|
url: url to this page
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
-%>
|
||||||
|
<li class="page-item <%= ' active' if page.current? %>">
|
||||||
|
<%= link_to page, url, remote: remote, rel: page.rel, class: "page-link" %>
|
||||||
|
<% if page.current? %>
|
||||||
|
<span class="sr-only">(current)</span>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
27
app/views/kaminari/_paginator.html.erb
Normal file
27
app/views/kaminari/_paginator.html.erb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<%# The container tag
|
||||||
|
- available local variables
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
paginator: the paginator that renders the pagination tags inside
|
||||||
|
-%>
|
||||||
|
<%= paginator.render do -%>
|
||||||
|
<nav role="navigation" aria-label="pager">
|
||||||
|
<ul class="pagination justify-content-center">
|
||||||
|
<%= first_page_tag unless current_page.first? %>
|
||||||
|
<%= prev_page_tag unless current_page.first? %>
|
||||||
|
<% each_page do |page| -%>
|
||||||
|
<% if page.display_tag? -%>
|
||||||
|
<%= page_tag page %>
|
||||||
|
<% elsif !page.was_truncated? -%>
|
||||||
|
<%= gap_tag %>
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
|
<% unless current_page.out_of_range? %>
|
||||||
|
<%= next_page_tag unless current_page.last? %>
|
||||||
|
<%= last_page_tag unless current_page.last? %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<% end -%>
|
11
app/views/kaminari/_prev_page.html.erb
Normal file
11
app/views/kaminari/_prev_page.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<%# Link to the "Previous" page
|
||||||
|
- available local variables
|
||||||
|
url: url to the previous page
|
||||||
|
current_page: a page object for the currently displayed page
|
||||||
|
total_pages: total number of pages
|
||||||
|
per_page: number of items to fetch per page
|
||||||
|
remote: data-remote
|
||||||
|
-%>
|
||||||
|
<li class="page-item <%= 'active' if current_page.first? %>">
|
||||||
|
<%= link_to t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote, class: "page-link" %>
|
||||||
|
</li>
|
12
config/initializers/kaminari_config.rb
Normal file
12
config/initializers/kaminari_config.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
Kaminari.configure do |config|
|
||||||
|
config.default_per_page = 20
|
||||||
|
config.max_per_page = 200
|
||||||
|
# config.window = 4
|
||||||
|
# config.outer_window = 0
|
||||||
|
# config.left = 0
|
||||||
|
# config.right = 0
|
||||||
|
# config.page_method_name = :page
|
||||||
|
# config.param_name = :page
|
||||||
|
# config.params_on_first_page = false
|
||||||
|
end
|
|
@ -23,6 +23,21 @@ fr:
|
||||||
check:
|
check:
|
||||||
create: "Créer"
|
create: "Créer"
|
||||||
update: "Valider"
|
update: "Valider"
|
||||||
|
page_entries_info:
|
||||||
|
one_page:
|
||||||
|
display_entries:
|
||||||
|
zero: "Pas de %{entry_name} trouvé."
|
||||||
|
one: "Affiche <b>1</b> %{entry_name}"
|
||||||
|
other: "Affiche <b>les %{count}</b> %{entry_name}"
|
||||||
|
more_pages:
|
||||||
|
display_entries: "Affiche %{entry_name} <b>%{first} - %{last}</b> de <b>%{total}</b> au total"
|
||||||
|
views:
|
||||||
|
pagination:
|
||||||
|
first: "« Début"
|
||||||
|
last: "Fin »"
|
||||||
|
previous: "‹ Préc"
|
||||||
|
next: "Suiv ›"
|
||||||
|
truncate: "…"
|
||||||
|
|
||||||
time:
|
time:
|
||||||
am: am
|
am: am
|
||||||
|
|
Loading…
Reference in a new issue