diff --git a/app/assets/images/communication/blocks/templates/definitions.jpg b/app/assets/images/communication/blocks/templates/definitions.jpg new file mode 100644 index 0000000000000000000000000000000000000000..22f28b0c20e2a2e71e1ada963bdd49e3594a3f64 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/definitions.jpg differ diff --git a/app/assets/images/communication/blocks/templates/push.jpg b/app/assets/images/communication/blocks/templates/push.jpg new file mode 100644 index 0000000000000000000000000000000000000000..22f28b0c20e2a2e71e1ada963bdd49e3594a3f64 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/push.jpg differ diff --git a/app/assets/images/communication/blocks/templates/timeline.jpg b/app/assets/images/communication/blocks/templates/timeline.jpg new file mode 100644 index 0000000000000000000000000000000000000000..22f28b0c20e2a2e71e1ada963bdd49e3594a3f64 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/timeline.jpg differ diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index dfc4f715b54ac36618b04332745f890d521d0939..a3c1789199b003144e25e9349915c94e1461ae2b 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -38,6 +38,9 @@ class Communication::Block < ApplicationRecord testimonials: 400, posts: 500, pages: 600 + timeline: 700, + definitions: 800, + push: 900, } before_save :update_template_images diff --git a/app/models/communication/block/template/definition.rb b/app/models/communication/block/template/definition.rb new file mode 100644 index 0000000000000000000000000000000000000000..63b6777e510812789f30dd1c28c071ecb0eb46d9 --- /dev/null +++ b/app/models/communication/block/template/definition.rb @@ -0,0 +1,12 @@ +class Communication::Block::Template::Definition < Communication::Block::Template + def definitions + @definitions ||= elements.map { |element| definition(element) } + .compact + end + + protected + + def definition(element) + element.to_dot + end +end diff --git a/app/models/communication/block/template/push.rb b/app/models/communication/block/template/push.rb new file mode 100644 index 0000000000000000000000000000000000000000..be67a4e311e900f6e79919351cd4902566b24c7e --- /dev/null +++ b/app/models/communication/block/template/push.rb @@ -0,0 +1,32 @@ +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 diff --git a/app/models/communication/block/template/timeline.rb b/app/models/communication/block/template/timeline.rb new file mode 100644 index 0000000000000000000000000000000000000000..13359cdfe3333169dbdbb089cae76bcf67cc7213 --- /dev/null +++ b/app/models/communication/block/template/timeline.rb @@ -0,0 +1,12 @@ +class Communication::Block::Template::Timeline < Communication::Block::Template + def events + @events ||= elements.map { |element| event(element) } + .compact + end + + protected + + def event(element) + element.to_dot + end +end diff --git a/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb b/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..08b6904d07cd7bda91fc900bf8bb1ec07456b0fe --- /dev/null +++ b/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb @@ -0,0 +1,44 @@ +<a class="<%= button_classes('mb-4') %>" + v-on:click="data.elements.push({title: '', text: ''})"> + <%= t '.add_definition' %> +</a> + +<draggable :list="data.elements" handle=".dragHandle" class="row"> + <div v-for="(definition, index) in data.elements" class="col-md-4"> + <div class="card"> + <div class="card-body"> + <div class="d-flex"> + <div> + <a class="btn ps-0 pt-0 dragHandle"> + <i class="fa fa-bars handle"></i> + </a> + </div> + <div class="flex-fill"> + <label class="form-label" + :for="'definition-' + index + '-title'"><%= t '.title_label' %></label> + <input class="form-control mb-2" + v-model="definition.title" + placeholder="<%= t '.title_placeholder' %>" + type="text" + :id="'definition-' + index + '-title'" /> + + <label class="form-label" + :for="'definition-' + index + '-text'"><%= t '.text_label' %></label> + <textarea class="form-control mb-2" + rows="3" + v-model="definition.text" + placeholder="<%= t '.text_placeholder' %>" + :id="'definition-' + index + '-text'"></textarea> + </div> + <div> + <a class="btn btn-sm btn-danger ms-3" + v-on:click="data.elements.splice(data.elements.indexOf(definition), 1)" + title="<%= t '.remove_definition' %>"> + <i class="fas fa-times"></i> + </a> + </div> + </div> + </div> + </div> + </div> +</draggable> diff --git a/app/views/admin/communication/blocks/templates/definitions/_show.html.erb b/app/views/admin/communication/blocks/templates/definitions/_show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e9aaa76eba5ab6851fd439547cf9f7a7ef07058c --- /dev/null +++ b/app/views/admin/communication/blocks/templates/definitions/_show.html.erb @@ -0,0 +1,6 @@ +<dl> + <% @block.template.definitions.each do |definition| %> + <dt><%= definition.title %></dt> + <dd><%= definition.text %></dd> + <% end %> +</dl> diff --git a/app/views/admin/communication/blocks/templates/definitions/_static.html.erb b/app/views/admin/communication/blocks/templates/definitions/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e648565b8a74a9cfd93dc76a393000ec6a2c24e2 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/definitions/_static.html.erb @@ -0,0 +1,6 @@ +<% block.template.definitions.each do |definition| %> + - title: >- + <%= prepare_text_for_static definition.title %> + text: >- + <%= prepare_text_for_static definition.text %> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/push/_edit.html.erb b/app/views/admin/communication/blocks/templates/push/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..3e7b44d7a974274e62c9e6a2ab3f70407d263c39 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/push/_edit.html.erb @@ -0,0 +1,87 @@ +<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 diff --git a/app/views/admin/communication/blocks/templates/push/_show.html.erb b/app/views/admin/communication/blocks/templates/push/_show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..94adc11c62f891252005db7d55117ff82fd19ab5 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/push/_show.html.erb @@ -0,0 +1,20 @@ +<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> diff --git a/app/views/admin/communication/blocks/templates/push/_static.html.erb b/app/views/admin/communication/blocks/templates/push/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..fe07289fb4d4d1de73db42aa29fa06fb03bc22e4 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/push/_static.html.erb @@ -0,0 +1,2 @@ + text: >- + <%= prepare_html_for_static block.template.text, about.university %> diff --git a/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb b/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a646b4816c4b05cc79ca75aa64a352d0c8cb928a --- /dev/null +++ b/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb @@ -0,0 +1,44 @@ +<a class="<%= button_classes('mb-4') %>" + v-on:click="data.elements.push({title: '', text: ''})"> + <%= t '.add_event' %> +</a> + +<draggable :list="data.elements" handle=".dragHandle" class="row"> + <div v-for="(event, index) in data.elements" class="col-md-4"> + <div class="card"> + <div class="card-body"> + <div class="d-flex"> + <div> + <a class="btn ps-0 pt-0 dragHandle"> + <i class="fa fa-bars handle"></i> + </a> + </div> + <div class="flex-fill"> + <label class="form-label" + :for="'event-' + index + '-title'"><%= t '.title_label' %></label> + <input class="form-control mb-2" + v-model="event.title" + placeholder="<%= t '.title_placeholder' %>" + type="text" + :id="'event-' + index + '-title'" /> + + <label class="form-label" + :for="'event-' + index + '-text'"><%= t '.text_label' %></label> + <textarea class="form-control mb-2" + rows="3" + v-model="event.text" + placeholder="<%= t '.text_placeholder' %>" + :id="'event-' + index + '-text'"></textarea> + </div> + <div> + <a class="btn btn-sm btn-danger ms-3" + v-on:click="data.elements.splice(data.elements.indexOf(event), 1)" + title="<%= t '.remove_event' %>"> + <i class="fas fa-times"></i> + </a> + </div> + </div> + </div> + </div> + </div> +</draggable> diff --git a/app/views/admin/communication/blocks/templates/timeline/_show.html.erb b/app/views/admin/communication/blocks/templates/timeline/_show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e7bb0b4b59b9d304a16018a95c11cc132c41cf74 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/timeline/_show.html.erb @@ -0,0 +1,12 @@ +<div class="row"> + <% @block.template.events.each do |event| %> + <div class="col-xxl-4 col-xl-6"> + <article class="card"> + <div class="card-body"> + <p class="lead"><%= event.title %></p> + <p><%= event.text %></p> + </div> + </article> + </div> + <% end %> +</div> diff --git a/app/views/admin/communication/blocks/templates/timeline/_static.html.erb b/app/views/admin/communication/blocks/templates/timeline/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..dbfed4bda9cb5d0792b85d456f5cb02b0659e50a --- /dev/null +++ b/app/views/admin/communication/blocks/templates/timeline/_static.html.erb @@ -0,0 +1,6 @@ +<% block.template.events.each do |event| %> + - title: >- + <%= prepare_text_for_static event.title %> + text: >- + <%= prepare_text_for_static event.text %> +<% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 9aa4e9313c0e006c5f6c892f5ed861464f1e6a49..10c760718fa8690129a5479a416831cc1e77276e 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -163,6 +163,22 @@ en: photo_label: Photo remove_photo: Remove photo remove_testimonial: Remove testimonial + timeline: + edit: + add_event: Add event + remove_event: Delete event + title_label: Title + title_placeholder: Enter title here + text_label: Text + text_placeholder: Enter text here + definitions: + edit: + add_definition: Add definition + remove_definition: Delete definition + title_label: Title + title_placeholder: Enter title here + text_label: Text + text_placeholder: Enter text here website: pages: delete_special_page_notice: Can't delete this page diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 08d1fec8ccca609c31ead92f2291ee94f39d08ae..00230ff5f4e3d395dfb0a862bb1bad4308a19785 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -163,6 +163,35 @@ fr: photo_label: Photo remove_photo: Enlever la photo remove_testimonial: Enlever le témoignage + timeline: + edit: + add_event: Ajouter un événement + remove_event: Supprimer l'événement + title_label: Titre + title_placeholder: Entrer le titre de l'événement + text_label: Texte + text_placeholder: Entrer le texte de l'événement + definitions: + edit: + add_definition: Ajouter une définition + remove_definition: Supprimer la définition + title_label: Titre + 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