-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3166 from projectblacklight/search-element
Add search element
- Loading branch information
Showing
2 changed files
with
44 additions
and
40 deletions.
There are no files selected for viewing
14 changes: 8 additions & 6 deletions
14
app/components/blacklight/search/sidebar_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<% facet_group_names.each do |groupname| %> | ||
<% fields = facet_fields_in_group(groupname) %> | ||
<%= render group_component_class.new(id: groupname, fields: fields, response: response) do |component| %> | ||
<% component.with_body do %> | ||
<%= render Blacklight::FacetComponent.with_collection(fields, response: response) %> | ||
<search> | ||
<% facet_group_names.each do |groupname| %> | ||
<% fields = facet_fields_in_group(groupname) %> | ||
<%= render group_component_class.new(id: groupname, fields: fields, response: response) do |component| %> | ||
<% component.with_body do %> | ||
<%= render Blacklight::FacetComponent.with_collection(fields, response: response) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</search> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
<%= form_with url: @url, local: true, method: @method, class: @classes.join(' '), scope: @prefix, role: 'search', **@form_options do |f| %> | ||
<%= render Blacklight::HiddenSearchStateComponent.new(params: @params) %> | ||
<% if search_fields.length > 1 %> | ||
<%= f.label :search_field, scoped_t('search_field.label'), class: 'sr-only visually-hidden' %> | ||
<% end %> | ||
<% before_input_groups.each do |input_group| %> | ||
<%= input_group %> | ||
<% end %> | ||
<div class="input-group"> | ||
<%= prepend %> | ||
<search> | ||
<%= form_with url: @url, local: true, method: @method, class: @classes.join(' '), scope: @prefix, role: 'search', **@form_options do |f| %> | ||
<%= render Blacklight::HiddenSearchStateComponent.new(params: @params) %> | ||
<% if search_fields.length > 1 %> | ||
<%= f.select(:search_field, | ||
options_for_select(search_fields, h(@search_field)), | ||
{}, | ||
title: scoped_t('search_field.title'), | ||
class: "custom-select form-select search-field") %> | ||
<% elsif search_fields.length == 1 %> | ||
<%= f.hidden_field :search_field, value: search_fields.first.last %> | ||
<%= f.label :search_field, scoped_t('search_field.label'), class: 'sr-only visually-hidden' %> | ||
<% end %> | ||
<%= f.label @query_param, scoped_t('search.label'), class: 'sr-only visually-hidden' %> | ||
<% if autocomplete_path.present? %> | ||
<auto-complete src="<%= autocomplete_path %>" for="autocomplete-popup" class="search-autocomplete-wrapper"> | ||
<%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", autofocus: @autofocus, aria: { label: scoped_t('search.label'), autocomplete: 'list', controls: 'autocomplete-popup' } %> | ||
<ul id="autocomplete-popup" role="listbox" aria-label="<%= scoped_t('search.label') %>" hidden></ul> | ||
</auto-complete> | ||
<% else %> | ||
<%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", autofocus: @autofocus, aria: { label: scoped_t('search.label') } %> | ||
<% before_input_groups.each do |input_group| %> | ||
<%= input_group %> | ||
<% end %> | ||
<div class="input-group"> | ||
<%= prepend %> | ||
<%= append %> | ||
<%= search_button || render(Blacklight::SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))) %> | ||
</div> | ||
<% end %> | ||
<% if search_fields.length > 1 %> | ||
<%= f.select(:search_field, | ||
options_for_select(search_fields, h(@search_field)), | ||
{}, | ||
title: scoped_t('search_field.title'), | ||
class: "custom-select form-select search-field") %> | ||
<% elsif search_fields.length == 1 %> | ||
<%= f.hidden_field :search_field, value: search_fields.first.last %> | ||
<% end %> | ||
<% if advanced_search_enabled? %> | ||
<%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-secondary'%> | ||
<% end %> | ||
<%= f.label @query_param, scoped_t('search.label'), class: 'sr-only visually-hidden' %> | ||
<% if autocomplete_path.present? %> | ||
<auto-complete src="<%= autocomplete_path %>" for="autocomplete-popup" class="search-autocomplete-wrapper"> | ||
<%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", autofocus: @autofocus, aria: { label: scoped_t('search.label'), autocomplete: 'list', controls: 'autocomplete-popup' } %> | ||
<ul id="autocomplete-popup" role="listbox" aria-label="<%= scoped_t('search.label') %>" hidden></ul> | ||
</auto-complete> | ||
<% else %> | ||
<%= f.search_field @query_param, value: @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", autofocus: @autofocus, aria: { label: scoped_t('search.label') } %> | ||
<% end %> | ||
<%= append %> | ||
<%= search_button || render(Blacklight::SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))) %> | ||
</div> | ||
<% end %> | ||
<% if advanced_search_enabled? %> | ||
<%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-secondary'%> | ||
<% end %> | ||
</search> |