diff --git a/app/models/communication/block/template/chapter.rb b/app/models/communication/block/template/chapter.rb index 688a91de7bc3a0965ab0d3627ce10cb018ae5141..b1738a00afe0723d83f1b18947fde5fc6d55047b 100644 --- a/app/models/communication/block/template/chapter.rb +++ b/app/models/communication/block/template/chapter.rb @@ -3,7 +3,7 @@ class Communication::Block::Template::Chapter < Communication::Block::Template:: has_rich_text :text has_rich_text :notes has_image :image - has_string :image_alt - has_rich_text :image_credit + has_string :alt + has_rich_text :credit end diff --git a/app/models/communication/block/template/image.rb b/app/models/communication/block/template/image.rb index 262bf513a14b3b6e033edaab97e63e70496b91fc..0eb8549314bdfbbb6e98bc627a8d83be90e7e997 100644 --- a/app/models/communication/block/template/image.rb +++ b/app/models/communication/block/template/image.rb @@ -1,23 +1,8 @@ class Communication::Block::Template::Image < Communication::Block::Template::Base - def sanitized_data - { - "text" => Osuny::Sanitizer.sanitize(text), - "image" => data['image'], - "image_alt" => Osuny::Sanitizer.sanitize(data['image_alt'], 'string'), - "image_credit" => Osuny::Sanitizer.sanitize(data['image_credit'], 'string') - } - end - def build_git_dependencies - add_dependency image&.blob - end - - def image - extract_image_alt_and_credit data, 'image' - end - - def text - "#{data['text']}" - end + has_image :image + has_string :alt + has_rich_text :credit + has_text :text end diff --git a/app/views/admin/communication/blocks/components/image/_edit.html.erb b/app/views/admin/communication/blocks/components/image/_edit.html.erb index 5758fe592a8e9ab3d21b8ef2e14470345db41682..2517ab791b6fab11e93a23d363be214c8f772b37 100644 --- a/app/views/admin/communication/blocks/components/image/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/image/_edit.html.erb @@ -15,9 +15,7 @@ remove = t 'admin.communication.blocks.components.image.input.remove' :id="<%= dom_id.html_safe %>"> </div> <div v-if="<%= model %>.<%= property %>.id"> - <img :src="getImageUrl(<%= model %>.<%= property %>)" - class="img-fluid mb-3" - /> + <img :src="getImageUrl(<%= model %>.<%= property %>)" class="img-fluid mb-3" /> </div> <a class="btn btn-sm btn-danger" v-on:click="<%= model %>.<%= property %>={}" diff --git a/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb b/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb index c179da125ffb8400cee7111c0f3f694b3df768d0..0bb837bc29d683b5dc90c6402aeb866f0db06a9c 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb @@ -1,9 +1,9 @@ <div class="row mb-4"> - <div class="col-md-6"> + <div class="col-xxl-4 col-md-6"> <%= block_component_edit :text %> <%= block_component_edit :notes %> </div> - <div class="col-md-6"> + <div class="col-xxl-8 col-md-6"> <label class="form-label"> </label> <div class="card"> <div class="card-header"> @@ -11,20 +11,16 @@ </div> <div class="card-body"> <div class="row"> - <div class="col-lg-6"> + <div class="col-xxl-6"> <%= block_component_edit :image %> </div> - </div> - <%= block_component_edit :image_alt, - label: t('admin.communication.blocks.components.image.alt.label'), - placeholder: t('admin.communication.blocks.components.image.alt.placeholder') %> - <%= block_component_edit :image_credit, - label: t('admin.communication.blocks.components.image.credit.label'), - placeholder: t('admin.communication.blocks.components.image.credit.placeholder') %> - <div class="row"> - <div class="col-xl-3 col-6 mb-3"> - </div> - <div class="col-xl-9"> + <div class="col-xxl-6"> + <%= block_component_edit :alt, + label: t('admin.communication.blocks.components.image.alt.label'), + placeholder: t('admin.communication.blocks.components.image.alt.placeholder') %> + <%= block_component_edit :credit, + label: t('admin.communication.blocks.components.image.credit.label'), + placeholder: t('admin.communication.blocks.components.image.credit.placeholder') %> </div> </div> </div> diff --git a/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb index f944f39d822877181ea3265de154ecf58581e2bb..d0ccddf6fb680bba7b0830b4eaf268ba468e0fd3 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb @@ -1,9 +1,9 @@ <%= block_component_preview :image %> <div class="small"> <p class="mb-0"> - <%= block_component_preview :image_alt %> + <%= block_component_preview :alt %> </p> - <%= block_component_preview :image_credit %> + <%= block_component_preview :credit %> </div> <%= block_component_preview :text %> <%= block_component_preview :notes %> diff --git a/app/views/admin/communication/blocks/templates/chapter/_static.html.erb b/app/views/admin/communication/blocks/templates/chapter/_static.html.erb index af81bc62d8f01c6b7e8b684349cd2ca27e98ba8c..7ff9efd4d66ede7eb6eae149f440a8cb700a5e33 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_static.html.erb @@ -1,5 +1,5 @@ <%= block_component_static :text %> <%= block_component_static :notes %> <%= block_component_static :image %> -<%= block_component_static :image_alt %> -<%= block_component_static :image_credit %> +<%= block_component_static :alt, depth: 4 %> +<%= block_component_static :credit, depth: 4 %> diff --git a/app/views/admin/communication/blocks/templates/image/_edit.html.erb b/app/views/admin/communication/blocks/templates/image/_edit.html.erb index f017fe6a31054413cca215bca389a74b1a5c2dea..343c8d38a50eb408eaefc88a22750235daf5a7c8 100644 --- a/app/views/admin/communication/blocks/templates/image/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/image/_edit.html.erb @@ -1,60 +1,14 @@ <div class="row mb-5"> <div class="col-xxl-4 col-md-6"> - <div v-if="!data.image"> - <label class="form-label" - for="image"> - <%= t 'admin.communication.blocks.components.image.input.label' %> - </label> - <input class="form-control mb-4" - type="file" - accept="image/*" - @change="onFileImageChange( $event, data, 'image' )" - id="image"> - </div> - <div v-if="data.image"> - <img :src="getImageUrl(data.image)" - class="img-fluid" - style="max-height: 80px" - /> - <br> - <a class="btn btn-sm btn-danger mt-2" - v-on:click="data.image=null"> - <i class="fas fa-times"></i> - <%= t 'admin.communication.blocks.components.image.input.remove' %> - </a> - </div> + <%= block_component_edit :image %> </div> <div class="col-xxl-4 col-md-6"> - <label class="form-label" - for="image_alt"> - <%= t 'admin.communication.blocks.components.image.alt.label' %> - </label> - <input id="image_alt" - type="text" - class="form-control mb-3" - v-model="data.image_alt" - placeholder="<%= t 'admin.communication.blocks.components.image.alt.placeholder' %>" /> - - <label class="form-label" - for="image_credit"> - <%= t 'admin.communication.blocks.components.image.credit.label' %> - </label> - <input id="image_credit" - type="text" - class="form-control mb-3" - v-model="data.image_credit" - placeholder="<%= t 'admin.communication.blocks.components.image.credit.placeholder' %>" /> - - <label class="form-label" - for="text"> - <%= t 'admin.communication.blocks.components.text.label' %> - </label> - <div class="summernote"> - <textarea id="text" - class="form-control summernote-vue" - v-model="data.text" - data-summernote-config="mini" - placeholder="<%= t 'admin.communication.blocks.components.text.placeholder' %>"></textarea> - </div> + <%= block_component_edit :alt, + label: t('admin.communication.blocks.components.image.alt.label'), + placeholder: t('admin.communication.blocks.components.image.alt.placeholder') %> + <%= block_component_edit :credit, + label: t('admin.communication.blocks.components.image.credit.label'), + placeholder: t('admin.communication.blocks.components.image.credit.placeholder') %> + <%= block_component_edit :text %> </div> </div> diff --git a/app/views/admin/communication/blocks/templates/image/_preview.html.erb b/app/views/admin/communication/blocks/templates/image/_preview.html.erb index bd8956bf2c34ebac1235edc452114b456195695b..c898f4de2014b85de1f306f6264a19d617682a3f 100644 --- a/app/views/admin/communication/blocks/templates/image/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/image/_preview.html.erb @@ -1,9 +1,8 @@ -<% if @block.template.image&.blob %> - <%= kamifusen_tag @block.template.image.blob, - width: 600, - alt: @block.template.image.alt, - class: 'img-fluid' if @block.template.image %> - <caption><%= @block.template.image.alt %></caption> - <p class="small"><%= @block.template.image.credit %></p> - <%= @block.template.text.html_safe %> -<% end %> +<%= block_component_preview :image %> +<div class="small"> + <p class="mb-0"> + <%= block_component_preview :alt %> + </p> + <%= block_component_preview :credit %> +</div> +<%= block_component_preview :text %> diff --git a/app/views/admin/communication/blocks/templates/image/_static.html.erb b/app/views/admin/communication/blocks/templates/image/_static.html.erb index 5c085b71e2fb240b0e53c1ee043d9b622a9df19c..df1923006b3ed405a10a5ba142c590dad1d9b1f6 100644 --- a/app/views/admin/communication/blocks/templates/image/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/image/_static.html.erb @@ -1,9 +1,4 @@ - text: >- - <%= prepare_html_for_static block.template.text, about.university %> - <% if block.template.image %> - image: - id: "<%= block.template.image.blob.id %>" - file: "<%= block.template.image.blob.id %>" - alt: <%= prepare_text_for_static block.template.image.alt %> - credit: <%= prepare_text_for_static block.template.image.credit %> - <% end %> +<%= block_component_static :text %> +<%= block_component_static :image %> +<%= block_component_static :alt, depth: 4 %> +<%= block_component_static :credit, depth: 4 %> diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index e29128dff5924d4af76de7345fca20cddae132a1..faa77b2e6b238ae335c0c1632c9eb76a583b58c0 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -243,6 +243,10 @@ fr: remove_image: Enlever l'image image: description: Une image avec sa description alternative accessible, son texte et son crédit. + edit: + text: + label: Texte + placeholder: Entrer le texte key_figures: description: Des chiffres clés avec une jolie animation. Chaque chiffre peut être doté d'une unité et d'un texte. edit: