Commit dffb8d28ed5919128ade70f7aa24dc07b8135cb5
1 parent
5ab65717
Exists in
master
and in
1 other branch
using kaminari for paging trough notices
Showing
12 changed files
with
60 additions
and
5 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -80,6 +80,8 @@ GEM |
80 | 80 | inherited_resources (1.3.0) |
81 | 81 | has_scope (~> 0.5.0) |
82 | 82 | responders (~> 0.6.0) |
83 | + kaminari (0.12.4) | |
84 | + rails (>= 3.0.0) | |
83 | 85 | libxml-ruby (2.2.2) |
84 | 86 | lighthouse-api (2.0) |
85 | 87 | activeresource (>= 3.0.0) |
... | ... | @@ -226,6 +228,7 @@ DEPENDENCIES |
226 | 228 | hoptoad_notifier (~> 2.4) |
227 | 229 | htmlentities (~> 4.3.0) |
228 | 230 | inherited_resources |
231 | + kaminari | |
229 | 232 | lighthouse-api |
230 | 233 | mongoid (= 2.1.2) |
231 | 234 | mongoid_rails_migrations | ... | ... |
app/controllers/errs_controller.rb
... | ... | @@ -31,7 +31,7 @@ class ErrsController < ApplicationController |
31 | 31 | def show |
32 | 32 | page = (params[:notice] || @problem.notices_count) |
33 | 33 | page = 1 if page.to_i.zero? |
34 | - @notices = @problem.notices.paginate(:page => page, :per_page => 1) | |
34 | + @notices = @problem.notices.page(page.to_i).per(1) | |
35 | 35 | @notice = @notices.first |
36 | 36 | @comment = Comment.new |
37 | 37 | if request.headers['X-PJAX'] | ... | ... |
app/views/errs/show.html.haml
... | ... | @@ -43,9 +43,7 @@ |
43 | 43 | |
44 | 44 | %h4= @notice.try(:message) |
45 | 45 | |
46 | -= will_paginate @notices, :param_name => :notice, :page_links => false, :class => 'notice-pagination' | |
47 | -viewing occurrence #{@notices.current_page} of #{@notices.total_pages} | |
48 | -.notice-pagination-loader= image_tag 'loader.gif' | |
46 | += paginate @notices, :param_name => :notice, :theme => :notices | |
49 | 47 | |
50 | 48 | .tab-bar |
51 | 49 | %ul | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +-# Link to the "First" page | |
2 | +-# available local variables | |
3 | +-# url: url to the first page | |
4 | +-# current_page: a page object for the currently displayed page | |
5 | +-# num_pages: total number of pages | |
6 | +-# per_page: number of items to fetch per page | |
7 | +-# remote: data-remote | |
8 | +%span.first | |
9 | + = link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote | ... | ... |
... | ... | @@ -0,0 +1,8 @@ |
1 | +-# Non-link tag that stands for skipped pages... | |
2 | +-# available local variables | |
3 | +-# current_page: a page object for the currently displayed page | |
4 | +-# num_pages: total number of pages | |
5 | +-# per_page: number of items to fetch per page | |
6 | +-# remote: data-remote | |
7 | +%span.page.gap | |
8 | + = raw(t 'views.pagination.truncate') | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +-# Link to the "Last" page | |
2 | +-# available local variables | |
3 | +-# url: url to the last page | |
4 | +-# current_page: a page object for the currently displayed page | |
5 | +-# num_pages: total number of pages | |
6 | +-# per_page: number of items to fetch per page | |
7 | +-# remote: data-remote | |
8 | +%span.last | |
9 | + = link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +-# Link showing page number | |
2 | +-# available local variables | |
3 | +-# page: a page object for "this" page | |
4 | +-# url: url to this page | |
5 | +-# current_page: a page object for the currently displayed page | |
6 | +-# num_pages: total number of pages | |
7 | +-# per_page: number of items to fetch per page | |
8 | +-# remote: data-remote | |
9 | +%span{:class => "page#{' current' if page.current?}"} | |
10 | + = link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +-# The container tag | |
2 | +-# available local variables | |
3 | +-# current_page: a page object for the currently displayed page | |
4 | +-# num_pages: total number of pages | |
5 | +-# per_page: number of items to fetch per page | |
6 | +-# remote: data-remote | |
7 | +-# paginator: the paginator that renders the pagination tags inside | |
8 | += paginator.render do | |
9 | + .notice-pagination< | |
10 | + = prev_page_tag | |
11 | + = next_page_tag | |
12 | +.notice-pagination-loader= image_tag 'loader.gif' | |
13 | +viewing occurrence #{current_page} of #{num_pages} | ... | ... |
spec/views/errs/show.html.haml_spec.rb
... | ... | @@ -8,7 +8,7 @@ describe "errs/show.html.haml" do |
8 | 8 | assign :problem, problem |
9 | 9 | assign :comment, comment |
10 | 10 | assign :app, problem.app |
11 | - assign :notices, err.notices.paginate(:page => 1, :per_page => 1) | |
11 | + assign :notices, err.notices.page(1).per(1) | |
12 | 12 | assign :notice, err.notices.first |
13 | 13 | controller.stub(:current_user) { Factory(:user) } |
14 | 14 | end | ... | ... |