Skip to content

Commit

Permalink
Merge pull request #605 from IU-Libraries-Joint-Development/refactor_…
Browse files Browse the repository at this point in the history
…collection_banner_lookup

[ESSI-1947] refactor banner lookup fedora query to solr query, add memoization
  • Loading branch information
aploshay authored Mar 8, 2024
2 parents 2b7edb4 + 64802b2 commit 9843106
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 16 deletions.
3 changes: 2 additions & 1 deletion app/views/_masthead.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
</div>
</nav>
<%= render '/campus' %>
<%= render 'shared/collection_banner' if @presenter.respond_to?(:collection) && @presenter.collection%>
<% @collection_presenter = @presenter.try(:collection_banner_presenter) %>
<%= render 'shared/collection_banner' if @collection_presenter %>
<%= render 'shared/collection_banner_for_collection' if @presenter.try(:collection?) && @presenter.model_name == 'Collection' %>

</header>
1 change: 0 additions & 1 deletion app/views/shared/_collection_banner_link.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<% @collection_presenter = Hyrax::CollectionPresenter.new(@presenter.collection, current_ability) %>
<%= link_to collection_path(@collection_presenter.id) do %>
<div class="row extended-banner extended-banner-linked hyc-banner-row">
<div class="col-md-12">
Expand Down
2 changes: 0 additions & 2 deletions app/views/shared/_collection_title_link.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<% @collection_presenter = Hyrax::CollectionPresenter.new(@presenter.collection, current_ability) %>

<div class="row extended-banner extended-banner-title-linked hyc-banner-row">
<% unless @collection_presenter.banner_file.blank? %>
<div class="col-md-12 hyc-banner-container" style="background-image:url(<%= @collection_presenter.banner_file %>)">
Expand Down
5 changes: 2 additions & 3 deletions lib/extensions/hyrax/file_set_presenter/collection_banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ module Extensions
module Hyrax
module FileSetPresenter
module CollectionBanner
def collection
# return fileset collection if any, else nil
FileSet.find(id)&.parent&.member_of_collections&.first
def collection_banner_presenter
@collection_banner_presenter ||= parent&.collection_banner_presenter
end
end
end
Expand Down
7 changes: 2 additions & 5 deletions lib/extensions/hyrax/work_show_presenter/collection_banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ module Extensions
module Hyrax
module WorkShowPresenter
module CollectionBanner
def collection
# return work collection if any, else nil
return false if member_of_collection_ids.empty?

Collection.find(member_of_collection_ids.first)
def collection_banner_presenter
@collection_banner_presenter ||= member_of_collection_presenters.first
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/hyrax/file_set_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
end

context 'When initialized' do
it '.collection is available' do
expect(subject).to respond_to(:collection)
it '.collection_banner_presenter is available' do
expect(subject).to respond_to(:collection_banner_presenter)
end
it '.campus_logo is available' do
expect(subject).to respond_to(:campus_logo)
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/hyrax/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
end

context 'When initialized' do
it '.collection is available' do
expect(subject).to respond_to(:collection)
it '.collection_banner_presenter is available' do
expect(subject).to respond_to(:collection_banner_presenter)
end
it '.campus_logo is available' do
expect(subject).to respond_to(:campus_logo)
Expand Down

0 comments on commit 9843106

Please sign in to comment.