Skip to content

Commit

Permalink
Merge pull request #2628 from projectblacklight/search-component-config
Browse files Browse the repository at this point in the history
Make some more search-related components configurable
  • Loading branch information
jcoyne committed Mar 18, 2022
2 parents d67cdef + 3299da8 commit 4c46d17
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/catalog/_constraints.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render(Blacklight::ConstraintsComponent.new(search_state: search_state)) %>
<%= render (blacklight_config&.view_config(document_index_view_type)&.constraints_component || Blacklight::ConstraintsComponent).new(search_state: search_state) %>
2 changes: 1 addition & 1 deletion app/views/catalog/_facets.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% # container for facet groups -%>
<% blacklight_config.facet_group_names.each do |groupname| %>
<% fields = blacklight_config.facet_fields_in_group(groupname) %>
<%= render Blacklight::Response::FacetGroupComponent.new(id: groupname, fields: fields, response: @response) do |component| %>
<%= render (blacklight_config&.view_config(document_index_view_type)&.facet_group_component || Blacklight::Response::FacetGroupComponent).new(id: groupname, fields: fields, response: @response) do |component| %>
<% component.body do %>
<%= render Blacklight::FacetComponent.with_collection(fields, response: @response) %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_search_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render(Blacklight::SearchBarComponent.new(
<%= render((blacklight_config&.view_config(document_index_view_type)&.search_bar_component || Blacklight::SearchBarComponent).new(
url: search_action_url,
advanced_search_url: search_action_url(action: 'advanced_search'),
params: search_state.params_for_search.except(:qt),
Expand Down
8 changes: 7 additions & 1 deletion lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ def default_values
# what field, if any, to use to render grouped results
group: false,
# additional response formats for search results
respond_to: OpenStructWithHashAccess.new
respond_to: OpenStructWithHashAccess.new,
# component class used to render the facet grouping
facet_group_component: nil,
# component class used to render search constraints
constraints_component: nil,
# component class used to render the search bar
search_bar_component: nil
)

# @!attribute show
Expand Down
6 changes: 6 additions & 0 deletions lib/blacklight/configuration/view_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class ViewConfig < Blacklight::OpenStructWithHashAccess
# @return [String, Symbol] icon file to use in the view picker
# @!attribute document_actions
# @return [NestedOpenStructWithHashAccess{Symbol => Blacklight::Configuration::ToolConfig}] 'tools' to render for each document
# @!attribute facet_group_component
# @return [Class] component class used to render a facet group
# @!attribute constraints_component
# @return [Class] component class used to render the constraints
# @!attribute search_bar_component
# @return [Class] component class used to render the search bar
def search_bar_presenter_class
super || Blacklight::SearchBarPresenter
end
Expand Down

0 comments on commit 4c46d17

Please sign in to comment.