blacklight 7.14.0 → 7.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/blacklight/_header.scss +0 -5
  5. data/app/assets/stylesheets/blacklight/_icons.scss +5 -1
  6. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -1
  7. data/app/components/blacklight/advanced_search_form_component.html.erb +46 -0
  8. data/app/components/blacklight/advanced_search_form_component.rb +75 -0
  9. data/app/components/blacklight/constraint_component.html.erb +1 -1
  10. data/app/components/blacklight/constraint_layout_component.html.erb +1 -1
  11. data/app/components/blacklight/constraints_component.rb +36 -17
  12. data/app/components/blacklight/document/action_component.html.erb +1 -1
  13. data/app/components/blacklight/document/action_component.rb +2 -1
  14. data/app/components/blacklight/document/actions_component.html.erb +1 -1
  15. data/app/components/blacklight/document/actions_component.rb +2 -1
  16. data/app/components/blacklight/document/thumbnail_component.html.erb +1 -1
  17. data/app/components/blacklight/document/thumbnail_component.rb +4 -1
  18. data/app/components/blacklight/document_component.rb +7 -2
  19. data/app/components/blacklight/document_metadata_component.rb +1 -1
  20. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +23 -0
  21. data/app/components/blacklight/facet_field_checkboxes_component.rb +24 -0
  22. data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +6 -0
  23. data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +29 -0
  24. data/app/components/blacklight/facet_field_list_component.html.erb +1 -0
  25. data/app/components/blacklight/facet_field_pagination_component.rb +1 -1
  26. data/app/components/blacklight/facet_item_component.rb +4 -2
  27. data/app/components/blacklight/search_bar_component.html.erb +4 -0
  28. data/app/components/blacklight/search_bar_component.rb +9 -3
  29. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  30. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  31. data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
  32. data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
  33. data/app/helpers/blacklight/configuration_helper_behavior.rb +4 -4
  34. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  35. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
  36. data/app/models/concerns/blacklight/suggest/response.rb +1 -1
  37. data/app/presenters/blacklight/clause_presenter.rb +37 -0
  38. data/app/presenters/blacklight/document_presenter.rb +13 -5
  39. data/app/presenters/blacklight/facet_field_presenter.rb +4 -0
  40. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +45 -0
  41. data/app/presenters/blacklight/facet_item_presenter.rb +32 -20
  42. data/app/presenters/blacklight/field_presenter.rb +1 -1
  43. data/app/presenters/blacklight/inclusive_facet_item_presenter.rb +16 -0
  44. data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
  45. data/app/presenters/blacklight/search_bar_presenter.rb +4 -0
  46. data/app/services/blacklight/search_service.rb +1 -1
  47. data/app/views/bookmarks/_tools.html.erb +1 -1
  48. data/app/views/catalog/_advanced_search_form.html.erb +7 -0
  49. data/app/views/catalog/_advanced_search_help.html.erb +24 -0
  50. data/app/views/catalog/_search_form.html.erb +1 -0
  51. data/app/views/catalog/_show_main_content.html.erb +2 -2
  52. data/app/views/catalog/_zero_results.html.erb +1 -1
  53. data/app/views/catalog/advanced_search.html.erb +17 -0
  54. data/blacklight.gemspec +1 -1
  55. data/config/i18n-tasks.yml +1 -0
  56. data/config/locales/blacklight.en.yml +17 -0
  57. data/lib/blacklight/configuration.rb +52 -6
  58. data/lib/blacklight/configuration/field.rb +1 -1
  59. data/lib/blacklight/configuration/sort_field.rb +1 -1
  60. data/lib/blacklight/configuration/view_config.rb +16 -5
  61. data/lib/blacklight/open_struct_with_hash_access.rb +22 -1
  62. data/lib/blacklight/routes/searchable.rb +1 -0
  63. data/lib/blacklight/search_builder.rb +2 -0
  64. data/lib/blacklight/search_state.rb +7 -3
  65. data/lib/blacklight/search_state/filter_field.rb +17 -7
  66. data/lib/blacklight/solr/repository.rb +11 -2
  67. data/lib/blacklight/solr/search_builder_behavior.rb +98 -24
  68. data/spec/components/blacklight/advanced_search_form_component_spec.rb +51 -0
  69. data/spec/components/blacklight/document_component_spec.rb +15 -0
  70. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +55 -0
  71. data/spec/components/blacklight/facet_field_list_component_spec.rb +39 -4
  72. data/spec/controllers/catalog_controller_spec.rb +9 -0
  73. data/spec/features/advanced_search_spec.rb +67 -0
  74. data/spec/features/bookmarks_spec.rb +1 -9
  75. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  76. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +20 -0
  77. data/spec/lib/blacklight/search_state/filter_field_spec.rb +65 -0
  78. data/spec/models/blacklight/configuration_spec.rb +64 -0
  79. data/spec/models/blacklight/solr/repository_spec.rb +12 -0
  80. data/spec/models/blacklight/solr/search_builder_spec.rb +60 -0
  81. data/spec/presenters/blacklight/clause_presenter_spec.rb +34 -0
  82. data/spec/presenters/blacklight/document_presenter_spec.rb +13 -0
  83. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +41 -0
  84. data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
  85. metadata +29 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 125e5713e43315d9fdbae35677048bb1a1bb9830970f8ff43101ecaed9979385
