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.27 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.45 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.44 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.43 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.42 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.41 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.40 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.39 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.38 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/content_presets_controller.rb
workarea-admin-3.4.37 app/controllers/workarea/admin/content_presets_controller.rb