Class: CamaleonCms::Admin::Appearances::Widgets::SidebarController

Inherits:
CamaleonCms::AdminController
  • Object
show all
Defined in:
app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the  GNU Affero General Public License (GPLv3) for more details.

Instance Method Summary collapse

Instance Method Details

#createObject


18
19
20
21
22
23
24
25
26
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 18

def create
  @sidebar = current_site.sidebars.new(params[:widget_sidebar])
  if @sidebar.save
    flash[:notice] = t('camaleon_cms.admin.widgets.sidebar.created')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.sidebar.error_created')
  end
  redirect_to cama_admin_appearances_widgets_main_index_path
end

#destroyObject


48
49
50
51
52
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 48

def destroy
  @sidebar = @sidebar.destroy
  flash[:notice] = t('camaleon_cms.admin.widgets.sidebar.error_deleted')
  redirect_to cama_admin_appearances_widgets_main_index_path
end

#editObject


28
29
30
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 28

def edit
  new
end

#newObject


13
14
15
16
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 13

def new
  @sidebar ||= current_site.sidebars.new
  render 'form', layout: false
end

#reorderObject


41
42
43
44
45
46
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 41

def reorder
  params[:pos].each_with_index do |assigned_id, index|
    current_site.sidebars.find(params[:sidebar_id]).assigned.find(assigned_id).update(item_order: index) if assigned_id.present?
  end
  render inline: ""
end

#updateObject


32
33
34
35
36
37
38
39
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 32

def update
  if @sidebar.update(params[:widget_sidebar])
    flash[:notice] = t('camaleon_cms.admin.widgets.sidebar.updated')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.sidebar.error_updated')
  end
  redirect_to cama_admin_appearances_widgets_main_index_path
end