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/models/communication/block.rb b/app/models/communication/block.rb index efff78873338f9357e1063247a12b1a2deb763d4..f446aa2d0537147f4872ce623f5640d1c62cf85c 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -38,6 +38,7 @@ class Communication::Block < ApplicationRecord testimonials: 400, posts: 500, timeline: 700, + definitions: 800, } 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/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/config/locales/communication/en.yml b/config/locales/communication/en.yml index 6fe8ac59a00ea9d321c9b26ecdf72e7fd36ea809..10c760718fa8690129a5479a416831cc1e77276e 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -171,6 +171,14 @@ en: 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 ffd6c906bea1c31e17ba68d1624a03c5ed27d792..5d2bf0c6ae075d5e99d4b665a0a98a00322feca1 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -171,6 +171,14 @@ fr: 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 website: pages: delete_special_page_notice: Impossible de supprimer cette page