diff --git a/app/views/admin/communication/blocks/templates/pages/_preview.html.erb b/app/views/admin/communication/blocks/templates/pages/_preview.html.erb index 42f0873509ba6bec96c72a782d8ebf2352379e5e..85c564f694b2d8496c1f6fcc858c325173a175cd 100644 --- a/app/views/admin/communication/blocks/templates/pages/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_preview.html.erb @@ -5,49 +5,90 @@ unless @block.title.blank? end class_name += " block-pages--" + @block.template.layout %> -<section class="<%= class_name %>" style="display: none;"> +<section class="<%= class_name %>"> <div class="container"> <div class="block-content"> - <% if @block.data %> - <% if @block.template.page %> - <%#= @block.template.page.slug %> - <% end %> + <% unless @block.title.blank? %> + <div class="top"> + <% unless @block.title.blank? %> - <% if @block.template.show_main_description %> - <p></p> + <% if @block.template.layout === "cards" || @block.template.layout === "list" %> + <h2><%= link_to @block.template.page, @block.template.page.url %></h2> + + <% elsif @block.template.layout === "grid" && @block.template.page %> + <h2><%= link_to @block.title, @block.template.page.url %></h2> + <p class="description"><%= @block.template.page.summary %></p> + + <% else %> + <h2><%= @block.title %></h2> + <% end %> + + <% end %> + <% if @block.template.layout === "cards" && @block.template.show_main_description && @block.data %> + <div class="description"> + <p><%= @block.template.page.summary %></p> + </div> + <% end %> + </div> + <% if @block.template.layout === "list" && @block.template.show_main_description && @block.data %> + <p class="description"><%= @block.template.page.summary %></p> <% end %> + <% end %> + <% if @block.data %> <% if @block.template.layout === "list" %> - <ul> - <% @block.template.elements.each do |element| %> - <li> - <%#= element %> - </li> + <% @block.template.selected_pages.each do |page| + next if page.nil? + %> + <li><%= link_to page, [:admin, page] %></li> <% end %> </ul> <% elsif @block.template.layout === "cards" %> - <div class="cards"> - <% @block.template.elements.each do |element| %> + <% @block.template.selected_pages.each do |page| + next if page.nil? + %> <article class="card"> - <%# <%= element %> + <h3> + <%= link_to page, [:admin, page] %> + </h3> <% if @block.template.show_description %> - <p><%#= element.summary %></p> + <p><%= page.summary %></p> + <% end %> + + <p class="more meta" aria-hidden="true"><%= t 'admin.communication.blocks.templates.pages.layouts.cards.more' %></p> + + <% if @block.template.show_image %> + <div class="media" itemprop="image"> + <% if page.featured_image.attached? %> + <%= kamifusen_tag page.featured_image %> + <% end %> + </div> <% end %> </article> <% end %> </div> <% else %> - <div class="grid"> - <% @block.template.elements.each do |element| %> + <% @block.template.selected_pages.each do |page| + next if page.nil? + %> <article> - <%# <%= element %> + <h3> + <%= link_to page, [:admin, page] %> + </h3> <% if @block.template.show_description %> - <p><%#= element.summary %></p> + <p><%= page.summary %></p> + <% end %> + <% if @block.template.show_image %> + <div class="media" itemprop="image"> + <% if page.featured_image.attached? %> + <%= kamifusen_tag page.featured_image %> + <% end %> + </div> <% end %> </article> <% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 609c93f67e84e8da98d5e20087a25fb09b7d648c..e286af195cea02007932cf7955fe81d11a37cd8a 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -467,6 +467,7 @@ en: cards: label: Cards description: Side by side cards, same height, strong color on rollover. Perfect for a small amount of pages. + more: Show more grid: label: Grid description: As a grid, left to right and top to bottom. diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index bd8bb87a8481ec6b37a48da42e9c09b7496ca8e3..7ffc42b334ffb299e9025232211af72766fb3d46 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -467,6 +467,7 @@ fr: cards: label: Cartes description: Des cartes côte à côte, de même hauteur, avec une couleur forte au survol. Ce format est idéal pour un petit nombre de pages. + more: En savoir plus grid: label: Grille description: Les pages sont présentées en grille, de gauche à droite puis de haut en bas.