Skip to content
Snippets Groups Projects
Commit 321ff630 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

refactor

parent cfc6f117
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@
class Communication::Website::Menu::Item < ApplicationRecord
include WithTree
include WithPosition
include WithTargets
attr_accessor :skip_publication_callback
......@@ -80,6 +81,7 @@ class Communication::Website::Menu::Item < ApplicationRecord
target = nil
active = website.send "menu_item_kind_#{kind}?"
return nil unless active
# Les méthodes target_for_ sont définies dans le concern WithTarget
method = "target_for_#{kind}"
target = respond_to?(method) ? send(method)
: about&.path
......@@ -88,75 +90,6 @@ class Communication::Website::Menu::Item < ApplicationRecord
: "#{target}/"
end
def target_for_blank
''
end
def target_for_url
url
end
def target_for_page
about.path if about&.published
end
def target_for_programs
"/#{website.structure.education_programs_path}"
end
def target_for_program
"/#{website.structure.education_programs_path}#{about.path}"
end
def target_for_news
"/#{website.structure.communication_posts_path}"
end
def target_for_news_article
"/#{website.structure.communication_posts_path}#{about.path}" if about&.published && about&.published_at
end
def target_for_news_category
# TODO use communication_categories_path
"/#{website.structure.communication_posts_path}/categories#{about.path}" if about
end
def target_for_staff
"/#{website.structure.persons_path}"
end
def target_for_administrators
"/#{website.structure.administrators_path}"
end
def target_for_authors
"/#{website.structure.authors_path}"
end
def target_for_researchers
"/#{website.structure.researchers_path}"
end
def target_for_teachers
"/#{website.structure.teachers_path}"
end
def target_for_research_volumes
"/#{website.structure.research_volumes_path}"
end
def target_for_research_volume
"/#{website.structure.research_volumes_path}#{about.path}" if about&.published && about&.published_at
end
def target_for_research_articles
"/#{website.structure.research_articles_path}"
end
def target_for_research_article
"/#{website.structure.research_articles_path}#{about.path}" if about&.published && about&.published_at
end
def list_of_other_items
items = []
menu.items.where.not(id: id).root.ordered.each do |item|
......@@ -177,9 +110,12 @@ class Communication::Website::Menu::Item < ApplicationRecord
end
def has_about?
kind_page? || kind_program? ||
kind_news_category? || kind_news_article? ||
kind_research_volume? || kind_research_article?
kind_page? ||
kind_program? ||
kind_news_category? ||
kind_news_article? ||
kind_research_volume? ||
kind_research_article?
end
def sync_menu
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment