Skip to content
Draft
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
8 changes: 7 additions & 1 deletion app/components/blacklight/document_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
<%= body %>
<% else %>
<div class="document-main-section">
<%= title %>
<header class="documentHeader row">
<%= title %>
<% actions.each do |action| %>
<%= action %>
<% end %>
</header>

<%= embed %>
<%= content %>
<%= metadata %>
Expand Down
26 changes: 22 additions & 4 deletions app/components/blacklight/document_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 8 additions & 14 deletions app/components/blacklight/document_title_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<header class="documentHeader row">
<%= 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 %>
</header>
<% end %>
19 changes: 1 addition & 18 deletions app/components/blacklight/document_title_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ 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
@counter = counter
@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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_show_main_content.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>
<!-- COinS, for Zotero among others. -->
Expand Down