section template selection

This commit is contained in:
Torsten 2022-11-29 20:03:48 +02:00
parent 6f6836630f
commit d1ecda07c4
6 changed files with 27 additions and 11 deletions

View File

@ -1,10 +1,14 @@
module Merged
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
@images = Image.all
end
def select_template
@sections = Style.sections
end
def set_image
@section.content["image"] = params[:image]
@ -12,6 +16,12 @@ module Merged
redirect_to page_section_url(@page.id,@section.id)
end
def set_template
@section.content["template"] = params[:template]
@page.save
redirect_to page_section_url(@page.id,@section.id)
end
def update
@section.content.each do |key , value|
next if key == "id"
@ -21,7 +31,7 @@ module Merged
end
end
@page.save
redirect_to :merged_page_section
redirect_to :page_section
end
private

View File

@ -2,6 +2,6 @@
= 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

View File

@ -10,10 +10,10 @@
%tbody
- @merged_sections.each do |merged_section|
%tr
%td= link_to 'Show', merged_section
%td= link_to 'Edit', edit_merged_section_path(merged_section)
%td= link_to 'Destroy', merged_section, method: :delete, data: { confirm: 'Are you sure?' }
%td= link_to 'Show', section
%td= link_to 'Edit', edit_section_path(merged_section)
%td= link_to 'Destroy', section, method: :delete, data: { confirm: 'Are you sure?' }
%br
= link_to 'New Section', new_merged_section_path
= link_to 'New Section', new_section_path

View File

@ -2,4 +2,4 @@
= render 'form'
= link_to 'Back', merged_sections_path
= link_to 'Back', sections_path

View 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

View File

@ -13,6 +13,6 @@
- @section.content.each do |key , 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