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.5.15 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.36 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.35 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.34 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.33 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.32 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.31 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.30 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.29 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.6 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.28 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.5 app/controllers/workarea/admin/content_presets_controller.rb