Class: Integral::Backend::PagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/integral/backend/pages_controller.rb

Overview

Pages controller

Instance Method Summary collapse

Instance Method Details

#activitiesObject

GET /:id/activities



75
76
77
# File 'app/controllers/integral/backend/pages_controller.rb', line 75

def activities
  respond_with_activities(:edit_backend_page_url)
end

#activityObject

GET /:id/activities/:id



80
81
82
83
84
85
86
87
# File 'app/controllers/integral/backend/pages_controller.rb', line 80

def activity
  authorize Version

  add_breadcrumb I18n.t('integral.navigation.activity'), :activities_backend_page_url
  add_breadcrumb I18n.t('integral.actions.view')

  @activity = PageVersion.find(params[:activity_id]).decorate
end

#createObject

POST / Page creation



36
37
38
39
40
41
42
43
44
# File 'app/controllers/integral/backend/pages_controller.rb', line 36

def create
  @page = Page.new(page_params)

  if @page.save
    respond_successfully(notification_message('creation_success'), edit_backend_page_path(@page))
  else
    respond_failure(notification_message('creation_failure'), @page, :new)
  end
end

#current_policyBasePolicy

Returns current authorization policy.

Returns:



90
91
92
93
# File 'app/controllers/integral/backend/pages_controller.rb', line 90

def current_policy
  return policy(@page) if @page
  policy(Integral::Page.new)
end

#destroyObject

DELETE /:id



64
65
66
67
68
69
70
71
72
# File 'app/controllers/integral/backend/pages_controller.rb', line 64

def destroy
  if @page.destroy
    respond_successfully(notification_message('delete_success'), backend_pages_path)
  else
    error_message = @page.errors.full_messages.to_sentence
    flash[:error] = "#{notification_message('delete_failure')} - #{error_message}"
    redirect_to backend_pages_path
  end
end

#editObject

GET /:id/edit Page edit form



48
49
50
51
# File 'app/controllers/integral/backend/pages_controller.rb', line 48

def edit
  # add_breadcrumb @page.title, backend_page_url(@page)
  add_breadcrumb I18n.t('integral.navigation.edit'), :edit_backend_page_path
end

#indexObject

GET / Lists all pages



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/integral/backend/pages_controller.rb', line 10

def index
  respond_to do |format|
    format.html do
      set_grid(Integral::Grids::PagesGrid)
    end

    format.json do
      if params[:gridview].present?
        set_grid(Integral::Grids::PagesGrid)
        render json: { content: render_to_string(partial: 'integral/backend/pages/grid', locals: { grid: @grid }) }
      else
        respond_to_record_selector(Integral::Page)
      end
    end
  end
end

#newObject

GET /new Page creation form



29
30
31
32
# File 'app/controllers/integral/backend/pages_controller.rb', line 29

def new
  add_breadcrumb I18n.t('integral.navigation.new'), :new_backend_page_path
  @page = Page.new
end

#updateObject

PUT /:id Updating an page



55
56
57
58
59
60
61
# File 'app/controllers/integral/backend/pages_controller.rb', line 55

def update
  if @page.update(page_params)
    respond_successfully(notification_message('edit_success'), edit_backend_page_path(@page))
  else
    respond_failure(notification_message('edit_failure'), @page, :edit)
  end
end