Class: CamaleonCms::Admin::Appearances::Widgets::SidebarController
Instance Method Summary
collapse
#ajax, #cama_get_i18n_frontend, #dashboard, #index, #search
Instance Method Details
#create ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 14
def create
@sidebar = current_site..new(params.require(:widget_sidebar).permit(:name, :slug, :description))
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
|
#destroy ⇒ Object
46
47
48
49
50
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 46
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
|
#edit ⇒ Object
24
25
26
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 24
def edit
new
end
|
#new ⇒ Object
9
10
11
12
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 9
def new
@sidebar ||= current_site..new
render 'form', layout: false
end
|
#reorder ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 37
def reorder
params[:pos].each_with_index do |assigned_id, index|
if assigned_id.present?
current_site..find(params[:sidebar_id]).assigned.find(assigned_id).update(item_order: index)
end
end
render plain: ''
end
|
#update ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb', line 28
def update
if @sidebar.update(params.require(:widget_sidebar).permit(:name, :slug, :description))
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
|