diff --git a/Gemfile b/Gemfile index 8356444..990a335 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index e13a405..ddafd54 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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 diff --git a/app/assets/stylesheets/playtime.scss b/app/assets/stylesheets/playtime.scss index 86d6da1..0576f6b 100644 --- a/app/assets/stylesheets/playtime.scss +++ b/app/assets/stylesheets/playtime.scss @@ -88,3 +88,9 @@ h3 { border-color: $teal; } } + +.pagination a { + color: $teal; + padding: 4px 8px; + text-decoration: underline; +} diff --git a/app/controllers/wishlist_items_controller.rb b/app/controllers/wishlist_items_controller.rb index 5cd4cf1..9e4e16e 100644 --- a/app/controllers/wishlist_items_controller.rb +++ b/app/controllers/wishlist_items_controller.rb @@ -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 diff --git a/app/controllers/wishlists_controller.rb b/app/controllers/wishlists_controller.rb index d3fcbab..d624342 100644 --- a/app/controllers/wishlists_controller.rb +++ b/app/controllers/wishlists_controller.rb @@ -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 diff --git a/app/views/wishlist_items/index.html.erb b/app/views/wishlist_items/index.html.erb index bedfd47..512e973 100644 --- a/app/views/wishlist_items/index.html.erb +++ b/app/views/wishlist_items/index.html.erb @@ -9,4 +9,5 @@ <%= render @wishlist_items %> + <%= paginate @wishlist_items %> diff --git a/app/views/wishlists/show.html.erb b/app/views/wishlists/show.html.erb index f9dc7fc..8049d9d 100644 --- a/app/views/wishlists/show.html.erb +++ b/app/views/wishlists/show.html.erb @@ -20,7 +20,8 @@ <%= @wishlist.users.map(&:display_name).join(", ") %>

- <%= render @wishlist.wishlist_items %> + <%= render @wishlist_items %> + <%= paginate @wishlist_items %> <%= link_to 'Back', root_path %> diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb new file mode 100644 index 0000000..b02c76f --- /dev/null +++ b/config/initializers/kaminari_config.rb @@ -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