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

Render orphan filesets #647

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/hyrax/file_sets/_show_details.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2>File Details</h2>
<dl class="dl-horizontal file-show-term file-show-details">
<% if current_ability&.can?(:edit, @presenter.parent.id) %>
<% if @presenter.parent&.id && current_ability&.can?(:edit, @presenter.parent.id) %>
<dt>Depositor</dt>
<dd itemprop="accountablePerson" itemscope itemtype="http://schema.org/Person"><span itemprop="name"><%= link_to_profile @presenter.depositor %></span></dd>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/file_sets/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<%# TODO: render 'show_descriptions' See https://github.com/samvera/hyrax/issues/1481 %>
<%= render 'show_details' %>
<% if current_ability&.can?(:edit, @presenter.parent.id) %>
<% if @presenter.parent&.id && current_ability&.can?(:edit, @presenter.parent.id) %>
<%= render 'hyrax/users/activity_log', events: @presenter.events %>
<% end %>
</div><!-- /columns second -->
Expand Down
3 changes: 3 additions & 0 deletions lib/extensions/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,6 @@ def attribute_will_change!(attr)

# support for memoizing the member_presenter_factory
Hyrax::WorkShowPresenter.prepend Extensions::Hyrax::WorkShowPresenter::MemberPresenterFactoryMemoization

# support for rendering an orphan FileSet
Hyrax::FileSetsController.prepend Extensions::Hyrax::FileSetsController::RenderOrphanFileSet
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# modified from hyrax 2.9.6
module Extensions
module Hyrax
module FileSetsController
module RenderOrphanFileSet

# modified from hyrax to handle missing parent without ruby error
def add_breadcrumb_for_action
case action_name
when 'edit'.freeze
add_breadcrumb I18n.t("hyrax.file_set.browse_view"), main_app.hyrax_file_set_path(params["id"])
when 'show'.freeze
add_breadcrumb presenter.parent.to_s, main_app.polymorphic_path(presenter.parent) if presenter.parent
add_breadcrumb presenter.to_s, main_app.polymorphic_path(presenter)
end
end
end
end
end
end