Class: Admin::SidebarController
Instance Method Summary
collapse
Methods included from BlogHelper
#blog_base_url, #this_blog
Instance Method Details
#destroy ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'app/controllers/admin/sidebar_controller.rb', line 22
def destroy
@sidebar = Sidebar.where(id: params[:id]).first
@sidebar&.destroy
respond_to do |format|
format.html { return redirect_to() }
format.js
end
end
|
#index ⇒ Object
4
5
6
7
|
# File 'app/controllers/admin/sidebar_controller.rb', line 4
def index
@available = SidebarRegistry.
@ordered_sidebars = Sidebar.
end
|
#sortable ⇒ Object
Callback for admin sidebar sortable plugin
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/admin/sidebar_controller.rb', line 37
def sortable
sorted = params[:sidebar].map(&:to_i)
Sidebar.transaction do
sorted.each_with_index do |, staged_index|
= if >= 9000
SidebarRegistry.[ - 9000]
.new(blog: this_blog)
else
Sidebar.valid.find()
end
.update(staged_position: staged_index)
end
end
@ordered_sidebars = Sidebar.
@available = SidebarRegistry.
respond_to do |format|
format.js
format.html do
return redirect_to
end
end
end
|
#update ⇒ Object
Just update a single active Sidebar instance at once
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/admin/sidebar_controller.rb', line 10
def update
@sidebar = Sidebar.where(id: params[:id]).first
@old_s_index = @sidebar.staged_position || @sidebar.active_position
@sidebar.update params[:configure][@sidebar.id.to_s].permit!
respond_to do |format|
format.js
format.html do
return redirect_to()
end
end
end
|