Extract methods to render a section in admin menu
This commit is contained in:
@@ -151,7 +151,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def booths_links
|
||||
link_to(t("admin.menu.title_booths"), "#", class: "booths-link") +
|
||||
section(t("admin.menu.title_booths"), class: "booths-link") do
|
||||
link_list(
|
||||
officers_link,
|
||||
booths_link,
|
||||
@@ -160,6 +160,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
id: "booths_menu", class: ("is-active" if booths?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def officers_link
|
||||
[
|
||||
@@ -204,7 +205,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def messages_links
|
||||
link_to(t("admin.menu.messaging_users"), "#", class: "messages-link") +
|
||||
section(t("admin.menu.messaging_users"), class: "messages-link") do
|
||||
link_list(
|
||||
newsletters_link,
|
||||
admin_notifications_link,
|
||||
@@ -213,6 +214,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
id: "messaging_users_menu", class: ("is-active" if messages_menu_active?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def newsletters_link
|
||||
[
|
||||
@@ -247,7 +249,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def site_customization_links
|
||||
link_to(t("admin.menu.title_site_customization"), "#", class: "site-customization-link") +
|
||||
section(t("admin.menu.title_site_customization"), class: "site-customization-link") do
|
||||
link_list(
|
||||
homepage_link,
|
||||
pages_link,
|
||||
@@ -260,6 +262,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
controller.class.module_parent != Admin::Poll::Questions::Answers)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def homepage_link
|
||||
[
|
||||
@@ -302,7 +305,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def moderated_content_links
|
||||
link_to(t("admin.menu.title_moderated_content"), "#", class: "moderated-content-link") +
|
||||
section(t("admin.menu.title_moderated_content"), class: "moderated-content-link") do
|
||||
link_list(
|
||||
(hidden_proposals_link if feature?(:proposals)),
|
||||
(hidden_debates_link if feature?(:debates)),
|
||||
@@ -314,6 +317,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
class: ("is-active" if moderated_content?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def hidden_proposals_link
|
||||
[
|
||||
@@ -372,7 +376,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def profiles_links
|
||||
link_to(t("admin.menu.title_profiles"), "#", class: "profiles-link") +
|
||||
section(t("admin.menu.title_profiles"), class: "profiles-link") do
|
||||
link_list(
|
||||
administrators_link,
|
||||
organizations_link,
|
||||
@@ -385,6 +389,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
class: ("is-active" if profiles?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def administrators_link
|
||||
[
|
||||
@@ -452,7 +457,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def settings_links
|
||||
link_to(t("admin.menu.title_settings"), "#", class: "settings-link") +
|
||||
section(t("admin.menu.title_settings"), class: "settings-link") do
|
||||
link_list(
|
||||
settings_link,
|
||||
tenants_link,
|
||||
@@ -462,6 +467,7 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
class: ("is-active" if settings?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def settings_link
|
||||
[
|
||||
@@ -522,13 +528,14 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def dashboard_links
|
||||
link_to(t("admin.menu.dashboard"), "#", class: "dashboard-link") +
|
||||
section(t("admin.menu.dashboard"), class: "dashboard-link") do
|
||||
link_list(
|
||||
dashboard_actions_link,
|
||||
administrator_tasks_link,
|
||||
class: ("is-active" if dashboard?)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def machine_learning_link
|
||||
[
|
||||
@@ -562,4 +569,12 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
sdg_managers?
|
||||
]
|
||||
end
|
||||
|
||||
def section(title, **, &content)
|
||||
section_opener(title, **) + content.call
|
||||
end
|
||||
|
||||
def section_opener(title, **options)
|
||||
link_to(title, "#", options)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ class Management::MenuComponent < ApplicationComponent
|
||||
private
|
||||
|
||||
def user_links
|
||||
link_to(t("management.menu.users"), "#", class: "users-link") +
|
||||
section(t("management.menu.users"), class: "users-link") do
|
||||
link_list(
|
||||
select_user_link,
|
||||
(reset_password_email_link if managed_user.email),
|
||||
@@ -25,6 +25,7 @@ class Management::MenuComponent < ApplicationComponent
|
||||
class: "is-active"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def select_user_link
|
||||
[
|
||||
@@ -151,4 +152,12 @@ class Management::MenuComponent < ApplicationComponent
|
||||
def user_invites?
|
||||
controller_name == "user_invites"
|
||||
end
|
||||
|
||||
def section(title, **, &content)
|
||||
section_opener(title, **) + content.call
|
||||
end
|
||||
|
||||
def section_opener(title, **options)
|
||||
link_to(title, "#", options)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user