helper for forms, done fighting rails on namespacing
This commit is contained in:
parent
6bb0b35d3f
commit
4814f53d1e
@ -3,7 +3,7 @@ module Cms
|
|||||||
class ImagesController < CmsController
|
class ImagesController < CmsController
|
||||||
|
|
||||||
@@root = "app/assets/images/cms/"
|
@@root = "app/assets/images/cms/"
|
||||||
@@files = Set.new Dir.new(Rails.root + @@root).children
|
@@files = Set.new Dir[Rails.root + @@root + "*.*"].collect{|f|f.split("/").last}
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@files = files
|
@files = files
|
||||||
|
@ -1,2 +1,10 @@
|
|||||||
module Cms::SectionHelper
|
module Cms::SectionHelper
|
||||||
|
|
||||||
|
def section_form(options)
|
||||||
|
url = cms_page_section_url( @page.id , @section.id)
|
||||||
|
puts "URL #{url}"
|
||||||
|
form_tag( url , {method: :patch}) do
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
module Cms
|
module Cms
|
||||||
class Page
|
class Page
|
||||||
include ActiveModel::Model
|
include ActiveModel::API
|
||||||
include ActiveModel::Conversion
|
include ActiveModel::Conversion
|
||||||
include ActiveModel::Dirty
|
extend ActiveModel::Naming
|
||||||
|
|
||||||
@@files = Set.new Dir.new(Rails.root.join("cms")).children
|
@@files = Set.new Dir.new(Rails.root.join("cms")).children
|
||||||
|
|
||||||
attr_reader :name , :content
|
attr_reader :name , :content
|
||||||
|
|
||||||
|
alias :id :name
|
||||||
|
|
||||||
def persisted?
|
def persisted?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
module Cms
|
module Cms
|
||||||
class Section
|
class Section
|
||||||
include ActiveModel::Model
|
include ActiveModel::API
|
||||||
include ActiveModel::Conversion
|
include ActiveModel::Conversion
|
||||||
include ActiveModel::Dirty
|
extend ActiveModel::Naming
|
||||||
|
|
||||||
attr_reader :name , :content , :page , :index
|
attr_reader :name , :content , :page , :index
|
||||||
|
|
||||||
|
@ -1,6 +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
|
||||||
= 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
|
= section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do
|
||||||
= text_field_tag( :header , @section.content["header"], class: "w-full.rounded-lg.border-gray-200.p-4.pr-12.text-sm.shadow-sm")
|
= 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"}
|
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"}
|
||||||
Update
|
Update
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
.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
|
||||||
|
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white
|
||||||
|
Update
|
||||||
|
|
||||||
.relative.block.border.border-gray-100
|
.relative.block.border.border-gray-100
|
||||||
-if value
|
-if value
|
||||||
= image_tag "cms/" + value
|
= image_tag "cms/" + value
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
.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
|
.relative.block.border.border-gray-100
|
||||||
%p= value
|
= section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do
|
||||||
|
= text_area_tag( :text , @section.content["text"], 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
|
||||||
|
Loading…
Reference in New Issue
Block a user