Skip to content
Snippets Groups Projects
Commit 60c689db authored by Arnaud Levy's avatar Arnaud Levy
Browse files

no more fields

parent cb64f57e
No related branches found
No related tags found
No related merge requests found
class Communication::Block::Template::Base
class_attribute :fields
class_attribute :components_descriptions
attr_reader :block
def self.has_string(property)
has_field property, :string
has_component property, :string
end
def self.has_text(property)
has_field property, :text
has_component property, :text
end
def self.has_rich_text(property)
has_field property, :rich_text
has_component property, :rich_text
end
def self.has_select(property, **args)
has_field property, :select
has_component property, :select
end
def self.has_image(property)
has_field property, :image
has_field "#{property}_alt".to_sym, :string
has_field "#{property}_credit".to_sym, :string
has_component property, :image
has_component "#{property}_alt".to_sym, :string
has_component "#{property}_credit".to_sym, :string
end
def self.has_field(property, kind)
self.fields ||= []
self.fields << { name: property, type: kind }
def self.has_component(property, kind)
self.components_descriptions ||= []
self.components_descriptions << { name: property, type: kind }
class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{property}_component
......@@ -142,9 +142,9 @@ class Communication::Block::Template::Base
end
def components
return [] if self.class.fields.nil?
self.class.fields.map do |field|
send "#{field[:name]}_component"
return [] if self.class.components_descriptions.nil?
self.class.components_descriptions.map do |component_description|
send "#{component_description[:name]}_component"
end
end
......
<%= render 'admin/communication/blocks/components/select/layout/edit',
<%= render 'admin/communication/blocks/components/layout/edit',
layouts: Communication::Block::Template::Gallery::LAYOUTS,
horizontal: true %>
......
......@@ -116,7 +116,7 @@
</div>
</div>
<%= render 'admin/communication/blocks/components/select/layout/edit',
<%= render 'admin/communication/blocks/components/layout/edit',
layouts: Communication::Block::Template::Page::LAYOUTS,
template: 'pages' %>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment