removing cards
This commit is contained in:
parent
3d61e44e09
commit
6287373dae
@ -26,6 +26,13 @@ module Merged
|
|||||||
redirect_to section_cards_url(@card.section.id)
|
redirect_to section_cards_url(@card.section.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove
|
||||||
|
section = @card.section
|
||||||
|
section.remove_card( @card )
|
||||||
|
section.save
|
||||||
|
redirect_to section_cards_url(section.id)
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@card.content.each do |key , value|
|
@card.content.each do |key , value|
|
||||||
next if key == "id"
|
next if key == "id"
|
||||||
|
@ -67,6 +67,15 @@ module Merged
|
|||||||
! cards.empty?
|
! cards.empty?
|
||||||
end
|
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
|
def move_up
|
||||||
@page.move_section_up(self)
|
@page.move_section_up(self)
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
|
= blue_button( "Up" , card_move_url(card.id , dir: :up) )
|
||||||
= blue_button( "Down" , card_move_url(card.id , dir: :down) )
|
= blue_button( "Down" , card_move_url(card.id , dir: :down) )
|
||||||
= green_button( "New" , "/index" )
|
= green_button( "New" , "/index" )
|
||||||
= red_button("Delete" , "/index")
|
= red_button( "Delete" , card_remove_path(card.id) )
|
||||||
.p-4
|
.p-4
|
||||||
%h3.mt-4.text-lg.font-bold Image
|
%h3.mt-4.text-lg.font-bold Image
|
||||||
= yellow_button("Change Image" , card_select_image_url(card.id) )
|
= yellow_button("Change Image" , card_select_image_url(card.id) )
|
||||||
|
Loading…
Reference in New Issue
Block a user