diff --git a/app/assets/images/communication/blocks/templates/features.jpg b/app/assets/images/communication/blocks/templates/features.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6c32f7e0dac707c1b58cf3c5f02ed8339cdd4096 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/features.jpg differ diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 7f4d9e282393d27b53756891308ad2c7518ba541..a18cea80675c5043b2ab837d9314e0c19aeb753c 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -38,12 +38,19 @@ class Communication::Block < ApplicationRecord # template_blobs would be a better name, because there are files has_many_attached :template_images + # Les numéros sont un peu en vrac + # Dans l'idée, pour le futur + # 1000 basic + # 2000 storytelling + # 3000 references + # 4000 utilities enum template_kind: { chapter: 50, image: 51, gallery: 300, video: 52, key_figures: 56, + features: 2010, datatable: 54, files: 55, embed: 53, @@ -61,7 +68,7 @@ class Communication::Block < ApplicationRecord CATEGORIES = { basic: [:chapter, :image, :video, :datatable], - storytelling: [:key_figures, :gallery, :call_to_action, :testimonials, :timeline], + storytelling: [:key_figures, :features, :gallery, :call_to_action, :testimonials, :timeline], references: [:pages, :posts, :organization_chart, :partners, :programs], utilities: [:files, :definitions, :embed, :contact] } diff --git a/app/models/communication/block/template/feature.rb b/app/models/communication/block/template/feature.rb new file mode 100644 index 0000000000000000000000000000000000000000..bd888d365cc1fecb680ab6301ca49411336f203b --- /dev/null +++ b/app/models/communication/block/template/feature.rb @@ -0,0 +1,6 @@ +class Communication::Block::Template::Feature < Communication::Block::Template::Base + + has_elements + has_component :description, :rich_text + +end diff --git a/app/models/communication/block/template/feature/element.rb b/app/models/communication/block/template/feature/element.rb new file mode 100644 index 0000000000000000000000000000000000000000..468d1bcdb377df270f1ebd8598ef33d3f71833cd --- /dev/null +++ b/app/models/communication/block/template/feature/element.rb @@ -0,0 +1,7 @@ +class Communication::Block::Template::Feature::Element < Communication::Block::Template::Base + + has_component :image, :image + has_component :title, :string + has_component :description, :text + +end diff --git a/app/views/admin/communication/blocks/templates/features/_edit.html.erb b/app/views/admin/communication/blocks/templates/features/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..baeaa3b4999b361c1de839ac8d9026f16b6dcdaf --- /dev/null +++ b/app/views/admin/communication/blocks/templates/features/_edit.html.erb @@ -0,0 +1,28 @@ +<div class="row pure__row--small"> + <div class="col-xl-6"> + <%= block_component_edit :description %> + </div> +</div> + +<draggable :list="data.elements" handle=".dragHandle" class="mb-3 row <%= if_appstack 'list-group' %>"> + <div v-for="(element, index) in data.elements" class="col-lg-4 draggable-item <%= if_appstack 'list-group-item' %>"> + <div> + <a class="btn ps-0 pt-0 dragHandle"> + <i class="<%= Icon::DRAG %> handle"></i> + </a> + <a class="btn btn-sm text-danger float-end pe-0" + v-on:click="data.elements.splice(data.elements.indexOf(element), 1)" + title="<%= t '.remove_element' %>"> + <i class="<%= Icon::DELETE %>"></i> + </a> + </div> + <div> + <%= block_component_edit :image, template: @element %> + <%= block_component_edit :title, template: @element %> + <%= block_component_edit :description, template: @element %> + </div> + <div> + </div> + </div> +</draggable> +<%= block_component_add_element t('.add_element') %> diff --git a/app/views/admin/communication/blocks/templates/features/_preview.html.erb b/app/views/admin/communication/blocks/templates/features/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/features/_static.html.erb b/app/views/admin/communication/blocks/templates/features/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..4af0f4d859ef57834aaf10692382035537f30e4a --- /dev/null +++ b/app/views/admin/communication/blocks/templates/features/_static.html.erb @@ -0,0 +1,7 @@ +<%= block_component_static :description %> + elements: +<% block.template.elements.each do |element| %> +<%= block_component_static :title, template: element, list: true, depth: 4 %> +<%= block_component_static :description, template: element, depth: 5 %> +<%= block_component_static :image, template: element, depth: 5 %> +<% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 30696959a57ef9179226ec6aa01fea6ca1dd949b..b829f6d995adec126a0beaca00c19e900969300b 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -363,6 +363,21 @@ en: label: Iframe title (mandatory for accessibility) placeholder: Enter the title warning: Beware, the code below is used as is, without any security filtering. Be extremely careful and never integrate possibly unreliable code. + features: + description: A list of features with images (often icons) and a description. + edit: + add_element: Add feature + remove_element: Remove feature + element: + image: + label: Image (.png, .jpg, .svg) + remove: Remove image + title: + label: Title + placeholder: Enter title here + description: + label: Text + placeholder: Enter text here files: description: A list of downloadable files, mentioning their file size. edit: @@ -703,6 +718,7 @@ en: datatable: Table definitions: Definitions embed: HTML embed + features: Features files: Files gallery: Gallery image: Image diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 046e1d967786f187d575b05658b60ee2d00a4035..87a098e11f611aaf8fe77fd1fab402503a56c916 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -363,6 +363,21 @@ fr: label: Titre de l'iframe (nécessaire pour l'accessibilité) placeholder: Entrer le titre warning: Attention, le code ci-dessous est intégré tel quel, sans filtrage de sécurité. N'intégrez jamais de code externe dont la fiabilité n'est pas certaine. + features: + description: Une liste de fonctionnalités avec des images, par exemple des icônes, et une description. + edit: + add_element: Ajouter une fonctionnalité + remove_element: Supprimer la fonctionnalité + element: + image: + label: Image (.png, .jpg, .svg) + remove: Enlever l'image + title: + label: Titre + placeholder: Entrer le titre de la fonctionnalité + description: + label: Texte + placeholder: Entrer la description de la fonctionnalité files: description: Une liste de fichiers téléchargeables, présentés avec leur poids. edit: @@ -703,6 +718,7 @@ fr: datatable: Tableau definitions: Définitions embed: Intégration HTML + features: Fonctionnalités files: Fichiers gallery: Galerie image: Image