Skip to content
Snippets Groups Projects
Unverified Commit 520eb0ac authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

whitelisted kinds for menu items depending of website.about

parent 867995d5
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
# fk_rails_... (website_id => communication_websites.id) # fk_rails_... (website_id => communication_websites.id)
# #
class Communication::Website::Menu::Item < ApplicationRecord class Communication::Website::Menu::Item < ApplicationRecord
KINDS_FOR_SCHOOL = ['programs', 'program', 'administrators', 'teachers']
KINDS_FOR_JOURNAL = ['researchers', 'research_volumes', 'research_volume', 'research_articles', 'research_article']
include WithTree include WithTree
include WithPosition include WithPosition
...@@ -72,6 +75,19 @@ class Communication::Website::Menu::Item < ApplicationRecord ...@@ -72,6 +75,19 @@ class Communication::Website::Menu::Item < ApplicationRecord
after_commit :sync_menu after_commit :sync_menu
def self.kinds_for_website(website)
whitelisted_kinds = self.kinds.dup
KINDS_FOR_SCHOOL.each { |school_kind|
whitelisted_kinds.delete(school_kind)
} unless website.about_school?
KINDS_FOR_JOURNAL.each { |journal_kind|
whitelisted_kinds.delete(journal_kind)
} unless website.about_journal?
whitelisted_kinds
end
def to_s def to_s
"#{title}" "#{title}"
end end
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<div class="card-body"> <div class="card-body">
<%= f.input :title %> <%= f.input :title %>
<%= f.input :kind, <%= f.input :kind,
collection: Communication::Website::Menu::Item.kinds_for_website(@website),
include_blank: false, include_blank: false,
input_html: { input_html: {
class: 'js-kind-input', class: 'js-kind-input',
......
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