Skip to content
Snippets Groups Projects
Commit 96855a07 authored by alexisben's avatar alexisben
Browse files

Block push

parent 9e4919fd
No related branches found
No related tags found
No related merge requests found
app/assets/images/communication/blocks/templates/push.jpg

124 KiB

......@@ -39,6 +39,7 @@ class Communication::Block < ApplicationRecord
posts: 500,
timeline: 700,
definitions: 800,
push: 900,
}
before_save :update_template_images
......
class Communication::Block::Template::Push < Communication::Block::Template
def build_git_dependencies
# image à déclarer
end
def text
"#{data['text']}"
end
def url
"#{data['url']}"
end
def button
"#{data['button']}"
end
def image
image_with_alt
end
protected
def image_with_alt
blob = find_blob data, 'image'
return if blob.nil?
{
blob: blob,
alt: data['image_alt']
}.to_dot
end
end
<div class="row">
<div class="col-xxl-4 col-md-6">
<label class="form-label"
for="text">
<%= t '.text_label' %>
</label>
<div class="summernote">
<textarea id="text"
class="form-control summernote-vue"
v-model="data.text"
data-summernote-config="mini"
placeholder="<%= t '.text_placeholder' %>"></textarea>
</div>
<label class="form-label mt-3"
for="url">
<%= t '.url_label' %>
</label>
<input id="url"
type="url"
class="form-control"
v-model="data.url"
placeholder="<%= t '.url_placeholder' %>" />
<label class="form-label mt-3"
for="button">
<%= t '.button_label' %>
</label>
<input id="button"
type="text"
class="form-control"
v-model="data.button"
placeholder="<%= t '.button_placeholder' %>" />
<label class="form-label mt-3"
for="button">
<%= t '.button_label' %>
</label>
<input id="button"
type="text"
class="form-control"
v-model="data.button"
placeholder="<%= t '.button_placeholder' %>" />
<hr>
<h3><%= t '.image_title' %></h3>
<div class="row">
<div class="col-md-6">
<div v-if="!data.image">
<%# TODO : create a uploader vue3 component %>
<label class="form-label"
for="image">
<%= t '.image_label' %>
</label>
<input class="form-control mb-2"
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 '.remove_image' %>
</a>
</div>
</div>
<div class="col-md-6">
<label class="form-label"
for="image_alt">
<%= t '.image_alt_label' %>
</label>
<input id="image_alt"
type="text"
class="form-control"
v-model="data.image_alt"
placeholder="<%= t '.image_alt_placeholder' %>" />
</div>
</div>
</div>
</div>
\ No newline at end of file
<div class="col-md-8 col-xl-6">
<div class="card">
<div class="card-body">
<% if @block.template.image %>
<div style= "max-width: 200px;" class="me-3">
<%= kamifusen_tag @block.template.image.blob,
width: 200,
alt: @block.template.image.alt,
class: 'img-fluid' %>
<caption><%= @block.template.image.alt %></caption>
</div>
<% end %>
<hr>
<%= @block.template.text.html_safe %>
<a href="<%= @block.template.url %>" class="btn btn-secondary" target="_blank" rel="noopener">
<%= @block.template.button %>
</a>
</div>
</div>
</div>
text: >-
<%= prepare_html_for_static block.template.text, about.university %>
......@@ -179,6 +179,19 @@ fr:
title_placeholder: Entrer le titre de la définition
text_label: Texte
text_placeholder: Entrer la description de la définition
push:
edit:
text_label: Texte
text_placeholder: Entrer le texte ici
url_label: Lien
url_placeholder: Entrer le lien ici avec "https://..."
button_label: Bouton
button_placeholder: Entrer le texte du bouton ici
image_title: Image
image_label: Fichier
remove_image: Supprimer l'image
image_alt_label: Texte alternatif
image_alt_placeholder: Entrer le texte alternatif de l'image ici
website:
pages:
delete_special_page_notice: Impossible de supprimer cette page
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment