first actual edit (header)
This commit is contained in:
parent
8d405e44e1
commit
6bb0b35d3f
@ -2,6 +2,17 @@ module Cms
|
|||||||
class SectionsController < CmsController
|
class SectionsController < CmsController
|
||||||
before_action :set_page, only: %i[ show edit update destroy ]
|
before_action :set_page, only: %i[ show edit update destroy ]
|
||||||
|
|
||||||
|
def update
|
||||||
|
@section.content.each do |key , value|
|
||||||
|
next if key == "id"
|
||||||
|
if(!params[key].nil?)
|
||||||
|
@section.update(key, params[key])
|
||||||
|
puts "updating:#{key}=#{params[key]}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@page.save
|
||||||
|
redirect_to :cms_page_section
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def set_page
|
def set_page
|
||||||
|
@ -18,6 +18,16 @@ module Cms
|
|||||||
@content = section_data
|
@content = section_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update(key , value)
|
||||||
|
return if key == "id" #not updating that
|
||||||
|
if(! @content[key].nil? )
|
||||||
|
if( @content[key].class != value.class )
|
||||||
|
raise "Type mismatch #{key} #{key.class}!=#{value.class}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@content[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
def template
|
def template
|
||||||
@content["template"]
|
@content["template"]
|
||||||
end
|
end
|
||||||
@ -27,7 +37,7 @@ module Cms
|
|||||||
end
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
false
|
raise "Called"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.all
|
def self.all
|
||||||
@ -35,6 +45,7 @@ module Cms
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.find(page_name , section_id)
|
def self.find(page_name , section_id)
|
||||||
|
raise "buggy"
|
||||||
Page.new(name + ".yaml")
|
Page.new(name + ".yaml")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
.relative.block.border.border-gray-100
|
.relative.block.border.border-gray-100
|
||||||
%h3.mt-4.text-lg.font-bold= key.upcase
|
%h3.mt-4.text-lg.font-bold= key.upcase
|
||||||
.relative.block.border.border-gray-100
|
= form_tag( {url: cms_page_section_path( @page.name, @section.id), class: "mx-auto.mt-8.mb-0.max-w.space-y-4"} , {method: :patch }) do
|
||||||
%p= value
|
= text_field_tag( :header , @section.content["header"], class: "w-full.rounded-lg.border-gray-200.p-4.pr-12.text-sm.shadow-sm")
|
||||||
|
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"}
|
||||||
|
Update
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
%p#notice= notice
|
%p#notice= notice
|
||||||
|
|
||||||
%h1 Page #{@page.name}
|
.flex.flex-col.bg-white
|
||||||
|
.flex.items-center.justify-center.flex-1
|
||||||
%h4 Section #{@section.id}
|
.max-w-xl.px-4.py-8.mx-auto.text-center
|
||||||
|
%h1.text-2xl.font-bold.tracking-tight.text-gray-900
|
||||||
|
Page #{@page.name}
|
||||||
|
.flex.items-center.justify-center.flex-1
|
||||||
|
%h3.text-xl.font-bold.tracking-tight.text-gray-900
|
||||||
|
Section #{@section.id}
|
||||||
|
|
||||||
.grid.grid-cols-2.gap-2.m-8
|
.grid.grid-cols-2.gap-2.m-8
|
||||||
- @section.content.each do |key , value|
|
- @section.content.each do |key , value|
|
||||||
|
Loading…
Reference in New Issue
Block a user