Class: Spotlight::PagesController

Inherits:
ApplicationController show all
Includes:
Blacklight::Catalog::SearchContext, Base, Catalog::AccessControlsEnforcement
Defined in:
app/controllers/spotlight/pages_controller.rb

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

#_prefixesObject



79
80
81
# File 'app/controllers/spotlight/pages_controller.rb', line 79

def _prefixes
  @_prefixes ||= super + ['catalog']
end

#createObject

POST /exhibits/1/pages



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/spotlight/pages_controller.rb', line 41

def create
  @page.attributes = page_params
  @page.last_edited_by = @page.created_by = current_user

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

#destroyObject

DELETE /pages/1



64
65
66
67
68
# File 'app/controllers/spotlight/pages_controller.rb', line 64

def destroy
  @page.destroy

  redirect_to [@page.exhibit, page_collection_name], notice: t(:'helpers.submit.page.destroyed', model: @page.class.model_name.human.downcase)
end

#editObject

GET /pages/1/edit



36
37
38
# File 'app/controllers/spotlight/pages_controller.rb', line 36

def edit
  @page.lock! current_user
end

#indexObject

GET /exhibits/1/pages



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

def index
  # set up a model the inline "add a new page" form
  @page = CanCan::ControllerResource.new(self).send(:build_resource)
end

#newObject

GET /exhibits/1/pages/new



32
33
# File 'app/controllers/spotlight/pages_controller.rb', line 32

def new
end

#previewObject



23
24
25
26
27
28
29
# File 'app/controllers/spotlight/pages_controller.rb', line 23

def preview
  @block = SirTrevorRails::Block.from_hash(JSON.parse(params[:block], symbolize_names: true), "block")

  respond_to do |format|
    format.html { render 'preview', layout: false }
  end
end

#showObject

GET /pages/1



19
20
21
# File 'app/controllers/spotlight/pages_controller.rb', line 19

def show
  fresh_when([@page.exhibit, @page])
end

#updateObject

PATCH/PUT /pages/1



53
54
55
56
57
58
59
60
61
# File 'app/controllers/spotlight/pages_controller.rb', line 53

def update
  @page.lock.delete if @page.lock

  if @page.update(page_params.merge(last_edited_by: current_user))
    redirect_to [@page.exhibit, @page], notice: t(:'helpers.submit.page.updated', model: @page.class.model_name.human.downcase)
  else
    render action: 'edit'
  end
end

#update_allObject



70
71
72
73
74
75
76
77
# File 'app/controllers/spotlight/pages_controller.rb', line 70

def update_all
  notice = if @exhibit.update update_all_page_params
    t(:'helpers.submit.page.batch_updated', model: human_name)
  else
    t(:'helpers.submit.page.batch_error', model: human_name)
  end
  redirect_to :back, notice: notice
end