removing cards

This commit is contained in:
Torsten 2022-12-02 22:48:55 +02:00
parent 3d61e44e09
commit 6287373dae
3 changed files with 17 additions and 1 deletions

View File

@ -26,6 +26,13 @@ module Merged
redirect_to section_cards_url(@card.section.id)
end
def remove
section = @card.section
section.remove_card( @card )
section.save
redirect_to section_cards_url(section.id)
end
def update
@card.content.each do |key , value|
next if key == "id"

View File

@ -67,6 +67,15 @@ module Merged
! cards.empty?
end
def remove_card(card)
from_index = card.index
@cards.delete_at(from_index)
@content["cards"].delete_at(from_index)
@cards.each_with_index do |card, index|
card.set_index(index)
end
end
def move_up
@page.move_section_up(self)
end

View File

@ -21,7 +21,7 @@
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
= blue_button( "Down" , card_move_url(card.id , dir: :down) )
= green_button( "New" , "/index" )
= red_button("Delete" , "/index")
= red_button( "Delete" , card_remove_path(card.id) )
.p-4
%h3.mt-4.text-lg.font-bold Image
= yellow_button("Change Image" , card_select_image_url(card.id) )