Skip to content

Commit

Permalink
Merge branch 'master' into t127-advanced-search
Browse files Browse the repository at this point in the history
  • Loading branch information
maxturer authored Apr 26, 2024
2 parents 01d0a78 + 7830c24 commit 4551f36
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 68 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ gem 'omniauth-saml', '2.1.0'
gem 'omniauth-rails_csrf_protection'

gem 'blacklight_range_limit'

gem 'blacklight_advanced_search'

group :development, :test do
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* Used by blacklight_range_limit
*= require 'blacklight_range_limit'
*
*= require chosen
*= require 'blacklight_advanced_search'
*/

@import "scholarspace/scholarspace";
62 changes: 0 additions & 62 deletions app/forms/batch_edit_form.rb

This file was deleted.

3 changes: 2 additions & 1 deletion app/models/search_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior

include BlacklightAdvancedSearch::AdvancedSearchBuilder
include BlacklightRangeLimit::RangeLimitBuilder
self.default_processor_chain += [:add_advanced_parse_q_to_solr, :add_advanced_search_to_solr]
Expand All @@ -16,4 +17,4 @@ class SearchBuilder < Blacklight::SearchBuilder
# def add_custom_data_to_query(solr_parameters)
# solr_parameters[:custom] = blacklight_params[:user_value]
# end
end
end
14 changes: 10 additions & 4 deletions app/services/hyrax/search_service_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
module Hyrax
module SearchServiceDecorator
def search_results
builder = search_builder.with(user_params)
# Patch to fix a bug with the blacklight_range_finder gem
# The catalog_controller#find_range method calls this method on an instance where the @user_params are empty
# Because of that, the builder receives empty @blacklight_params, and the fetch_specific_range_limits method on the processor change
# fails. The range limits are included in the @params attribute, however.
# In all other cases, we want to fall back on the @user_params attribute.
if (respond_to?(:params) && user_params.empty?)
builder = search_builder.with(params)
else
builder = search_builder.with(user_params)
end
builder.page = user_params[:page] if user_params[:page]
builder.rows = (user_params[:per_page] || user_params[:rows]) if user_params[:per_page] || user_params[:rows]

builder = yield(builder) if block_given?
# OVERRIDE: without this merge, Blightlight seems to ignore the sort params on Collections
builder.merge(sort: user_params[:sort]) if user_params[:sort]
response = repository.search(builder)

if response.grouped? && grouped_key_for_results
[response.group(grouped_key_for_results), []]
elsif response.grouped? && response.grouped.length == 1
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
concern :exportable, Blacklight::Routes::Exportable.new
concern :searchable, Blacklight::Routes::Searchable.new
concern :oai_provider, BlacklightOaiProvider::Routes.new
concern :range_searchable, BlacklightRangeLimit::Routes::RangeSearchable.new

resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
concerns :oai_provider
Expand Down

0 comments on commit 4551f36

Please sign in to comment.