diff --git a/app/components/orangelight/advanced_search_form_component.html.erb b/app/components/orangelight/advanced_search_form_component.html.erb index 150f45f87..b593d3c42 100644 --- a/app/components/orangelight/advanced_search_form_component.html.erb +++ b/app/components/orangelight/advanced_search_form_component.html.erb @@ -15,9 +15,10 @@
<%# End Column 1 %> diff --git a/app/components/orangelight/advanced_search_form_component.rb b/app/components/orangelight/advanced_search_form_component.rb index d66fb4da8..2f0eca2bf 100644 --- a/app/components/orangelight/advanced_search_form_component.rb +++ b/app/components/orangelight/advanced_search_form_component.rb @@ -25,18 +25,23 @@ def pub_date_field def pub_date_presenter view_context.facet_field_presenter(pub_date_field, {}) end + def initialize_search_field_controls - search_fields.values.each.with_index do |field, i| + search_fields.values.each.with_index do |field, index| with_search_field_control do - fields_for('clause[]', i, include_id: false) do |f| - content_tag(:div, class: 'form-group advanced-search-field row mb-3') do - f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label text-md-right") + - content_tag(:div, class: 'col-sm-9') do - f.hidden_field(:field, value: field.key) + - f.text_field(:query, value: query_for_search_clause(field.key), class: 'form-control') - end + fields_for_etc(index:, field:) + end + end + end + + def fields_for_etc(index:, field:) + fields_for('clause[]', index, include_id: false) do |foo| + content_tag(:div, class: 'form-group advanced-search-field row mb-3') do + foo.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label text-md-right") + + content_tag(:div, class: 'col-sm-9') do + foo.hidden_field(:field, value: field.key) + + foo.text_field(:query, value: query_for_search_clause(field.key), class: 'form-control') end - end end end end diff --git a/config/features.rb b/config/features.rb index 46fcbb76b..eb2574c20 100644 --- a/config/features.rb +++ b/config/features.rb @@ -36,6 +36,5 @@ feature :view_components_advanced_search, description: "When on / true, use the built-in advanced search form. When off / false, use the traditional one" - end end diff --git a/spec/components/orangelight/advanced_search_form_component_spec.rb b/spec/components/orangelight/advanced_search_form_component_spec.rb index 07ccf5e89..ff8fae31f 100644 --- a/spec/components/orangelight/advanced_search_form_component_spec.rb +++ b/spec/components/orangelight/advanced_search_form_component_spec.rb @@ -6,7 +6,7 @@ subject(:render) do component.render_in(view_context) end - let(:component) { described_class.new(url: '/whatever', response: , params:) } + let(:component) { described_class.new(url: '/whatever', response:, params:) } let(:response) do Blacklight::Solr::Response.new({}.with_indifferent_access, {}) @@ -35,11 +35,12 @@ allow(view_context).to receive(:facet_limit_for).and_return(nil) end - it "renders fields in the correct order" do - expected_order = [ - "Keyword", "Title", "Author/Creator", "Subject", "Title starts with", + it "has a dropdown with the expected options" do + expected_options = [ + "Keyword", "Title", "Author/Creator", "Subject", "Title starts with", "Publisher", "Notes", "Series title", "ISBN", "ISSN" ] - expect(rendered.all('label').map(&:text)).to match_array(expected_order) + options = rendered.all('select')[1].all('option').map(&:text) + expect(options).to eq(expected_options) end end diff --git a/spec/features/advanced_searching_spec.rb b/spec/features/advanced_searching_spec.rb index 3c5e97d94..f12dbd04a 100644 --- a/spec/features/advanced_searching_spec.rb +++ b/spec/features/advanced_searching_spec.rb @@ -64,12 +64,11 @@ expect(page).to have_content('Limit results by') end - xit 'has drop-downs for search fields' do + it 'has drop-downs for search fields' do search_fields = page.find_all('.search-field') expect(search_fields.size).to eq(4) # expect(page).to have_selector('.search-field') end - end context 'with a numismatics advanced search type' do