From b38fe4cdbd8c9f3973a74ea66a3983db8f901a0f Mon Sep 17 00:00:00 2001
From: alexisben <alexiben7@gmail.com>
Date: Fri, 13 May 2022 14:29:53 +0200
Subject: [PATCH] Fix block page with legacy

---
 app/models/communication/block/template/page.rb        |  4 ++++
 .../blocks/templates/pages/_edit.html.erb              | 10 ++++++++++
 .../blocks/templates/pages/_static.html.erb            |  6 +++---
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/app/models/communication/block/template/page.rb b/app/models/communication/block/template/page.rb
index f9afb2c77..41b048fdb 100644
--- a/app/models/communication/block/template/page.rb
+++ b/app/models/communication/block/template/page.rb
@@ -16,6 +16,10 @@ class Communication::Block::Template::Page < Communication::Block::Template
     @main_page ||= page(data['page_id'])
   end
 
+  def show_main_description
+    data['show_main_description'] || false
+  end
+
   def show_description
     data['show_description'] || false
   end
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 4a9d993a2..2e9fe6ef4 100644
--- a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb
+++ b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb
@@ -28,6 +28,16 @@
   </div>
   <div class="col-md-6">
     <h2 class="h3">Options d'affichage</h2>
+    <div class="form-check">
+      <input  v-model="data.show_main_description"
+              class="form-check-input boolean optional"
+              id="show_main_description"
+              type="checkbox">
+      <label  class="form-check-label boolean optional"
+              for="show_main_description">
+        Afficher la description courte de la page principale
+      </label>
+    </div>
     <div class="form-check">
       <input  v-model="data.show_description"
               class="form-check-input boolean optional"
diff --git a/app/views/admin/communication/blocks/templates/pages/_static.html.erb b/app/views/admin/communication/blocks/templates/pages/_static.html.erb
index 7137b0eed..d6fe87c33 100644
--- a/app/views/admin/communication/blocks/templates/pages/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/pages/_static.html.erb
@@ -1,11 +1,11 @@
 <% if block.template.main_page %>
       page: <%= block.template.main_page.generated_path %>
 <% end %>
+      show_main_description: <%= block.template.show_main_description %>
       show_descriptions: <%= block.template.show_description %>
       show_images: <%= block.template.show_image %>
       pages:
 <% block.template.selected_pages.each do |element| %>
-        - slug: <%= element.generated_path %>
-          show_description: <%= block.template.show_description %>
-          show_image: <%= block.template.show_image %>
+        - page: <%= element.generated_path %>
+          slug: <%= element.generated_path %>
 <% end %>
-- 
GitLab