Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANW-1506 Display representative file version in PUI #2656

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion public/app/assets/stylesheets/archivesspace/aspace.scss
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,20 @@ i.giant {

/* record details */
.objectimage {
width: 50%;
max-width: 50%;
float: right;
margin: 0 0 1em 1em;
}
.objectimage img {
margin: 0 auto;
display: block;
max-width: 100%;
border-top-right-radius: var(--bootstrap-rounded-corner-radius);
border-top-left-radius: var(--bootstrap-rounded-corner-radius);
}

.objectimage figcaption {
padding: 0.5rem;
}

.objectimage button[type='submit'] {
Expand Down
1 change: 1 addition & 0 deletions public/app/assets/stylesheets/archivesspace/helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
:root {
--bootstrap-horizontal-white-space-unit: 15px;
--bootstrap-rounded-corner-radius: 4px;
}

.flex {
Expand Down
1 change: 1 addition & 0 deletions public/app/controllers/objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def show
fill_request_info
if @result['primary_type'] == 'digital_object' || @result['primary_type'] == 'digital_object_component'
@dig = process_digital(@result['json'])
@rep_fv = @result['json']['representative_file_version']
else
@dig = process_digital_instance(@result['json']['instances'])
process_extents(@result['json'])
Expand Down
1 change: 1 addition & 0 deletions public/app/controllers/resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def show
fill_request_info
if @result['primary_type'] == 'digital_object' || @result['primary_type'] == 'digital_object_component'
@dig = process_digital(@result['json'])
@rep_fv = @result['json']['representative_file_version']
else
@dig = process_digital_instance(@result['json']['instances'])
process_extents(@result['json'])
Expand Down
3 changes: 1 addition & 2 deletions public/app/views/objects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<% if defined?(comp_id) && !comp_id && !@result['json']['ref_id'].blank? %>
<span class='ref_id'>[<%= t('archival_object._public.header.ref_id') %>: <%= @result['json']['ref_id'] %>]</span>
<% end %>
<%= render partial: 'shared/digital', locals: {:dig_objs => @dig} %>

<%= render partial: 'shared/digital', locals: {:rep_fv => @rep_fv} %>
<%= render partial: 'shared/record_innards' %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion public/app/views/resources/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<div class="row" id="notes_row">
<div class="col-sm-9">
<%= render partial: 'shared/digital', locals: {:dig_objs => @dig} %>
<%= render partial: 'shared/digital', locals: {:rep_fv => @rep_fv} %>
<%= render partial: 'shared/record_innards' %>
</div>
<div id="sidebar" class="col-sm-3 sidebar sidebar-container resizable-sidebar" <% unless @has_children %>style="display: none"<% end %>>
Expand Down
45 changes: 7 additions & 38 deletions public/app/views/shared/_digital.html.erb
Original file line number Diff line number Diff line change
@@ -1,42 +1,11 @@
<%# expects 'dig_objs' as an array of hashes %>
<%# expects 'rep_fv' as a file_version hash %>

<% unless dig_objs.blank? %>
<% unless rep_fv.blank? %>
<div class="images">
<% dig_objs.each do |d_file| %>
<% if !d_file['out'].blank? %>
<% if d_file['thumb'].blank? %>
<div class="objectimage">
<div class="panel panel-default">
<a class="btn btn-default record-type-badge digital_object" style="width: 100%" href="<%= d_file['out'] %>" target="new" title="<%= t('digital_object._public.link')%>">
<i class="fa <%= { '(moving_image)' => 'fa-file-video-o' ,
'(sound_recording)' => 'fa-file-audio-o',
'(sound_recording_musical)' => 'fa-file-audio-o',
'(sound_recording_nonmusical)' => 'fa-file-audio-o' ,
'(still_image)' => 'fa-file-image-o' ,
'(text)' => 'fa-file-text'}.fetch( d_file['material'], 'fa-file-o' ) %> fa-4x"></i><br/>
<div class="panel-heading">
<%= d_file['caption'].blank? ? "#{t('enumerations.instance_instance_type.digital_object')} #{d_file['material']}" : d_file['caption'].html_safe %>
</div>
</a>
</div>
</div>
<% else %>
<div class="objectimage">
<div class="panel panel-default">
<a class="thumbnail" href="<%= d_file['out'] %>" target="new" title="<%= t('digital_object._public.link')%>">
<img src="<%= d_file['thumb'] %>" alt="<%= strip_mixed_content(d_file['caption'] || t('enumerations.instance_instance_type.digital_object')) %>" />
</a>
<div class="panel-heading">
<%= (d_file['caption'] || t('enumerations.instance_instance_type.digital_object')).html_safe %>
</div>
</div>
</div>
<% end %>
<% elsif !d_file['thumb'].blank? %>
<div class="objectimage">
<img src="<%= d_file['thumb'] %>" alt="<%= strip_mixed_content(d_file['caption'] || t('digital_object._public.thumbnail')) %>" />
</div>
<% end %>
<% end %>
<div class="objectimage">
<div class="panel panel-default">
<%= render partial: 'shared/representative_file_version', locals: {:uri => rep_fv['file_uri'], :caption => rep_fv['caption']} %>
</div>
</div>
</div>
<% end %>
8 changes: 8 additions & 0 deletions public/app/views/shared/_representative_file_version.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<figure>
<a href="<%= uri %>" target="new" title="<%= t('digital_object._public.link')%>">
<img src="<%= uri %>" alt="<%= caption.blank? ? '' : caption %>">
</a>
<% unless caption.blank? %>
<figcaption><%= caption %></figcaption>
<% end %>
</figure>
31 changes: 31 additions & 0 deletions public/spec/controllers/digital_objects_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'spec_helper'

img_uri = 'http://foo.com/image.jpg'

describe DigitalObjectsController, type: :controller do
before(:all) do
@repo = create(:repo, repo_code: "do_test_#{Time.now.to_i}",
Expand Down Expand Up @@ -82,4 +84,33 @@
expect(response.status).to eq(404)
end
end

describe "Digital Object" do
render_views

before(:all) do
@do2 = create(:digital_object, publish: true, :file_versions => [
build(:file_version, {
:publish => true,
:is_representative => true,
:file_uri => img_uri,
:use_statement => 'image-service'
})
])

run_indexers
end

it 'should have a representative file version image when one is set' do
expect(JSONModel(:digital_object).find(@do2.id)["representative_file_version"]["file_uri"]).to eq(img_uri)
end

it 'should render the representative file version image when one is set' do
get(:tree_root, params: { rid: @repo.id, id: @do2.id })

expect(response.body).to match(img_uri)
end

quoideneuf marked this conversation as resolved.
Show resolved Hide resolved
end

end