diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index b7d8384fc4f43b70b9264aa5d7658059f4f09256..6624b56e07360292df1790e1ac3a1da152b2b18a 100644 --- a/app/models/communication/block/template/base.rb +++ b/app/models/communication/block/template/base.rb @@ -1,5 +1,5 @@ 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 } diff --git a/app/models/communication/block/template/gallery.rb b/app/models/communication/block/template/gallery.rb index 833ef1c6b658cdbb6a72c832f92a8ad03c5cdfd1..9b0e2d27deac24dc45f32004782df785d102088b 100644 --- a/app/models/communication/block/template/gallery.rb +++ b/app/models/communication/block/template/gallery.rb @@ -1,8 +1,6 @@ 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 diff --git a/app/models/communication/block/template/page.rb b/app/models/communication/block/template/page.rb index ef482aa88eec827e42ad756763aca05dae7b51dc..023ccda4668ea9041449b2bcbd1e7cb5612e544f 100644 --- a/app/models/communication/block/template/page.rb +++ b/app/models/communication/block/template/page.rb @@ -1,7 +1,7 @@ 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 diff --git a/app/views/admin/communication/blocks/components/layout/_edit.html.erb b/app/views/admin/communication/blocks/components/layouts/_edit.html.erb similarity index 97% rename from app/views/admin/communication/blocks/components/layout/_edit.html.erb rename to app/views/admin/communication/blocks/components/layouts/_edit.html.erb index aa0ce6a4a806f06870569d37afc3558fb8b139bd..1544fa810925b5d1008f58ecf70b146f3a145396 100644 --- a/app/views/admin/communication/blocks/components/layout/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/layouts/_edit.html.erb @@ -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| %> diff --git a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb index 49e7b69f68a4c637476ec1fef3cca3430278fd80..a8c9c1003ca38b2ff79cdfb400bb267753c19e9d 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb @@ -1,5 +1,4 @@ -<%= 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', diff --git a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb index d9a1da6466a23aa1b2b2c6b0d717e13c6c1fbbcb..efde9f5080ea76524b1a712c16567ccb266818d9 100644 --- a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb @@ -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>