Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
- Search form is searching correct fields
- Needs more testing
- Booleans are not actually hooked up correctly - not sure if this is possible within json syntax
- Locally there are some failing tests when I turn the feature on for everything, mostly in browse specs - don't know if this is related to local solr config change
  • Loading branch information
maxkadel committed Aug 22, 2023
1 parent 5add049 commit c4b7aec
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
<div class="input-criteria">

<div id="guided_search">
<%= render 'advanced/guided_search_fields' %>
<%# search_field_controls.each do |control| %>
<%# control %>
<%# end %>
<%= render 'advanced/guided_search_fields_bl_8' %>
</div>
</div>
<%# End Column 1 %>
Expand All @@ -41,9 +38,9 @@
<div class="form-group advanced-search-facet row">
<%= label_tag pub_date_field.parameterize, :class => "col-sm-4 control-label advanced-facet-label" do %>Publication Year<% end %>
<div class="col-sm-8 range_limit">
<label for="range_pub_date_start_sort_begin" class="sr-only">date range (starting year)</label>
<label for="range_pub_date_start_sort_begin" class="sr-only">Publication date range (starting year)</label>
<%= BlacklightRangeLimit::RangeFormComponent.new(facet_field: pub_date_presenter).render_range_input(:begin) %>
<label for="range_pub_date_start_sort_end" class="sr-only">date range (ending year)</label>
<label for="range_pub_date_start_sort_end" class="sr-only">Publication date range (ending year)</label>
<%= BlacklightRangeLimit::RangeFormComponent.new(facet_field: pub_date_presenter).render_range_input(:end) %>
</div>
</div>
Expand Down
74 changes: 74 additions & 0 deletions app/views/advanced/_guided_search_fields_bl_8.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<div class="advanced-search-field">
<div class="search-field">
<label for="clause_0_field" class="sr-only">Options for advanced search</label>
<%= select_tag(
'clause[0][field]',
options_for_select(
advanced_key_value,
guided_field(:clause_0_field, 'all_fields')
),
class: "search_field") %>
<div name="row1">
<label for='clause_0_query' class='sr-only'>Advanced search terms</label>
<%= text_field_tag(
"clause[0][query]",
label_tag_default_for(:clause_0_query),
class: 'form-control',
autocorrect: "off",
autocapitalize: "off",
autocomplete: "off",
spellcheck: "false") %>
</div>
</div>
<div class="search-operators" role="radiogroup" aria-label="Search operators">
<label><%= radio_button_tag("op2", "AND", guided_radio(:op2, "AND")) %> AND</label>
<label><%= radio_button_tag("op2", "OR", guided_radio(:op2, "OR")) %> OR</label>
<label><%= radio_button_tag("op2", "NOT", guided_radio(:op2, "NOT")) %> NOT</label>
</div>
<div class="search-field">
<label for="clause_1_field" class="sr-only">Options for advanced search - second parameter</label>
<%= select_tag(
'clause[1][field]',
options_for_select(
advanced_key_value,
guided_field(:clause_1_field, 'author')
),
class: "search_field") %>
<div name="row2">
<label for='clause_1_query' class='sr-only'>Advanced search terms - second parameter</label>
<%= text_field_tag(
"clause[1][query]",
label_tag_default_for(:clause_1_query),
class: 'form-control',
autocorrect: "off",
autocapitalize: "off",
autocomplete: "off",
spellcheck: "false") %>
</div>
</div>
<div class="search-operators" role="radiogroup" aria-label="Search operators">
<label><%= radio_button_tag("op3", "AND", guided_radio(:op3, "AND")) %> AND</label>
<label><%= radio_button_tag("op3", "OR", guided_radio(:op3, "OR")) %> OR</label>
<label><%= radio_button_tag("op3", "NOT", guided_radio(:op3, "NOT")) %> NOT</label>
</div>
<div class="search-field">
<label for="clause_2_field" class="sr-only">Options for advanced search - third parameter</label>
<%= select_tag(
'clause[2][field]',
options_for_select(
advanced_key_value,
guided_field(:clause_2_field, 'title')
),
class: "search_field") %>
<div name="row3">
<label for='clause_2_query' class='sr-only'>Advanced search terms - third parameter</label>
<%= text_field_tag(
"clause[2][query]",
label_tag_default_for(:clause_2_query),
:class => 'form-control',
autocorrect: "off",
autocapitalize: "off",
spellcheck: "false") %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

RSpec.describe Orangelight::AdvancedSearchFormComponent, type: :component do
RSpec.describe Orangelight::AdvancedSearchFormComponent, type: :component, advanced_search: true do
subject(:render) do
component.render_in(view_context)
end
Expand Down Expand Up @@ -43,4 +43,11 @@
options = rendered.all('select')[1].all('option').map(&:text)
expect(options).to eq(expected_options)
end

it 'has text fields for each search field' do
expect(rendered).to have_selector '.advanced-search-field', count: 1
expect(rendered).to have_field 'clause_0_field', with: 'all_fields'
expect(rendered).to have_field 'clause_1_field', with: 'author'
expect(rendered).to have_field 'clause_2_field', with: 'title'
end
end
2 changes: 1 addition & 1 deletion spec/features/advanced_searching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

describe 'advanced searching' do
describe 'advanced searching', advanced_search: true do
before do
stub_holding_locations
end
Expand Down

0 comments on commit c4b7aec

Please sign in to comment.