From 60c689db65d1ed58cf37fc23e70f3abd7d2159ed Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 3 Jun 2022 09:47:25 +0200 Subject: [PATCH] no more fields --- .../communication/block/template/base.rb | 28 +++++++++---------- .../{select => }/layout/_edit.html.erb | 0 .../blocks/templates/gallery/_edit.html.erb | 2 +- .../blocks/templates/pages/_edit.html.erb | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) rename app/views/admin/communication/blocks/components/{select => }/layout/_edit.html.erb (100%) diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index 66c9346b0..66ac3cfe2 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 8311ec86d..716de6c95 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 f6528081e..d9a1da646 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> -- GitLab