From 3959b33acf8f9939ec486794f20a418798cd3a45 Mon Sep 17 00:00:00 2001 From: Olivia Simonet <olivia.simonet@mmibordeaux.com> Date: Thu, 9 Jun 2022 14:05:38 +0200 Subject: [PATCH] Refactor embed incomplete --- .../communication/block/template/embed.rb | 10 ++------- .../blocks/templates/embed/_edit.html.erb | 22 ++++--------------- .../blocks/templates/embed/_preview.html.erb | 4 ++-- .../blocks/templates/embed/_static.html.erb | 6 ++--- .../blocks/templates/video/_edit.html.erb | 4 +++- config/locales/communication/en.yml | 13 +++++------ config/locales/communication/fr.yml | 13 +++++------ 7 files changed, 25 insertions(+), 47 deletions(-) diff --git a/app/models/communication/block/template/embed.rb b/app/models/communication/block/template/embed.rb index 556f425af..64bf946f5 100644 --- a/app/models/communication/block/template/embed.rb +++ b/app/models/communication/block/template/embed.rb @@ -1,12 +1,6 @@ class Communication::Block::Template::Embed < Communication::Block::Template::Base - def build_git_dependencies - end - def code - "#{data['code']}" - end + has_text :code + has_text :transcription - def transcription - "#{data['transcription']}" - end end diff --git a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb index 517a37fbe..1b573cd59 100644 --- a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb @@ -1,28 +1,14 @@ <div class="row mb-4"> <div class="col-md-6"> - <label class="form-label" - for="text"> - <%= t '.code_label' %> - </label> <div class="mb-3"> - <textarea id="text" - rows="10" - class="form-control" - v-model="data.code" - placeholder="<%= t '.code_placeholder' %>"></textarea> + <%= block_component_edit :code %> </div> </div> <div class="col-md-6"> - <label class="form-label" - for="transcription"> - <%= t '.transcription_label' %> - </label> <div class="mb-3"> - <textarea id="transcription" - rows="10" - class="form-control" - v-model="data.transcription" - placeholder="<%= t '.transcription_placeholder' %>"></textarea> + <%= block_component_edit :transcription, + label: t('admin.communication.blocks.components.text.transcription.label'), + placeholder: t('admin.communication.blocks.components.text.transcription.placeholder') %> </div> </div> </div> diff --git a/app/views/admin/communication/blocks/templates/embed/_preview.html.erb b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb index 560be01fc..8f5b62501 100644 --- a/app/views/admin/communication/blocks/templates/embed/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb @@ -1,2 +1,2 @@ -<%= @block.template.code.html_safe %> -<p><%= @block.template.transcription %></p> \ No newline at end of file +<%= block_component_preview :code %> +<%= block_component_preview :transcription %> diff --git a/app/views/admin/communication/blocks/templates/embed/_static.html.erb b/app/views/admin/communication/blocks/templates/embed/_static.html.erb index 70c103de6..7d7abfb81 100644 --- a/app/views/admin/communication/blocks/templates/embed/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_static.html.erb @@ -1,4 +1,2 @@ - code: >- - <%= prepare_html_for_static block.template.code, about.university %> - transcription: >- - <%= prepare_text_for_static block.template.transcription, 4 %> + <%= block_component_static :code %> + <%= block_component_static :transcription %> diff --git a/app/views/admin/communication/blocks/templates/video/_edit.html.erb b/app/views/admin/communication/blocks/templates/video/_edit.html.erb index c3c395f42..099d9cc7a 100644 --- a/app/views/admin/communication/blocks/templates/video/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/video/_edit.html.erb @@ -4,6 +4,8 @@ <%= block_component_edit :video_title %> </div> <div class="col-md-6"> - <%= block_component_edit :transcription, rows: 10 %> + <%= block_component_edit :transcription,, + label: t('admin.communication.blocks.components.text.transcription.label'), + placeholder: t('admin.communication.blocks.components.text.transcription.placeholder'), rows: 10 %> </div> </div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 838b4f543..793b29759 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -140,6 +140,9 @@ en: text: label: Text placeholder: Enter text + transcription: + label: Text transcript + placeholder: Enter text transcript image: input: label: Image (.png, .jpg, .svg) @@ -198,10 +201,9 @@ en: embed: description: HTML raw code, so you can integrate maps or iframe components. edit: - code_label: Code - code_placeholder: Enter code - transcription_label: Text transcript - transcription_placeholder: Enter text transcript + code: + label: Code + code_placeholder: Enter code files: description: A list of downloadable files, mentioning their file size. edit: @@ -323,9 +325,6 @@ en: video: description: An embedded video from most platforms, with the text transcription for accessibility, and no autoplay. edit: - transcription: - label: Text transcript - placeholder: Enter text transcript url: label: Video url placeholder: Enter video's url diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 45fad5ead..6bf20ba4e 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -140,6 +140,9 @@ fr: text: label: Texte placeholder: Entrer le texte + transcription: + label: Transcription textuelle du contenu + placeholder: Entrer ici la transcription image: input: label: Image (.png, .jpg, .svg) @@ -204,10 +207,9 @@ fr: embed: description: Du code HTML brut, permettant d'intégrer des cartes ou divers composants en iframe. edit: - code_label: Code du bloc d'intégration HTML - code_placeholder: Entrez ici le code - transcription_label: Transcription textuelle du contenu - transcription_placeholder: Entrez ici la transcription + code: + label: Code du bloc d'intégration HTML + placeholder: Entrez ici le code files: description: Une liste de fichiers téléchargeables, présentés avec leur poids. edit: @@ -341,9 +343,6 @@ fr: video: description: Une vidéo intégrée dans la page depuis diverses plateformes, avec la transcription et sans lecture automatique. edit: - transcription: - label: Transcription textuelle du contenu - placeholder: Entrer ici la transcription url: label: Url de la vidéo placeholder: Entrer l'url de la vidéo -- GitLab