blacklight 7.13.2 → 7.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +23 -3
  3. data/README.md +0 -2
  4. data/VERSION +1 -1
  5. data/app/assets/javascripts/blacklight/blacklight.js +4 -2
  6. data/app/assets/stylesheets/blacklight/_header.scss +0 -5
  7. data/app/assets/stylesheets/blacklight/_icons.scss +5 -1
  8. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -1
  9. data/app/components/blacklight/advanced_search_form_component.html.erb +46 -0
  10. data/app/components/blacklight/advanced_search_form_component.rb +75 -0
  11. data/app/components/blacklight/constraint_component.html.erb +1 -1
  12. data/app/components/blacklight/constraint_layout_component.html.erb +1 -1
  13. data/app/components/blacklight/constraints_component.rb +42 -17
  14. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -2
  15. data/app/components/blacklight/document/thumbnail_component.rb +5 -2
  16. data/app/components/blacklight/document_component.rb +7 -2
  17. data/app/components/blacklight/document_metadata_component.rb +1 -1
  18. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +23 -0
  19. data/app/components/blacklight/facet_field_checkboxes_component.rb +24 -0
  20. data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +6 -0
  21. data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +29 -0
  22. data/app/components/blacklight/facet_field_list_component.html.erb +1 -0
  23. data/app/components/blacklight/facet_field_pagination_component.rb +1 -1
  24. data/app/components/blacklight/facet_item_component.rb +4 -2
  25. data/app/components/blacklight/hidden_search_state_component.rb +54 -0
  26. data/app/components/blacklight/search_bar_component.html.erb +4 -0
  27. data/app/components/blacklight/search_bar_component.rb +4 -2
  28. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  29. data/app/controllers/concerns/blacklight/catalog.rb +6 -0
  30. data/app/helpers/blacklight/component_helper_behavior.rb +1 -1
  31. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
  32. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  33. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -38
  34. data/app/helpers/blacklight/icon_helper_behavior.rb +1 -1
  35. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
  36. data/app/javascript/blacklight/button_focus.js +1 -0
  37. data/app/javascript/blacklight/modal.js +10 -4
  38. data/app/models/concerns/blacklight/suggest/response.rb +1 -1
  39. data/app/presenters/blacklight/clause_presenter.rb +37 -0
  40. data/app/presenters/blacklight/document_presenter.rb +5 -1
  41. data/app/presenters/blacklight/facet_field_presenter.rb +4 -0
  42. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +45 -0
  43. data/app/presenters/blacklight/facet_item_presenter.rb +32 -20
  44. data/app/presenters/blacklight/field_presenter.rb +1 -1
  45. data/app/presenters/blacklight/inclusive_facet_item_presenter.rb +16 -0
  46. data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
  47. data/app/presenters/blacklight/search_bar_presenter.rb +4 -0
  48. data/app/views/bookmarks/_tools.html.erb +1 -1
  49. data/app/views/catalog/_advanced_search_form.html.erb +7 -0
  50. data/app/views/catalog/_advanced_search_help.html.erb +24 -0
  51. data/app/views/catalog/_search_form.html.erb +1 -0
  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 +5 -4
  55. data/config/i18n-tasks.yml +1 -0
  56. data/config/locales/blacklight.en.yml +17 -0
  57. data/lib/blacklight/configuration.rb +2 -1
  58. data/lib/blacklight/configuration/field.rb +1 -1
  59. data/lib/blacklight/configuration/sort_field.rb +1 -1
  60. data/lib/blacklight/open_struct_with_hash_access.rb +18 -1
  61. data/lib/blacklight/routes/searchable.rb +1 -0
  62. data/lib/blacklight/search_builder.rb +2 -0
  63. data/lib/blacklight/search_state.rb +5 -1
  64. data/lib/blacklight/search_state/filter_field.rb +17 -7
  65. data/lib/blacklight/solr/repository.rb +11 -2
  66. data/lib/blacklight/solr/search_builder_behavior.rb +87 -23
  67. data/package.json +1 -1
  68. data/spec/components/blacklight/advanced_search_form_component_spec.rb +51 -0
  69. data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -1
  70. data/spec/components/blacklight/document_component_spec.rb +17 -0
  71. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +55 -0
  72. data/spec/components/blacklight/facet_field_list_component_spec.rb +39 -4
  73. data/spec/components/blacklight/hidden_search_state_component_spec.rb +24 -0
  74. data/spec/controllers/catalog_controller_spec.rb +9 -0
  75. data/spec/features/advanced_search_spec.rb +67 -0
  76. data/spec/features/bookmarks_spec.rb +1 -9
  77. data/spec/features/facets_spec.rb +2 -17
  78. data/spec/features/search_filters_spec.rb +0 -20
  79. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +1 -0
  80. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -0
  81. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +8 -0
  82. data/spec/lib/blacklight/search_state/filter_field_spec.rb +65 -0
  83. data/spec/models/blacklight/solr/repository_spec.rb +12 -0
  84. data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
  85. data/spec/models/blacklight/solr/search_builder_spec.rb +28 -0
  86. data/spec/presenters/blacklight/clause_presenter_spec.rb +34 -0
  87. data/spec/presenters/blacklight/document_presenter_spec.rb +13 -0
  88. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +41 -0
  89. data/spec/spec_helper.rb +8 -3
  90. data/spec/test_app_templates/Gemfile.extra +1 -1
  91. data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
  92. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +2 -0
  93. metadata +66 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f57c80d2b77a3b8bd0d536f3800fad183aa43d5aec10b71f921dfb23cbb6b26c
