blacklight 7.23.0 → 7.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +4 -4
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/blacklight/blacklight.js +2 -2
  5. data/app/assets/stylesheets/blacklight/_constraints.scss +1 -0
  6. data/app/components/blacklight/constraint_component.rb +1 -1
  7. data/app/components/blacklight/constraint_layout_component.rb +1 -1
  8. data/app/components/blacklight/constraints_component.rb +1 -1
  9. data/app/components/blacklight/document/action_component.rb +1 -1
  10. data/app/components/blacklight/document/actions_component.rb +1 -1
  11. data/app/components/blacklight/document/bookmark_component.rb +1 -1
  12. data/app/components/blacklight/document/citation_component.rb +2 -2
  13. data/app/components/blacklight/document/group_component.rb +3 -2
  14. data/app/components/blacklight/document/more_like_this_component.rb +1 -1
  15. data/app/components/blacklight/document/thumbnail_component.rb +1 -1
  16. data/app/components/blacklight/document_component.rb +1 -2
  17. data/app/components/blacklight/document_metadata_component.rb +1 -1
  18. data/app/components/blacklight/document_title_component.rb +1 -1
  19. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  20. data/app/components/blacklight/facet_field_component.rb +1 -1
  21. data/app/components/blacklight/facet_field_filter_component.rb +1 -1
  22. data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +1 -1
  23. data/app/components/blacklight/facet_field_list_component.rb +1 -1
  24. data/app/components/blacklight/facet_field_no_layout_component.rb +1 -1
  25. data/app/components/blacklight/facet_field_pagination_component.rb +1 -1
  26. data/app/components/blacklight/facet_item_component.rb +1 -1
  27. data/app/components/blacklight/facet_item_pivot_component.rb +1 -1
  28. data/app/components/blacklight/hidden_search_state_component.rb +2 -2
  29. data/app/components/blacklight/metadata_field_component.rb +1 -1
  30. data/app/components/blacklight/metadata_field_layout_component.rb +1 -1
  31. data/app/components/blacklight/response/facet_group_component.html.erb +1 -1
  32. data/app/components/blacklight/response/facet_group_component.rb +1 -1
  33. data/app/components/blacklight/response/pagination_component.rb +3 -3
  34. data/app/components/blacklight/search_bar_component.html.erb +7 -7
  35. data/app/components/blacklight/search_bar_component.rb +18 -13
  36. data/app/components/blacklight/search_context_component.rb +1 -1
  37. data/app/components/blacklight/start_over_button_component.rb +1 -1
  38. data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -1
  39. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  40. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +5 -7
  41. data/app/javascript/blacklight/modal.js +2 -2
  42. data/app/presenters/blacklight/search_bar_presenter.rb +2 -0
  43. data/app/services/blacklight/field_retriever.rb +1 -1
  44. data/app/views/catalog/_constraints.html.erb +2 -2
  45. data/app/views/catalog/_facet_group.html.erb +1 -1
  46. data/app/views/catalog/_search_form.html.erb +2 -2
  47. data/app/views/shared/_header_navbar.html.erb +5 -1
  48. data/lib/blacklight/component.rb +40 -0
  49. data/lib/blacklight/configuration/facet_field.rb +1 -1
  50. data/lib/blacklight/configuration/fields.rb +10 -11
  51. data/lib/blacklight/configuration/view_config.rb +6 -0
  52. data/lib/blacklight/configuration.rb +320 -179
  53. data/lib/blacklight/deprecations/search_state_normalization.rb +52 -0
  54. data/lib/blacklight/engine.rb +7 -0
  55. data/lib/blacklight/runtime_registry.rb +1 -5
  56. data/lib/blacklight/search_state/filter_field.rb +44 -16
  57. data/lib/blacklight/search_state.rb +53 -22
  58. data/lib/blacklight/solr/search_builder_behavior.rb +3 -1
  59. data/lib/blacklight.rb +1 -0
  60. data/lib/generators/blacklight/assets_generator.rb +4 -1
  61. data/package.json +1 -1
  62. data/spec/components/blacklight/constraints_component_spec.rb +14 -1
  63. data/spec/components/blacklight/facet_field_list_component_spec.rb +6 -1
  64. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +7 -1
  65. data/spec/controllers/blacklight/base_spec.rb +4 -1
  66. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +23 -6
  67. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -0
  68. data/spec/lib/blacklight/component_spec.rb +43 -0
  69. data/spec/lib/blacklight/search_state/filter_field_spec.rb +12 -1
  70. data/spec/lib/blacklight/search_state_spec.rb +22 -4
  71. data/spec/models/blacklight/configuration_spec.rb +2 -2
  72. data/spec/models/blacklight/solr/search_builder_spec.rb +15 -0
  73. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +10 -4
  74. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +6 -1
  75. data/spec/presenters/blacklight/field_presenter_spec.rb +2 -0
  76. data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
  77. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 982aa4e78d4586096d97f31ccfdd52bfbfe5ff7f562248454240bca9c409d910
