Class: Cms::InlineContentController

Inherits:
BaseController show all
Defined in:
app/controllers/cms/inline_content_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

allow_guests_to

Methods inherited from ApplicationController

#no_browser_caching

Instance Method Details

#updateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/cms/inline_content_controller.rb', line 5

def update
  content_block = Content.find_draft(params[:content_name], params[:id])
  content_block.update_attributes(filtered_content(content_block))
  @page = Page.find_draft(params[:page_id].to_i)
  if (!@page.live?)
    page_status = "draft"
    status_label = "This page is in draft status"
  else
    page_status = "published"
    status_label = "Published"
  end

  # After a page update, all the connector ids can change. So we need to send
  # the new move up/down/remove paths to client so they will work after an inline update.
  routes = []
  if params[:container]
    connectors = @page.current_connectors(params[:container].to_sym)
    connectors.each do |c|
      routes << {
          move_up: cms.move_up_connector_path(c, format: :json),
          move_down: cms.move_down_connector_path(c, format: :json),
          remove: cms.connector_path(c, format: :json)
      }
    end
  end
  results = {
      page_status: page_status,
      status_label: status_label,
      page_title: @page.title,
      container: params[:container].to_s,
      routes: routes
  }
  render json: results, layout: false
end