diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index aba81c4f1626d1d99319f2c912b86f36109c2bf3..edad92b4380db489a165277bec2341cfa5daab9f 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -91,6 +91,15 @@ module Admin::ApplicationHelper '' end + def collection(list) + list.ordered.map do |e| + { + label: e.to_s, + id: e.id + } + end + end + def collection_tree(list, except = nil) collection = [] list.root.ordered.each do |object| 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 14b8c2991323385d24121e8341dd5e2cb8d3da10..ec0a2a457952efd57638e85f5353e58e478e953c 100644 --- a/app/views/admin/communication/websites/menus/items/_form.html.erb +++ b/app/views/admin/communication/websites/menus/items/_form.html.erb @@ -21,27 +21,19 @@ <% if item.has_about? if item.kind_page? - about_collection = collection_tree(@website.pages) + about_collection = collection_tree @website.pages elsif item.kind_diploma? - about_collection = @website.education_diplomas - .ordered - .map { |e| { label: e.to_s, id: e.id } } + about_collection = collection @website.education_diplomas elsif item.kind_program? - about_collection = collection_tree(@website.education_programs) + about_collection = collection_tree @website.education_programs elsif item.kind_news_category? - about_collection = collection_tree(@website.categories) + about_collection = collection_tree @website.categories elsif item.kind_news_article? - about_collection = @website.posts - .ordered - .map { |e| { label: e.to_s, id: e.id } } + about_collection = collection @website.posts elsif item.kind_research_volume? - about_collection = @website.research_volumes - .ordered - .map { |e| { label: e.to_s, id: e.id } } + about_collection = collection @website.research_volumes elsif item.kind_research_article? - about_collection = @website.research_articles - .ordered - .map { |e| { label: e.to_s, id: e.id } } + about_collection = collection @website.research_articles end else about_collection = []