4
- data.tar.gz: 34d83a1474edd010642bc2ddf9f72a5409dd66f80bd28f3e6576fafdaa119475
3
+ metadata.gz: 6ceacfa202c3acda3cb375ea3f76dd2e854f786aaba9e5a83a40cce15a1a77f5
4
+ data.tar.gz: b09a2d694145f7b8da82ecb99314632c1e521d63748ea0854a8d7dd131710633
5
5
  SHA512:
6
- metadata.gz: ab411c9cd2690a01b3d61fa1c8f602b910686b920e26ac638eddfb08e4b43af86d6beca036509056f510a2d56041059dadcfa0ee92cccedcbe238bfe5d7abc4b
7
- data.tar.gz: ed2cea2667023dbe7720c4939f4dc4b3cd98d26be0e7a1bc89dba416d0b077bf3792b810fe9e479ef5890f2cad3b3003154822778722b5528051df106f570e51
6
+ metadata.gz: 9fd109f991c7cf33507b73fa8e40bd67c90601751abca9374da323d0e907f8117ab676406f2edba878e1aba39f2bfd477fe4892e1dd015b11a30ef9311d95d6f
7
+ data.tar.gz: a10adadf6affff113b5ee41dd10c469ace59eda64afb560052fb8cdd94a1188ee11b1dc7c7cafe92ff229a43504a8590c8508c407f64c6fdfadb9dfbc70a7ccd
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Blacklight
2
2
 