4
- data.tar.gz: b9fc47ba21552ab4f29c166f04585bbbf70b25bdbe818f70d8d3bfd2c891db58
3
+ metadata.gz: e758c87d1a1961258d284421d258d39a53600da0df9980f294c2174da1a2fe6f
4
+ data.tar.gz: cc0da20194f1a185f3847f724e89677a28ef233d5cc89b7ec73dc55dee4ee6f3
5
5
  SHA512:
6
- metadata.gz: 05d918ebf0f597eaaf5950e34a74785a79a0b7f0174f9d4458c8fa5f906abefb4016f8d307548d80cdc901a7b6a8288083623f9a7db52ebeb6bcc68f29140272
7
- data.tar.gz: efcc57d374d646fe0f0113298383244c85180d059db1bb4e4f24537dbf24fee5f38b3a9f8f4ea8b5cbd0bffd3a3bfaffcbf3663d667ea48f33ae26ae0f6837e9
6
+ metadata.gz: 7b94f8337cb6c1c5cb9747d2a5efe67144dca742418e18e15baa4cb10fcc333608f43d94d25157b2e7be8267a9aa4cef9c8b2544e574745e5c2d1ea6fdf93383
7
+ data.tar.gz: 85db04a2e0ab1e7736e10afa94e8fe007c2c7163dd8ab551827928a0baa5da426d8106d3b075c1e2621c5a6409d6a5c2e403891b497cf30edf497ca3b47e1d2c
@@ -31,7 +31,7 @@ jobs:
31
31
  runs-on: ubuntu-latest
32
32
  strategy:
33
33
  matrix:
34
- ruby: [2.7, '3.0']
34
+ ruby: [2.7, '3.0', 3.1]
35
35
  steps:
36
36
  - uses: actions/checkout@v2
37
37
  - name: Set up Ruby
@@ -103,7 +103,7 @@ jobs:
103
103
  RAILS_VERSION: 5.2.4.6
104
104
  ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
105
105
 
106
- test_rails7_0:
106
+ test_rails6_1:
107
107
  runs-on: ubuntu-latest
108
108
  strategy:
109
109
  matrix:
@@ -117,11 +117,11 @@ jobs:
117
117
  - name: Install dependencies
118
118
  run: bundle install
119
119
  env:
120
- RAILS_VERSION: 7.0.0
120
+ RAILS_VERSION: 6.1.5
121
121
  - name: Run tests
122
122
  run: bundle exec rake ci
123
123
  env:
124
- RAILS_VERSION: 7.0.0
124
+ RAILS_VERSION: 6.1.5
125
125
  ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-keeps --skip-action-cable --skip-test'
126
126
  api_test:
127
127
  runs-on: ubuntu-latest
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.23.0
1
+ 7.25.0
@@ -441,7 +441,7 @@ Blacklight.modal.checkCloseModal = function (event) {
441
441
  };
442
442
 
