forked from projectblacklight/blacklight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy SearchContextComponent to ServerItemPaginationComponent to ease …
…BL8 upgrade path Closes projectblacklight#3313
- Loading branch information
Showing
7 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/components/blacklight/search_context/server_item_pagination_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class='pagination-search-widgets'> | ||
|
||
<div class="page-links"> | ||
<%= link_to_previous_document %> | | ||
|
||
<%= item_page_entry_info %> | | ||
|
||
<%= link_to_next_document %> | ||
</div> | ||
</div> |
37 changes: 37 additions & 0 deletions
37
app/components/blacklight/search_context/server_item_pagination_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
module SearchContext | ||
class ServerItemPaginationComponent < Blacklight::Component | ||
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 | ||
|
||
def render? | ||
@search_context.present? && (@search_context[:prev] || @search_context[:next]) | ||
end | ||
|
||
def item_page_entry_info | ||
Deprecation.silence(Blacklight::CatalogHelperBehavior) do | ||
helpers.item_page_entry_info | ||
end | ||
end | ||
|
||
def link_to_previous_document(document = nil, *args, **kwargs) | ||
Deprecation.silence(Blacklight::UrlHelperBehavior) do | ||
helpers.link_to_previous_document(document || @search_context[:prev], *args, **kwargs) | ||
end | ||
end | ||
|
||
def link_to_next_document(document = nil, *args, **kwargs) | ||
Deprecation.silence(Blacklight::UrlHelperBehavior) do | ||
helpers.link_to_next_document(document || @search_context[:next], *args, **kwargs) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<% Deprecation.warn(self, 'The partial _previous_next_doc.html.erb will be removed in 8.0. Render Blacklight::SearchContextComponent instead.') %> | ||
<%= render(Blacklight::SearchContextComponent.new(search_context: @search_context, search_session: search_session)) %> | ||
<% Deprecation.warn(self, 'The partial _previous_next_doc.html.erb will be removed in 8.0. Render Blacklight::SearchContext::ServerItemPaginationComponent instead.') %> | ||
<%= render(Blacklight::SearchContext::ServerItemPaginationComponent.new(search_context: @search_context, search_session: search_session, current_document: @current_document)) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters