delegating section data rendering, first version

This commit is contained in:
Torsten 2022-11-25 21:14:57 +02:00
parent 1245c55b65
commit 33bbae0ae5
6 changed files with 37 additions and 11 deletions

View File

@ -1,18 +1,25 @@
%p#notice= notice %p#notice= notice
-@page.sections.each_with_index do |section , index| -@page.sections.each_with_index do |section , index|
.grid.grid-cols-6.gap-4.m-8{class: (index%2)==1 ? 'bg-emerald-50/50' : 'bg-yellow-50/50' } .grid.grid-cols-6.gap-2.m-8{class: (index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
=#image_tag("cms/#{file}" , class: "h-56 w-full object-contain lg:h-72") =#image_tag("cms/#{file}" , class: "h-56 w-full object-contain lg:h-72")
.p-6 =# section.template #PREVIEW here
%h3.mt-4.text-lg.font-bold= section.template #PREVIEW here .p-4
%button.mt-4.block.w-full.rounded-sm.bg-yellow-500.p-4.text-sm.font-medium{:type => "button"} %h3.mt-4.text-lg.font-bold Section #{index + 1}
=index #up down delete actions here %button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Up" , "/index"
%button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4
=link_to "Delete" , "/index"
-section.content.each do |key , value| -section.content.each do |key , value|
.p-6 = render "cms/sections/#{key}", section: section , key: key , value: value
%h3.mt-4.text-lg.font-bold= key.upcase
%p= value
= link_to 'Edit', edit_cms_page_path(@page.name) .grid.grid-cols-6.gap-2.m-8
\| %button.mt-4.rounded-lg.bg-cyan-400.p-4
= link_to 'Back', cms_pages_path =link_to "New Section" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Save Changes" , "/index"

View File

@ -0,0 +1,8 @@
.p-6
%h3.mt-4.text-lg.font-bold= key.upcase
%p
.font-bold Text
= value["text"]
%p
.font-bold Link
= value["link"]

View File

@ -0,0 +1,3 @@
.p-6
%h3.mt-4.text-lg.font-bold= key.upcase
%p= value

View File

@ -0,0 +1,2 @@
.p-6
= image_tag "cms/" + value

View File

@ -0,0 +1,3 @@
.p-6{style: bg(section)}
%h3.mt-4.text-lg.font-bold= key.upcase
%p= value

View File

@ -0,0 +1,3 @@
.p-6
%h3.mt-4.text-lg.font-bold= key.upcase
%p= value