Skip to content

Commit

Permalink
Restyle the display of the Keywords in the Show page. (#134)
Browse files Browse the repository at this point in the history
* Moved keywords and license to the sidebar partial
  • Loading branch information
hectorcorrea authored Jan 27, 2022
1 parent afad2c3 commit b7af779
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
18 changes: 18 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ def render_field_row_search_link(title, value, field)
end
# rubocop:enable Rails/OutputSafety

# Outputs the HTML to render a list of subjects
# rubocop:disable Rails/OutputSafety
def render_subject_search_links(title, values, field)
return if values.count.zero?
links_html = values.map do |value|
"<span>#{link_to(value, "/?f[#{field}][]=#{CGI.escape(value)}&q=&search_field=all_fields", class: 'badge badge-dark')}</span>"
end

html = <<-HTML
<tr>
<th scope="row" style="vertical-align: top;"><span>#{title}: </span></th>
<td style="vertical-align: top;">#{links_html.join(' ')}</td>
</tr>
HTML
html.html_safe
end
# rubocop:enable Rails/OutputSafety

# rubocop:disable Rails/OutputSafety
def render_globus_download(uri)
return if uri.blank?
Expand Down
6 changes: 0 additions & 6 deletions app/views/catalog/_show_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@
<% @document.access_rights.each do |access_rights| %>
<%= render_field_row "Access Rights", access_rights %>
<% end %>
<% @document.license.each do |license| %>
<%= render_field_row "License", license %>
<% end %>
<% @document.subject.each do |subject| %>
<%= render_field_row_search_link "Subject", subject, "subject_all_ssim" %>
<% end %>
<% @document.subject_classification.each do |subject_classification| %>
<%= render_field_row_search_link "Classification", subject_classification, "subject_all_ssim" %>
<% end %>
Expand Down
9 changes: 9 additions & 0 deletions app/views/catalog/_show_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
<li><span class="number"><%= Rails.env.production? ? views : 'X' %> </span> <i class="bi bi-eye-fill"></i>views</li>
</ul>
</div>

<div id="sidebar-keywords" class="sidebar">
<table>
<%= render_subject_search_links "Keywords", @document.subject, "subject_all_ssim" %>
<% @document.license.each do |license| %>
<%= render_field_row "License: ", license %>
<% end %>
</table>
</div>

0 comments on commit b7af779

Please sign in to comment.