Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagination for wishlist_items. #141 #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ gem 'jbuilder', '~> 2.5'
# A gem to automate using jQuery with Rails
gem 'jquery-rails', '~> 4.3.1'

# A gem for pagination
gem 'kaminari'

# required for Bootstrap tooltips
source 'https://rails-assets.org' do
gem 'rails-assets-tether', '>= 1.3.3'
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jwt (1.5.6)
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)
addressable (~> 2.3)
listen (3.1.5)
Expand Down Expand Up @@ -281,6 +293,7 @@ DEPENDENCIES
httparty
jbuilder (~> 2.5)
jquery-rails (~> 4.3.1)
kaminari
launchy (~> 2.4.3)
listen (>= 3.0.5, < 3.2)
omniauth-amazon
Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/playtime.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ h3 {
border-color: $teal;
}
}

.pagination a {
color: $teal;
padding: 4px 8px;
text-decoration: underline;
}
2 changes: 1 addition & 1 deletion app/controllers/wishlist_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class WishlistItemsController < ApplicationController

def index
skip_authorization
@wishlist_items = WishlistItem.includes(:item, :wishlist)
@wishlist_items = WishlistItem.includes(:item, :wishlist).page params[:page]
end

def create
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/wishlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def show
skip_authorization
@wishlist = Wishlist.includes(wishlist_items: :item).find(params[:id])
@site_managers = @wishlist.users
@wishlist_items = @wishlist.wishlist_items
@wishlist_items = @wishlist.wishlist_items.page params[:page]
end

def new
Expand Down
1 change: 1 addition & 0 deletions app/views/wishlist_items/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
</div>

<%= render @wishlist_items %>
<%= paginate @wishlist_items %>
</div>
3 changes: 2 additions & 1 deletion app/views/wishlists/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<%= @wishlist.users.map(&:display_name).join(", ") %>
</p>

<%= render @wishlist.wishlist_items %>
<%= render @wishlist_items %>
<%= paginate @wishlist_items %>

<%= link_to 'Back', root_path %>
</div>
12 changes: 12 additions & 0 deletions config/initializers/kaminari_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true
Kaminari.configure do |config|
config.default_per_page = 5
# config.max_per_page = nil
# 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