Sha256: ff11f35229f6ef6ea6d34501217a9aeaecd62fc32dafdc19b7753ab8af6af71a

Contents?: true

Size: 1.41 KB

Versions: 66

Compression:

Stored size: 1.41 KB

Contents

class CamaleonCms::Admin::Appearances::Widgets::MainController < CamaleonCms::AdminController
  before_action :check_permission_role
  before_action :set_widgets, only: [:edit, :update, :destroy]
  add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.appearance")
  add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.widgets")

  def index
    @widgets = current_site.widgets
  end

  def new
    @widget ||= current_site.widgets.new
    render "form", layout: false
  end

  def edit
    new
  end

  def create
    params[:widget_main][:status] = "simple"
    @widget = current_site.widgets.new(params.require(:widget_main).permit!)
    if @widget.save!
      flash[:notice] = t('camaleon_cms.admin.widgets.message.created')
    else
      flash[:error] = t('camaleon_cms.admin.widgets.message.error_created')
    end
    redirect_to action: :index
  end

  def update
    if @widget.update!(params.require(:widget_main).permit!)
      flash[:notice] = t('camaleon_cms.admin.widgets.message.updated')
    else
      flash[:error] = t('camaleon_cms.admin.widgets.message.error_updated')
    end
    redirect_to action: :index
  end

  def destroy
    @widget = @widget.destroy!
    flash[:notice] = t('camaleon_cms.admin.widgets.message.deleted')
    redirect_to action: :index
  end

  private

  def set_widgets
    @widget = current_site.widgets.find(params[:id])
  end

  def check_permission_role
    authorize! :manage, :widgets
  end
end

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
camaleon_cms-2.6.0 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.5.3.1 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.5.3 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.5.2 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms_rails6-2.5.0 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.5.1 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.5.0 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.9 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.8 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.7 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.6 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.5 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.4 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.3 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.2 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.1 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.6.0 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.5.14 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.5.13 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb
camaleon_cms-2.4.5.12 app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb