-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract components for document behaviors
- Loading branch information
Showing
8 changed files
with
80 additions
and
23 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
app/components/blacklight/document/more_like_this_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,12 @@ | ||
<div class="card"> | ||
<div class="card-header">More Like This</div> | ||
<div class="card-body"> | ||
<ul> | ||
<%= @document.more_like_this.each do |document| %> | ||
<li class="more_like_this_document"> | ||
<span class="mlt_title"><%= link_to_document document %></span> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> |
21 changes: 21 additions & 0 deletions
21
app/components/blacklight/document/more_like_this_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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
module Document | ||
class MoreLikeThisComponent < ::ViewComponent::Base | ||
with_collection_parameter :document | ||
|
||
def initialize(document:) | ||
@document = document | ||
end | ||
|
||
def render? | ||
@document.more_like_this.present? | ||
end | ||
|
||
def link_to_document(*args) | ||
@view_context.link_to_document(*args) | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
app/components/blacklight/search_context_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 @search_context[:prev] %> | | ||
|
||
<%= item_page_entry_info %> | | ||
|
||
<%= link_to_next_document @search_context[:next] %> | ||
</div> | ||
</div> |
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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
class SearchContextComponent < ::ViewComponent::Base | ||
with_collection_parameter :search_context | ||
|
||
def initialize(search_context:, search_session:) | ||
@search_context = search_context | ||
@search_session = search_session | ||
end | ||
|
||
def render? | ||
@search_context.present? && (@search_context[:prev] || @search_context[:next]) | ||
end | ||
|
||
def item_page_entry_info | ||
Deprecation.silence(Blacklight::CatalogHelperBehavior) do | ||
@view_context.item_page_entry_info | ||
end | ||
end | ||
|
||
def link_to_previous_document(*args) | ||
@view_context.link_to_previous_document(*args) | ||
end | ||
|
||
def link_to_next_document(*args) | ||
@view_context.link_to_next_document(*args) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1 @@ | ||
<% if @search_context[:prev] || @search_context[:next] %> | ||
<div class='pagination-search-widgets'> | ||
|
||
<div class="page-links"> | ||
<%= link_to_previous_document @search_context[:prev] %> | | ||
|
||
<%= item_page_entry_info %> | | ||
|
||
<%= link_to_next_document @search_context[:next] %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= render(Blacklight::SearchContextComponent.new(search_context: @search_context, search_session: search_session)) %> |
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,12 +1,2 @@ | ||
<%= render 'show_tools' %> | ||
<% unless document.more_like_this.empty? %> | ||
<div class="card"> | ||
<div class="card-header">More Like This</div> | ||
<div class="card-body"> | ||
<%= render collection: document.more_like_this, | ||
partial: 'show_more_like_this', | ||
as: :document %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= render(Blacklight::Document::MoreLikeThisComponent.new(document: 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