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

has_layouts

parent 7fb62223
No related branches found
No related tags found
No related merge requests found
class Communication::Block::Template::Base
class_attribute :components_descriptions
class_attribute :components_descriptions, :layouts
attr_reader :block
......@@ -25,6 +25,10 @@ class Communication::Block::Template::Base
has_component "#{property}_credit".to_sym, :string
end
def self.has_layouts(list)
self.layouts = list
end
def self.has_component(property, kind)
self.components_descriptions ||= []
self.components_descriptions << { name: property, type: kind }
......
class Communication::Block::Template::Gallery < Communication::Block::Template::Base
LAYOUTS = [:grid, :carousel].freeze
# has_select :layout, options: LAYOUTS, default: LAYOUTS.first
has_layouts [:grid, :carousel]
def default_element
Communication::Block::Template::Gallery::Image.new block
......
class Communication::Block::Template::Page < Communication::Block::Template::Base
has_rich_text :text
LAYOUTS = [:grid, :list, :cards].freeze
has_layouts [:grid, :list, :cards]
has_rich_text :text
def build_git_dependencies
add_dependency main_page
......
......@@ -2,7 +2,7 @@
horizontal ||= false
template = @block.template
template_kind = @block.template_kind
layouts = template.class::LAYOUTS
layouts = template.class.layouts
%>
<% if horizontal %><div class="row"><% end %>
<% layouts.each do |layout| %>
......
<%= render 'admin/communication/blocks/components/layout/edit',
layouts: Communication::Block::Template::Gallery::LAYOUTS,
<%= render 'admin/communication/blocks/components/layouts/edit',
horizontal: true %>
<%= render 'admin/communication/blocks/components/add_element/edit',
......
......@@ -116,8 +116,6 @@
</div>
</div>
<%= render 'admin/communication/blocks/components/layout/edit',
layouts: Communication::Block::Template::Page::LAYOUTS,
template: 'pages' %>
<%= render 'admin/communication/blocks/components/layouts/edit' %>
</div>
</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