From afdce793dcc069638696748dcee10d22da26f07e Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Sat, 4 Jun 2022 09:00:26 +0200
Subject: [PATCH] default layout

---
 app/models/communication/block/template/base.rb    | 9 +++++++++
 app/models/communication/block/template/gallery.rb | 4 ----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb
index 6624b56e0..8c8ee497e 100644
--- a/app/models/communication/block/template/base.rb
+++ b/app/models/communication/block/template/base.rb
@@ -99,12 +99,21 @@ class Communication::Block::Template::Base
     data['elements']
   end
 
+  def default_layout
+    self.class.layouts.first
+  end
+
+  def layout
+    data['layout']
+  end
+
   def blob_with_id(id)
     university.active_storage_blobs.find id
   end
 
   def default_data
     {
+      'layout' => default_layout,
       'elements' => []
     }
   end
diff --git a/app/models/communication/block/template/gallery.rb b/app/models/communication/block/template/gallery.rb
index 9b0e2d27d..38f353f75 100644
--- a/app/models/communication/block/template/gallery.rb
+++ b/app/models/communication/block/template/gallery.rb
@@ -10,10 +10,6 @@ class Communication::Block::Template::Gallery < Communication::Block::Template::
     add_dependency active_storage_blobs
   end
 
-  def layout
-    data['layout'] || LAYOUTS.first
-  end
-
   def images_with_alt
     @images_with_alt ||= elements.map { |element|
       extract_image_alt_and_credit element, 'file'
-- 
GitLab