Skip to content

Commit

Permalink
Override the relations component to fix styling
Browse files Browse the repository at this point in the history
This ensures that the relations widget displays with styling
more similar to the other sections in our sidebar.
  • Loading branch information
thatbudakguy committed Oct 31, 2024
1 parent bd8dc5d commit d8f6d02
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/components/relations_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="card relations relationship-<%= relationship_type.downcase %>">
<div class="card-header">
<h2 class="h4"><%= t("#{rel_type_info.label}") %></h2>
</div>

<ul class="list-group list-group-flush">
<% relationship_type_results['docs'][0..2].map { |hash| SolrDocument.new(hash) }.each do |doc| %>
<li class="list-group-item border-bottom-0">
<%= link_to solr_document_path(doc) do %>
<%= relations_icon(doc, rel_type_info.icon) unless rel_type_info.icon.nil? %>
<%= doc.title %>
<% end %>
</li>
<% end %>
<% unless (relationship_type_results['numFound'].to_i <= 3) %>
<li class="list-group-item border-bottom-0">
<%= link_to search_catalog_path({f: {"#{Settings.RELATIONSHIPS_SHOWN.public_send(relationship_type).field}" => [relations.link_id]}}) do %>
<%= t('geoblacklight.relations.browse_all', count: relationship_type_results['numFound']) %>
<% end %>
</li>
<% end %>
</ul>
</div>
4 changes: 4 additions & 0 deletions app/components/relations_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class RelationsComponent < Geoblacklight::RelationsComponent
end
3 changes: 3 additions & 0 deletions app/views/relation/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%- Settings.RELATIONSHIPS_SHOWN.each do |relationship_type, rel_type_info| %>
<%= render RelationsComponent.new(relations: @relations, relationship_type:, rel_type_info:) %>
<% end %>

0 comments on commit d8f6d02

Please sign in to comment.