Skip to content

Commit

Permalink
i3232: Remove basic search bar and sort results from numismatics page
Browse files Browse the repository at this point in the history
  • Loading branch information
sandbergja committed Dec 1, 2023
1 parent f67f5ee commit f162645
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 23 deletions.
6 changes: 0 additions & 6 deletions app/components/numismatics_search_form_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
</div>

<div class="search-submit-buttons clearfix col-sm-7">
<% if sort_fields_select %>
<div class="form-group sort-buttons pull-left">
<%= content_tag :label, t('blacklight.advanced_search.form.sort_label'), id: 'advanced-search-sort-label', for: 'sort', class: 'control-label' %>
<%= sort_fields_select %>
</div>
<% end %>
<div class="submit-buttons pull-right form-group">
<%= submit_tag t('blacklight.advanced_search.form.search_btn_html'), class: 'btn btn-primary advanced-search-submit', id: "advanced-search-submit" %>
</div>
Expand Down
7 changes: 0 additions & 7 deletions app/components/numismatics_search_form_component.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# frozen_string_literal: true

class NumismaticsSearchFormComponent < Blacklight::AdvancedSearchFormComponent
def sort_fields_select
options = sort_fields.values.map { |field_config| [helpers.sort_field_label(field_config.key), field_config.key] }
return unless options.any?

select_tag(:sort, options_for_select(options, params[:sort]), class: "sort-select", aria: { labelledby: 'advanced-search-sort-label' })
end

private

def initialize_search_filter_controls
Expand Down
6 changes: 6 additions & 0 deletions app/views/advanced/_advanced_search_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
</div>

<div class="search-submit-buttons clearfix col-sm-7">
<div class="sort-buttons pull-left">
<% sort_fields = active_sort_fields.values.map { |field_config| [sort_field_label(field_config.key), field_config.key] } %>
<%= label_tag(:sort, t('blacklight.advanced_search.form.sort_label'), :class => "control-label") %>
<%= select_tag(:sort, options_for_select(sort_fields, h(params[:sort])), :class => "sort-select") %>
<%= hidden_field_tag(:search_field, blacklight_config.advanced_search[:url_key]) %>
</div>
<%= render 'advanced_search_submit_btns' %>
</div>
<% end %>
7 changes: 0 additions & 7 deletions app/views/advanced/_advanced_search_submit_btns.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<div class="sort-buttons pull-left">
<% sort_fields = active_sort_fields.values.map { |field_config| [sort_field_label(field_config.key), field_config.key] } %>
<%= label_tag(:sort, t('blacklight.advanced_search.form.sort_label'), :class => "control-label") %>
<%= select_tag(:sort, options_for_select(sort_fields, h(params[:sort])), :class => "sort-select") %>
<%= hidden_field_tag(:search_field, blacklight_config.advanced_search[:url_key]) %>
</div>

<div class="submit-buttons pull-right">
<%= submit_tag t('blacklight.advanced_search.form.search_btn_html'), :class=>'btn btn-primary advanced-search-submit', :id => "advanced-search-submit" %>
</div>
6 changes: 5 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
<body class="<%= render_body_class %>"
data-bibdata-base-url="<%= Requests.config['bibdata_base'] %>" >
<nav id="skip-link" role="navigation" aria-label="<%= t('blacklight.skip_links.label') %>">
<%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
<% unless %w[generate numismatics].include? params[:action] %>
<%# Certain screens do not display the basic search form. Don't show this link on such pages,
# because it will be broken. %>
<%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
<% end %>
<%= link_to t('blacklight.skip_links.main_content'), '#main-container', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
<%= content_for(:skip_links) %>
</nav>
Expand Down
8 changes: 7 additions & 1 deletion app/views/shared/_header_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
</div>
</div>
</div>
<% unless params[:action] == 'generate' %>

<%# Display the basic search bar on most (but not all) interfaces.
# Note: if you remove the search bar from a particular
# screen, also remove the "Skip to Search" link from the
# skip navigation links, so that there aren't broken
# skip navigation links. %>
<% unless %w[generate numismatics].include? params[:action] %>
<div class="header__secondary">
<nav class="container" aria-label='Search'>
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion spec/components/numismatics_search_form_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'Object Type', 'Denomination', 'Metal', 'City', 'State',
'Region', 'Ruler', 'Artist', 'Find Place', 'Year',
'date range (starting year)', 'date range (ending year)',
'Keyword', 'Sort results by'
'Keyword'
]
expect(rendered.all('label').map(&:text)).to match_array(expected_fields)
end
Expand Down
20 changes: 20 additions & 0 deletions spec/system/numismatics_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'

RSpec.describe 'Numismatics search form' do
context 'when using the view components numismatics form' do
before { allow(Flipflop).to_receive(:view_components_numismatics?).and_return(true) }
end
it 'does not display the basic search form' do
visit '/numismatics'
expect(page).not_to have_selector('.search-query-form')
end

context 'when using the original numismatics form' do
before { allow(Flipflop).to_receive(:view_components_numismatics?).and_return(false) }
end
it 'does not display the basic search form' do
visit '/numismatics'
expect(page).not_to have_selector('.search-query-form')
end
end
7 changes: 7 additions & 0 deletions spec/system/skip_links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@
expect(page).to have_selector('#skip-link a', text: 'Skip to result 1 of 9', visible: false)
end
end

context 'when no basic search bar' do
it 'only has one skip link' do
visit '/numismatics'
expect(page).to have_selector('#skip-link a', count: 1, visible: false)
end
end
end
end

0 comments on commit f162645

Please sign in to comment.