3
- [![Build Status](https://travis-ci.com/projectblacklight/blacklight.png?branch=master)](https://travis-ci.com/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Test Coverage](https://api.codeclimate.com/v1/badges/83fd270492c136594e59/test_coverage)](https://codeclimate.com/github/projectblacklight/blacklight/test_coverage)
4
-
5
3
  Blacklight is an open source Solr user interface discovery platform.
6
4
  You can use Blacklight to enable searching and browsing of your collections.
7
5
  Blacklight uses the [Apache Solr](http://lucene.apache.org/solr) search engine
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.14.0
1
+ 7.16.0
@@ -14,11 +14,6 @@
14
14
  background: transparent $logo-image no-repeat top left;
15
15
  }
16
16
 
17
- @if $logo_image {
18
- // deprecated
19
- background: transparent image_url($logo_image) no-repeat top left;
20
- }
21
-
22
17
  display: inline-block;
23
18
  flex: 0 0 150px;
24
19
  height: 50px;
@@ -14,8 +14,12 @@
14
14
 
15
15
  .btn.btn-icon {
16
16
  padding: $btn-padding-y;
17
-
17
+
18
18
  &.btn-sm {
19
19
  padding: $btn-padding-y-sm;
20
20
  }
21
21
  }
22
+
23
+ .remove-icon {
24
+ font-family: $remove-icon-font-family;
25
+ }
@@ -1,8 +1,12 @@
1
1
  /* Warning! If you want to change these, just copy them into your own theme css. But you want to remove the !default, which only will set them if not already set. */
2
2
 
3
3
  $logo-image: image_url('blacklight/logo.png') !default;
4
- $logo_image: false !default; // deprecated
5
4
 
6
5
  /* label (field names) */
7
6
  $field_name_color: $text-muted !default;
8
7
  $zindex-typeahead: $zindex-dropdown;
8
+
9
+ // the default bootstrap font-family list includes "Segoe UI Emoji", which, on windows
10
+ // renders our remove icon as an emoji-sized x instead of what we see on all other platforms...
11
+ // so, for now (until we replace it with an SVG icon or something), we get to override bootstrap:
12
+ $remove-icon-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif !default;
@@ -0,0 +1,46 @@
1
+ <% if constraints.present? %>
2
+ <div class="constraints well search_history">
3
+ <h4><%= t 'blacklight.advanced_search.form.search_context' %></h4>
4
+ <%= constraints %>
5
+ </div>
6
+ <% end %>
7
+
8
+ <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => t('blacklight.search.form.submit') do %>
9
+ <%= render_hash_as_hidden_fields(@params) %>
10
+
11
+ <div class="input-criteria">
12
+ <div class="query-criteria">
13
+ <h2 class="query-criteria-heading">
14
+ <%= t('blacklight.advanced_search.form.query_criteria_heading_html', select_menu: default_operator_menu) %>
15
+ </h2>
16
+
17
+ <div id="advanced_search">
18
+ <%= search_field_controls %>
19
+ </div>
20
+ </div>
21
+
22
+ <div class="limit-criteria">
23
+ <h2 class="limit-criteria-heading"><%= t('blacklight.advanced_search.form.limit_criteria_heading_html')%></h2>
24
+
25
+ <div id="advanced_search_facets" class="limit_input">
26
+ <div class="advanced-facet-limits panel-group">
27
+ <%= search_filter_controls %>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </div>
32
+
33
+ <%= content_tag :h2, t('blacklight.advanced_search.form.sort_label') %>
34
+ <div class="form-group row">
35
+ <div class="col-sm-offset-3 col-sm-4">
36
+ <%= sort_fields_select %>
37
+ </div>
38
+ </div>
39
+
40
+ <div class="form-group row">
41
+ <div class="submit-buttons col-sm-offset-3 col-sm-9">
42
+ <%= submit_tag t('blacklight.advanced_search.form.search_btn_html'), class: 'btn btn-primary advanced-search-submit', id: "advanced-search-submit" %>
43
+ <%= button_tag t('blacklight.advanced_search.form.start_over_html'), type: 'reset', class: 'btn btn-link advanced-search-start-over' %>
44
+ </div>
45
+ </div>
46
+ <% end %>
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class AdvancedSearchFormComponent < SearchBarComponent
5
+ with_content_areas :constraints, :search_field_controls, :search_filter_controls
6
+
7
+ def initialize(response:, **options)
8
+ super(**options)
9
+ @response = response
10
+ end
11
+
12
+ def default_operator_menu
13
+ options_with_labels = [:must, :should].index_by { |op| t(op, scope: 'blacklight.advanced_search.op') }
14
+ select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
15
+ end
16
+
17
+ # Rubocop is just wrong here, so...:
18
+ # rubocop:disable Rails/ContentTag
19
+ def search_field_controls
20
+ @search_field_controls || safe_join(search_fields.values.map.with_index do |field, i|
21
+ fields_for('clause[]', i, include_id: false) do |f|
22
+ content_tag(:div, class: 'form-group advanced-search-field row') do
23
+ f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label") +
24
+ content_tag(:div, class: 'col-sm-9') do
25
+ f.hidden_field(:field, value: field.key) +
26
+ f.text_field(:query, value: query_for_search_clause(field.key), class: 'form-control')
27
+ end
28
+ end
29
+ end
30
+ end, "\n")
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')
38
+ end
39
+
40
+ def search_filter_controls
41
+ return @search_filter_controls if @search_filter_controls
42
+
43
+ fields = blacklight_config.facet_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
44
+
45
+ safe_join(fields.map do |_k, config|
46
+ display_facet = @response.aggregations[config.field]
47
+
48
+ presenter = (config.presenter || Blacklight::FacetFieldPresenter).new(config, display_facet, @view_context)
49
+ component = config.advanced_search_component || Blacklight::FacetFieldCheckboxesComponent
50
+ @view_context.render(component.new(facet_field: presenter))
51
+ end, "\n")
52
+ end
53
+
54
+ def constraints
55
+ params = @view_context.search_state.params_for_search.except :page, :f_inclusive, :q, :search_field, :op, :index, :sort
56
+
57
+ params.except!(*search_fields.map { |_key, field_def| field_def[:key] })
58
+
59
+ @view_context.render_search_to_s(params)
60
+ end
61
+
62
+ def sort_fields_select
63
+ options = sort_fields.values.map { |field_config| [@view_context.sort_field_label(field_config.key), field_config.key] }
64
+ select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select")
65
+ end
66
+
67
+ def search_fields
68
+ blacklight_config.search_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
69
+ end
70
+
71
+ def sort_fields
72
+ blacklight_config.sort_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,5 @@
1
1
  <%= render(@layout.new(
2
- classes: (Array(@classes) + ["filter-#{@facet_item_presenter.facet_config.key.parameterize}"]).join(' '),
2
+ classes: (Array(@classes) + ["filter-#{@facet_item_presenter.key.parameterize}"]).join(' '),
3
3
  label: @facet_item_presenter.field_label,
4
4
  value: @facet_item_presenter.label,
5
5
  remove_path: @facet_item_presenter.remove_href)) %>
@@ -9,7 +9,7 @@
9
9
  </span>
10
10
  <% if @remove_path.present? %>
11
11
  <%= link_to(@remove_path, class: 'btn btn-outline-secondary remove') do %>
12
- <span class="remove-icon">✖</span>
12
+ <span class="remove-icon" aria-hidden="true">✖</span>
13
13
  <span class="sr-only">
14
14
  <%= if @label.blank?
15
15
  t('blacklight.search.filters.remove.value', value: @value)
@@ -15,23 +15,25 @@ module Blacklight
15
15
  end
16
16
 
17
17
  def query_constraints
18
- return if @search_state.query_param.blank?
19
-
20
18
  Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
21
- @view_context.render(
22
- @query_constraint_component.new(
23
- search_state: @search_state,
24
- value: @search_state.query_param,
25
- label: label,
26
- remove_path: @view_context.remove_constraint_url(@search_state),
27
- classes: 'query'
19
+ if @search_state.query_param.present?
20
+ @view_context.render(
21
+ @query_constraint_component.new(
22
+ search_state: @search_state,
23
+ value: @search_state.query_param,
24
+ label: label,
25
+ remove_path: @view_context.remove_constraint_url(@search_state),
26
+ classes: 'query'
27
+ )
28
28
  )
29
- )
30
- end
29
+ else
30
+ ''.html_safe
31
+ end
32
+ end + @view_context.render(@facet_constraint_component.with_collection(clause_presenters.to_a))
31
33
  end
32
34
 
33
35
  def facet_constraints
34
- @view_context.render(@facet_constraint_component.with_collection(facet_item_presenters))
36
+ @view_context.render(@facet_constraint_component.with_collection(facet_item_presenters.to_a))
35
37
  end
36
38
 
37
39
  def start_over_path
@@ -53,21 +55,38 @@ module Blacklight
53
55
  end
54
56
 
55
57
  def facet_item_presenters
56
- Deprecation.silence(Blacklight::SearchState) do
57
- @search_state.filter_params.each_pair.flat_map do |facet, values|
58
- facet_config = @view_context.facet_configuration_for_field(facet)
58
+ return to_enum(:facet_item_presenters) unless block_given?
59
59
 
60
- Array(values).map do |val|
60
+ Deprecation.silence(Blacklight::SearchState) do
61
+ @search_state.filters.map do |facet|
62
+ facet.values.map do |val|
61
63
  next if val.blank? # skip empty string
62
64
 
63
- facet_item_presenter(facet_config, val, facet)
65
+ if val.is_a?(Array)
66
+ yield inclusive_facet_item_presenter(facet.config, val, facet.key) if val.any?(&:present?)
67
+ else
68
+ yield facet_item_presenter(facet.config, val, facet.key)
69
+ end
64
70
  end
65
71
  end
66
72
  end
67
73
  end
68
74
 
75
+ def clause_presenters
76
+ return to_enum(:clause_presenters) unless block_given?
77
+
78
+ @search_state.clause_params.each do |key, clause|
79
+ field_config = @view_context.blacklight_config.search_fields[clause[:field]]
80
+ yield Blacklight::ClausePresenter.new(key, clause, field_config, @view_context)
81
+ end
82
+ end
83
+
69
84
  def facet_item_presenter(facet_config, facet_item, facet_field)
70
85
  Blacklight::FacetItemPresenter.new(facet_item, facet_config, @view_context, facet_field)
71
86
  end
87
+
88
+ def inclusive_facet_item_presenter(facet_config, facet_item, facet_field)
89
+ Blacklight::InclusiveFacetItemPresenter.new(facet_item, facet_config, @view_context, facet_field)
90
+ end
72
91
  end
73
92
  end
@@ -2,7 +2,7 @@
2
2
  <%= link_to label,
3
3
  url,
4
4
  id: @id,
5
- class: 'nav-link',
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?
@@ -1,6 +1,6 @@
1
1
  <%= content_tag @tag, class: @classes do %>
2
2
  <% @actions.each do |action| %>
3
- <% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts)) } %>
3
+ <% result = capture { @view_context.render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: @document, options: @options, url_opts: @url_opts, link_classes: @link_classes)) } %>
4
4
 
