blacklight 7.24.0 → 7.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -4
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +2 -2
- data/app/components/blacklight/constraint_component.rb +1 -1
- data/app/components/blacklight/constraint_layout_component.rb +1 -1
- data/app/components/blacklight/constraints_component.rb +1 -1
- data/app/components/blacklight/document/action_component.rb +1 -1
- data/app/components/blacklight/document/actions_component.rb +1 -1
- data/app/components/blacklight/document/bookmark_component.rb +1 -1
- data/app/components/blacklight/document/citation_component.rb +2 -2
- data/app/components/blacklight/document/group_component.rb +3 -2
- data/app/components/blacklight/document/more_like_this_component.rb +1 -1
- data/app/components/blacklight/document/thumbnail_component.rb +1 -1
- data/app/components/blacklight/document_component.rb +1 -2
- data/app/components/blacklight/document_metadata_component.rb +1 -1
- data/app/components/blacklight/document_title_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_component.rb +1 -1
- data/app/components/blacklight/facet_field_filter_component.rb +1 -1
- data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +1 -1
- data/app/components/blacklight/facet_field_list_component.rb +1 -1
- data/app/components/blacklight/facet_field_no_layout_component.rb +1 -1
- data/app/components/blacklight/facet_field_pagination_component.rb +1 -1
- data/app/components/blacklight/facet_item_component.rb +1 -1
- data/app/components/blacklight/facet_item_pivot_component.rb +1 -1
- data/app/components/blacklight/hidden_search_state_component.rb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +1 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +1 -1
- data/app/components/blacklight/response/facet_group_component.rb +1 -1
- data/app/components/blacklight/response/pagination_component.rb +1 -1
- data/app/components/blacklight/search_bar_component.html.erb +7 -7
- data/app/components/blacklight/search_bar_component.rb +18 -13
- data/app/components/blacklight/search_context_component.rb +1 -1
- data/app/components/blacklight/start_over_button_component.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +5 -7
- data/app/javascript/blacklight/modal.js +2 -2
- data/app/presenters/blacklight/search_bar_presenter.rb +2 -0
- data/app/services/blacklight/field_retriever.rb +1 -1
- data/app/views/catalog/_constraints.html.erb +2 -2
- data/app/views/catalog/_facet_group.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +2 -2
- data/app/views/shared/_header_navbar.html.erb +5 -1
- data/lib/blacklight/component.rb +40 -0
- data/lib/blacklight/configuration/facet_field.rb +1 -1
- data/lib/blacklight/configuration/fields.rb +10 -11
- data/lib/blacklight/configuration/view_config.rb +6 -0
- data/lib/blacklight/configuration.rb +320 -179
- data/lib/blacklight/deprecations/search_state_normalization.rb +52 -0
- data/lib/blacklight/search_state/filter_field.rb +44 -16
- data/lib/blacklight/search_state.rb +55 -31
- data/lib/blacklight/solr/search_builder_behavior.rb +3 -1
- data/lib/blacklight.rb +1 -0
- data/package.json +1 -1
- data/spec/components/blacklight/constraints_component_spec.rb +14 -1
- data/spec/components/blacklight/facet_field_list_component_spec.rb +6 -1
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +7 -1
- data/spec/controllers/blacklight/base_spec.rb +4 -1
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +23 -6
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -0
- data/spec/lib/blacklight/component_spec.rb +43 -0
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +12 -1
- data/spec/lib/blacklight/search_state_spec.rb +17 -3
- data/spec/models/blacklight/configuration_spec.rb +2 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +15 -0
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +10 -4
- data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +6 -1
- data/spec/presenters/blacklight/field_presenter_spec.rb +2 -0
- data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
- metadata +7 -3
@@ -13,6 +13,10 @@
|
|
13
13
|
|
14
14
|
<%= content_tag :div, class: 'navbar-search navbar navbar-light bg-light', role: 'navigation', aria: { label: t('blacklight.search.header') } do %>
|
15
15
|
<div class="<%= container_classes %>">
|
16
|
-
<%=
|
16
|
+
<%= render((blacklight_config&.view_config(document_index_view_type)&.search_bar_component ||Blacklight::SearchBarComponent).new(
|
17
|
+
url: search_action_url,
|
18
|
+
advanced_search_url: search_action_url(action: 'advanced_search'),
|
19
|
+
params: search_state.params_for_search.except(:qt),
|
20
|
+
autocomplete_path: search_action_path(action: :suggest))) %>
|
17
21
|
</div>
|
18
22
|
<% end %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
class Component < ViewComponent::Base
|
5
|
+
class << self
|
6
|
+
# rubocop:disable Naming/MemoizedInstanceVariableName
|
7
|
+
def compiler
|
8
|
+
@__vc_compiler ||= EngineCompiler.new(self)
|
9
|
+
end
|
10
|
+
# rubocop:enable Naming/MemoizedInstanceVariableName
|
11
|
+
end
|
12
|
+
|
13
|
+
class EngineCompiler < ::ViewComponent::Compiler
|
14
|
+
# ViewComponent::Compiler locates and caches templates from sidecar files to the component source file.
|
15
|
+
# While this is sensible in a Rails application, it prevents component templates defined in an Engine
|
16
|
+
# from being overridden by an installing application without subclassing the component, which may also
|
17
|
+
# require modifying any partials rendering the component. This subclass of compiler overrides the template
|
18
|
+
# location algorithm to take the sidecar file names from the Engine, but look to see if a file of the
|
19
|
+
# same name existing in the installing application (ie, under Rails.root). If the latter exists, this
|
20
|
+
# compiler will cache that template instead of the engine-defined file; if not, the compiler will fall
|
21
|
+
# back to the engine-defined file.
|
22
|
+
def templates
|
23
|
+
@templates ||= begin
|
24
|
+
extensions = ActionView::Template.template_handler_extensions
|
25
|
+
|
26
|
+
component_class._sidecar_files(extensions).each_with_object([]) do |path, memo|
|
27
|
+
pieces = File.basename(path).split(".")
|
28
|
+
app_path = "#{Rails.root}/#{path.slice(path.index(component_class.view_component_path)..-1)}"
|
29
|
+
|
30
|
+
memo << {
|
31
|
+
path: File.exist?(app_path) ? app_path : path,
|
32
|
+
variant: pieces.second.split("+").second&.to_sym,
|
33
|
+
handler: pieces.last
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -47,7 +47,7 @@ module Blacklight
|
|
47
47
|
# @!attribute pivot
|
48
48
|
# @return []
|
49
49
|
# @!attribute filter_query_builder
|
50
|
-
# @return [nil, #call] a Proc (or other object responding to #call) that receives as parameters: 1) the search builder, 2)
|
50
|
+
# @return [nil, #call] a Proc (or other object responding to #call) that receives as parameters: 1) the search builder, 2) the Blacklight::FilterField instance
|
51
51
|
# and 3) the solr parameters hash. The Proc returns a string suitable for e.g. Solr's fq parameter, or a 2-element array of the string and a hash of additional
|
52
52
|
# parameters to include with the query (i.e. for referenced subqueries); note that implementations are responsible for ensuring
|
53
53
|
# the additional parameter keys are unique.
|
@@ -10,18 +10,13 @@ module Blacklight
|
|
10
10
|
|
11
11
|
class_methods do
|
12
12
|
# Add a configuration block for a collection of solr fields
|
13
|
-
def define_field_access(key,
|
13
|
+
def define_field_access(key, base_class_name = nil, class: nil)
|
14
14
|
key = key.to_s if respond_to? :to_s
|
15
15
|
|
16
16
|
default_values[key.pluralize.to_sym] = ActiveSupport::OrderedHash.new
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
unless const_defined? key.camelcase
|
21
|
-
class_eval <<-END_EVAL, __FILE__, __LINE__ + 1
|
22
|
-
class #{key.camelcase} < #{base_class_name}; end
|
23
|
-
END_EVAL
|
24
|
-
end
|
18
|
+
@field_type_for_class ||= {}
|
19
|
+
@field_type_for_class[key] = binding.local_variable_get(:class) || base_class_name
|
25
20
|
|
26
21
|
class_eval <<-END_EVAL, __FILE__, __LINE__ + 1
|
27
22
|
def add_#{key}(*args, &block)
|
@@ -29,8 +24,11 @@ module Blacklight
|
|
29
24
|
end
|
30
25
|
END_EVAL
|
31
26
|
end
|
32
|
-
end
|
33
27
|
|
28
|
+
def field_type_for_class(key)
|
29
|
+
@field_type_for_class&.dig(key.to_s) || Blacklight::Configuration::Field
|
30
|
+
end
|
31
|
+
end
|
34
32
|
# Add a solr field configuration to the given configuration key
|
35
33
|
#
|
36
34
|
# The recommended and strongly encouraged format is a field name, configuration pair, e.g.:
|
@@ -198,8 +196,9 @@ module Blacklight
|
|
198
196
|
end
|
199
197
|
|
200
198
|
# convert a config key to the appropriate Field class
|
201
|
-
|
202
|
-
|
199
|
+
# @param [String] key
|
200
|
+
def field_class_from_key(key)
|
201
|
+
self.class.field_type_for_class(key)
|
203
202
|
end
|
204
203
|
end
|
205
204
|
end
|
@@ -17,6 +17,12 @@ class Blacklight::Configuration
|
|
17
17
|
# @return [String, Symbol] icon file to use in the view picker
|
18
18
|
# @!attribute document_actions
|
19
19
|
# @return [NestedOpenStructWithHashAccess{Symbol => Blacklight::Configuration::ToolConfig}] 'tools' to render for each document
|
20
|
+
# @!attribute facet_group_component
|
21
|
+
# @return [Class] component class used to render a facet group
|
22
|
+
# @!attribute constraints_component
|
23
|
+
# @return [Class] component class used to render the constraints
|
24
|
+
# @!attribute search_bar_component
|
25
|
+
# @return [Class] component class used to render the search bar
|
20
26
|
def search_bar_presenter_class
|
21
27
|
super || Blacklight::SearchBarPresenter
|
22
28
|
end
|