diff --git a/app/components/blacklight/header_component.html.erb b/app/components/blacklight/header_component.html.erb index 7e869ec8c4..9869e301f0 100644 --- a/app/components/blacklight/header_component.html.erb +++ b/app/components/blacklight/header_component.html.erb @@ -1,2 +1 @@ <%= top_bar %> -<%= search_bar %> \ No newline at end of file diff --git a/app/components/blacklight/header_component.rb b/app/components/blacklight/header_component.rb index 76dd990c2c..8550f0cd68 100644 --- a/app/components/blacklight/header_component.rb +++ b/app/components/blacklight/header_component.rb @@ -6,10 +6,6 @@ class HeaderComponent < Blacklight::Component component.new(blacklight_config: blacklight_config) } - renders_one :search_bar, lambda { |component: Blacklight::SearchNavbarComponent| - component.new(blacklight_config: blacklight_config) - } - def initialize(blacklight_config:) @blacklight_config = blacklight_config end @@ -20,7 +16,6 @@ def initialize(blacklight_config:) # so that we don't have to do c.with_top_bar() in the call. def before_render set_slot(:top_bar, nil) unless top_bar - set_slot(:search_bar, nil) unless search_bar end end end diff --git a/app/components/blacklight/search/sidebar_component.html.erb b/app/components/blacklight/search/sidebar_component.html.erb index 1f7058e6c0..78493e4cb4 100644 --- a/app/components/blacklight/search/sidebar_component.html.erb +++ b/app/components/blacklight/search/sidebar_component.html.erb @@ -1,10 +1,8 @@ - - <% 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 %> +<% 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 %> diff --git a/app/components/blacklight/search_bar_component.html.erb b/app/components/blacklight/search_bar_component.html.erb index bb9f37355d..bbc24ee547 100644 --- a/app/components/blacklight/search_bar_component.html.erb +++ b/app/components/blacklight/search_bar_component.html.erb @@ -1,41 +1,39 @@ - - <%= 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) %> +<%= form_with url: @url, local: true, method: @method, class: @classes.join(' '), scope: @prefix, **@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: 'visually-hidden' %> + <% end %> + <% before_input_groups.each do |input_group| %> + <%= input_group %> + <% end %> +
+ <%= prepend %> + <% if search_fields.length > 1 %> - <%= f.label :search_field, scoped_t('search_field.label'), class: 'visually-hidden' %> - <% end %> - <% before_input_groups.each do |input_group| %> - <%= input_group %> + <%= 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 %> -
- <%= prepend %> - <% 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 %> - - <%= f.label @query_param, scoped_t('search.label'), class: 'visually-hidden' %> - <% if autocomplete_path.present? %> - - <%= 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' } %> - - - <% 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 %> + <%= f.label @query_param, scoped_t('search.label'), class: 'visually-hidden' %> + <% if autocomplete_path.present? %> + + <%= 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' } %> + + + <% 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'))) %> -
- <% end %> + <%= append %> + <%= search_button || render(Blacklight::SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))) %> +
+<% end %> - <% if advanced_search_enabled? %> - <%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-secondary'%> - <% end %> -
+<% if advanced_search_enabled? %> + <%= link_to t('blacklight.advanced_search.more_options'), @advanced_search_url, class: 'advanced_search btn btn-secondary'%> +<% end %> diff --git a/app/components/blacklight/search_context/server_applied_params_component.html.erb b/app/components/blacklight/search_context/server_applied_params_component.html.erb index 735c7e8071..c21d8bfd69 100644 --- a/app/components/blacklight/search_context/server_applied_params_component.html.erb +++ b/app/components/blacklight/search_context/server_applied_params_component.html.erb @@ -1,4 +1,4 @@ -
+
<%= render 'start_over' %> <%= link_back_to_catalog class: 'btn btn-outline-secondary' %> -
+ diff --git a/app/views/layouts/blacklight/base.html.erb b/app/views/layouts/blacklight/base.html.erb index 61d177455b..1de20bb379 100644 --- a/app/views/layouts/blacklight/base.html.erb +++ b/app/views/layouts/blacklight/base.html.erb @@ -34,14 +34,33 @@ <%= render partial: 'shared/header_navbar' %> -
- <%= content_for(:container_header) %> +
+ <% if controller.is_a?(Blacklight::Catalog) && controller_name != 'bookmarks' && controller.action_name == "index" %> + + <%= render Blacklight::SearchNavbarComponent.new(blacklight_config: blacklight_config) %> +
+ <%= content_for(:container_header) %> - <%= render partial: 'shared/flash_msg', layout: 'shared/flash_messages' %> + <%= render partial: 'shared/flash_msg', layout: 'shared/flash_messages' %> -
- <%= content_for?(:content) ? yield(:content) : yield %> -
+
+ <%= content_for?(:content) ? yield(:content) : yield %> +
+
+
+ <% else %> + + <%= render Blacklight::SearchNavbarComponent.new(blacklight_config: blacklight_config) %> + + <%# content on this page is not related to search %> +
+ <%= render partial: 'shared/flash_msg', layout: 'shared/flash_messages' %> + +
+ <%= content_for?(:content) ? yield(:content) : yield %> +
+
+ <% end %>
<%= render partial: 'shared/footer' %>