Skip to content

Commit

Permalink
Merge pull request #2178 from sul-dlss/2108-sdr-record-context-panels
Browse files Browse the repository at this point in the history
SDR display - Record view - Update Context Panels
  • Loading branch information
Jessie Keck committed Nov 19, 2018
2 parents 1c1ca3d + 02e1172 commit f57a8ef
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 25 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/modules/panel-in-collection.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
h4 {
margin-top: 0;
}

dl {
margin-top: 15px;
}
}
4 changes: 4 additions & 0 deletions app/models/concerns/extent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def extent
].reject(&:blank?).compact.join(' — ')
end

def extent_sans_format
[physical_string, characteristics_string].compact.join(' ')
end

private

def physical_string
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/access_panels/_appears_in.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% if document.set_member? && document.parent_sets.present? %>
<div class="panel panel-default access-panel panel-appears-in">
<div class="access-panel-heading panel-heading">
<h3>Appears in</h3>
<h3>Item is included in another record</h3>
</div>

<div class="panel-body">
Expand Down
16 changes: 6 additions & 10 deletions app/views/catalog/access_panels/_in_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% @document.parent_collections.each do |parent_collection| %>
<div class="panel panel-default access-panel panel-in-collection">
<div class="access-panel-heading panel-heading">
<h3>In collection</h3>
<h3>Item belongs to a collection</h3>
</div>
<div class="panel-body">
<h4><%= link_to(show_presenter(parent_collection).heading, solr_document_path(parent_collection[:id])) %></h4>
Expand All @@ -11,23 +11,19 @@
<%= parent_collection[:summary_display].join(', ') %>
</div>
<% end %>
</div>
<div class="panel-footer">
<dl class="dl-invert">
<% if parent_collection.collection_members.present? %>
<dt>Digital content</dt>
<dd><%= link_to_collection_members(pluralize(parent_collection.collection_members.total, 'item'), parent_collection) %></dd>
<dt>Digital collection</dt>
<dd><%= link_to_collection_members(pluralize(parent_collection.collection_members.total, 'digital item'), parent_collection) %></dd>
<% end %>
<% if parent_collection.extent.present? %>
<dt><%= parent_collection.extent_label %></dt>
<dd><%= parent_collection.extent %></dd>
<% if parent_collection.extent_sans_format.present? %>
<dt>Physical collection</dt>
<dd><%= parent_collection.extent_sans_format %></dd>
<% end %>
<% if parent_collection.index_links.finding_aid.present? %>
<dt>Finding aid</dt>
<dd><%= parent_collection.index_links.finding_aid.first.html.html_safe %></dd>
<% end %>
<dt>Collection PURL</dt>
<dd><%= link_to("https://purl.stanford.edu/#{parent_collection.druid}", "https://purl.stanford.edu/#{parent_collection.druid}") %></dd>
</dl>
</div>
</div>
Expand Down
12 changes: 10 additions & 2 deletions app/views/catalog/record/_metadata_panels.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<%
appears_in = render "catalog/access_panels/appears_in"
in_collection = render "catalog/access_panels/in_collection"
%>

<div class="metadata-panels">
<%= render "catalog/access_panels/online" %>
<%= render "catalog/access_panels/course_reserve" %>
<%= render "catalog/access_panels/location" %>
<%= render "catalog/access_panels/appears_in" %>
<%= render "catalog/access_panels/in_collection" %>
<% if appears_in.present? || in_collection.present? %>
<h2>Context</h2>
<% end %>
<%= appears_in %>
<%= in_collection %>
<%= render "catalog/access_panels/related" %>
</div>
14 changes: 7 additions & 7 deletions spec/features/access_panels/in_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
scenario "for MODS derived documents" do
visit solr_document_path('mf774fs2413')

within('.metadata-panels') do
expect(page).to have_css('h2', text: 'Context')
end

within(".panel-in-collection") do
within(".panel-heading") do
expect(page).to have_content("In collection")
expect(page).to have_content('Item belongs to a collection')
end
within('.panel-body') do
expect(page).to have_css("h4 a", text: "Image Collection1")
expect(page).to have_css("[data-behavior='truncate']", text: /A collection of fixture images/)
end
within(".panel-footer") do
expect(page).to have_css("dt", text: "Digital content")
expect(page).to have_css("dd a", text: /\d+ items?/)
expect(page).to have_css("dt", text: 'Digital collection')
expect(page).to have_css("dd a", text: /\d+ digital items?/)
expect(page).to have_css("dt", text: "Finding aid")
expect(page).to have_css("dd a", text: "Online Archive of California")
expect(page).to have_css("dt", text: "Collection PURL")
expect(page).to have_css("dd a", text: "https://purl.stanford.edu/29")
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/models/concerns/extent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@
}
it "should not be present if the appropriate metadata is not available" do
expect(no_extent.extent).to_not be_present
expect(no_extent.extent_sans_format).to_not be_present
end
it "should include a single extent statement" do
expect(single_extent.extent).to eq 'an extent statement'
expect(single_extent.extent_sans_format).to eq 'an extent statement'
end
it "should join multiple extent statements" do
expect(multi_extent.extent).to eq 'Extent1, Extent2'
expect(multi_extent.extent_sans_format).to eq 'Extent1, Extent2'
end
it "should join physical and characteristics statements" do
expect(marc_extent.extent).to eq 'Extent Sound: digital; optical; surround; stereo; Dolby. Video: NTSC. Digital: video file; DVD video; Region 1.'
expect(marc_extent.extent_sans_format).to eq 'Extent Sound: digital; optical; surround; stereo; Dolby. Video: NTSC. Digital: video file; DVD video; Region 1.'
end

describe 'including format' do
Expand All @@ -67,5 +71,14 @@
expect(bad_format.extent).to start_with 'Book'
end
end
describe 'not including format' do
it 'should not append the format' do
expect(single_extent.extent_sans_format).to start_with 'an extent statement'
end

it 'should use both fields in marc_extent' do
expect(marc_extent.extent_sans_format).to start_with 'Extent'
end
end
end
end
6 changes: 2 additions & 4 deletions spec/views/catalog/access_panels/_appears_in.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
[{ id: 'abc123', format_main_ssim: 'Map', title_display: 'The Set Object' }]
end

describe 'panel heading' do
it 'renders an h3 with "Appears in"' do
expect(subject).to have_css('.panel-heading h3', text: 'Appears in')
end
it 'renders a panel heading' do
expect(subject).to have_css('.panel-heading h3', text: 'Item is included in another record')
end

describe 'panel body' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
render
end
it 'should render the block properly if the collection members are not present' do
expect(rendered).to have_css("h3", text: 'In collection')
expect(rendered).to have_css("h3", text: 'Item belongs to a collection')
expect(rendered).to_not have_content("Digital content")
end
end
Expand Down

0 comments on commit f57a8ef

Please sign in to comment.