443
443
  Blacklight.modal.hide = function (el) {
444
- if (bootstrap.Modal.VERSION >= "5") {
444
+ if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
445
445
  bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide();
446
446
  } else {
447
447
  $(el || Blacklight.modal.modalSelector).modal('hide');
@@ -449,7 +449,7 @@ Blacklight.modal.hide = function (el) {
449
449
  };
450
450
 
451
451
  Blacklight.modal.show = function (el) {
452
- if (bootstrap.Modal.VERSION >= "5") {
452
+ if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
453
453
  bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show();
454
454
  } else {
455
455
  $(el || Blacklight.modal.modalSelector).modal('show');
@@ -12,6 +12,7 @@
12
12
  cursor: default;
13
13
  text-overflow: ellipsis;
14
14
  overflow: hidden;
15
+ white-space: nowrap;
15
16
 
16
17
  @media (max-width: breakpoint-min(sm)) {
17
18
  max-width: breakpoint-min(sm) * .5;
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class ConstraintComponent < ::ViewComponent::Base
4
+ class ConstraintComponent < Blacklight::Component
5
5
  with_collection_parameter :facet_item_presenter
6
6
 
7
7
  def initialize(facet_item_presenter:, classes: 'filter', layout: Blacklight::ConstraintLayoutComponent)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class ConstraintLayoutComponent < ::ViewComponent::Base
4
+ class ConstraintLayoutComponent < Blacklight::Component
5
5
  def initialize(value:, label: nil, remove_path: nil, classes: nil, search_state: nil)
6
6
  @value = value
7
7
  @label = label
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class ConstraintsComponent < ::ViewComponent::Base
4
+ class ConstraintsComponent < Blacklight::Component
5
5
  include Blacklight::ContentAreasShim
6
6
 
7
7
  renders_many :query_constraints_area
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render a bookmark widget to bookmark / unbookmark a document
6
- class ActionComponent < ::ViewComponent::Base
6
+ class ActionComponent < Blacklight::Component
7
7
  with_collection_parameter :action
8
8
 
9
9
  # @param [Blacklight::Document] document
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render a bookmark widget to bookmark / unbookmark a document
6
- class ActionsComponent < ::ViewComponent::Base
6
+ class ActionsComponent < Blacklight::Component
7
7
  renders_many :actions, (lambda do |action:, component: nil, **kwargs|
8
8
  component ||= action.component || Blacklight::Document::ActionComponent
9
9
  component.new(action: action, document: @document, options: @options, url_opts: @url_opts, link_classes: @link_classes, **kwargs)
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render a bookmark widget to bookmark / unbookmark a document
6
- class BookmarkComponent < ::ViewComponent::Base
6
+ class BookmarkComponent < Blacklight::Component
7
7
  # @param [Blacklight::Document] document
8
8
  # @param [Boolean] checked
9
9
  # @param [Object] bookmark_path the rails route to use for bookmarks
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render citations for the document
6
- class CitationComponent < ::ViewComponent::Base
6
+ class CitationComponent < Blacklight::Component
7
7
  DEFAULT_FORMATS = {
8
8
  'blacklight.citation.mla': :export_as_mla_citation_txt,
9
9
  'blacklight.citation.apa': :export_as_apa_citation_txt,
@@ -13,7 +13,7 @@ module Blacklight
13
13
  with_collection_parameter :document
14
14
 
15
15
  # @param [Blacklight::Document] document
16
- # @param [Hash<String => Symbol>] map of citation format names (suspiciously, i18n keys
16
+ # @param [Hash<String => Symbol>] formats map of citation format names (suspiciously, i18n keys
17
17
  # for them) to document methods that return the formatted citation.
18
18
  def initialize(document:, formats: DEFAULT_FORMATS)
19
19
  @document = document
@@ -3,10 +3,11 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render the 'more like this' results from the response
6
- class GroupComponent < ::ViewComponent::Base
6
+ class GroupComponent < Blacklight::Component
7
7
  with_collection_parameter :group
8
8
 
9
- # @param [Blacklight::Document] document
9
+ # @param [Blacklight::Solr::Response::Group] group
10
+ # @param [Integer] group_limit
10
11
  def initialize(group:, group_limit: -1)
11
12
  @group = group
12
13
  @group_limit = group_limit
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render the 'more like this' results from the response
6
- class MoreLikeThisComponent < ::ViewComponent::Base
6
+ class MoreLikeThisComponent < Blacklight::Component
7
7
  with_collection_parameter :document
8
8
 
9
9
  # @param [Blacklight::Document] document
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render the thumbnail for the document
6
- class ThumbnailComponent < ::ViewComponent::Base
6
+ class ThumbnailComponent < Blacklight::Component
7
7
  with_collection_parameter :presenter
8
8
 
9
9
  # @param [Blacklight::DocumentPresenter] presenter
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class DocumentComponent < ::ViewComponent::Base
4
+ class DocumentComponent < Blacklight::Component
5
5
  include Blacklight::ContentAreasShim
6
6
 
7
7
  # Content appearing before the document
@@ -69,7 +69,6 @@ module Blacklight
69
69
  # @param classes [Array, String] additional HTML classes for the root element
70
70
  # @param component [Symbol, String] HTML tag type to use for the root element
71
71
  # @param title_component [Symbol, String] HTML tag type to use for the title element
72
- # @param metadata_component [Blacklight::DocumentMetadataComponent]
73
72
  # @param counter [Number, nil] a pre-computed counter for the position of this document in a search result set
74
73
  # @param document_counter [Number, nil] alternatively, the document's position in a collection and,
75
74
  # @param counter_offset [Number] with `document_counter`, the offset of the start of that collection counter to the overall result set
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class DocumentMetadataComponent < ::ViewComponent::Base
4
+ class DocumentMetadataComponent < Blacklight::Component
5
5
  renders_many :fields, (lambda do |component: nil, **kwargs|
6
6
  (component || Blacklight::MetadataFieldComponent).new(**kwargs)
7
7
  end)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class DocumentTitleComponent < ::ViewComponent::Base
4
+ class DocumentTitleComponent < Blacklight::Component
5
5
  renders_many :before_title
6
6
  renders_many :after_title
7
7
  renders_many :actions
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldCheckboxesComponent < ::ViewComponent::Base
4
+ class FacetFieldCheckboxesComponent < Blacklight::Component
5
5
  def initialize(facet_field:, layout: nil)
6
6
  @facet_field = facet_field
7
7
  @layout = layout == false ? FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldComponent < ::ViewComponent::Base
4
+ class FacetFieldComponent < Blacklight::Component
5
5
  include Blacklight::ContentAreasShim
6
6
 
7
7
  renders_one :label
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldFilterComponent < ::ViewComponent::Base
4
+ class FacetFieldFilterComponent < Blacklight::Component
5
5
  def initialize(facet_field:)
6
6
  @facet_field = facet_field
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldInclusiveConstraintComponent < ::ViewComponent::Base
4
+ class FacetFieldInclusiveConstraintComponent < Blacklight::Component
5
5
  with_collection_parameter :facet_field
6
6
 
7
7
  def initialize(facet_field:, values: nil)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldListComponent < ::ViewComponent::Base
4
+ class FacetFieldListComponent < Blacklight::Component
5
5
  def initialize(facet_field:, layout: nil)
6
6
  @facet_field = facet_field
7
7
  @layout = layout == false ? FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldNoLayoutComponent < ::ViewComponent::Base
4
+ class FacetFieldNoLayoutComponent < Blacklight::Component
5
5
  include Blacklight::ContentAreasShim
6
6
 
7
7
  renders_one :label
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetFieldPaginationComponent < ::ViewComponent::Base
4
+ class FacetFieldPaginationComponent < Blacklight::Component
5
5
  def initialize(facet_field:)
6
6
  @facet_field = facet_field
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class FacetItemComponent < ::ViewComponent::Base
4
+ class FacetItemComponent < Blacklight::Component
5
5
  extend Deprecation
6
6
 
7
7
  with_collection_parameter :facet_item
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Blacklight
4
4
  # Render facet items and any subtree
5
- class FacetItemPivotComponent < ::ViewComponent::Base
5
+ class FacetItemPivotComponent < Blacklight::Component
6
6
  # Somewhat arbitrary number; the only important thing is that
7
7
  # it is bigger than the number of leaf nodes in any collapsing
8
8
  # pivot facet on the page.
@@ -4,8 +4,8 @@ module Blacklight
4
4
  # Writes out zero or more <input type="hidden"> elements, completely
5
5
  # representing a hash passed in using Rails-style request parameters
6
6
  # for hashes nested with arrays and other hashes.
7
- class HiddenSearchStateComponent < ::ViewComponent::Base
8
- # @param [Hash] hash
7
+ class HiddenSearchStateComponent < Blacklight::Component
8
+ # @param [Hash] params
9
9
  def initialize(params:)
10
10
  Deprecation.warn(self, "Passing page as a parameter to HiddenSearchStateComponent is deprecated and will not be supported in Blacklight 8") if params.key?(:page)
11
11
  @params = params.except(:utf8)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class MetadataFieldComponent < ::ViewComponent::Base
4
+ class MetadataFieldComponent < Blacklight::Component
5
5
  with_collection_parameter :field
6
6
 
7
7
  # @param field [Blacklight::FieldPresenter]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class MetadataFieldLayoutComponent < ::ViewComponent::Base
4
+ class MetadataFieldLayoutComponent < Blacklight::Component
5
5
  include Blacklight::ContentAreasShim
6
6
 
7
7
  with_collection_parameter :field
@@ -22,7 +22,7 @@
22
22
  </div>
23
23
 
24
24
  <%= content_tag :div, id: @panel_id, class: 'facets-collapse collapse' do %>
25
- <% Deprecation.silence(Blacklight::FacetsHelperBehavior) do %>
25
+ <% ::Deprecation.silence(Blacklight::FacetsHelperBehavior) do %>
26
26
  <%= helpers.render_facet_partials @fields, response: @response %>
27
27
  <% end %>
28
28
  <% end %>
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  module Response
5
5
  # Render a group of facet fields
6
- class FacetGroupComponent < ::ViewComponent::Base
6
+ class FacetGroupComponent < Blacklight::Component
7
7
  # @param [Blacklight::Response] response
8
8
  # @param [Array<String>] fields facet fields to render
9
9
  # @param [String] title the title of the facet group section
@@ -3,17 +3,17 @@
3
3
  module Blacklight
4
4
  module Response
5
5
  # Render a pagination widget for search results
6
- class PaginationComponent < ::ViewComponent::Base
6
+ class PaginationComponent < Blacklight::Component
7
7
  # @param [Blacklight::Response] response
8
8
  # @param [Hash] html html options for the pagination container
9
9
  def initialize(response:, html: {}, **pagination_args)
10
10
  @response = response
11
11
  @html_attr = { aria: { label: t('views.pagination.aria.container_label') } }.merge(html)
12
- @pagination_args = { outer_window: 2, theme: 'blacklight' }.merge(pagination_args)
12
+ @pagination_args = pagination_args
13
13
  end
14
14
 
15
15
  def pagination
16
- helpers.paginate @response, **@pagination_args
16
+ helpers.paginate @response, **Blacklight::Engine.config.blacklight.default_pagination_options, **@pagination_args
17
17
  end
18
18
  end
19
19
  end
@@ -1,23 +1,23 @@
1
1
  <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => scoped_t('submit') do %>
2
2
  <%= render_hash_as_hidden_fields(@params) %>
3
- <% if @search_fields.length > 1 %>
3
+ <% if search_fields.length > 1 %>
4
4
  <label for="search_field" class="sr-only visually-hidden"><%= scoped_t('search_field.label') %></label>
5
5
  <% end %>
6
6
  <div class="input-group">
7
7
  <%= prepend %>
8
8
 
9
- <% if @search_fields.length > 1 %>
9
+ <% if search_fields.length > 1 %>
10
10
  <%= select_tag(:search_field,
11
- options_for_select(@search_fields, h(@search_field)),
11
+ options_for_select(search_fields, h(@search_field)),
12
12
  title: scoped_t('search_field.title'),
13
13
  id: "#{@prefix}search_field",
14
14
  class: "custom-select form-select search-field") %>
15
- <% elsif @search_fields.length == 1 %>
16
- <%= hidden_field_tag :search_field, @search_fields.first.last %>
15
+ <% elsif search_fields.length == 1 %>
16
+ <%= hidden_field_tag :search_field, search_fields.first.last %>
17
17
  <% end %>
18
18
 
19
19
  <label for="<%= @prefix %><%= @query_param %>" class="sr-only visually-hidden"><%= scoped_t('search.label') %></label>
20
- <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{@search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %>
20
+ <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %>
21
21
 
22
22
  <span class="input-group-append">
23
23
  <%= append %>
@@ -30,6 +30,6 @@
30
30
  </div>
31
31
  <% end %>
32
32
 
33
- <% if presenter.advanced_search_enabled? %>
33
+ <% if advanced_search_enabled? %>
34
34
  <%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-secondary'%>
35
35
  <% end %>
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class SearchBarComponent < ::ViewComponent::Base
4
+ class SearchBarComponent < Blacklight::Component
5
5
  include Blacklight::ContentAreasShim
6
6
 
7
7
  renders_one :append
@@ -9,10 +9,11 @@ module Blacklight
9
9
 
10
10
  # rubocop:disable Metrics/ParameterLists
11
11
  def initialize(
12
- url:, advanced_search_url: nil, params:,
13
- classes: ['search-query-form'], presenter: nil, prefix: '',
12
+ url:, params:,
13
+ advanced_search_url: nil,
14
+ classes: ['search-query-form'], prefix: nil,
14
15
  method: 'GET', q: nil, query_param: :q,
15
- search_field: nil, search_fields: [], autocomplete_path: nil,
16
+ search_field: nil, search_fields: nil, autocomplete_path: nil,
16
17
  autofocus: nil, i18n: { scope: 'blacklight.search.form' }
17
18
  )
18
19
  @url = url
@@ -23,7 +24,6 @@ module Blacklight
23
24
  @params = params.except(:q, :search_field, :utf8, :page)
24
25
  @prefix = prefix
25
26
  @classes = classes
26
- @presenter = presenter
27
27
  @method = method
28
28
  @autocomplete_path = autocomplete_path
29
29
  @autofocus = autofocus
@@ -33,29 +33,34 @@ module Blacklight
33
33
  # rubocop:enable Metrics/ParameterLists
34
34
 
35
35
  def autocomplete_path
36
- return nil unless presenter.autocomplete_enabled?
36
+ return nil unless blacklight_config.autocomplete_enabled
37
37
 
38
38
  @autocomplete_path
39
39
  end
40
40
 
41
41
  def autofocus
42
42
  if @autofocus.nil?
43
- presenter.autofocus?
43
+ blacklight_config.enable_search_bar_autofocus &&
44
+ controller.is_a?(Blacklight::Catalog) &&
45
+ controller.action_name == "index" &&
46
+ !controller.has_search_parameters?
44
47
  else
45
48
  @autofocus
46
49
  end
47
50
  end
48
51
 
49
- private
50
-
51
- def presenter
52
- @presenter ||= presenter_class.new(controller, blacklight_config)
52
+ def search_fields
53
+ @search_fields ||= blacklight_config.search_fields.values
54
+ .select { |field_def| helpers.should_render_field?(field_def) }
55
+ .collect { |field_def| [helpers.label_for_search_field(field_def.key), field_def.key] }
53
56
  end
54
57
 
55
- def presenter_class
56
- blacklight_config.view_config(action_name: :index).search_bar_presenter_class
58
+ def advanced_search_enabled?
59
+ blacklight_config.advanced_search.enabled
57
60
  end
58
61
 
62
+ private
63
+
59
64
  def blacklight_config
60
65
  helpers.blacklight_config
61
66
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class SearchContextComponent < ::ViewComponent::Base
4
+ class SearchContextComponent < Blacklight::Component
5
5
  with_collection_parameter :search_context
6
6
 
7
7
  def initialize(search_context:, search_session:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blacklight
4
- class StartOverButtonComponent < ::ViewComponent::Base
4
+ class StartOverButtonComponent < Blacklight::Component
5
5
  def call
6
6
  link_to t('blacklight.search.start_over'), start_over_path, class: 'catalog_startOverLink btn btn-primary'
7
7
  end
@@ -81,6 +81,7 @@ module Blacklight::BlacklightHelperBehavior
81
81
  def render_search_bar
82
82
  search_bar_presenter.render
83
83
  end
84
+ deprecation_deprecate render_search_bar: "Call `render Blacklight::SearchBarComponent.new' instead"
84
85
 
85
86
  # @!group Presenter extension helpers
86
87
  ##
@@ -88,6 +89,7 @@ module Blacklight::BlacklightHelperBehavior
88
89
  def search_bar_presenter
89
90
  @search_bar ||= search_bar_presenter_class.new(controller, blacklight_config)
90
91
  end
92
+ deprecation_deprecate :search_bar_presenter
91
93
 
92
94
  # @!group Document helpers
93
95
  ##
@@ -361,7 +363,7 @@ module Blacklight::BlacklightHelperBehavior
361
363
 
362
364
  ##
363
365
  # Override this method if you want to use a differnet presenter for your documents
364
- # @param [Blacklight::Document] optional, here for extension + backwards compatibility only
366
+ # @param [Blacklight::Document] document optional, here for extension + backwards compatibility only
365
367
  def document_presenter_class(document = nil)
366
368
  Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
367
369
  case action_name
@@ -319,7 +319,7 @@ module Blacklight::CatalogHelperBehavior
319
319
  end
320
320
 
321
321
  # Render an html <title> appropriate string for a set of search parameters
322
- # @param [ActionController::Parameters] params2
322
+ # @param [ActionController::Parameters] params
323
323
  # @return [String]
324
324
  def render_search_to_page_title(search_state_or_params)
325
325
  search_state = if search_state_or_params.is_a? Blacklight::SearchState
@@ -84,14 +84,12 @@ module Blacklight::RenderConstraintsHelperBehavior
84
84
  Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, 'render_constraints_filters is deprecated')
85
85
  search_state = convert_to_search_state(params_or_search_state)
86
86
 
87
- Deprecation.silence(Blacklight::SearchState) do
88
- return "".html_safe if search_state.filter_params.blank?
87
+ return "".html_safe unless search_state.filters.any?
89
88
 
90
- Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
91
- safe_join(search_state.filters.map do |field|
92
- render_filter_element(field.key, field.values, search_state)
93
- end, "\n")
94
- end
89
+ Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
90
+ safe_join(search_state.filters.map do |field|
91
+ render_filter_element(field.key, field.values, search_state)
92
+ end, "\n")
95
93
  end
96
94
  end
97
95
 
@@ -206,7 +206,7 @@ Blacklight.modal.checkCloseModal = function(event) {
206
206
  }
207
207
 
208
208
  Blacklight.modal.hide = function(el) {
209
- if (bootstrap && bootstrap.Modal && bootstrap.Modal.VERSION >= "5") {
209
+ if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
210
210
  bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide();
211
211
  } else {
212
212
  $(el || Blacklight.modal.modalSelector).modal('hide');
@@ -214,7 +214,7 @@ Blacklight.modal.hide = function(el) {
214
214
  }
215
215
 
216
216
  Blacklight.modal.show = function(el) {
217
- if (bootstrap && bootstrap.Modal && bootstrap.Modal.VERSION >= "5") {
217
+ if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
218
218
  bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show();
219
219
  } else {
220
220
  $(el || Blacklight.modal.modalSelector).modal('show');
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Blacklight
4
4
  class SearchBarPresenter
5
+ extend Deprecation
5
6
  attr_reader :configuration, :view_context, :controller
6
7
 
7
8
  # Set the partial this presenter draws
@@ -17,6 +18,7 @@ module Blacklight
17
18
  def render
18
19
  view_context.render partial, presenter: self
19
20
  end
21
+ deprecation_deprecate render: "The SearchBarPresenter has been deprecated. Call `render Blacklight::SearchBarComponent.new' instead"
20
22
 
21
23
  ##
22
24
  # @return [Boolean] should autocomplete be enabled in the UI
@@ -4,7 +4,7 @@ module Blacklight
4
4
  class FieldRetriever
5
5
  # @param [Blacklight::Document] document
6
6
  # @param [Blacklight::Configuration::Field] field_config solr field configuration
7
- # @param [ActionView::Base] Rails rendering context
7
+ # @param [ActionView::Base] view_context Rails rendering context
8
8
  def initialize(document, field_config, view_context = nil)
9
9
  @document = document
10
10
  @field_config = field_config