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

Use ServerItemPaginationComponent #4480

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
4 changes: 2 additions & 2 deletions app/assets/stylesheets/components/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ a.clear-bookmarks, a.clear-search-history {
.pagination-search-widgets .btn-default,
.search-widgets button,
.browse-header button,
#sortAndPerPage .page_links .prev a,
#sortAndPerPage .page_links .next a,
#sortAndPerPage .page-links .prev a,
#sortAndPerPage .page-links .next a,
.prev.is-disabled,
.next.is-disabled,
.pagination-search-widgets .previous,
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/components/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ul.pagination {
padding: 0;
}

.pagination-search-widgets .page_links {
.pagination-search-widgets .page-links {
padding: 0;
border: 0;
display: inline-block;
Expand All @@ -52,7 +52,7 @@ ul.pagination {
}
}

.page_links {
.page-links {
padding: 10px 0;
border: 0;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%# This can be removed after migrating to Blacklight 8 %>
<div class='pagination-search-widgets'>

<div class="page-links">
<%= link_to_previous_document %> |

<%= item_page_entry_info %> |

<%= link_to_next_document %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# This can be removed after migrating to Blacklight 8
module Blacklight
module SearchContext
# This class makes the ServerItemPaginationComponent that is present in Blacklight 8
# available while we are still on Blacklight 7
class ServerItemPaginationComponent < Blacklight::SearchContextComponent
with_collection_parameter :search_context

def initialize(search_context:, search_session:, current_document:)
@search_context = search_context
@search_session = search_session
@current_document_id = current_document.id
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="page-links">
<%= link_to_previous_document %>
<%= link_to_next_document %>
<%= item_page_entry_info %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class Orangelight::SearchContext::ServerItemPaginationComponent < Blacklight::SearchContext::ServerItemPaginationComponent
end
58 changes: 1 addition & 57 deletions app/views/catalog/_previous_next_doc.html.erb
Original file line number Diff line number Diff line change
@@ -1,57 +1 @@
<% #Using the Bootstrap Pagination class -%>
<div class='pagination-search-widgets col'>
<div class="row">
<div class="col-xs-12 px-4">
<div class="button--start-over">
<%= render_start_over_link(root_path) %>
</div>
<% if @search_context %>
<% if @search_context[:prev] || @search_context[:next] %>
<%= link_back_to_catalog_safe class: 'btn btn-default button--back-to-search', label: t('blacklight.back_to_search').html_safe %>
<div class="page_links">
<%= link_to_previous_document @search_context[:prev] %>
<%= link_to_next_document @search_context[:next] %>
<%= item_page_entry_info %>
</div>
<% end %>
<% end %>
</div>
<div class="search-widgets col pr-4">
<ul class="navbar navbar-nav pull-right">
<% if @document.alma_record? || @document.scsb_record? %>
<li>
<%= render_cite_link(citation_solr_document_path(id: @document)) %>
</li>
<% end %>
<li class="dropdown">
<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown"><span class="icon-share" aria-hidden="true"></span> Send <span class="d-none d-lg-inline">to <span class="caret"></span></span></button>
<ul class="dropdown-menu position-absolute">
<li class="sms">
<%= link_to "SMS", sms_solr_document_path(:id => @document), {:id => 'smsLink', :data => {:blacklight_modal => "trigger"}, class: "icon-mobile dropdown-item", rel: 'nofollow'} %>
</li>
<li class="email">
<%= link_to "Email", email_solr_document_path(:id => @document), {:id => 'emailLink', :data => {:blacklight_modal => "trigger"}, class: "icon-email dropdown-item", rel: 'nofollow'} %>
</li>
<% if @document.alma_record? %>
<li class="endnote">
<%= link_to "EndNote", solr_document_path(@document, :format => 'endnote'), rel: 'nofollow', class: "icon-external dropdown-item" %>
</li>
<li class="refworks">
<%= link_to "RefWorks", refworks_export_url({url: polymorphic_url(search_state.url_for_document(@document), format: :refworks_marc_txt, only_path: false)}), rel: 'nofollow', class: "icon-external dropdown-item", :target => "_blank" %>
</li>
<li class="ris">
<%= link_to 'RIS', solr_document_path(@document, :format => 'ris'), rel: 'nofollow', class: "icon-external dropdown-item" %>
</li>
<% end %>
<li class="print">
<a href="javascript:if(window.print)window.print()" class="dropdown-item"><span class="icon-print" aria-hidden="true"></span>Printer</a>
</li>
</ul>
</li>
<li>
<%= render BookmarkButtonComponent.new(document: @document) if current_or_guest_user %>
</li>
</ul>
</div>
</div>
</div>
<%= render(Orangelight::SearchContext::ServerItemPaginationComponent.new(search_context: @search_context, search_session: search_session, current_document: @document)) %>
37 changes: 37 additions & 0 deletions app/views/catalog/_show_tools.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="search-widgets col pr-4">
<ul class="navbar navbar-nav pull-right">
<% if @document.alma_record? || @document.scsb_record? %>
<li>
<%= render_cite_link(citation_solr_document_path(id: @document)) %>
</li>
<% end %>
<li class="dropdown">
<button class="btn btn-outline-primary dropdown-toggle" data-toggle="dropdown"><span class="icon-share" aria-hidden="true"></span> Send <span class="d-none d-lg-inline">to <span class="caret"></span></span></button>
<ul class="dropdown-menu position-absolute">
<li class="sms">
<%= link_to "SMS", sms_solr_document_path(:id => @document), {:id => 'smsLink', :data => {:blacklight_modal => "trigger"}, class: "icon-mobile dropdown-item", rel: 'nofollow'} %>
</li>
<li class="email">
<%= link_to "Email", email_solr_document_path(:id => @document), {:id => 'emailLink', :data => {:blacklight_modal => "trigger"}, class: "icon-email dropdown-item", rel: 'nofollow'} %>
</li>
<% if @document.alma_record? %>
<li class="endnote">
<%= link_to "EndNote", solr_document_path(@document, :format => 'endnote'), rel: 'nofollow', class: "icon-external dropdown-item" %>
</li>
<li class="refworks">
<%= link_to "RefWorks", refworks_export_url({url: polymorphic_url(search_state.url_for_document(@document), format: :refworks_marc_txt, only_path: false)}), rel: 'nofollow', class: "icon-external dropdown-item", :target => "_blank" %>
</li>
<li class="ris">
<%= link_to 'RIS', solr_document_path(@document, :format => 'ris'), rel: 'nofollow', class: "icon-external dropdown-item" %>
</li>
<% end %>
<li class="print">
<a href="javascript:if(window.print)window.print()" class="dropdown-item"><span class="icon-print" aria-hidden="true"></span>Printer</a>
</li>
</ul>
</li>
<li>
<%= render BookmarkButtonComponent.new(document: @document) if current_or_guest_user %>
</li>
</ul>
</div>
2 changes: 1 addition & 1 deletion app/views/catalog/_sort_and_per_page.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="sortAndPerPage" class="clearfix">
<div class="pagination-rss pull-left">
<div class="page_links">
<div class="page-links">
<%= render :partial => "paginate_compact", :object => @response if show_pagination? %>
<%= link_to(" ", search_catalog_path(params.permit!.merge(format: 'atom',
sort: 'cataloged_tdt desc, pub_date_start_sort desc, title_sort asc').except(:controller, :action)),
Expand Down
17 changes: 16 additions & 1 deletion app/views/catalog/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<%= render 'previous_next_doc' %>
<% #Using the Bootstrap Pagination class -%>
<div class='pagination-search-widgets col'>
<div class="row">
<div class="col-xs-12 px-4">
<div class="button--start-over">
<%= render_start_over_link(root_path) %>
</div>
<% if @search_context %>
<%= link_back_to_catalog_safe class: 'btn btn-default button--back-to-search', label: t('blacklight.back_to_search').html_safe %>
<%= render 'previous_next_doc' %>
<% end %>
</div>
<%= render 'show_tools' %>
</div>
</div>

<div id="main-content" class="col-12 main-content" data-host-id="<%= @document.host_id %>">
<div id="sidebar" class="<%= render_document_class %>">
<%= render_document_sidebar_partial(@document) %>
Expand Down