Class: Spotlight::SearchesController
Overview
CRUD actions for curating browse categories (see BrowseController for the end-user read and index actions)
Instance Method Summary
collapse
Methods included from Base
#autocomplete_json_response, #autocomplete_json_response_for_document, #blacklight_config
Methods included from Config
#exhibit_specific_blacklight_config
Methods included from Controller
#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #default_masthead?, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url
Instance Method Details
#autocomplete ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/spotlight/searches_controller.rb', line 32
def autocomplete
search_params = autocomplete_params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field)
(_, document_list) = search_results(search_params, search_params_logic)
respond_to do |format|
format.json do
render json: { docs: autocomplete_json_response(document_list) }
end
end
end
|
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/spotlight/searches_controller.rb', line 14
def create
@search.attributes = search_params
@search.query_params = params.except(:exhibit_id, :search, *blacklisted_search_session_params).reject { |_k, v| v.blank? }
if @search.save
redirect_to :back, notice: t(:'helpers.submit.search.created', model: @search.class.model_name.human.downcase)
else
redirect_to :back, alert: @search.errors.full_messages.join('<br>'.html_safe)
end
end
|
#destroy ⇒ Object
56
57
58
59
|
# File 'app/controllers/spotlight/searches_controller.rb', line 56
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
43
44
45
46
|
# File 'app/controllers/spotlight/searches_controller.rb', line 43
def edit
add_breadcrumb @search.title, edit_exhibit_search_path(@search.exhibit, @search)
@exhibit = @search.exhibit
end
|
#index ⇒ Object
25
26
27
28
29
30
|
# File 'app/controllers/spotlight/searches_controller.rb', line 25
def index
respond_to do |format|
format.html
format.json { render json: @searches.published.as_json(methods: [:count, :thumbnail_image_url]), root: false }
end
end
|
#show ⇒ Object
70
71
72
|
# File 'app/controllers/spotlight/searches_controller.rb', line 70
def show
redirect_to exhibit_browse_url(@search.exhibit, @search)
end
|
#update ⇒ Object
48
49
50
51
52
53
54
|
# File 'app/controllers/spotlight/searches_controller.rb', line 48
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'
end
end
|
#update_all ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'app/controllers/spotlight/searches_controller.rb', line 61
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
|