From ec4a5cbd98fa79c3dd39b3ba394e1828c2a90a37 Mon Sep 17 00:00:00 2001 From: alexisben <alexiben7@gmail.com> Date: Mon, 16 May 2022 10:15:47 +0200 Subject: [PATCH] Block files polished --- .../blocks/templates/files/_preview.html.erb | 19 +++++++++++++++++++ .../blocks/templates/files/_static.html.erb | 2 +- config/locales/communication/en.yml | 4 +++- config/locales/communication/fr.yml | 7 +++++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/views/admin/communication/blocks/templates/files/_preview.html.erb b/app/views/admin/communication/blocks/templates/files/_preview.html.erb index e69de29bb..48e6bad1f 100644 --- a/app/views/admin/communication/blocks/templates/files/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/files/_preview.html.erb @@ -0,0 +1,19 @@ +<ul> + <% @block.template.files.each do |file| %> + <% file.title ||= file.blob.filename if file.blob %> + <% if file.title + title = file.title + elsif file.blob + title = file.blob.filename + else + title = '' + end %> + <li> + <% if file.blob %> + <a href="<%= file.blob.url %>" download><%= title %> <small>(<%= file.blob.filename %>)</small></a> + <% else %> + <%= title %> <small>(<%= t 'admin.communication.blocks.components.file.not_linked' %>)</small> + <% end %> + </li> + <% end %> +</ul> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/files/_static.html.erb b/app/views/admin/communication/blocks/templates/files/_static.html.erb index bf2a453f5..cbfb04c22 100644 --- a/app/views/admin/communication/blocks/templates/files/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/files/_static.html.erb @@ -1,5 +1,5 @@ files: <% block.template.files.each do |file| %> - title: "<%= file.title %>" - id: "<%= file.blob.id %>" + id: "<%= file.blob.id if file.blob %>" <% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 1a6257f0f..03e75b921 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -137,6 +137,8 @@ en: credit: label: Credit placeholder: Enter credit + file: + not_linked: Pas de fichier lié template_kinds: call_to_action: edit: @@ -179,10 +181,10 @@ en: files: edit: add_file: Add a file - remove_file: Remove a file file_label: File title_label: Title title_placeholder: Enter title here + remove_file: Remove a file gallery: edit: add_image: Add image diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 5d7f1a2cb..a406c0e00 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -137,6 +137,9 @@ fr: credit: label: Crédit placeholder: Entrer le crédit + file: + not_linked: Pas de fichier lié + templates: call_to_action: edit: @@ -179,10 +182,10 @@ fr: files: edit: add_file: Ajouter un fichier - remove_file: Supprimer le fichier file_label: Fichier title_label: Titre - title_placeholder: Entrer le titre du fichier + title_placeholder: Entrer le titre du fichier + remove_file: Supprimer le fichier gallery: edit: add_image: Ajouter une image -- GitLab