Class: Breeze::SectionsController
Instance Method Summary
collapse
#authenticate_if, #current_member_email
Instance Method Details
#destroy ⇒ Object
33
34
35
36
|
# File 'app/controllers/breeze/sections_controller.rb', line 33
def destroy
@section.delete_and_reset_index(current_member_email)
redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.} removed"
end
|
#index ⇒ Object
5
6
7
|
# File 'app/controllers/breeze/sections_controller.rb', line 5
def index
@page = Page.find(params[:page_id])
end
|
#move ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'app/controllers/breeze/sections_controller.rb', line 70
def move
if( params[:dir] == "up")
@section.move_up
else
@section.move_down
end
@section.edit_save(current_member_email)
redirect_to page_sections_url(@section.page.id)
end
|
#new ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/breeze/sections_controller.rb', line 21
def new
page = Page.find(params[:page_id] || params[:section_id])
template = params[:template]
new_section = page.new_section(template)
new_section.add_save(current_member_email)
if(template.blank?) redirect_to section_select_template_url(new_section.id), notice: "New section created"
else redirect_to section_url(new_section.id), notice: "Section copied"
end
end
|
#select_card_template ⇒ Object
17
18
19
|
# File 'app/controllers/breeze/sections_controller.rb', line 17
def select_card_template
@cards = CardStyle.all
end
|
#select_template ⇒ Object
13
14
15
|
# File 'app/controllers/breeze/sections_controller.rb', line 13
def select_template
@sections = SectionStyle.all
end
|
#set_card_template ⇒ Object
62
63
64
65
66
67
68
|
# File 'app/controllers/breeze/sections_controller.rb', line 62
def set_card_template
card_template = params[:card_template]
raise "no card template given" if card_template.blank?
@section.card_template = card_template
@section.edit_save(current_member_email)
redirect_to section_url(@section.id)
end
|
#set_image ⇒ Object
38
39
40
41
42
43
|
# File 'app/controllers/breeze/sections_controller.rb', line 38
def set_image
@section.image_id = params[:image_id].to_i
@section.edit_save(current_member_email)
message = @section.image ? "#{@section.image.name} selected" : "Image removed"
redirect_to section_url(@section.id) , notice: message
end
|
#set_template ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/breeze/sections_controller.rb', line 45
def set_template
template = params[:template]
raise "no template given" if template.blank?
style = SectionStyle.find_by_template(template)
raise "no such template #{template}" unless style
if(! style.has_cards?)
if( @section.cards.length > 0 )
redirect_to section_url(@section.id) , alert: "Must delete cards first"
return
end
@section.card_template = ""
end
@section.set_template( template )
@section.edit_save(current_member_email)
redirect_to section_url(@section.id)
end
|
#show ⇒ Object
9
10
11
|
# File 'app/controllers/breeze/sections_controller.rb', line 9
def show
@ids = [ @section.type_id ]
end
|
#update ⇒ Object
80
81
82
83
84
85
86
87
88
|
# File 'app/controllers/breeze/sections_controller.rb', line 80
def update
@section.update(params[:section])
@section.update_options( params[:options])
@section.edit_save(current_member_email)
respond_to do |format|
format.html { redirect_to :section , notice: "Update ok" }
format.json { render status: 200, json: {} }
end
end
|