Skip to content

Commit

Permalink
Merge pull request #2705 from archivesspace/make-representative-file-…
Browse files Browse the repository at this point in the history
…version-opt-in

restore digital object views in public app and turn off new represent…
  • Loading branch information
mark-cooper committed May 25, 2022
2 parents 617416d + 0247275 commit 9ead8ff
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 9 deletions.
1 change: 1 addition & 0 deletions backend/app/model/mixins/representative_file_version.rb
Expand Up @@ -12,6 +12,7 @@ module ClassMethods

def sequel_to_jsonmodel(objs, opts = {})
jsons = super
return jsons unless AppConfig[:enable_representative_file_version]
jsons.each do |json|
case self.name
when "Resource", "Accession", "ArchivalObject"
Expand Down
5 changes: 5 additions & 0 deletions backend/spec/mixin_representative_file_version_spec.rb
Expand Up @@ -3,6 +3,11 @@
# see https://archivesspace.atlassian.net/browse/ANW-1522
describe 'Representative File Version mixin' do

before(:each) do
allow(AppConfig).to receive(:[]).and_call_original
allow(AppConfig).to receive(:[]).with(:enable_representative_file_version) { true }
end

describe "Resource, Accession, and Archival Object representative file version" do
it "If the record has an is_representative instance, and that instance refers to a digital object which has a representative_file_version (or one could be calculated), use / copy the representative_file_version object on the linked digital object." do

Expand Down
5 changes: 5 additions & 0 deletions backend/spec/model_digital_object_component_spec.rb
Expand Up @@ -4,6 +4,11 @@

describe 'DigitalObjectComponent model' do

before(:each) do
allow(AppConfig).to receive(:[]).and_call_original
allow(AppConfig).to receive(:[]).with(:enable_representative_file_version) { true }
end

it "Allows digital object components to be created" do
doc = create(:json_digital_object_component,
:has_unpublished_ancestor => true)
Expand Down
5 changes: 5 additions & 0 deletions backend/spec/model_digital_object_spec.rb
Expand Up @@ -3,6 +3,11 @@

describe 'Digital object model' do

before(:each) do
allow(AppConfig).to receive(:[]).and_call_original
allow(AppConfig).to receive(:[]).with(:enable_representative_file_version) { true }
end

it "allows digital objects to be created" do
json = build(:json_digital_object)

Expand Down
2 changes: 1 addition & 1 deletion common/config/config-aliases.rb
Expand Up @@ -10,4 +10,4 @@
AppConfig.add_deprecated(:bulk_import_size)
AppConfig.add_deprecated(:solr_home_directory)

# AppConfig.ensure_false(:enable_custom_reports)
AppConfig.ensure_false(:enable_representative_file_version)
3 changes: 3 additions & 0 deletions common/config/config-defaults.rb
Expand Up @@ -749,3 +749,6 @@

# If enabled, use slugs instead of URIs in finding aid links (856 $u)
AppConfig[:use_slug_finding_aid_urls_in_marc_exports] = false

# Turns on representative file version features - still in development
AppConfig[:enable_representative_file_version] = false
3 changes: 1 addition & 2 deletions public/app/views/objects/show.html.erb
Expand Up @@ -16,7 +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: {:rep_fv => @rep_fv} %>
<%= render partial: 'shared/digital', locals: {:rep_fv => @rep_fv, :dig_objs => @dig} %>
<%= render partial: 'shared/record_innards' %>
</div>

Expand All @@ -39,4 +39,3 @@
</div>
<%= render partial: 'shared/modal_actions' %>
</div>

2 changes: 1 addition & 1 deletion public/app/views/resources/show.html.erb
Expand Up @@ -20,7 +20,7 @@

<div class="row" id="notes_row">
<div class="col-sm-9">
<%= render partial: 'shared/digital', locals: {:rep_fv => @rep_fv} %>
<%= render partial: 'shared/digital', locals: {:rep_fv => @rep_fv, :dig_objs => @dig} %>
<%= 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
47 changes: 44 additions & 3 deletions public/app/views/shared/_digital.html.erb
@@ -1,11 +1,52 @@
<%# expects 'rep_fv' as a file_version hash %>
<% unless rep_fv.blank? %>
<% if false %><!-- comment -->
expects 'rep_fv' as a file_version hash when AppConfig[:enable_representative_file_version]
otherwise expects to-be-deprecated 'dig_objs' as an array of hashes
<!-- /comment --><% end %>
<% if AppConfig[:enable_representative_file_version] && rep_fv.present? %>
<div class="images">
<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>
<% elsif dig_objs.present? %>
<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>
<% end %>
4 changes: 2 additions & 2 deletions public/spec/controllers/digital_objects_controller_spec.rb
Expand Up @@ -101,11 +101,11 @@
run_indexers
end

it 'should have a representative file version image when one is set' do
xit '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
xit '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)
Expand Down

0 comments on commit 9ead8ff

Please sign in to comment.