From 6cada37a8d774f1ab748f620bb61963bb8924f3e Mon Sep 17 00:00:00 2001
From: alexisben <alexiben7@gmail.com>
Date: Wed, 20 Apr 2022 21:48:10 +0200
Subject: [PATCH] Block page : update page lists

---
 .../blocks/templates/pages/_edit.html.erb             | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

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 0aad5c53f..628602fcc 100644
--- a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb
+++ b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb
@@ -1,3 +1,5 @@
+<% pages = collection_tree(@block.about&.website.pages) %>
+
 <h2 class="mt-5">Page principale</h2>
 <div class="row mb-1">
   <div class="col-md-6">
@@ -7,8 +9,8 @@
           class="form-select select"
           v-model="data.page_id">
       <option value="">Aucune page sélectionnée</option>
-      <% @block.about&.website.pages.ordered.each_with_index do |page, index| %>
-        <option value="<%= page.id %>"><%= page %></option>
+      <% pages.each_with_index do |page, index| %>
+        <option value="<%= page[:id] %>"><%= page[:label].html_safe %></option>
       <% end %>
     </select>
   </div>
@@ -53,10 +55,11 @@
                         class="form-select select"
                         v-model="page.id">
                   <option value="" disabled>Aucune page</option>
-                  <% @block.about&.website.pages.ordered.each_with_index do |page, index| %>
-                    <option value="<%= page.id %>"><%= page.title %></option>
+                  <% pages.each_with_index do |page, index| %>
+                    <option value="<%= page[:id] %>"><%= page[:label].html_safe %></option>
                   <% end %>
                 </select>
+                
               </div>
               <div class="col-6">
                 <div class="col-md-6">
-- 
GitLab