Sha256: fde70c853f656584d3c12c7df879876373b84ff137ebe02fe3080ad625fabede

Contents?: true

Size: 1.18 KB

Versions: 71

Compression:

Stored size: 1.18 KB

Contents

class CamaleonCms::Admin::Appearances::Widgets::AssignController < CamaleonCms::AdminController
  before_action :check_permission_role
  before_action :find_sidebar
  before_action :find_assigned_sidebar, only: [:update, :destroy]

  def new
    @widget = current_site.widgets.find(params[:widget_id])
    @assigned = @sidebar.assigned.create!({title: "Default", widget_id: @widget.id})
    render partial: "form", locals: {assigned: @assigned, widget: @widget, sidebar: @sidebar}, layout: "camaleon_cms/admin/ajax"
  end

  def update
    if @assigned.update(params.require(:assign).permit!)
      @assigned.set_field_values(params[:field_options])
      flash[:notice] = t('camaleon_cms.admin.widgets.assign.updated')
    else
      flash[:error] = t('camaleon_cms.admin.widgets.assign.error_updated')
    end
    redirect_to cama_admin_appearances_widgets_main_index_path
  end

  def destroy
    @assigned.destroy
    render inline: ''
  end

  private

  def find_sidebar
    @sidebar = current_site.sidebars.find(params[:sidebar_id])
  end

  def find_assigned_sidebar
    @assigned = @sidebar.assigned.find(params[:id])
  end

  def check_permission_role
    authorize! :manage, :widgets
  end

end

Version data entries

71 entries across 71 versions & 2 rubygems

Version Path
camaleon_cms-2.6.4 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.6.3 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.6.2 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.6.1 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.6.0.1 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.6.0 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.5.3.1 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.5.3 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.5.2 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms_rails6-2.5.0 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.5.1 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.5.0 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.9 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.8 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.7 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.6 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.5 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.4 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.3 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb
camaleon_cms-2.4.6.2 app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb