Sha256: 3ff093cc69f9dac139d866d9e505b8665cd871d0da453de688035e95bd9f746a

Contents?: true

Size: 999 Bytes

Versions: 62

Compression:

Stored size: 999 Bytes

Contents

module Workarea
  class Admin::ContentPresetsController < Admin::ApplicationController
    required_permissions :store
    before_action :set_content_block, only: :create

    def new
    end

    def create
      @preset = Content::Preset.new(params[:content_preset])
      @preset.apply_block(@block) if @block.present?

      if @preset.save
        flash[:success] = t('workarea.admin.content_presets.flash_messages.saved')

        if request.xhr?
          head :created
        else
          redirect_to return_to || edit_content_path(@content)
        end
      else
        flash[:error] = t('workarea.admin.content_presets.flash_messages.preset_error')
        head :unprocessable_entity
      end
    end

    def destroy
      preset = Content::Preset.find(params[:id])
      preset.destroy
      head :no_content
    end

    private

    def set_content_block
      @content = Content.find(params[:content_id])
      @block = @content.blocks.find(params[:block_id])
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.4.27 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.4 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.26 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.3 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.25 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.2 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.24 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.1 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.23 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.22 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.0 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.21 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.0.beta.1 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.20 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.19 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.18 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.17 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.16 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.15 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.14 app/controllers/workarea/admin/content_presets_controller.rb