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