Skip to content

Commit

Permalink
better pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
alishaevn committed Feb 1, 2022
1 parent de9b753 commit e25c013
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/presenters/hyrax/text_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@ module Hyrax
class TextPresenter < Hyku::WorkShowPresenter
# Adds behaviors for hyrax-doi plugin.
# include Hyrax::DOI::DOIPresenterBehavior

# OVERRIDE: Hyrax 2.9.6
def total_pages(members=nil)
# if we're hiding the derivatives, we won't have as many pages to show
pages = members.presence || total_items

(pages.to_f / rows_from_params.to_f).ceil
end
end
end
5 changes: 4 additions & 1 deletion app/views/hyrax/base/_items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<h2><%= t('.header') %></h2>
<% array_of_ids = presenter.list_of_item_ids_to_display %>
<% members = presenter.member_presenters_for(array_of_ids) %>
<%# OVERRIDE: Hyrax 2.9.6 %>
<% page_count = presenter.total_pages %>
<%
# OVERRIDE: Hyrax 2.9.6
unless current_user&.has_role?(:admin, Site.instance) || current_user&.has_role?(:superadmin, Site.instance)
# hide the jpg derivatives
members = members.reject { |m| m.solr_document['is_derived_ssi'] == 'true' }
page_count = presenter.total_pages(members.count)
end
%>
Expand All @@ -27,7 +30,7 @@
</tbody>
</table>
<div class="row">
<% if presenter.total_pages > 1 %>
<% if page_count > 1 %>
<div class="row record-padding col-md-9">
<%= paginate array_of_ids, outer_window: 2, theme: 'blacklight', param_name: :page, route_set: main_app %>
</div><!-- /pager -->
Expand Down

0 comments on commit e25c013

Please sign in to comment.