Skip to content

Commit

Permalink
Merge pull request #2362 from tulibraries/qa
Browse files Browse the repository at this point in the history
FindingAids with no subjects
  • Loading branch information
cdoyle-temple authored May 23, 2022
2 parents 27e9196 + fbc5922 commit e5dc431
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@ GEM
rubocop-ast (>= 1.17.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.17.0)
rubocop-ast (1.18.0)
parser (>= 3.1.1.0)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.10.0)
rubocop-rspec (2.11.1)
rubocop (~> 1.19)
ruby-graphviz (1.2.5)
rexml
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/finding_aids_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def return_aids

def get_subject_filter_values(finding_aids)
finding_aids
.has_subjects
.map(&:subject)
.flatten
.sort
Expand All @@ -41,6 +42,7 @@ def get_subject_filter_values(finding_aids)

def get_collection_filter_values(finding_aids)
finding_aids
.has_collections
.map(&:collections)
.flatten
.sort
Expand Down
8 changes: 6 additions & 2 deletions app/models/finding_aid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class FindingAid < ApplicationRecord
has_rich_text :covid_alert
validates :collection_id, collection_or_subject: true

scope :has_subjects, -> { where.not(subject: []) }
scope :has_collections, -> { where.not(collections: []) }
scope :with_subject, ->(subjects) {
where(subject_query(subjects), *(subjects.map { |s| "%#{s}%" })) if subjects.present?
}
Expand Down Expand Up @@ -47,9 +49,11 @@ def schema_dot_org_type
end

def additional_schema_dot_org_attributes
subjects = subject.map(&:inspect).join(", ") if subject.present?
collections = collections.map(&:inspect).join(", ") if collections.present?
{
about: subject.map(&:inspect).join(", "),
isPartOf: collections.map(&:inspect).join(", "),
about: subjects,
isPartOf: collections,
identifier: identifier
}
end
Expand Down
12 changes: 8 additions & 4 deletions app/views/finding_aids/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@
<div class="col-12 col-lg-6">

<h1 class="page-title">
<%= title sanitize @finding_aid.name.html_safe %>
<%== title sanitize @finding_aid.name %>
</h1>

<div class="details">
<h2><%= t("manifold.finding_aids.show.headings.collection_id") %></h2>
<p><%= @finding_aid.identifier %></p>

<% if @finding_aid.subject.present? %>
<h2><%= t("manifold.finding_aids.show.headings.related_subjects") %></h2>
<ul class="list-unstyled subjects">
<% @finding_aid.subject.each do |subject| %>
<li><%= link_to subject, finding_aids_path(subject: subject), class: "inline" %></li>
<% end %>
<% end if @finding_aid.subject.present? %>
</ul>
<% end %>

<% if @finding_aid.collections.present? %>
<h2><%= t("manifold.finding_aids.show.headings.collecting_areas") %></h2>
<ul class="list-unstyled collections">
<% @finding_aid.collections.each do |collection| %>
<% @finding_aid.collections.each do |collection| %>
<li><%= link_to collection.name, collection_path(collection), class: "inline" %></li>
<% end %>
<% end %>
</ul>
<% end %>

<h2><%= t("manifold.finding_aids.show.headings.description") %></h2>
<%= @finding_aid.description %>
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ en:
breadcrumb: Finding Aids Directory
headings:
collection_id: Collection ID
related_subjects: Related Subject(s)
collecting_areas: Collecting Area(s)
related_subjects: Related Subjects
collecting_areas: Collecting Areas
description: Description
intro_html: >-
<p>Finding aids are online guides to selected archival materials in the
Expand Down

0 comments on commit e5dc431

Please sign in to comment.