4
- data.tar.gz: 9748a16edba74f0a1f24b1d6813987196088e1d217dd621b6455ca235aec37be
3
+ metadata.gz: ab13b2ca3b5250f0ef85bb4f3b64f949a4c646b4f39e83ce5002bb26f40df1da
4
+ data.tar.gz: ceeb2e13d5dd1fa7459c6c743087043728ba680c7cf935365912198af3de736b
5
5
  SHA512:
6
- metadata.gz: af48c90bc958243c5177660307c059a974c647f27b1fd890061e6efbba253b68d4690e46547b488fee11fe92140db88d39051a0a666e656f478d89e9650fd541
7
- data.tar.gz: '019a8e8383aff4582a98a74348c2b40cf7e57aa121213fbd43702c13ff66f2f30c455d43c06dfa0f26c39ebc74f9d34ff40f72b72ed30bdd180384f58deb25cb'
6
+ metadata.gz: 89889eeb5499865e09a8b9b4887fadf3784ff449b92de38a2619f29371ddce31015b39a45e5feb78a0193195751d1e7982e4b776995e49f17839979126eb4177
7
+ data.tar.gz: d7913a9cd2a87b01b8e657bc0cf7427fd1e7cae7d6c82a4ceb3d9e1842bfdfefdbf2689ff637593728d6176f032e3e8737405d04aac713f1ae3e0f926d51f719
@@ -30,7 +30,7 @@ jobs:
30
30
  runs-on: ubuntu-latest
31
31
  strategy:
32
32
  matrix:
33
- ruby: [2.6, 2.7]
33
+ ruby: [2.7, 3.0]
34
34
  steps:
35
35
  - uses: actions/checkout@v2
36
36
  - name: Set up Ruby
@@ -43,11 +43,31 @@ jobs:
43
43
  run: bundle exec rake ci
44
44
  env:
45
45
  ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
46
- test_rails5:
46
+ test_rails6_0:
47
47
  runs-on: ubuntu-latest
48
48
  strategy:
49
49
  matrix:
50
- ruby: [2.5, 2.6]
50
+ ruby: [2.6]
51
+ steps:
52
+ - uses: actions/checkout@v2
53
+ - name: Set up Ruby
54
+ uses: ruby/setup-ruby@v1
55
+ with:
56
+ ruby-version: ${{ matrix.ruby }}
57
+ - name: Install dependencies
58
+ run: bundle install
59
+ env:
60
+ RAILS_VERSION: 6.0.3.4
61
+ - name: Run tests
62
+ run: bundle exec rake ci
63
+ env:
64
+ RAILS_VERSION: 6.0.3.4
65
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
66
+ test_rails5_2:
67
+ runs-on: ubuntu-latest
68
+ strategy:
69
+ matrix:
70
+ ruby: [2.5]
51
71
  steps:
