diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index 66c9346b0b0f843671c196a4cd82ca96fcccd947..66ac3cfe2bad3104fc0338ad7ff400fe3bd7cffa 100644 --- a/app/models/communication/block/template/base.rb +++ b/app/models/communication/block/template/base.rb @@ -1,33 +1,33 @@ 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 diff --git a/app/views/admin/communication/blocks/components/select/layout/_edit.html.erb b/app/views/admin/communication/blocks/components/layout/_edit.html.erb similarity index 100% rename from app/views/admin/communication/blocks/components/select/layout/_edit.html.erb rename to app/views/admin/communication/blocks/components/layout/_edit.html.erb 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 8311ec86d7f69d5af66d9a0d0a2f89c6ac68f0bb..716de6c95ed889d0c88f483d518e26aee6446288 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb @@ -1,4 +1,4 @@ -<%= render 'admin/communication/blocks/components/select/layout/edit', +<%= render 'admin/communication/blocks/components/layout/edit', layouts: Communication::Block::Template::Gallery::LAYOUTS, horizontal: true %> 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 f6528081e15b220a15d33f186aac6282e8fe3ddd..d9a1da6466a23aa1b2b2c6b0d717e13c6c1fbbcb 100644 --- a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb @@ -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>