Class: Breeze::CardsController

Inherits:
BreezeController show all
Defined in:
app/controllers/breeze/cards_controller.rb

Instance Method Summary collapse

Methods inherited from BreezeController

#authenticate_if, #current_member_email

Instance Method Details

#destroyObject



33
34
35
36
# File 'app/controllers/breeze/cards_controller.rb', line 33

def destroy
  @card.delete_and_reset_index(current_member_email)
  redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
end

#indexObject



5
6
7
# File 'app/controllers/breeze/cards_controller.rb', line 5

def index
  @section = Section.find(params[:section_id])
end

#moveObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/breeze/cards_controller.rb', line 16

def move
  if( params[:dir] == "up")
    @card.move_up
  else
    @card.move_down
  end
  @card.edit_save(current_member_email)
  redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
end

#newObject



26
27
28
29
30
31
# File 'app/controllers/breeze/cards_controller.rb', line 26

def new
  @section = Section.find(params[:section_id] || params[:card_id])
  new_card =  @section.new_card
  new_card.add_save(current_member_email)
  redirect_to section_cards_url(@section.id) , notice: "Card created"
end

#set_imageObject



9
10
11
12
13
14
# File 'app/controllers/breeze/cards_controller.rb', line 9

def set_image
  @card.image_id = params[:image_id].to_i
  @card.edit_save(current_member_email)
  message = @card.image ? "#{@card.image.name} selected" : "Image removed"
  redirect_to section_cards_url(@card.section.id) , notice: message
end

#updateObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/breeze/cards_controller.rb', line 38

def update
  @card.update(params[:card])
  @card.update_options( params[:options])
  @card.edit_save(current_member_email)
  respond_to do |format|
     format.html do
       redirect_to section_cards_url(@card.section_id) , notice: "Updated #{@card.header}"
     end
     format.json { render status: 200, json: {} }
   end

end