diff --git a/app/components/blacklight/document_component.html.erb b/app/components/blacklight/document_component.html.erb index cd9bcd6d8..74e1898af 100644 --- a/app/components/blacklight/document_component.html.erb +++ b/app/components/blacklight/document_component.html.erb @@ -12,7 +12,13 @@ <%= body %> <% else %>
- <%= title %> +
+ <%= title %> + <% actions.each do |action| %> + <%= action %> + <% end %> +
+ <%= embed %> <%= content %> <%= metadata %> diff --git a/app/components/blacklight/document_component.rb b/app/components/blacklight/document_component.rb index e6199ceb3..1b136af3e 100644 --- a/app/components/blacklight/document_component.rb +++ b/app/components/blacklight/document_component.rb @@ -36,7 +36,7 @@ class DocumentComponent < Blacklight::Component renders_one :title, (lambda do |component: nil, **kwargs| component ||= view_config.document_title_component - component&.new(counter: @counter, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs) + component&.new(counter: @counter, presenter: @presenter, as: @title_component, link_to_document: !@show, document_component: self, **kwargs) end) renders_one :embed, (lambda do |static_content = nil, component: nil, **kwargs| @@ -57,6 +57,8 @@ class DocumentComponent < Blacklight::Component # Additional metadata sections renders_many :metadata_sections + renders_one :actions + renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, component: nil, **kwargs| next image_options_or_static_content if image_options_or_static_content.is_a? String @@ -69,9 +71,6 @@ class DocumentComponent < Blacklight::Component # the ecosystem fully adopts view components. renders_many :partials - # Backwards compatibility - renders_one :actions - # rubocop:disable Metrics/ParameterLists # @param document [Blacklight::DocumentPresenter] # @param partials [Array, nil] view partial names that should be used to provide content for the `partials` slot @@ -127,12 +126,31 @@ def before_render end end + # Content for the document actions area + def actions + return [] if hide_actions? + + if block_given? + return super + end + + if actions? + return Array(super) + end + + Array(helpers.render_index_doc_actions(presenter.document, wrapping_class: 'index-document-functions col-sm-3 col-lg-2 mb-4 mb-sm-0')) + end + private delegate :view_config, to: :@presenter attr_reader :document_counter, :counter, :document, :presenter, :view_partials + def hide_actions? + show? + end + def show? @show end diff --git a/app/components/blacklight/document_title_component.html.erb b/app/components/blacklight/document_title_component.html.erb index 97f729fdb..492b9e5bb 100644 --- a/app/components/blacklight/document_title_component.html.erb +++ b/app/components/blacklight/document_title_component.html.erb @@ -1,17 +1,11 @@ -
- <%= content_tag @as, class: @classes do %> - <% before_titles.each do |t| %> - <%= t %> - <% end %> - - <%= counter -%><%= title -%> - - <% after_titles.each do |t| %> - <%= t %> - <% end %> +<%= content_tag @as, class: @classes do %> + <% before_titles.each do |t| %> + <%= t %> <% end %> - <% actions.each do |action| %> - <%= action %> + <%= counter -%><%= title -%> + + <% after_titles.each do |t| %> + <%= t %> <% end %> -
+<% end %> diff --git a/app/components/blacklight/document_title_component.rb b/app/components/blacklight/document_title_component.rb index 0cc9c2b3f..c4f58d3f0 100644 --- a/app/components/blacklight/document_title_component.rb +++ b/app/components/blacklight/document_title_component.rb @@ -4,11 +4,9 @@ module Blacklight class DocumentTitleComponent < Blacklight::Component renders_many :before_titles renders_many :after_titles - renders_many :actions # rubocop:disable Metrics/ParameterLists - def initialize(title = nil, presenter:, as: :h3, counter: nil, classes: 'index_title document-title-heading col h5', link_to_document: true, document_component: nil, - actions: true) + def initialize(title = nil, presenter:, as: :h3, counter: nil, classes: 'index_title document-title-heading col h5', link_to_document: true, document_component: nil) @title = title @presenter = presenter @as = as || :h3 @@ -16,7 +14,6 @@ def initialize(title = nil, presenter:, as: :h3, counter: nil, classes: 'index_t @classes = classes @link_to_document = link_to_document @document_component = document_component - @actions = actions @document = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@presenter.document, "Don't use the @document instance variable. Instead use @presenter", ActiveSupport::Deprecation.new) @@ -34,20 +31,6 @@ def title end end - # Content for the document actions area - def actions - return [] unless @actions - - if block_given? - @has_actions_slot = true - return super - end - - (@has_actions_slot && get_slot(:actions)) || - ([@document_component&.actions] if @document_component&.actions.present?) || - [helpers.render_index_doc_actions(presenter.document, wrapping_class: 'index-document-functions col-sm-3 col-lg-2 mb-4 mb-sm-0')] - end - def counter return unless @counter diff --git a/app/views/catalog/_show_main_content.html.erb b/app/views/catalog/_show_main_content.html.erb index 6797fa6a3..f1c375964 100644 --- a/app/views/catalog/_show_main_content.html.erb +++ b/app/views/catalog/_show_main_content.html.erb @@ -8,7 +8,7 @@ <% document_component = presenter.view_config.document_component -%> <%= render document_component.new(id: 'document', document: presenter, component: :div, show: true, partials: presenter.view_config.partials) do |component| %> - <% component.with_title(as: 'h1', classes: '', link_to_document: false, actions: false) %> + <% component.with_title(as: 'h1', classes: '', link_to_document: false) %> <% component.with_footer do %> <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>