5
5
  <% if @wrapping_tag %>
6
6
  <%= content_tag(@wrapping_tag, class: Array(@wrapping_classes) + [action.key]) do %>
@@ -6,7 +6,7 @@ module Blacklight
6
6
  class ActionsComponent < ::ViewComponent::Base
7
7
  # @param [Blacklight::Document] document
8
8
  # 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)
9
+ 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
10
  @document = document
11
11
  @actions = actions
12
12
  @tag = tag
@@ -15,6 +15,7 @@ module Blacklight
15
15
  @url_opts = url_opts
16
16
  @wrapping_tag = wrapping_tag
17
17
  @wrapping_classes = wrapping_classes
18
+ @link_classes = link_classes
18
19
  end
19
20
  # rubocop:enable Metrics/ParameterLists
20
21
 
@@ -1,4 +1,4 @@
1
- <% value = @use_thumbnail_tag ? @presenter.thumbnail.thumbnail_tag({ alt: '' }, 'aria-hidden': true, tabindex: -1, counter: @counter) : @presenter.thumbnail.render({ alt: '' }) %>
1
+ <% value = @use_thumbnail_tag ? @presenter.thumbnail.thumbnail_tag(@image_options, 'aria-hidden': true, tabindex: -1, counter: @counter) : @presenter.thumbnail.render(@image_options) %>
2
2
 
