diff --git a/app/assets/images/communication/blocks/templates/key_figures.jpg b/app/assets/images/communication/blocks/templates/key_figures.jpg new file mode 100644 index 0000000000000000000000000000000000000000..de66f462ccf6e2ca5a376e7c32a6da9919036d5b Binary files /dev/null and b/app/assets/images/communication/blocks/templates/key_figures.jpg differ diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 733a971a2bcca774877080b7b140ffcebccc930c..7e9d8a1e18f40b7d9bc213b048ec078033a8641c 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -46,6 +46,7 @@ class Communication::Block < ApplicationRecord partners: 200, posts: 500, pages: 600, + key_figures: 56, } before_save :update_template_images diff --git a/app/models/communication/block/template/key_figure.rb b/app/models/communication/block/template/key_figure.rb new file mode 100644 index 0000000000000000000000000000000000000000..0c4abee7d7d9722a106e21a5728ced277a7e47b7 --- /dev/null +++ b/app/models/communication/block/template/key_figure.rb @@ -0,0 +1,15 @@ +class Communication::Block::Template::KeyFigure < Communication::Block::Template + def build_git_dependencies + end + + def figures + @figures ||= elements.map { |element| figure(element) } + .compact + end + + protected + + def figure(element) + element.to_dot + end +end diff --git a/app/views/admin/communication/blocks/templates/key_figures/_edit.html.erb b/app/views/admin/communication/blocks/templates/key_figures/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..dcd9e2463af441dfc8d98f912e5c04fdf171d9e4 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/key_figures/_edit.html.erb @@ -0,0 +1,50 @@ +<a class="<%= button_classes('mb-4') %>" + v-on:click="data.elements.push({number: 0, unit: '', description: ''})"> + <%= t '.add_key' %> +</a> + +<draggable :list="data.elements" handle=".dragHandle" class="row"> + <div v-for="(key, 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="'key-' + index + '-number'"><%= t '.number_label' %></label> + <input class="form-control mb-3" + v-model="key.number" + placeholder="<%= t '.number_placeholder' %>" + type="number" + :id="'key-' + index + '-number'" /> + + <label class="form-label" + :for="'key-' + index + '-unit'"><%= t '.unit_label' %></label> + <input class="form-control mb-3" + v-model="key.unit" + placeholder="<%= t '.unit_placeholder' %>" + :id="'key-' + index + '-unit'"> + + <label class="form-label" + :for="'key-' + index + '-description'"><%= t '.description_label' %></label> + <input class="form-control mb-3" + v-model="key.description" + placeholder="<%= t '.description_placeholder' %>" + :id="'key-' + index + '-description'"> + </div> + <div> + <a class="btn btn-sm btn-danger ms-3" + v-on:click="data.elements.splice(data.elements.indexOf(key), 1)" + title="<%= t '.remove_key' %>"> + <i class="fas fa-times"></i> + </a> + </div> + </div> + </div> + </div> + </div> +</draggable> diff --git a/app/views/admin/communication/blocks/templates/key_figures/_preview.html.erb b/app/views/admin/communication/blocks/templates/key_figures/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb b/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6870d3caab69caed0baa0ba6802b53b4cd55779c --- /dev/null +++ b/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb @@ -0,0 +1,9 @@ + figures: +<% block.template.figures.each do |figure| %> + - number: >- + <%= prepare_text_for_static figure.number, 6 %> + unit: >- + <%= prepare_text_for_static figure.unit, 6 %> + description: >- + <%= prepare_text_for_static figure.description, 6 %> +<% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 03e75b9218918a6e371f90e67593e5f78ad7bb54..6fca96732b7f94d15297f83fc4a388d0186208d5 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -196,6 +196,16 @@ en: text_label: Text text_placeholder: Enter text remove_image: Remove image + key_figures: + edit: + add_key: Add key figure + unit_label: Unit + unit_placeholder: Enter unit here + number_label: Number + number_placeholder: Enter key figure's value here + description_label: Description + description_placeholder: Enter description here + remove_key: Remove key figure organization_chart: edit: add_person: Add person diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index a406c0e00ede63134167eae90abb283944c11348..1b62eae7a6b24508a4308cf7ac59e77797b0b9ac 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -197,6 +197,16 @@ fr: text_label: Texte text_placeholder: Entrer le texte remove_image: Enlever l'image + key_figures: + edit: + add_key: Add key figure + unit_label: Unit + unit_placeholder: Enter unit here + number_label: Number + number_placeholder: Enter key figure's value here + description_label: Description + description_placeholder: Enter description here + remove_key: Remove key figure organization_chart: edit: add_person: Ajouter une personne