From 08b87397621a737134905673649a2bbce71e7001 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Mon, 30 May 2022 11:38:19 +0200 Subject: [PATCH] wip #396 --- .../admin/communication/menu_items.js | 5 ++- app/models/communication/website/menu/item.rb | 40 +++++++++---------- .../website/menu/item/with_targets.rb | 16 ++++---- .../communication/website/with_menu_items.rb | 16 ++++---- .../websites/menus/items/_form.html.erb | 8 ++-- .../websites/menus/items/kind_switch.js.erb | 8 ++-- config/locales/communication/en.yml | 16 ++++---- config/locales/communication/fr.yml | 16 ++++---- 8 files changed, 64 insertions(+), 61 deletions(-) diff --git a/app/assets/javascripts/admin/communication/menu_items.js b/app/assets/javascripts/admin/communication/menu_items.js index fe5006d91..ad81bcaf9 100644 --- a/app/assets/javascripts/admin/communication/menu_items.js +++ b/app/assets/javascripts/admin/communication/menu_items.js @@ -73,7 +73,10 @@ window.osuny.communication.menuItems = { window.addEventListener('DOMContentLoaded', function () { 'use strict'; - if (document.body.classList.contains('items-new') || document.body.classList.contains('items-edit')) { + if (document.body.classList.contains('items-new') || + document.body.classList.contains('items-edit') || + document.body.classList.contains('items-create') || + document.body.classList.contains('items-update')) { window.osuny.communication.menuItems.init(); } }); diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index b0d4cb9b4..03f6be1a2 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -57,19 +57,19 @@ class Communication::Website::Menu::Item < ApplicationRecord program: 31, diplomas: 32, diploma: 33, - news: 40, - news_category: 41, - news_article: 42, + posts: 40, + category: 41, + post: 42, organizations: 45, - staff: 50, + persons: 50, administrators: 51, authors: 52, researchers: 53, teachers: 54, - research_volumes: 60, - research_volume: 61, - research_articles: 62, - research_article: 63 + volumes: 60, + volume: 61, + articles: 62, + article: 63 }, _prefix: :kind validates :title, presence: true @@ -84,19 +84,19 @@ class Communication::Website::Menu::Item < ApplicationRecord 'blank' => 'font', 'diploma' => Icon::EDUCATION_DIPLOMA, 'diplomas' => Icon::EDUCATION_DIPLOMA, - 'news' => 'newspaper', - 'news_article' => 'newspaper', - 'news_category' => 'newspaper', + 'posts' => 'newspaper', + 'post' => 'newspaper', + 'category' => 'newspaper', 'page' => 'file', 'program' => Icon::EDUCATION_PROGRAM, 'programs' => Icon::EDUCATION_PROGRAM, - 'research_article' => Icon::RESEARCH_LABORATORY, - 'research_articles' => Icon::RESEARCH_LABORATORY, - 'research_volumes' => Icon::RESEARCH_LABORATORY, - 'research_volume' => Icon::RESEARCH_LABORATORY, + 'article' => Icon::RESEARCH_LABORATORY, + 'articles' => Icon::RESEARCH_LABORATORY, + 'volumes' => Icon::RESEARCH_LABORATORY, + 'volume' => Icon::RESEARCH_LABORATORY, 'researchers' => Icon::RESEARCH_RESEARCHER, 'organizations' => Icon::UNIVERSITY_ORGANIZATION, - 'staff' => 'user', + 'persons' => 'user', 'teachers' => Icon::EDUCATION_TEACHER, 'url' => 'globe', } @@ -144,10 +144,10 @@ class Communication::Website::Menu::Item < ApplicationRecord kind_page? || kind_diploma? || kind_program? || - kind_news_category? || - kind_news_article? || - kind_research_volume? || - kind_research_article? + kind_category? || + kind_post? || + kind_volume? || + kind_article? end def sync_menu diff --git a/app/models/communication/website/menu/item/with_targets.rb b/app/models/communication/website/menu/item/with_targets.rb index 12ee6deae..dbc8a06db 100644 --- a/app/models/communication/website/menu/item/with_targets.rb +++ b/app/models/communication/website/menu/item/with_targets.rb @@ -31,16 +31,16 @@ module Communication::Website::Menu::Item::WithTargets Static.clean_path website.special_page(:education_diplomas).path end - def target_for_news + def target_for_posts Static.clean_path website.special_page(:communication_posts).path end - def target_for_news_article + def target_for_post return unless about&.published? Static.clean_path "#{website.special_page(:communication_posts).path}#{about.path}" end - def target_for_news_category + def target_for_category return unless about Static.clean_path "#{website.special_page(:communication_posts).path}#{about.path}" end @@ -49,7 +49,7 @@ module Communication::Website::Menu::Item::WithTargets Static.clean_path website.special_page(:organizations).path end - def target_for_staff + def target_for_persons Static.clean_path website.special_page(:persons).path end @@ -69,20 +69,20 @@ module Communication::Website::Menu::Item::WithTargets Static.clean_path website.special_page(:teachers).path end - def target_for_research_volumes + def target_for_volumes Static.clean_path website.special_page(:research_volumes).path end - def target_for_research_volume + def target_for_volume return unless about&.published && about&.published_at Static.clean_path "#{website.special_page(:research_volumes).path}#{about.path}" end - def target_for_research_articles + def target_for_articles Static.clean_path website.special_page(:research_articles).path end - def target_for_research_article + def target_for_article return unless about&.published && about&.published_at Static.clean_path "#{website.special_page(:research_articles).path}#{about.path}" end diff --git a/app/models/communication/website/with_menu_items.rb b/app/models/communication/website/with_menu_items.rb index 46ec529d1..1a8c9c6a3 100644 --- a/app/models/communication/website/with_menu_items.rb +++ b/app/models/communication/website/with_menu_items.rb @@ -36,15 +36,15 @@ module Communication::Website::WithMenuItems has_education_diplomas? end - def menu_item_kind_news? + def menu_item_kind_posts? has_communication_posts? end - def menu_item_kind_news_category? + def menu_item_kind_category? has_communication_categories? end - def menu_item_kind_news_article? + def menu_item_kind_post? has_communication_posts? end @@ -52,7 +52,7 @@ module Communication::Website::WithMenuItems has_organizations? end - def menu_item_kind_staff? + def menu_item_kind_persons? has_persons? end @@ -72,19 +72,19 @@ module Communication::Website::WithMenuItems has_teachers? end - def menu_item_kind_research_volumes? + def menu_item_kind_volumes? has_research_volumes? end - def menu_item_kind_research_volume? + def menu_item_kind_volume? has_research_volumes? end - def menu_item_kind_research_articles? + def menu_item_kind_articles? has_research_articles? end - def menu_item_kind_research_article? + def menu_item_kind_article? has_research_articles? end end diff --git a/app/views/admin/communication/websites/menus/items/_form.html.erb b/app/views/admin/communication/websites/menus/items/_form.html.erb index ec0a2a457..7dc309043 100644 --- a/app/views/admin/communication/websites/menus/items/_form.html.erb +++ b/app/views/admin/communication/websites/menus/items/_form.html.erb @@ -26,13 +26,13 @@ about_collection = collection @website.education_diplomas elsif item.kind_program? about_collection = collection_tree @website.education_programs - elsif item.kind_news_category? + elsif item.kind_category? about_collection = collection_tree @website.categories - elsif item.kind_news_article? + elsif item.kind_post? about_collection = collection @website.posts - elsif item.kind_research_volume? + elsif item.kind_volume? about_collection = collection @website.research_volumes - elsif item.kind_research_article? + elsif item.kind_article? about_collection = collection @website.research_articles end else diff --git a/app/views/admin/communication/websites/menus/items/kind_switch.js.erb b/app/views/admin/communication/websites/menus/items/kind_switch.js.erb index 53849db77..484357c7b 100644 --- a/app/views/admin/communication/websites/menus/items/kind_switch.js.erb +++ b/app/views/admin/communication/websites/menus/items/kind_switch.js.erb @@ -37,7 +37,7 @@ function hideAbout() { end %> displayAbout('Education::Program', "<%= j(raw(options.join(''))) %>"); -<% elsif @kind == 'news_category' %> +<% elsif @kind == 'category' %> <% options = ['<option value="" label=" "></option>'] collection_tree(@website.categories).each do |category| @@ -45,7 +45,7 @@ function hideAbout() { end %> displayAbout('Communication::Website::Category', "<%= j(raw(options.join(''))) %>"); -<% elsif @kind == 'news_article' %> +<% elsif @kind == 'post' %> <% options = ['<option value="" label=" "></option>'] @website.posts.ordered.each do |post| @@ -53,7 +53,7 @@ function hideAbout() { end %> displayAbout('Communication::Website::Post', "<%= j(raw(options.join(''))) %>"); -<% elsif @kind == 'research_volume' %> +<% elsif @kind == 'volume' %> <% options = ['<option value="" label=" "></option>'] @website.research_volumes.ordered.each do |volume| @@ -61,7 +61,7 @@ function hideAbout() { end %> displayAbout('Research::Journal::Volume', "<%= j(raw(options.join(''))) %>"); -<% elsif @kind == 'research_article' %> +<% elsif @kind == 'article' %> <% options = ['<option value="" label=" "></option>'] @website.research_articles.ordered.each do |article| diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index a6c0ea914..2944077a3 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -467,19 +467,19 @@ en: blank: Title diploma: Specific diploma diplomas: Diplomas index - news: News index - news_article: Specific news - news_category: News category + posts: News index + post: Specific news + category: News category organizations: Third parties index page: Specific Page program: Specific program programs: Programs index - research_article: Specific research article - research_articles: Research articles index - research_volume: Specific research volume - research_volumes: Research volumes index + article: Specific research article + articles: Research articles index + volume: Specific research volume + volumes: Research volumes index researchers: Research staff - staff: Staff + persons: Staff teachers: Educational staff url: URL simple_form: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 0c8195b6f..8dfb9f365 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -470,19 +470,19 @@ fr: blank: Titre intermédiaire diploma: Diplôme spécifique diplomas: Liste des diplômes - news: Liste des actualités - news_article: Actualité spécifique - news_category: Catégorie d'actualités + posts: Liste des actualités + post: Actualité spécifique + category: Catégorie d'actualités organizations: Liste des tierces parties page: Page spécifique program: Formation spécifique programs: Liste des formations - research_article: Article spécifique - research_articles: Liste des articles - research_volume: Volume spécifique - research_volumes: Liste des volumes + article: Article spécifique + articles: Liste des articles + volume: Volume spécifique + volumes: Liste des volumes researchers: Équipe de recherche - staff: Équipe + persons: Équipe teachers: Équipe pédagogique url: URL simple_form: -- GitLab