3
3
  <% if value %>
4
4
  <div class="document-thumbnail">
@@ -7,9 +7,12 @@ module Blacklight
7
7
  with_collection_parameter :presenter
8
8
 
9
9
  # @param [Blacklight::DocumentPresenter] presenter
10
- def initialize(presenter:, counter:)
10
+ # @param [Integer] counter
11
+ # @param [Hash] image_options options for the thumbnail presenter's image tag
12
+ def initialize(presenter:, counter:, image_options: {})
11
13
  @presenter = presenter
12
14
  @counter = counter
15
+ @image_options = { alt: '' }.merge(image_options)
13
16
  @use_thumbnail_tag = !@presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
14
17
  end
15
18
 
@@ -26,6 +26,7 @@ module Blacklight
26
26
  id: nil, classes: [], component: :article, title_component: :h4,
27
27
  metadata_component: Blacklight::DocumentMetadataComponent,
28
28
  embed_component: nil,
29
+ thumbnail_component: Blacklight::Document::ThumbnailComponent,
29
30
  counter: nil, document_counter: nil, counter_offset: 0,
30
31
  show: false)
31
32
  if presenter.nil? && document.nil?
@@ -42,6 +43,7 @@ module Blacklight
42
43
 
43
44
  @embed_component = embed_component
