From bd45b33fb0d98c8e737425e669c51b57382f59f3 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Thu, 2 Jun 2022 22:17:50 +0200 Subject: [PATCH] no components allowed --- app/models/communication/block/component/image.rb | 3 +++ app/models/communication/block/template/base.rb | 5 +++++ app/models/communication/block/template/gallery.rb | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/communication/block/component/image.rb b/app/models/communication/block/component/image.rb index 6d056894f..3915f6f1e 100644 --- a/app/models/communication/block/component/image.rb +++ b/app/models/communication/block/component/image.rb @@ -1,6 +1,9 @@ class Communication::Block::Component::Image < Communication::Block::Component::Base + def data + # Loading the blob when needed, not saved in the database @data['blob'] = template.blob_with_id @data['id'] if @data&.has_key? 'id' @data end + end diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index 25f8a7934..66c9346b0 100644 --- a/app/models/communication/block/template/base.rb +++ b/app/models/communication/block/template/base.rb @@ -87,6 +87,10 @@ class Communication::Block::Template::Base [] end + def elements + data['elements'] + end + def blob_with_id(id) university.active_storage_blobs.find id end @@ -138,6 +142,7 @@ class Communication::Block::Template::Base end def components + return [] if self.class.fields.nil? self.class.fields.map do |field| send "#{field[:name]}_component" end diff --git a/app/models/communication/block/template/gallery.rb b/app/models/communication/block/template/gallery.rb index 38c7d1b3d..a74d7d5b8 100644 --- a/app/models/communication/block/template/gallery.rb +++ b/app/models/communication/block/template/gallery.rb @@ -2,7 +2,7 @@ class Communication::Block::Template::Gallery < Communication::Block::Template:: LAYOUTS = [:grid, :carousel].freeze - has_select :layout, options: LAYOUTS, default: LAYOUTS.first + # has_select :layout, options: LAYOUTS, default: LAYOUTS.first def build_git_dependencies add_dependency active_storage_blobs -- GitLab