From 92197acbddc5840f9c599ae8e8591dcbaacfd72b Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Fri, 10 Jun 2022 10:22:47 +0200
Subject: [PATCH] List

---
 .../blocks/components/_static.html.erb        | 22 ++++++++++++++++++-
 .../blocks/components/image/_static.html.erb  | 10 +--------
 .../blocks/components/string/_static.html.erb |  7 +++++-
 .../templates/definitions/_static.html.erb    |  4 ++--
 4 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/app/views/admin/communication/blocks/components/_static.html.erb b/app/views/admin/communication/blocks/components/_static.html.erb
index 5e681405f..57e05ca8e 100644
--- a/app/views/admin/communication/blocks/components/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/_static.html.erb
@@ -3,6 +3,25 @@ template ||= @block.template
 component = template.public_send "#{property}_component"
 value = template.public_send property
 depth ||= 3
+# ---
+# List
+# ---
+#
+# No list for an image
+#       image:
+#         id: "6481e276-23c7-43bb-84aa-87820706ef27"
+#         file: "6481e276-23c7-43bb-84aa-87820706ef27"
+# List for an image (removes the property name)
+#       - id: "1372a56a-8859-45b9-a7db-d6f9c0e1f38f"
+#         file: "1372a56a-8859-45b9-a7db-d6f9c0e1f38f
+#
+# No list for a string
+#       title: >-
+#         def 1
+# List for a string
+#       - title: >-
+#           def 1
+list ||= false
 indentation = '  ' * depth
 partial = "admin/communication/blocks/components/#{component.kind}/static"
 
@@ -10,6 +29,7 @@ local_assigns[:template] = template
 local_assigns[:component] = component
 local_assigns[:value] = value
 local_assigns[:depth] = depth
+local_assigns[:list] = list
 local_assigns[:indentation] = indentation
 %>
-<%= render partial, **local_assigns %>
\ No newline at end of file
+<%= render partial, **local_assigns %>
diff --git a/app/views/admin/communication/blocks/components/image/_static.html.erb b/app/views/admin/communication/blocks/components/image/_static.html.erb
index 2902bb655..e851ab535 100644
--- a/app/views/admin/communication/blocks/components/image/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/image/_static.html.erb
@@ -1,13 +1,5 @@
 <%
 blob = component.blob
-list ||= false
-# No list
-# image:
-#   id: "6481e276-23c7-43bb-84aa-87820706ef27"
-#   file: "6481e276-23c7-43bb-84aa-87820706ef27"
-# List
-# - id: "1372a56a-8859-45b9-a7db-d6f9c0e1f38f"
-#   file: "1372a56a-8859-45b9-a7db-d6f9c0e1f38f
 return unless blob
 %>
 <% if list %>
@@ -16,4 +8,4 @@ return unless blob
 <%= indentation %><%= property %>:
 <%= indentation %>  id: "<%= blob.id %>"
 <% end %>
-<%= indentation %>  file: "<%= blob.id %>"
\ No newline at end of file
+<%= indentation %>  file: "<%= blob.id %>"
diff --git a/app/views/admin/communication/blocks/components/string/_static.html.erb b/app/views/admin/communication/blocks/components/string/_static.html.erb
index a05f07761..f6f87c8bd 100644
--- a/app/views/admin/communication/blocks/components/string/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/string/_static.html.erb
@@ -1,2 +1,7 @@
+<% if list %>
+<%= indentation %>- <%= property %>: >-
+<%= indentation %>    <%= prepare_text_for_static value, depth + 2 %>
+<% else %>
 <%= indentation %><%= property %>: >-
-<%= indentation %>  <%= prepare_text_for_static value, depth + 1 %>
\ No newline at end of file
+<%= indentation %>  <%= prepare_text_for_static value, depth + 1 %>
+<% end %>
diff --git a/app/views/admin/communication/blocks/templates/definitions/_static.html.erb b/app/views/admin/communication/blocks/templates/definitions/_static.html.erb
index 1cf45d362..b1d9780c1 100644
--- a/app/views/admin/communication/blocks/templates/definitions/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/definitions/_static.html.erb
@@ -1,4 +1,4 @@
 <% block.template.elements.each do |element| %>
-<%= block_component_static :title, template: element, depth:4, list: true %>
-<%= block_component_static :description, template: element, depth: 5 %>
+<%= block_component_static :title, template: element, list: true %>
+<%= block_component_static :description, template: element, depth: 4 %>
 <% end %>
-- 
GitLab