Skip to content

Commit

Permalink
refactor advanced search to reduce the amount of BL overrides and add…
Browse files Browse the repository at this point in the history
…ress depreciations
  • Loading branch information
Smullz622 committed Apr 19, 2024
1 parent a3585af commit b3b5b9a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 201 deletions.
29 changes: 13 additions & 16 deletions app/components/blacklight/advanced_search_form_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@
</div>
</div>

<% if search_filter_controls? %>
<div class="limit-criteria">
<h3 class="limit-criteria-heading"><%= t('blacklight.advanced_search.form.limit_criteria_heading_html') %></h3>

<div id="advanced_search_facets" class="limit_input">
<% if blacklight_config.try(:advanced_search).try {|h| h[:form_facet_partial] } %>
<%= render blacklight_config.advanced_search[:form_facet_partial] %>
<% else %>
<%= render 'advanced_search_facets' %>
<% end %>
</div>
</div>
<% end %>

<!-- original BL code
<% if search_filter_controls? %>
<div class="limit-criteria mb-4">
<h2 class="limit-criteria-heading h3"><%= t('blacklight.advanced_search.form.limit_criteria_heading_html') %></h2>
Expand All @@ -50,9 +35,21 @@
</div>
</div>
<% end %>
-->
</div>

<%# Publication Date is a range input %>
<% pub_date = helpers.facet_configuration_for_field('pub_date_itsi') %>
<div class="form-group advanced-search-facet row">
<%= label_tag pub_date.field.parameterize, class: 'col-sm-4 control-label' do %>
<%= pub_date.label %>
<% end %>
<div class="col-sm-8 range_limit">
<label for="range_pub_date_start_sort_begin" class="sr-only">Publication date range (starting year)</label>
<%= number_field_tag("range[pub_date_itsi][begin]", nil, maxlength: 6, class: "form-control text-center range_begin") %>
<label for="range_pub_date_start_sort_end" class="sr-only">Publication date range (ending year)</label>
<%= number_field_tag("range[pub_date_itsi][end]", nil, maxlength: 6, class: "form-control text-center range_end") %>
</div>
</div>

<div class="sort-submit-buttons clearfix">
<%= render 'advanced_search_submit_btns' %>
Expand Down
134 changes: 0 additions & 134 deletions app/components/blacklight/advanced_search_form_component.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="form-group advanced-search-facet">
<p><%= @facet_field.label %>
<span class="col-sm-9">
<%= content_tag(:select,
multiple: true,
name: "f_inclusive[#{@facet_field.key}][]",
id: @facet_field.key,
class: 'form-control selectpicker',
data: { 'live-search': 'true', placeholder: "Type or select #{@facet_field.key.downcase.pluralize}" }) do %>
<% presenters.each_with_index do |presenter, idx| -%>
<%= content_tag :option, value: presenter.value do %>
<%= presenter.label %>
<% end %>
<% end %>
<% end %>
<span>
</p>
</div>
38 changes: 0 additions & 38 deletions app/views/catalog/_advanced_search_facets_as_select.html.erb

This file was deleted.

26 changes: 13 additions & 13 deletions spec/features/advanced_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
context 'when doing single term searches' do
context 'when searching by series title' do
before do
fill_in 'clause_series_query', with: 'Yale studies in political science'
fill_in 'clause_5_query', with: 'Yale studies in political science'
click_on 'advanced-search-submit'
end

Expand All @@ -26,7 +26,7 @@

context 'when searching by series keyword' do
before do
fill_in 'clause_series_query', with: 'political science'
fill_in 'clause_5_query', with: 'political science'
click_on 'advanced-search-submit'
end

Expand All @@ -37,7 +37,7 @@

context 'when searching by isbn' do
before do
fill_in 'clause_identifiers_query', with: '9780442290917'
fill_in 'clause_4_query', with: '9780442290917'
click_on 'advanced-search-submit'
end

Expand All @@ -48,7 +48,7 @@

context 'when searching by issn' do
before do
fill_in 'clause_identifiers_query', with: '10756787'
fill_in 'clause_4_query', with: '10756787'
click_on 'advanced-search-submit'
end

Expand All @@ -59,7 +59,7 @@

context 'when searching by LCCN' do
before do
fill_in 'clause_identifiers_query', with: '2001270122'
fill_in 'clause_4_query', with: '2001270122'
click_on 'advanced-search-submit'
end

Expand All @@ -70,7 +70,7 @@

context 'when searching by publisher' do
before do
fill_in 'clause_publisher_query', with: 'Norton'
fill_in 'clause_6_query', with: 'Norton'
click_on 'advanced-search-submit'
end

Expand Down Expand Up @@ -107,8 +107,8 @@
context 'when doing combination searches' do
context 'when searching for a specific book about quilts in Cumberland County' do
before do
fill_in 'clause_title_query', with: 'quilts cumberland'
fill_in 'clause_author_query', with: 'quilters'
fill_in 'clause_1_query', with: 'quilts cumberland'
fill_in 'clause_2_query', with: 'quilters'
find('button[data-id="access_facet"]').click
find_by_id('bs-select-1-1').click
find('button[data-id="format"]').click
Expand All @@ -127,9 +127,9 @@

context 'when searching for a specific book on geological perspectives of climate change' do
before do
fill_in 'clause_subject_query', with: 'Climatology'
fill_in 'clause_series_query', with: 'AAPG studies in geology'
fill_in 'clause_publisher_query', with: 'Petroleum Geologists'
fill_in 'clause_3_query', with: 'Climatology'
fill_in 'clause_5_query', with: 'AAPG studies in geology'
fill_in 'clause_6_query', with: 'Petroleum Geologists'
find('button[data-id="library_facet"]').click
find_by_id('bs-select-6-4').click
click_on 'advanced-search-submit'
Expand All @@ -144,7 +144,7 @@
context 'when using vernacular language' do
context 'when searching in simplified chinese' do
before do
fill_in 'clause_title_query', with: '上海理论'
fill_in 'clause_1_query', with: '上海理论'
click_on 'advanced-search-submit'
end

Expand All @@ -155,7 +155,7 @@

context 'when searching in traditional chinese' do
before do
fill_in 'clause_title_query', with: '上海理論'
fill_in 'clause_1_query', with: '上海理論'
click_on 'advanced-search-submit'
end

Expand Down

0 comments on commit b3b5b9a

Please sign in to comment.