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