Class: Spotlight::CustomSearchFieldsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/custom_search_fields_controller.rb

Overview

CRUD actions for exhibit custom search field management.

Instance Method Summary collapse

Methods included from Spotlight::Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_path, #resource_masthead?, #search_action_url, #search_facet_path, #search_state, #set_exhibit_locale_scope, #set_locale

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#createObject

POST /custom_search_fields



23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/spotlight/custom_search_fields_controller.rb', line 23

def create
  @custom_search_field.attributes = custom_search_field_params
  @custom_search_field.exhibit = current_exhibit

  if @custom_search_field.save
    redirect_to edit_exhibit_search_configuration_path(@custom_search_field.exhibit),
                notice: t(:'helpers.submit.custom_search_field.created', model: @custom_search_field.class.model_name.human.downcase)
  else
    render action: 'new'
  end
end

#destroyObject



45
46
47
48
49
50
# File 'app/controllers/spotlight/custom_search_fields_controller.rb', line 45

def destroy
  @custom_search_field.destroy

  redirect_to edit_exhibit_search_configuration_path(@custom_search_field.exhibit),
              notice: t(:'helpers.submit.custom_search_field.destroyed', model: @custom_search_field.class.model_name.human.downcase)
end

#editObject

GET /custom_search_fields/1/edit



18
19
20
# File 'app/controllers/spotlight/custom_search_fields_controller.rb', line 18

def edit
  add_breadcrumb @custom_search_field.label, edit_exhibit_custom_search_field_path(@custom_search_field.exhibit, @custom_search_field)
end

#newObject

GET /custom_search_fields/new



13
14
15
# File 'app/controllers/spotlight/custom_search_fields_controller.rb', line 13

def new
  add_breadcrumb t(:'helpers.action.spotlight/custom_search_field.create'), new_exhibit_custom_search_field_path(@exhibit)
end

#updateObject

PATCH/PUT /custom_search_fields/1



36
37
38
39
40
41
42
43
# File 'app/controllers/spotlight/custom_search_fields_controller.rb', line 36

def update
  if @custom_search_field.update(custom_search_field_params)
    redirect_to edit_exhibit_search_configuration_path(@custom_search_field.exhibit),
                notice: t(:'helpers.submit.custom_search_field.updated', model: @custom_search_field.class.model_name.human.downcase)
  else
    render :edit
  end
end