Sha256: 81a3a88a678223e71907c4daf44f8c504f878f024446f44f641445a1617de3dd

Contents?: true

Size: 1.55 KB

Versions: 10

Compression:

Stored size: 1.55 KB

Contents

module Cms
  class InlineContentController < Cms::BaseController
    respond_to :js

    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

    private

    def filtered_content(content_block)
      ContentFilter.new.filter(content_params(content_block))
    end

    def content_params(content)
      params.require(:content).permit(content.class.permitted_params)
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
browsercms-artirix-4.0.4 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.3.3 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.3.2 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.3.1 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.3 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.2 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.1.1 app/controllers/cms/inline_content_controller.rb
browsercms-artirix-4.0.0.rc1.art4 app/controllers/cms/inline_content_controller.rb
browsercms-4.0.0.rc1 app/controllers/cms/inline_content_controller.rb
browsercms-4.0.0.beta app/controllers/cms/inline_content_controller.rb