2022-11-30 10:22:45 +01:00
|
|
|
module Merged
|
|
|
|
class CardsController < MergedController
|
2022-12-02 22:22:43 +01:00
|
|
|
before_action :set_card , except: [:index , :new]
|
2022-11-30 10:22:45 +01:00
|
|
|
|
|
|
|
def index
|
2022-11-30 15:22:11 +01:00
|
|
|
@section = Section.find(params[:section_id])
|
2022-11-30 10:22:45 +01:00
|
|
|
end
|
|
|
|
|
2022-11-30 22:49:23 +01:00
|
|
|
def set_image
|
2022-12-19 17:55:11 +01:00
|
|
|
@card.image_id = params[:image_id].to_i
|
2023-10-23 19:20:31 +02:00
|
|
|
@card.edit_save(current_member_email)
|
2023-01-02 21:52:01 +01:00
|
|
|
message = @card.image ? "#{@card.image.name} selected" : "Image removed"
|
|
|
|
redirect_to section_cards_url(@card.section.id) , notice: message
|
2022-11-30 22:49:23 +01:00
|
|
|
end
|
|
|
|
|
2022-12-01 18:25:22 +01:00
|
|
|
def move
|
|
|
|
if( params[:dir] == "up")
|
|
|
|
@card.move_up
|
|
|
|
else
|
|
|
|
@card.move_down
|
|
|
|
end
|
2023-10-23 19:20:31 +02:00
|
|
|
@card.edit_save(current_member_email)
|
2022-12-11 20:30:25 +01:00
|
|
|
redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
|
2022-12-01 18:25:22 +01:00
|
|
|
end
|
|
|
|
|
2022-12-02 22:22:43 +01:00
|
|
|
def new
|
|
|
|
@section = Section.find(params[:section_id])
|
2022-12-11 15:27:08 +01:00
|
|
|
new_card = @section.new_card
|
2023-10-23 19:20:31 +02:00
|
|
|
new_card.add_save(current_member_email)
|
2022-12-07 13:14:18 +01:00
|
|
|
redirect_to section_cards_url(@section.id) , notice: "Card created"
|
2022-12-02 22:22:43 +01:00
|
|
|
end
|
|
|
|
|
2022-12-05 10:56:43 +01:00
|
|
|
def destroy
|
2023-10-23 19:20:31 +02:00
|
|
|
@card.delete_and_reset_index(current_member_email)
|
2022-12-11 20:30:25 +01:00
|
|
|
redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
|
2022-12-02 21:48:55 +01:00
|
|
|
end
|
|
|
|
|
2022-11-30 22:49:23 +01:00
|
|
|
def update
|
2023-01-20 15:49:11 +01:00
|
|
|
@card.update(params[:card])
|
|
|
|
@card.update_options( params[:options])
|
2023-10-23 19:20:31 +02:00
|
|
|
@card.edit_save(current_member_email)
|
2023-01-20 18:54:20 +01:00
|
|
|
redirect_to section_cards_url(@card.section_id) , notice: "Updated #{@card.header}"
|
2022-11-30 22:49:23 +01:00
|
|
|
end
|
|
|
|
|
2022-11-30 10:22:45 +01:00
|
|
|
private
|
2022-11-30 22:49:23 +01:00
|
|
|
def set_card
|
|
|
|
card_id = params[:id] || params[:card_id]
|
2022-12-11 13:31:04 +01:00
|
|
|
@card = Card.find( card_id )
|
2022-11-30 10:22:45 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|