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 ed1cd6658bd8b56ea6754cdea1997025a078c4fe..e1af31ce1eea741ddf330d6fa08343fce50337eb 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -41,12 +41,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, @@ -64,7 +71,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..25cd20876617e71004bcb3143b0ecb5568192a4b --- /dev/null +++ b/app/models/communication/block/template/feature/element.rb @@ -0,0 +1,9 @@ +class Communication::Block::Template::Feature::Element < Communication::Block::Template::Base + + has_component :title, :string + has_component :description, :text + has_component :image, :image + has_component :alt, :string + has_component :credit, :rich_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..e9a60f1c569c753464c16a159eeab64dd613273f --- /dev/null +++ b/app/views/admin/communication/blocks/templates/features/_edit.html.erb @@ -0,0 +1,35 @@ +<div class="row pure__row--small"> + <div class="col-xl-6"> + <%= block_component_edit :description %> + </div> +</div> + +<%= block_component_add_element t('.add_element') %> +<draggable :list="data.elements" handle=".dragHandle" class="mb-3 <%= if_appstack 'list-group' %>"> + <div v-for="(element, index) in data.elements" class="draggable-item <%= if_appstack 'list-group-item' %>"> + <div> + <a class="btn ps-0 pt-0 dragHandle"><i class="<%= Icon::DRAG %> handle"></i></a>{{element.title}} + <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 class="row pure__row--small"> + <div class="col-lg-4"> + <%= block_component_edit :title, template: @element %> + <%= block_component_edit :description, template: @element, rows: 5 %> + </div> + <div class="col-lg-4"> + <%= block_component_edit :image, template: @element %> + </div> + <div class="col-lg-4" v-show="element.image.id != ''"> + <%= block_component_edit :alt, template: @element %> + <%= block_component_edit :credit, template: @element %> + </div> + </div> + </div> +</draggable> +<div v-show="data.elements.length > 2"> + <%= block_component_add_element t('.add_element') %> +</div> \ No newline at end of file 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..2dd180eae5b5d1367c84827e7f24a8b8f89d7ea0 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/features/_static.html.erb @@ -0,0 +1,9 @@ +<%= 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 %> +<%= block_component_static :alt, template: element, depth: 5 %> +<%= block_component_static :credit, template: element, depth: 5 %> +<% end %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index b025025ad206d7cbecaa572f0320811af7e2eb56..609c93f67e84e8da98d5e20087a25fb09b7d648c 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -361,6 +361,27 @@ 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 + alt: + label: Alternative text + placeholder: Enter text description + credit: + label: Credit + placeholder: Enter image's credit here + 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: @@ -706,6 +727,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 7a1ff04a8f549a0ffc701f83c798e93634ca46a7..bd8bb87a8481ec6b37a48da42e9c09b7496ca8e3 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -361,6 +361,27 @@ 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 + alt: + label: Texte alternatif + placeholder: Entrer la description textuelle + credit: + label: CrƩdit + placeholder: Entrer le crƩdit de l'image ici + 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: @@ -706,6 +727,7 @@ fr: datatable: Tableau definitions: DƩfinitions embed: IntƩgration HTML + features: FonctionnalitƩs files: Fichiers gallery: Galerie image: Image