From 2e0df2348abbe57c959a62199757c97177ecf6a2 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Sat, 4 Jun 2022 09:08:29 +0200
Subject: [PATCH] better string edit

---
 app/models/communication/block/template/base.rb        |  2 +-
 .../blocks/components/string/_edit.html.erb            | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb
index f061e4b36..4d869b184 100644
--- a/app/models/communication/block/template/base.rb
+++ b/app/models/communication/block/template/base.rb
@@ -107,7 +107,7 @@ class Communication::Block::Template::Base
   end
 
   def default_layout
-    self.class.layouts.first
+    self.class.layouts&.first
   end
 
   def layout
diff --git a/app/views/admin/communication/blocks/components/string/_edit.html.erb b/app/views/admin/communication/blocks/components/string/_edit.html.erb
index 9868c058b..bd975931e 100644
--- a/app/views/admin/communication/blocks/components/string/_edit.html.erb
+++ b/app/views/admin/communication/blocks/components/string/_edit.html.erb
@@ -1,10 +1,16 @@
+<%
+template_kind = @block.template_kind
+namespace = "admin.communication.blocks.templates.#{template_kind}.edit.#{property}"
+label ||= t "#{namespace}.label"
+placeholder ||= t "#{namespace}.placeholder"
+%>
 <label  class="form-label" for="<%= property %>">
-  <%= t "admin.communication.blocks.templates.#{@block.template_kind}.edit.#{property}.label" %>
+  <%= label%>
 </label>
 <div class="mb-3">
   <input  id="<%= property %>"
           class="form-control mb-3"
           v-model="data.<%= property %>"
-          placeholder="<%= t "admin.communication.blocks.templates.#{@block.template_kind}.edit.#{property}.placeholder" %>"
+          placeholder="<%= placeholder %>"
           type="text" />
 </div>
-- 
GitLab