remove sections ok
This commit is contained in:
parent
2eaa344ed0
commit
3d61e44e09
@ -23,6 +23,13 @@ module Merged
|
||||
redirect_to section_select_template_url(new_section.id)
|
||||
end
|
||||
|
||||
def remove
|
||||
page = @section.page
|
||||
page.remove_section( @section )
|
||||
page.save
|
||||
redirect_to page_sections_url(page.name)
|
||||
end
|
||||
|
||||
def set_image
|
||||
@section.content["image"] = params[:image]
|
||||
@section.save
|
||||
|
@ -12,8 +12,8 @@ module Merged
|
||||
def green_button( text, url)
|
||||
button( text , url , "bg-green-500" )
|
||||
end
|
||||
def submit_button(text)
|
||||
clazz = "bg-blue-500 " + button_classes
|
||||
def submit_button(text , danger = false )
|
||||
clazz = danger ? "bg-blue-500 " : "bg-blue-500 " + button_classes
|
||||
content_tag(:button , class: clazz , type: :submit) do
|
||||
text
|
||||
end
|
||||
|
@ -43,6 +43,15 @@ module Merged
|
||||
section
|
||||
end
|
||||
|
||||
def remove_section(section)
|
||||
from_index = section.index
|
||||
@sections.delete_at(from_index)
|
||||
@content.delete_at(from_index)
|
||||
@sections.each_with_index do |section, index|
|
||||
section.set_index(index)
|
||||
end
|
||||
end
|
||||
|
||||
def first_template
|
||||
@content[0]["template"]
|
||||
end
|
||||
|
@ -13,7 +13,7 @@
|
||||
= blue_button( "Up" , section_move_url(section.id , dir: :up) )
|
||||
= blue_button( "Down" , section_move_url(section.id , dir: :down) )
|
||||
= yellow_button("Edit" , section_path(section.id) )
|
||||
= red_button( "Delete" , "/index" )
|
||||
= red_button( "Delete" , section_remove_path(section.id) )
|
||||
.relative.block.border.border-gray-100.p-4
|
||||
%h3.mt-4.text-lg.font-bold Template
|
||||
%p= section.template
|
||||
|
@ -10,12 +10,17 @@ Merged::Engine.routes.draw do
|
||||
get :select_card_template
|
||||
get :set_card_template
|
||||
get :move
|
||||
get :remove
|
||||
resources :cards do
|
||||
get :select_image
|
||||
get :set_image
|
||||
get :move
|
||||
get :remove
|
||||
end
|
||||
end
|
||||
get :remove
|
||||
end
|
||||
resources :images do
|
||||
get :remove
|
||||
end
|
||||
resources :images
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user