52
72
  - uses: actions/checkout@v2
53
73
  - name: Set up Ruby
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Blacklight
2
2
 
3
- [![Build Status](https://travis-ci.org/projectblacklight/blacklight.png?branch=master)](https://travis-ci.org/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.13.2
1
+ 7.15.2
@@ -99,6 +99,7 @@ Blacklight.onLoad(function () {
99
99
  Blacklight.onLoad(function () {
100
100
  // Button clicks should change focus. As of 10/3/19, Firefox for Mac and
101
101
  // Safari both do not set focus to a button on button click.
102
+ // See https://zellwk.com/blog/inconsistent-button-behavior/ for background information
102
103
  document.querySelectorAll('button.collapse-toggle').forEach(button => {
103
104
  button.addEventListener('click', () => {
104
105
  event.target.focus();
@@ -349,8 +350,9 @@ Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]'; // Calle
349
350
  // to show to user in modal. Right now called only for extreme
350
351
  // network errors.
351
352
 
352
- Blacklight.modal.onFailure = function (data) {
353
- var contents = '<div class="modal-header">' + '<div class="modal-title">Network Error</div>' + '<button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">' + ' <span aria-hidden="true">&times;</span>' + '</button>';
353
+ Blacklight.modal.onFailure = function (jqXHR, textStatus, errorThrown) {
354
+ console.error('Server error:', this.url, jqXHR.status, errorThrown);
355
+ var contents = '<div class="modal-header">' + '<div class="modal-title">There was a problem with your request.</div>' + '<button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">' + ' <span aria-hidden="true">&times;</span>' + '</button></div>' + ' <div class="modal-body"><p>Expected a successful response from the server, but got an error</p>' + '<pre>' + this.type + ' ' + this.url + "\n" + jqXHR.status + ': ' + errorThrown + '</pre></div>';
354
356
  $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
355
357
  $(Blacklight.modal.modalSelector).modal('show');
356
358
  };
@@ -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: @view_context.constraint_query_label(@search_state.params),
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
@@ -46,22 +48,45 @@ module Blacklight
46
48
 
47
49
  private
48
50
 
51
+ def label
52
+ Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
53
+ @view_context.constraint_query_label(@search_state.params)
54
+ end
55
+ end
56
+
49
57
  def facet_item_presenters
50
- Deprecation.silence(Blacklight::SearchState) do
51
- @search_state.filter_params.each_pair.flat_map do |facet, values|
52
- facet_config = @view_context.facet_configuration_for_field(facet)
58
+ return to_enum(:facet_item_presenters) unless block_given?
53
59
 
54
- Array(values).map do |val|
60
+ Deprecation.silence(Blacklight::SearchState) do
61
+ @search_state.filters.map do |facet|
62
+ facet.values.map do |val|
55
63
  next if val.blank? # skip empty string
56
64
 
57
- 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
58
70
  end
59
71
  end
60
72
  end
61
73
  end
62
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
+
63
84
  def facet_item_presenter(facet_config, facet_item, facet_field)
64
85
  Blacklight::FacetItemPresenter.new(facet_item, facet_config, @view_context, facet_field)
65
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
66
91
  end
67
92
  end
@@ -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">
@@ -6,7 +6,7 @@
6
6
  <% warn_about_deprecated_behavior %>
7
7
  <%= value %>
8
8
  <% else %>
9
- <%= @view_context.link_to_document(@presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
9
+ <%= helpers.link_to_document(@presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
10
10
  <% end %>
11
11
  </div>
12
12
  <% end %>
@@ -7,10 +7,13 @@ 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
13
- @use_thumbnail_tag = @presenter.thumbnail != Blacklight::ThumbnailPresenter
15
+ @image_options = { alt: '' }.merge(image_options)
16
+ @use_thumbnail_tag = !@presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
14
17
  end
15
18
 
16
19
  def render?
@@ -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 %>