Class: Spotlight::SearchesController
Instance Method Summary
collapse
Methods included from Base
#autocomplete_json_response, #blacklight_config
Methods included from Config
#exhibit_specific_blacklight_config
Methods included from Controller
#blacklight_config, #current_exhibit, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url
Instance Method Details
#autocomplete ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'app/controllers/spotlight/searches_controller.rb', line 27
def autocomplete
(_, document_list) = get_search_results autocomplete_params
respond_to do |format|
format.json do
render json: { docs: autocomplete_json_response(document_list) }
end
end
end
|
#create ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/spotlight/searches_controller.rb', line 10
def create
params_copy = params.dup
params_copy.delete(:exhibit_id)
@search.title = params_copy.delete(:search)[:title]
@search.query_params = params_copy.reject { |k,v| blacklisted_search_session_params.include?(k.to_sym) or v.blank? }
@search.save!
redirect_to :back, notice: t(:'helpers.submit.search.created', model: @search.class.model_name.human.downcase)
end
|
#destroy ⇒ Object
49
50
51
52
|
# File 'app/controllers/spotlight/searches_controller.rb', line 49
def destroy
@search.destroy
redirect_to exhibit_searches_path(@search.exhibit), alert: t(:'helpers.submit.search.destroyed', model: @search.class.model_name.human.downcase)
end
|
#edit ⇒ Object
36
37
38
39
|
# File 'app/controllers/spotlight/searches_controller.rb', line 36
def edit
add_breadcrumb @search.title, edit_exhibit_search_path(@search.exhibit, @search)
@exhibit = @search.exhibit
end
|
#index ⇒ Object
20
21
22
23
24
25
|
# File 'app/controllers/spotlight/searches_controller.rb', line 20
def index
respond_to do |format|
format.html
format.json { render json: @searches, root: false }
end
end
|
#update ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/controllers/spotlight/searches_controller.rb', line 41
def update
if @search.update params.require(:search).permit(:title, :short_description, :long_description, :featured_item_id)
redirect_to exhibit_searches_path(@search.exhibit), notice: t(:'helpers.submit.search.updated', model: @search.class.model_name.human.downcase)
else
render action: 'edit'
end
end
|
#update_all ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/controllers/spotlight/searches_controller.rb', line 54
def update_all
notice = if @exhibit.update batch_search_params
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_to :back, notice: notice
end
|