44
45
  @metadata_component = metadata_component
46
+ @thumbnail_component = thumbnail_component
45
47
 
46
48
  @document_counter = document_counter
47
49
  @counter = counter
@@ -83,11 +85,14 @@ module Blacklight
83
85
  end
84
86
 
85
87
  # Content for the document thumbnail area
86
- def thumbnail
88
+ def thumbnail(image_options = {})
87
89
  return super if block_given?
90
+ return @thumbnail if @thumbnail
91
+
88
92
  return if @show
89
93
 
90
- @thumbnail || render(Blacklight::Document::ThumbnailComponent.new(presenter: presenter, counter: @counter))
94
+ component = @thumbnail_component || presenter.view_config.thumbnail_component
95
+ render(component.new(presenter: presenter, counter: @counter, image_options: image_options))
91
96
  end
92
97
 
93
98
  # Content for the document metadata area
@@ -15,7 +15,7 @@ module Blacklight
15
15
  end
16
16
 
17
17
  def field_component(field)
18
- field.try(:component) || Blacklight::MetadataFieldComponent
18
+ field&.component || Blacklight::MetadataFieldComponent
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,23 @@
1
+ <%= render(@layout.new(facet_field: @facet_field)) do |component| %>
2
+ <% component.with(:label) do %>
3
+ <%= @facet_field.label %>
4
+ <% end %>
5
+
6
+ <% component.with(:body) do %>
7
+ <ul class="facet-values list-unstyled blacklight-facet-checkboxes">
8
+ <% presenters.each_with_index do |presenter, idx| -%>
9
+ <li>
10
+ <span class="facet-checkbox">
11
+ <%= check_box_tag "f_inclusive[#{@facet_field.key}][]", presenter.value, presenter.selected?, id: "f_inclusive_#{@facet_field.key}_#{idx}"%>
12
+ </span>
13
+
14
+ <span class="label-and-count">
15
+ <%= label_tag "f_inclusive_#{@facet_field.key}_#{idx}" do %>
16
+ <%= presenter.label %>
17
+ <% end %>
18
+ <span>
19
+ </li>
20
+ <% end -%>
21
+ </ul>
22
+ <% end %>
23
+ <% end %>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class FacetFieldCheckboxesComponent < ::ViewComponent::Base
5
+ def initialize(facet_field:, layout: nil)
6
+ @facet_field = facet_field
7
+ @layout = layout == false ? FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
8
+ end
9
+
10
+ def render?
11
+ presenters.any?
12
+ end
13
+
14
+ def presenters
15
+ return [] unless @facet_field.paginator
16
+
17
+ return to_enum(:presenters) unless block_given?
18
+
19
+ @facet_field.paginator.items.each do |item|
20
+ yield Blacklight::FacetItemPresenter.new(item, @facet_field.facet_field, @view_context, @facet_field.key, @facet_field.search_state)
21
+ end
22
+ end
23
+ end
24
+ end