section template selection
This commit is contained in:
parent
6f6836630f
commit
d1ecda07c4
@ -1,10 +1,14 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class SectionsController < MergedController
|
class SectionsController < MergedController
|
||||||
before_action :set_page, only: %i[ show edit update destroy set_image select_image]
|
before_action :set_page
|
||||||
|
#, only: %i[ show edit update destroy set_image select_image]
|
||||||
|
|
||||||
def select_image
|
def select_image
|
||||||
@images = Image.all
|
@images = Image.all
|
||||||
end
|
end
|
||||||
|
def select_template
|
||||||
|
@sections = Style.sections
|
||||||
|
end
|
||||||
|
|
||||||
def set_image
|
def set_image
|
||||||
@section.content["image"] = params[:image]
|
@section.content["image"] = params[:image]
|
||||||
@ -12,6 +16,12 @@ module Merged
|
|||||||
redirect_to page_section_url(@page.id,@section.id)
|
redirect_to page_section_url(@page.id,@section.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_template
|
||||||
|
@section.content["template"] = params[:template]
|
||||||
|
@page.save
|
||||||
|
redirect_to page_section_url(@page.id,@section.id)
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@section.content.each do |key , value|
|
@section.content.each do |key , value|
|
||||||
next if key == "id"
|
next if key == "id"
|
||||||
@ -21,7 +31,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
@page.save
|
@page.save
|
||||||
redirect_to :merged_page_section
|
redirect_to :page_section
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
= link_to 'Show', merged_page_url(@merged_page.name)
|
= link_to 'Show', page_url(@merged_page.name)
|
||||||
\|
|
\|
|
||||||
= link_to 'Back', merged_pages_path
|
= link_to 'Back', pages_path
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
%tbody
|
%tbody
|
||||||
- @merged_sections.each do |merged_section|
|
- @merged_sections.each do |merged_section|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to 'Show', merged_section
|
%td= link_to 'Show', section
|
||||||
%td= link_to 'Edit', edit_merged_section_path(merged_section)
|
%td= link_to 'Edit', edit_section_path(merged_section)
|
||||||
%td= link_to 'Destroy', merged_section, method: :delete, data: { confirm: 'Are you sure?' }
|
%td= link_to 'Destroy', section, method: :delete, data: { confirm: 'Are you sure?' }
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
|
||||||
= link_to 'New Section', new_merged_section_path
|
= link_to 'New Section', new_section_path
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
= link_to 'Back', merged_sections_path
|
= link_to 'Back', sections_path
|
||||||
|
6
app/views/merged/sections/select_template.haml
Normal file
6
app/views/merged/sections/select_template.haml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.grid.grid-cols-4.gap-2.m-8
|
||||||
|
- @sections.each do |style|
|
||||||
|
.relative.block.border.border-gray-100
|
||||||
|
= link_to( page_section_set_template_path( template: style.template )) do
|
||||||
|
=image_tag(style.section_preview , class: "h-56 w-full object-contain lg:h-72")
|
||||||
|
= style.header
|
@ -13,6 +13,6 @@
|
|||||||
- @section.content.each do |key , value|
|
- @section.content.each do |key , value|
|
||||||
= render "merged/sections/editors/#{key}", section: @section , key: key , value: value
|
= render "merged/sections/editors/#{key}", section: @section , key: key , value: value
|
||||||
|
|
||||||
= #link_to 'Edit', edit_merged_section_path(@merged_section)
|
= #link_to 'Edit', edit_section_path(@merged_section)
|
||||||
\|
|
\|
|
||||||
= #link_to 'Back', merged_sections_path
|
= #link_to 'Back', sections_path
|
||||||
|
Loading…
Reference in New Issue
Block a user