From 4ccafdf314379adb7a17e87bfee503ffda4959b0 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 8 Jun 2022 08:14:34 +0200 Subject: [PATCH] stable --- .../block/template/gallery/image.rb | 3 ++- .../blocks/components/image/_static.html.erb | 7 ++++++- .../blocks/components/layout/_static.html.erb | 2 +- .../blocks/templates/gallery/_preview.html.erb | 10 ++++++++-- .../blocks/templates/gallery/_static.html.erb | 18 ++++-------------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/models/communication/block/template/gallery/image.rb b/app/models/communication/block/template/gallery/image.rb index 6221774cd..6dc5a8e2c 100644 --- a/app/models/communication/block/template/gallery/image.rb +++ b/app/models/communication/block/template/gallery/image.rb @@ -14,7 +14,8 @@ class Communication::Block::Template::Gallery::Image < Communication::Block::Tem 'id' => '' }, 'alt' => '', - 'credit' => '' + 'credit' => '', + 'text' => '' } end end 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 af09d1a54..a0a65ccdf 100644 --- a/app/views/admin/communication/blocks/components/image/_static.html.erb +++ b/app/views/admin/communication/blocks/components/image/_static.html.erb @@ -2,9 +2,14 @@ component = template.public_send "#{property}_component" blob = component.blob depth ||= 3 +list ||= false indentation = ' ' * depth +return unless blob %> -<% if blob %> +<% if list %> +<%= indentation %>- id: "<%= blob.id %>" +<%= indentation %> file: "<%= blob.id %>" +<% else %> <%= indentation %><%= property %>: <%= indentation %> id: "<%= blob.id %>" <%= indentation %> file: "<%= blob.id %>" diff --git a/app/views/admin/communication/blocks/components/layout/_static.html.erb b/app/views/admin/communication/blocks/components/layout/_static.html.erb index 21c135f27..2d29f732a 100644 --- a/app/views/admin/communication/blocks/components/layout/_static.html.erb +++ b/app/views/admin/communication/blocks/components/layout/_static.html.erb @@ -1 +1 @@ - layout: <%= @block.template.layout %> + layout: <%= template.layout %> diff --git a/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb b/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb index 4307e5f9e..e1ae5e3a5 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb @@ -1,11 +1,17 @@ <div class="row"> <% @block.template.elements.each do |element| %> + <% next unless element.blob %> <div class="col-6"> <article class="card"> <%= block_component_preview :image, template: element %> <div class="card-body"> - <p class="mb-0"><%= element.alt %></p> - <p class="mb-0 small"><%= element.text %></p> + <p class="small mb-0"> + <%= block_component_preview :alt, template: element %> + <%= block_component_preview :credit, template: element %> + </p> + <p class="mb-0"> + <%= block_component_preview :text, template: element %> + </p> </div> </article> </div> diff --git a/app/views/admin/communication/blocks/templates/gallery/_static.html.erb b/app/views/admin/communication/blocks/templates/gallery/_static.html.erb index 06a195a30..860632e82 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_static.html.erb @@ -2,18 +2,8 @@ images: <% block.template.elements.each do |element| %> <% next unless element.blob %> - - -<%= block_component_static :image, template: element, depth: 5 %> -<%= block_component_static :alt, template: element, depth: 6 %> -<%= block_component_static :credit, template: element, depth: 6 %> -<%= block_component_static :text, template: element, depth: 6 %> - - id: "<%= element.blob.id %>" - file: "<%= element.blob.id %>" - alt: > - <%= prepare_text_for_static element.alt, 6 %> - credit: > - <%= prepare_text_for_static element.credit, 6 %> - text: > - <%= prepare_text_for_static element.text, 6 %> - +<%= block_component_static :image, template: element, depth: 4, list: true %> +<%= block_component_static :alt, template: element, depth: 5 %> +<%= block_component_static :credit, template: element, depth: 5 %> +<%= block_component_static :text, template: element, depth: 5 %> <% end %> -- GitLab