app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-3.5.0.4 vs app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-3.6.0.beta1
- old
+ new
@@ -12,10 +12,30 @@
before_action :attach_breadcrumbs, only: %i[index edit], unless: -> { request.format.json? }
include Spotlight::Base
include Spotlight::SearchHelper
+ def index
+ @groups = @exhibit.groups
+ respond_to do |format|
+ format.html
+ format.json do
+ render json: @searches.as_json(methods: %i[full_title count thumbnail_image_url]), root: false
+ end
+ end
+ end
+
+ def show
+ redirect_to exhibit_browse_url(@search.exhibit, @search)
+ end
+
+ def edit
+ @groups = @exhibit.groups
+ add_breadcrumb @search.full_title, edit_exhibit_search_path(@search.exhibit, @search)
+ @exhibit = @search.exhibit
+ end
+
def create
@search.assign_attributes(search_params.except((:title unless @search.new_record?)))
@search.query_params = query_params
if @search.save
@@ -24,39 +44,23 @@
else
redirect_back fallback_location: fallback_url, alert: @search.errors.full_messages.join('<br>'.html_safe)
end
end
- def index
- @groups = @exhibit.groups
- respond_to do |format|
- format.html
- format.json do
- render json: @searches.as_json(methods: %i[full_title count thumbnail_image_url]), root: false
- end
- end
- end
-
def autocomplete
search_params = autocomplete_params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field)
- (_, document_list) = search_service.search_results do |builder|
+ (response, _document_list) = search_service.search_results do |builder|
builder.with(search_params)
end
respond_to do |format|
format.json do
- render json: { docs: autocomplete_json_response(document_list) }
+ render json: { docs: autocomplete_json_response(response.documents) }
end
end
end
- def edit
- @groups = @exhibit.groups
- add_breadcrumb @search.full_title, edit_exhibit_search_path(@search.exhibit, @search)
- @exhibit = @search.exhibit
- end
-
def update
if @search.update search_params
redirect_to exhibit_searches_path(@search.exhibit), notice: t(:'helpers.submit.search.updated', model: @search.class.model_name.human.downcase)
else
render action: 'edit'
@@ -73,13 +77,9 @@
t(:'helpers.submit.search.batch_updated', model: Spotlight::Search.model_name.human.pluralize)
else
t(:'helpers.submit.search.batch_error', model: Spotlight::Search.model_name.human.pluralize.downcase)
end
redirect_back fallback_location: fallback_url, notice: notice
- end
-
- def show
- redirect_to exhibit_browse_url(@search.exhibit, @search)
end
protected
def autocomplete_params