inlined sectionoverview templates
This commit is contained in:
parent
204ab1abcc
commit
e29f2b79e8
@ -12,5 +12,13 @@ module Merged
|
||||
Image.image_root
|
||||
end
|
||||
|
||||
#image tag for the preview, passing options through
|
||||
def section_preview(section , options)
|
||||
image_tag("merged/section_preview/#{section.template}" , options)
|
||||
end
|
||||
|
||||
def card_preview(section , options)
|
||||
image_tag("merged/card_preview/#{section.card_template}" , options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,6 +9,7 @@ module Merged
|
||||
|
||||
attr_reader :name , :content , :page , :index , :cards
|
||||
|
||||
|
||||
def initialize(page , index , section_data)
|
||||
@page = page
|
||||
raise "No number #{index}" unless index.is_a?(Integer)
|
||||
@ -24,6 +25,15 @@ module Merged
|
||||
end
|
||||
end
|
||||
|
||||
[:template , :card_template , :id , :text , :header, :image].each do |meth|
|
||||
define_method(meth) do
|
||||
@content[meth.to_s]
|
||||
end
|
||||
end
|
||||
|
||||
def cards?
|
||||
@content["cards"] == true
|
||||
end
|
||||
|
||||
def update(key , value)
|
||||
return if key == "id" #not updating that
|
||||
@ -35,17 +45,6 @@ module Merged
|
||||
@content[key] = value
|
||||
end
|
||||
|
||||
def template
|
||||
@content["template"]
|
||||
end
|
||||
def card_template
|
||||
@content["card_template"]
|
||||
end
|
||||
|
||||
def id
|
||||
@content["id"]
|
||||
end
|
||||
|
||||
def save
|
||||
page.save
|
||||
end
|
||||
|
@ -20,7 +20,7 @@ module Merged
|
||||
def text
|
||||
@content["text"]
|
||||
end
|
||||
def cards
|
||||
def cards?
|
||||
@content["cards"] == true
|
||||
end
|
||||
def section_preview
|
||||
|
@ -6,19 +6,38 @@
|
||||
Page #{@page.name}
|
||||
|
||||
-@page.sections.each do |section |
|
||||
.grid.grid-cols-6.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
|
||||
.relative.block.border.border-gray-100
|
||||
.p-4
|
||||
%h3.mt-4.text-lg.font-bold Section #{section.index + 1}
|
||||
%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" , section_path(section.id)
|
||||
%button.mt-4.rounded-lg.bg-cyan-400.p-4
|
||||
=link_to "New" , "/index"
|
||||
%button.mt-4.rounded-lg.bg-red-400.p-4
|
||||
=link_to "Delete" , "/index"
|
||||
-section.content.each do |key , value|
|
||||
= render "merged/sections/overview/#{key}", section: section , key: key , value: value
|
||||
.grid.grid-cols-5.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
|
||||
.relative.block.border.border-gray-100.p-4
|
||||
%h3.mt-4.text-lg.font-bold Section #{section.index + 1}
|
||||
%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" , section_path(section.id)
|
||||
%button.mt-4.rounded-lg.bg-cyan-400.p-4
|
||||
=link_to "New" , "/index"
|
||||
%button.mt-4.rounded-lg.bg-red-400.p-4
|
||||
=link_to "Delete" , "/index"
|
||||
.relative.block.border.border-gray-100.p-4
|
||||
%h3.mt-4.text-lg.font-bold Template
|
||||
%p= section.template
|
||||
= section_preview(section , class: "w-full object-contain")
|
||||
.relative.block.border.border-gray-100.p-4
|
||||
%h3.mt-4.text-lg.font-bold Header
|
||||
%p= section.header
|
||||
%h3.mt-4.text-lg.font-bold Text
|
||||
%p= section.text
|
||||
.relative.block.border.border-gray-100.p-4
|
||||
- if section.cards?
|
||||
%h3.mt-4.text-lg.font-bold #{section.content['cards'].length} Cards
|
||||
=card_preview(section , class: "w-full object-contain")
|
||||
- else
|
||||
%h3.mt-4.text-lg.font-bold Image
|
||||
-if section.image
|
||||
= image_tag "cms/" + section.image
|
||||
-else
|
||||
No image
|
||||
.relative.block.border.border-gray-100.p-4
|
||||
%h3.mt-4.text-lg.font-bold Options
|
||||
%p To be done
|
||||
|
@ -1,8 +0,0 @@
|
||||
.p-6
|
||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||
%p
|
||||
.font-bold Text
|
||||
= value["text"]
|
||||
%p
|
||||
.font-bold Link
|
||||
= value["link"]
|
@ -1,5 +0,0 @@
|
||||
.p-6
|
||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||
%p= value
|
||||
=image_tag("merged/card_preview/#{value}" , class: "w-full object-contain")
|
||||
%p #{section.content['cards'].length} cards
|
@ -1,3 +0,0 @@
|
||||
.p-6
|
||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||
%p= value
|
@ -1,6 +0,0 @@
|
||||
.p-6
|
||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||
-if value
|
||||
= image_tag "cms/" + value
|
||||
-else
|
||||
No image
|
@ -1,4 +0,0 @@
|
||||
.p-6
|
||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||
%p= value
|
||||
=image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain")
|
@ -1,3 +0,0 @@
|
||||
.p-6
|
||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||
%p= value
|
Loading…
Reference in New Issue
Block a user