blacklight 7.15.1 → 7.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/VERSION +1 -1
- data/app/components/blacklight/advanced_search_form_component.html.erb +9 -3
- data/app/components/blacklight/advanced_search_form_component.rb +48 -35
- data/app/components/blacklight/constraints_component.html.erb +19 -3
- data/app/components/blacklight/constraints_component.rb +5 -1
- data/app/components/blacklight/content_areas_shim.rb +12 -0
- data/app/components/blacklight/document/action_component.html.erb +1 -1
- data/app/components/blacklight/document/action_component.rb +6 -1
- data/app/components/blacklight/document/actions_component.html.erb +3 -5
- data/app/components/blacklight/document/actions_component.rb +16 -2
- data/app/components/blacklight/document_component.html.erb +4 -7
- data/app/components/blacklight/document_component.rb +73 -73
- data/app/components/blacklight/document_metadata_component.html.erb +2 -2
- data/app/components/blacklight/document_metadata_component.rb +13 -2
- data/app/components/blacklight/document_title_component.html.erb +17 -0
- data/app/components/blacklight/document_title_component.rb +59 -0
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_component.rb +4 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -1
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_layout_component.html.erb +3 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +26 -1
- data/app/components/blacklight/response/view_type_button_component.html.erb +4 -0
- data/app/components/blacklight/response/view_type_button_component.rb +38 -0
- data/app/components/blacklight/response/view_type_component.html.erb +2 -5
- data/app/components/blacklight/response/view_type_component.rb +9 -13
- data/app/components/blacklight/search_bar_component.rb +9 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +4 -7
- data/app/components/blacklight/system/dropdown_component.rb +24 -0
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +7 -1
- data/app/components/blacklight/system/modal_component.rb +7 -1
- data/app/controllers/concerns/blacklight/catalog.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/presenters/blacklight/document_presenter.rb +8 -4
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +2 -2
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +3 -3
- data/app/views/catalog/email.html.erb +2 -2
- data/app/views/catalog/email_success.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +3 -3
- data/app/views/catalog/sms.html.erb +2 -2
- data/app/views/catalog/sms_success.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.de.yml +2 -2
- data/lib/blacklight/configuration.rb +50 -5
- data/lib/blacklight/configuration/view_config.rb +18 -5
- data/lib/blacklight/engine.rb +3 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +22 -1
- data/lib/blacklight/search_state.rb +2 -2
- data/lib/blacklight/solr/facet_paginator.rb +2 -0
- data/lib/blacklight/solr/request.rb +31 -0
- data/lib/blacklight/solr/response.rb +2 -16
- data/lib/blacklight/solr/response/facets.rb +76 -22
- data/lib/blacklight/solr/response/params.rb +104 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +57 -27
- data/lib/generators/blacklight/assets_generator.rb +6 -2
- data/lib/generators/blacklight/user_generator.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +3 -3
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +20 -0
- data/spec/models/blacklight/configuration_spec.rb +64 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +4 -0
- data/spec/models/blacklight/solr/request_spec.rb +62 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +109 -0
- data/spec/models/blacklight/solr/response_spec.rb +10 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +49 -0
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +8 -9
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cacc94e8533f909ef9e137dca8f86809489626624507e04051c0923f1471d21c
|
4
|
+
data.tar.gz: 83c86c5a1789266ca17d1ad446320f4634acf0c6a95c456dffd7cbd1653bb4e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07aa3c78687f57145209b5834d4f3512ced41f80b34e4b2dd6d72271d229922041de56f015271ba58ad62dc9c21fbd7f7f9cc0eb284080036e6e6092de73a48e
|
7
|
+
data.tar.gz: 7cd2dd6b95c77c07d06b3c1c58e4e5d7dda5fe415a6dfd61498a8e2fc83778685b0a86d08a354fbc8fc60f69dbe842f1a45a9fea5da133978d75888ee9506026
|
data/.rubocop.yml
CHANGED
@@ -57,6 +57,7 @@ Naming/MethodParameterName:
|
|
57
57
|
AllowedNames:
|
58
58
|
- id
|
59
59
|
- q
|
60
|
+
- as
|
60
61
|
|
61
62
|
Naming/PredicateName:
|
62
63
|
ForbiddenPrefixes:
|
@@ -122,3 +123,6 @@ Style/RedundantRegexpEscape:
|
|
122
123
|
|
123
124
|
Style/SlicingWithRange:
|
124
125
|
Enabled: true
|
126
|
+
|
127
|
+
Rails/ContentTag:
|
128
|
+
Enabled: false
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.17.2
|
@@ -1,7 +1,9 @@
|
|
1
1
|
<% if constraints.present? %>
|
2
2
|
<div class="constraints well search_history">
|
3
3
|
<h4><%= t 'blacklight.advanced_search.form.search_context' %></h4>
|
4
|
-
|
4
|
+
<% constraints.each do |constraint| %>
|
5
|
+
<%= constraint %>
|
6
|
+
<% end %>
|
5
7
|
</div>
|
6
8
|
<% end %>
|
7
9
|
|
@@ -15,7 +17,9 @@
|
|
15
17
|
</h2>
|
16
18
|
|
17
19
|
<div id="advanced_search">
|
18
|
-
|
20
|
+
<% search_field_controls.each do |control| %>
|
21
|
+
<%= control %>
|
22
|
+
<% end %>
|
19
23
|
</div>
|
20
24
|
</div>
|
21
25
|
|
@@ -24,7 +28,9 @@
|
|
24
28
|
|
25
29
|
<div id="advanced_search_facets" class="limit_input">
|
26
30
|
<div class="advanced-facet-limits panel-group">
|
27
|
-
|
31
|
+
<% search_filter_controls.each do |control| %>
|
32
|
+
<%= control %>
|
33
|
+
<% end %>
|
28
34
|
</div>
|
29
35
|
</div>
|
30
36
|
</div>
|
@@ -2,66 +2,79 @@
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
class AdvancedSearchFormComponent < SearchBarComponent
|
5
|
-
|
5
|
+
include Blacklight::ContentAreasShim
|
6
|
+
|
7
|
+
renders_many :constraints
|
8
|
+
renders_many :search_field_controls
|
9
|
+
renders_many :search_filter_controls, (lambda do |config:, display_facet:, presenter: nil, component: nil, **kwargs|
|
10
|
+
presenter ||= (config.presenter || Blacklight::FacetFieldPresenter).new(config, display_facet, @view_context)
|
11
|
+
component = component || config.advanced_search_component || Blacklight::FacetFieldCheckboxesComponent
|
12
|
+
|
13
|
+
component.new(facet_field: presenter, **kwargs)
|
14
|
+
end)
|
6
15
|
|
7
16
|
def initialize(response:, **options)
|
8
17
|
super(**options)
|
9
18
|
@response = response
|
10
19
|
end
|
11
20
|
|
21
|
+
def before_render
|
22
|
+
initialize_search_field_controls if search_field_controls.blank?
|
23
|
+
initialize_search_filter_controls if search_filter_controls.blank?
|
24
|
+
initialize_constraints if constraints.blank?
|
25
|
+
end
|
26
|
+
|
12
27
|
def default_operator_menu
|
13
28
|
options_with_labels = [:must, :should].index_by { |op| t(op, scope: 'blacklight.advanced_search.op') }
|
14
29
|
select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
|
15
30
|
end
|
16
31
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
def sort_fields_select
|
33
|
+
options = sort_fields.values.map { |field_config| [@view_context.sort_field_label(field_config.key), field_config.key] }
|
34
|
+
select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def initialize_search_field_controls
|
40
|
+
search_fields.values.each.with_index do |field, i|
|
41
|
+
search_field_control do
|
42
|
+
fields_for('clause[]', i, include_id: false) do |f|
|
43
|
+
content_tag(:div, class: 'form-group advanced-search-field row') do
|
44
|
+
f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label") +
|
45
|
+
content_tag(:div, class: 'col-sm-9') do
|
46
|
+
f.hidden_field(:field, value: field.key) +
|
47
|
+
f.text_field(:query, value: query_for_search_clause(field.key), class: 'form-control')
|
48
|
+
end
|
27
49
|
end
|
28
50
|
end
|
29
51
|
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
# rubocop:enable Rails/ContentTag
|
33
|
-
|
34
|
-
def query_for_search_clause(key)
|
35
|
-
field = (@params[:clause] || {}).values.find { |value| value['field'].to_s == key.to_s }
|
36
|
-
|
37
|
-
field&.dig('query')
|
52
|
+
end
|
38
53
|
end
|
39
54
|
|
40
|
-
def
|
41
|
-
return @search_filter_controls if @search_filter_controls
|
42
|
-
|
55
|
+
def initialize_search_filter_controls
|
43
56
|
fields = blacklight_config.facet_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
|
44
57
|
|
45
|
-
|
58
|
+
fields.each do |_k, config|
|
46
59
|
display_facet = @response.aggregations[config.field]
|
47
|
-
|
48
|
-
|
49
|
-
component = config.advanced_search_component || Blacklight::FacetFieldCheckboxesComponent
|
50
|
-
@view_context.render(component.new(facet_field: presenter))
|
51
|
-
end, "\n")
|
60
|
+
search_filter_control(config: config, display_facet: display_facet)
|
61
|
+
end
|
52
62
|
end
|
53
63
|
|
54
|
-
def
|
55
|
-
|
64
|
+
def initialize_constraints
|
65
|
+
constraint do
|
66
|
+
params = @view_context.search_state.params_for_search.except :page, :f_inclusive, :q, :search_field, :op, :index, :sort
|
56
67
|
|
57
|
-
|
68
|
+
params.except!(*search_fields.map { |_key, field_def| field_def[:key] })
|
58
69
|
|
59
|
-
|
70
|
+
@view_context.render_search_to_s(params)
|
71
|
+
end
|
60
72
|
end
|
61
73
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
74
|
+
def query_for_search_clause(key)
|
75
|
+
field = (@params[:clause] || {}).values.find { |value| value['field'].to_s == key.to_s }
|
76
|
+
|
77
|
+
field&.dig('query')
|
65
78
|
end
|
66
79
|
|
67
80
|
def search_fields
|
@@ -4,7 +4,23 @@
|
|
4
4
|
<%= link_to t('blacklight.search.start_over'), start_over_path, class: "catalog_startOverLink btn btn-primary" %>
|
5
5
|
|
6
6
|
<span class="constraints-label sr-only"><%= t('blacklight.search.filters.title') %></span>
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
<% if query_constraints_area.present? %>
|
8
|
+
<% query_constraints_area.each do |constraint| %>
|
9
|
+
<%= constraint %>
|
10
|
+
<% end %>
|
11
|
+
<% else %>
|
12
|
+
<%= query_constraints %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% if facet_constraints_area.present? %>
|
16
|
+
<% facet_constraints_area.each do |constraint| %>
|
17
|
+
<%= constraint %>
|
18
|
+
<% end %>
|
19
|
+
<% else %>
|
20
|
+
<%= facet_constraints %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<% additional_constraints.each do |constraints| %>
|
24
|
+
<%= constraints %>
|
25
|
+
<% end %>
|
10
26
|
<% end %>
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
class ConstraintsComponent < ::ViewComponent::Base
|
5
|
-
|
5
|
+
include Blacklight::ContentAreasShim
|
6
|
+
|
7
|
+
renders_many :query_constraints_area
|
8
|
+
renders_many :facet_constraints_area
|
9
|
+
renders_many :additional_constraints
|
6
10
|
|
7
11
|
def initialize(search_state:,
|
8
12
|
id: 'appliedParams', classes: 'clearfix constraints-container',
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
# Shim to support ViewComponent v2 slots using the content_areas API for backwards compatibility
|
5
|
+
module ContentAreasShim
|
6
|
+
# Shim the `with` helper to write content into slots instead
|
7
|
+
def with(slot_name, *args, **kwargs, &block)
|
8
|
+
Deprecation.warn('ViewComponents deprecated `with` and it will be removed in ViewComponents 3.0. content_areas. Use slots (https://viewcomponent.org/guide/slots.html) instead.')
|
9
|
+
public_send(slot_name, *args, **kwargs, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%= link_to label,
|
3
3
|
url,
|
4
4
|
id: @id,
|
5
|
-
class:
|
5
|
+
class: @link_classes,
|
6
6
|
data: {}.merge(({ blacklight_modal: "trigger" } if @action.modal != false) || {}) %>
|
7
7
|
<% else %>
|
8
8
|
<%= @view_context.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options)) %>
|
@@ -7,12 +7,13 @@ module Blacklight
|
|
7
7
|
with_collection_parameter :action
|
8
8
|
|
9
9
|
# @param [Blacklight::Document] document
|
10
|
-
def initialize(document:, action:, options: {}, url_opts: {}, id: nil)
|
10
|
+
def initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link')
|
11
11
|
@document = document
|
12
12
|
@action = action
|
13
13
|
@options = options
|
14
14
|
@url_opts = url_opts
|
15
15
|
@id = id || @action.fetch(:id, "#{@action.name}Link")
|
16
|
+
@link_classes = link_classes
|
16
17
|
end
|
17
18
|
|
18
19
|
def using_default_document_action?
|
@@ -33,6 +34,10 @@ module Blacklight
|
|
33
34
|
@view_context.document_action_path(@action, @url_opts.merge(({ id: @document } if @document) || {}))
|
34
35
|
end
|
35
36
|
end
|
37
|
+
|
38
|
+
def key
|
39
|
+
@action.key
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
<%= content_tag @tag, class: @classes do %>
|
2
|
-
<%
|
3
|
-
<% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts)) } %>
|
4
|
-
|
2
|
+
<% actions.each do |action| %>
|
5
3
|
<% if @wrapping_tag %>
|
6
4
|
<%= content_tag(@wrapping_tag, class: Array(@wrapping_classes) + [action.key]) do %>
|
7
|
-
<%=
|
5
|
+
<%= action %>
|
8
6
|
<% end %>
|
9
7
|
<% else %>
|
10
|
-
<%=
|
8
|
+
<%= action %>
|
11
9
|
<% end %>
|
12
10
|
<% end %>
|
13
11
|
<% end %>
|
@@ -4,9 +4,14 @@ module Blacklight
|
|
4
4
|
module Document
|
5
5
|
# Render a bookmark widget to bookmark / unbookmark a document
|
6
6
|
class ActionsComponent < ::ViewComponent::Base
|
7
|
+
renders_many :actions, (lambda do |action:, component: nil, **kwargs|
|
8
|
+
component ||= action.component || Blacklight::Document::ActionComponent
|
9
|
+
component.new(action: action, document: @document, options: @options, url_opts: @url_opts, link_classes: @link_classes, **kwargs)
|
10
|
+
end)
|
11
|
+
|
7
12
|
# @param [Blacklight::Document] document
|
8
13
|
# rubocop:disable Metrics/ParameterLists
|
9
|
-
def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil)
|
14
|
+
def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil, link_classes: 'nav-link')
|
10
15
|
@document = document
|
11
16
|
@actions = actions
|
12
17
|
@tag = tag
|
@@ -15,11 +20,20 @@ module Blacklight
|
|
15
20
|
@url_opts = url_opts
|
16
21
|
@wrapping_tag = wrapping_tag
|
17
22
|
@wrapping_classes = wrapping_classes
|
23
|
+
@link_classes = link_classes
|
18
24
|
end
|
19
25
|
# rubocop:enable Metrics/ParameterLists
|
20
26
|
|
27
|
+
def before_render
|
28
|
+
return if actions.present?
|
29
|
+
|
30
|
+
@actions.each do |a|
|
31
|
+
action(component: a.component, action: a)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
21
35
|
def render?
|
22
|
-
|
36
|
+
actions.present?
|
23
37
|
end
|
24
38
|
end
|
25
39
|
end
|
@@ -12,16 +12,13 @@
|
|
12
12
|
<%= body %>
|
13
13
|
<% else %>
|
14
14
|
<div class="document-main-section">
|
15
|
-
|
16
|
-
<%= content_tag @title_component, class: 'index_title document-title-heading' do %>
|
17
|
-
<%= before_title %><%= title %><%= after_title %>
|
18
|
-
<% end %>
|
19
|
-
<%= actions %>
|
20
|
-
</header>
|
21
|
-
|
15
|
+
<%= title %>
|
22
16
|
<%= embed %>
|
23
17
|
<%= content %>
|
24
18
|
<%= metadata %>
|
19
|
+
<% metadata_sections.each do |section| %>
|
20
|
+
<%= section %>
|
21
|
+
<% end %>
|
25
22
|
</div>
|
26
23
|
|
27
24
|
<%= thumbnail %>
|
@@ -2,12 +2,64 @@
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
class DocumentComponent < ::ViewComponent::Base
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
include Blacklight::ContentAreasShim
|
6
|
+
|
7
|
+
# Content appearing before the document
|
8
|
+
renders_one :header
|
9
|
+
|
10
|
+
# Content appearing after the document
|
11
|
+
renders_one :footer
|
12
|
+
|
13
|
+
# Content appearing instead of the regularly rendered document; its use is discouraged, but is a stop-gap until
|
14
|
+
# the ecosystem fully adopts view components.
|
15
|
+
renders_one :body
|
16
|
+
|
17
|
+
# The document title with some reasonable default behavior
|
18
|
+
renders_one :title, (lambda do |*args, component: nil, **kwargs|
|
19
|
+
component ||= Blacklight::DocumentTitleComponent
|
20
|
+
|
21
|
+
component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, link_to_document: !@show, document_component: self, **kwargs)
|
22
|
+
end)
|
23
|
+
|
24
|
+
renders_one :embed, (lambda do |static_content = nil, *args, component: nil, **kwargs|
|
25
|
+
next static_content if static_content.present?
|
26
|
+
next unless component
|
27
|
+
|
28
|
+
Deprecation.warn('Pass the presenter to the DocumentComponent') if @presenter.nil?
|
29
|
+
|
30
|
+
component.new(*args, document: @document, presenter: @presenter, document_counter: @document_counter, **kwargs)
|
31
|
+
end)
|
32
|
+
|
33
|
+
# The primary metadata section
|
34
|
+
renders_one :metadata, (lambda do |static_content = nil, *args, component: nil, fields: nil, **kwargs|
|
35
|
+
next static_content if static_content.present?
|
36
|
+
|
37
|
+
Deprecation.warn('Pass the presenter to the DocumentComponent') if !fields && @presenter.nil?
|
38
|
+
|
39
|
+
component ||= Blacklight::DocumentMetadataComponent
|
40
|
+
|
41
|
+
component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
|
42
|
+
end)
|
43
|
+
|
44
|
+
# Additional metadata sections
|
45
|
+
renders_many :metadata_sections
|
46
|
+
|
47
|
+
renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, *args, component: nil, **kwargs|
|
48
|
+
next image_options_or_static_content if image_options_or_static_content.is_a? String
|
49
|
+
|
50
|
+
component ||= @presenter&.view_config&.thumbnail_component || Blacklight::Document::ThumbnailComponent
|
51
|
+
Deprecation.warn('Pass the presenter to the DocumentComponent') if !component && @presenter.nil?
|
52
|
+
|
53
|
+
component.new(*args, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
|
54
|
+
end)
|
55
|
+
|
56
|
+
# A container for partials rendered using the view config partials configuration. Its use is discouraged, but necessary until
|
57
|
+
# the ecosystem fully adopts view components.
|
58
|
+
renders_many :partials
|
59
|
+
|
60
|
+
# Backwards compatibility
|
61
|
+
renders_one :actions
|
62
|
+
|
11
63
|
with_collection_parameter :document
|
12
64
|
|
13
65
|
# rubocop:disable Metrics/ParameterLists
|
@@ -23,10 +75,10 @@ module Blacklight
|
|
23
75
|
# @param counter_offset [Number] with `document_counter`, the offset of the start of that collection counter to the overall result set
|
24
76
|
# @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
|
25
77
|
def initialize(document: nil, presenter: nil,
|
26
|
-
id: nil, classes: [], component: :article, title_component:
|
27
|
-
metadata_component:
|
78
|
+
id: nil, classes: [], component: :article, title_component: nil,
|
79
|
+
metadata_component: nil,
|
28
80
|
embed_component: nil,
|
29
|
-
thumbnail_component:
|
81
|
+
thumbnail_component: nil,
|
30
82
|
counter: nil, document_counter: nil, counter_offset: 0,
|
31
83
|
show: false)
|
32
84
|
if presenter.nil? && document.nil?
|
@@ -41,9 +93,14 @@ module Blacklight
|
|
41
93
|
@id = id || ('document' if show)
|
42
94
|
@classes = classes
|
43
95
|
|
96
|
+
Deprecation.warn('Passing embed_component is deprecated') if @embed_component.present?
|
44
97
|
@embed_component = embed_component
|
45
|
-
|
46
|
-
|
98
|
+
|
99
|
+
Deprecation.warn('Passing metadata_component is deprecated') if @metadata_component.present?
|
100
|
+
@metadata_component = metadata_component || Blacklight::DocumentMetadataComponent
|
101
|
+
|
102
|
+
Deprecation.warn('Passing thumbnail_component is deprecated') if @thumbnail_component.present?
|
103
|
+
@thumbnail_component = thumbnail_component || Blacklight::Document::ThumbnailComponent
|
47
104
|
|
48
105
|
@document_counter = document_counter
|
49
106
|
@counter = counter
|
@@ -63,72 +120,15 @@ module Blacklight
|
|
63
120
|
].compact.flatten
|
64
121
|
end
|
65
122
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@
|
71
|
-
content_tag('span', presenter.heading, itemprop: "name")
|
72
|
-
else
|
73
|
-
@view_context.link_to_document @document, counter: @counter, itemprop: 'name'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Content for the document actions area
|
78
|
-
def actions
|
79
|
-
return super if block_given?
|
80
|
-
|
81
|
-
return if @show
|
82
|
-
|
83
|
-
@actions ||
|
84
|
-
@view_context.render_index_doc_actions(@document, wrapping_class: "index-document-functions col-sm-3 col-lg-2")
|
85
|
-
end
|
86
|
-
|
87
|
-
# Content for the document thumbnail area
|
88
|
-
def thumbnail(image_options = {})
|
89
|
-
return super if block_given?
|
90
|
-
return @thumbnail if @thumbnail
|
91
|
-
|
92
|
-
return if @show
|
93
|
-
|
94
|
-
component = @thumbnail_component || presenter.view_config.thumbnail_component
|
95
|
-
render(component.new(presenter: presenter, counter: @counter, image_options: image_options))
|
96
|
-
end
|
97
|
-
|
98
|
-
# Content for the document metadata area
|
99
|
-
def metadata
|
100
|
-
return super if block_given?
|
101
|
-
|
102
|
-
@metadata || @view_context.render(@metadata_component.new(fields: presenter.field_presenters, show: show?))
|
103
|
-
end
|
104
|
-
|
105
|
-
# Content that goes before the document title (e.g. the counter)
|
106
|
-
def before_title
|
107
|
-
return super if block_given?
|
108
|
-
|
109
|
-
@before_title || counter
|
110
|
-
end
|
111
|
-
|
112
|
-
def embed
|
113
|
-
return @embed if @embed
|
114
|
-
|
115
|
-
component = @embed_component || presenter.view_config.embed_component
|
116
|
-
|
117
|
-
return unless component
|
118
|
-
|
119
|
-
@view_context.render(component.new(document: @document, presenter: presenter, document_counter: @document_counter))
|
123
|
+
def before_render
|
124
|
+
set_slot(:title) unless title
|
125
|
+
set_slot(:thumbnail, component: @thumbnail_component || presenter.view_config&.thumbnail_component) unless thumbnail || show?
|
126
|
+
set_slot(:metadata, component: @metadata_component, fields: presenter.field_presenters) unless metadata
|
127
|
+
set_slot(:embed, component: @embed_component || presenter.view_config&.embed_component) unless embed
|
120
128
|
end
|
121
129
|
|
122
130
|
private
|
123
131
|
|
124
|
-
def counter
|
125
|
-
return unless @counter
|
126
|
-
|
127
|
-
content_tag :span, class: 'document-counter' do
|
128
|
-
t('blacklight.search.documents.counter', counter: @counter)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
132
|
def presenter
|
133
133
|
@presenter ||= @view_context.document_presenter(@document)
|
134
134
|
end
|