diff --git a/app/models/communication/block/template/agenda.rb b/app/models/communication/block/template/agenda.rb index a3eafdfc7bb328ebd40f655616c58db743fd9254..86fbe46b1313579da22877825873da38aa5333fb 100644 --- a/app/models/communication/block/template/agenda.rb +++ b/app/models/communication/block/template/agenda.rb @@ -8,8 +8,17 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::B ] has_elements - has_layouts [:grid, :list, :large] - has_component :mode, :option, options: [:all, :category, :selection] + has_layouts [ + :grid, + :list, + :large + ] + has_component :mode, :option, options: [ + :all, + :category, + :selection, + :categories + ] has_component :category_id, :category has_component :description, :rich_text has_component :quantity, :number, options: 3 @@ -62,4 +71,8 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::B }.compact end + def selected_events_categories + [] + end + end diff --git a/app/models/communication/block/template/post.rb b/app/models/communication/block/template/post.rb index fc2279fa058866ae215acd52fcaad65b93219103..e437000d93dd4f5200b532e839b769614ae3d86c 100644 --- a/app/models/communication/block/template/post.rb +++ b/app/models/communication/block/template/post.rb @@ -8,7 +8,12 @@ class Communication::Block::Template::Post < Communication::Block::Template::Bas :alternate, :large ] - has_component :mode, :option, options: [:all, :category, :selection] + has_component :mode, :option, options: [ + :all, + :category, + :selection, + :categories + ] has_component :posts_quantity, :number, options: 3 has_component :category_id, :category @@ -61,6 +66,10 @@ class Communication::Block::Template::Post < Communication::Block::Template::Bas }.compact end + def selected_posts_categories + [] + end + def post(id) return if id.blank? block.about&.website diff --git a/app/views/admin/communication/blocks/components/option/_static.html.erb b/app/views/admin/communication/blocks/components/option/_static.html.erb index e7e1732f246c835efd046479044043da7fdd97d9..10c417295fdab3a0121daef30d1b515246c9d280 100644 --- a/app/views/admin/communication/blocks/components/option/_static.html.erb +++ b/app/views/admin/communication/blocks/components/option/_static.html.erb @@ -1 +1 @@ -<%= indentation %><%= property %>: <%= value %> +<%= indentation %><%= property %>: <%= value %> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb b/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb index 1dbe1ecefb7bb378f8e0d924236318e6b9814fbd..12bb26f4df9ff619843ce6bb2ad96c6c92185587 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb @@ -1,55 +1,63 @@ -<%= block_component_edit block, :layout %> - <div class="row pure__row--small"> - <div class="col-xl-6 mb-5"> + <div class="col-xl-6"> <%= block_component_edit block, :description %> </div> - <div class="col-xl-6 mb-5"> - <%= osuny_label t('admin.communication.blocks.templates.agenda.edit.show.label') %> - <%= block_component_edit block, :show_summary %> - <%= block_component_edit block, :show_category %> - <%= block_component_edit block, :show_status %> - </div> </div> <div class="row pure__row--small"> - <div class="col-xl-6 mb-5"> + <div class="col-xl-6 mb-3"> <%= block_component_edit block, :mode %> - <div v-show="data.mode != 'selection'"> + </div> + <div class="col-xl-6 mb-3" v-show="data.mode != 'selection' && data.mode != 'categories'"> + <%= block_component_edit block, :time %> + </div> +</div> + +<div v-if="data.mode !== 'categories'"> + <div class="mb-3"> + <%= block_component_edit block, :layout %> + </div> + + <div class="row pure__row--small"> + <div class="col-xl-6 mb-3" v-show="data.mode != 'selection'"> <%= block_component_edit block, :quantity %> </div> - <div v-if="data.mode === 'category'"> + <div class="col-xl-6 mb-3" v-show="data.mode === 'category'"> <%= block_component_edit block, :category_id %> - </div> - </div> - <div class="col-xl-6 mb-5"> - <div v-if="data.mode != 'selection'"> - <%= block_component_edit block, :time %> </div> </div> -</div> -<div v-show="data.mode === 'selection'"> - <%= block_component_add_element block, t('.add_event') %> - <draggable :list="data.elements" handle=".dragHandle" class="<%= if_appstack 'list-group' %>"> - <div v-for="(element, index) in data.elements" class="draggable-item <%= if_appstack 'list-group-item' %>"> - <div class="d-flex mb-n3"> - <div> - <a class="btn ps-0 pt-0 dragHandle" title="Drag and drop"> - <i class="<%= Icon::DRAG %> handle"></i> - </a> - </div> - <div class="flex-fill"> - <%= block_component_edit block, :id, template: @element %> - </div> - <div> - <a class="btn btn-sm text-danger ms-3" - v-on:click="data.elements.splice(data.elements.indexOf(element), 1)" - title="Supprimer"> - <i class="<%= Icon::DELETE %>"></i> - </a> + <div class="mb-3" v-show="data.mode === 'selection'"> + <%= block_component_add_element block, t('.add_event') %> + <draggable :list="data.elements" handle=".dragHandle" class="<%= if_appstack 'list-group' %>"> + <div v-for="(element, index) in data.elements" class="draggable-item <%= if_appstack 'list-group-item' %>"> + <div class="d-flex mb-n3"> + <div> + <a class="btn ps-0 pt-0 dragHandle" title="Drag and drop"> + <i class="<%= Icon::DRAG %> handle"></i> + </a> + </div> + <div class="flex-fill"> + <%= block_component_edit block, :id, template: @element %> + </div> + <div> + <a class="btn btn-sm text-danger ms-3" + v-on:click="data.elements.splice(data.elements.indexOf(element), 1)" + title="Supprimer"> + <i class="<%= Icon::DELETE %>"></i> + </a> + </div> </div> </div> + </draggable> + </div> + + <div class="row pure__row--small"> + <div class="col-xl-6"> + <%= osuny_label t('admin.communication.blocks.templates.agenda.edit.show.label') %> + <%= block_component_edit block, :show_summary %> + <%= block_component_edit block, :show_category %> + <%= block_component_edit block, :show_status %> </div> - </draggable> -</div> \ No newline at end of file + </div> +</div> diff --git a/app/views/admin/communication/blocks/templates/agenda/_snippet.html.erb b/app/views/admin/communication/blocks/templates/agenda/_snippet.html.erb index 8b93201cc662546ed8fa2c21b485a77622e11e68..7b7df003702eb4555ba49bd49bad0d7ac1415d1d 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_snippet.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_snippet.html.erb @@ -1,3 +1,7 @@ <p class="mb-0"> - <%= block.template.selected_events.first(2).collect(&:to_s).join(', ') %>... + <% if block.template.mode == 'categories' %> + TODO... + <% else %> + <%= block.template.selected_posts.first(2).collect(&:to_s).join(', ') %>... + <% end %> </p> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/agenda/_static.html.erb b/app/views/admin/communication/blocks/templates/agenda/_static.html.erb index fb4b3f48a3eb1b54c2edc14f7258a0c4e4194f71..966c8cab0b216233cbc51b3f06a5463ff0dc2732 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_static.html.erb @@ -1,6 +1,6 @@ - layout: <%= block.template.layout %> +<%= block_component_static block, :mode %> +<%= block_component_static block, :layout %> <%= block_component_static block, :description %> - mode: <%= block.template.mode %> <% if block.template.mode == 'category' && block.template.category %> category: "<%= block.template.category.path %>" <% end %> diff --git a/app/views/admin/communication/blocks/templates/license/_static.html.erb b/app/views/admin/communication/blocks/templates/license/_static.html.erb index d5e7c79f2883516eb06a6dbee635eb9cac9dd944..e375b8ee199aaa5aadf42bd6ac5e37e2ac2b44d9 100644 --- a/app/views/admin/communication/blocks/templates/license/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/license/_static.html.erb @@ -1,7 +1,7 @@ <% cc = Licenses::CreativeCommons.create_from_block(block) %> -<%= block_component_static block, :type -%> +<%= block_component_static block, :type %> creative_commons: attribution: <%= block.template.creative_commons_attribution %> commercial_use: <%= block.template.creative_commons_commercial_use %> diff --git a/app/views/admin/communication/blocks/templates/posts/_edit.html.erb b/app/views/admin/communication/blocks/templates/posts/_edit.html.erb index 49f62f428327ec425b54e82392cbc6140bd7f243..95428d0d5e0dec52d88b717b06e0b4fab778a942 100644 --- a/app/views/admin/communication/blocks/templates/posts/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/posts/_edit.html.erb @@ -1,14 +1,13 @@ -<%= block_component_edit block, :layout %> - -<div class="mb-3"> - <%= block_component_edit block, :mode %> - <div class="row pure__row--small"> - <div v-if="data.mode === 'category' || data.mode === 'all'" class="col-lg-3"> - <%= block_component_edit block, :posts_quantity %> - </div> - <div v-if="data.mode === 'category'" class="col-lg-9"> - <%= block_component_edit block, :category_id %> - </div> +<%= block_component_edit block, :mode %> +<div v-if="data.mode !== 'categories'"> + <%= block_component_edit block, :layout %> +</div> +<div class="row pure__row--small"> + <div v-if="data.mode === 'category' || data.mode === 'all'" class="col-lg-3"> + <%= block_component_edit block, :posts_quantity %> + </div> + <div v-if="data.mode === 'category'" class="col-lg-9"> + <%= block_component_edit block, :category_id %> </div> </div> <div v-if="data.mode === 'selection'"> diff --git a/app/views/admin/communication/blocks/templates/posts/_snippet.html.erb b/app/views/admin/communication/blocks/templates/posts/_snippet.html.erb index 3c3af41adc0dc4c7518539fb2f5a6064fa5e69c7..655eb923f085bf1f541940be8980084463ed4867 100644 --- a/app/views/admin/communication/blocks/templates/posts/_snippet.html.erb +++ b/app/views/admin/communication/blocks/templates/posts/_snippet.html.erb @@ -1,3 +1,7 @@ <p class="mb-0"> - <%= block.template.selected_posts.first(2).collect(&:to_s).join(', ') %>... + <% if block.template.mode == 'categories' %> + <%= @website.categories.ordered.first(2).collect(&:to_s).join(', ') %>... + <% else %> + <%= block.template.selected_posts.first(2).collect(&:to_s).join(', ') %>... + <% end %> </p> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/posts/_static.html.erb b/app/views/admin/communication/blocks/templates/posts/_static.html.erb index 167e7e361c87955622b10570652ec5db3a6da0fa..63122832eb34f550d171eae8d333ebc1fbc7d557 100644 --- a/app/views/admin/communication/blocks/templates/posts/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/posts/_static.html.erb @@ -1,3 +1,4 @@ +<%= block_component_static block, :mode %> <% if block.template.mode == 'all' %> all: true <% elsif block.template.mode == 'category' && block.template.category %> diff --git a/config/locales/communication/contents/en.yml b/config/locales/communication/contents/en.yml index 4dbb688f84ce4c538ca29aaef80b23fd26138805..40ec14283366c29281c254f3a2232da9af39959e 100644 --- a/config/locales/communication/contents/en.yml +++ b/config/locales/communication/contents/en.yml @@ -82,6 +82,7 @@ en: all: All events, regardless of category category: A specific category of events selection: A selection of events + categories: A list of all events' categories quantity: label: Quantity of events to show placeholder: Enter quantity @@ -453,6 +454,7 @@ en: all: All posts category: A specific category selection: A selection of posts + categories: A list of all posts' categories posts_quantity: label: Quantity placeholder: Enter quantity diff --git a/config/locales/communication/contents/fr.yml b/config/locales/communication/contents/fr.yml index 9df3eb5e64c24503e96ee7f9fbf03ca216b54f3c..29545085793dd11c52c451fc9f055f81773dca6a 100644 --- a/config/locales/communication/contents/fr.yml +++ b/config/locales/communication/contents/fr.yml @@ -82,6 +82,7 @@ fr: all: Tous les événements, peu importe la catégorie category: Une catégorie spécifique d'événements selection: Une sélection d'événements + categories: La liste des catégories d'événements quantity: label: Quantité d'événements à afficher placeholder: Entrer la quantité @@ -453,6 +454,7 @@ fr: all: Toutes les actualités category: Une catégorie spécifique selection: Une sélection d'actualités + categories: La liste des catégories d'actualités posts_quantity: label: Quantité d'articles placeholder: Entrer la quantité