Move admin menu methods to the component
This way we finish what we started in commit 1046ec5e7, making the menu
easier to customize.
This commit is contained in:
@@ -2,6 +2,27 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
include LinkListHelper
|
||||
delegate :can?, to: :helpers
|
||||
|
||||
def links
|
||||
[
|
||||
(proposals_link if feature?(:proposals)),
|
||||
(debates_link if feature?(:debates)),
|
||||
comments_link,
|
||||
(polls_link if feature?(:polls)),
|
||||
(legislation_link if feature?(:legislation)),
|
||||
(budgets_link if feature?(:budgets)),
|
||||
booths_links,
|
||||
(signature_sheets_link if feature?(:signature_sheets)),
|
||||
messages_links,
|
||||
site_customization_links,
|
||||
moderated_content_links,
|
||||
profiles_links,
|
||||
stats_link,
|
||||
settings_links,
|
||||
dashboard_links,
|
||||
(machine_learning_link if ::MachineLearning.enabled?)
|
||||
]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def moderated_content?
|
||||
@@ -77,6 +98,71 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
controller_name == "managers" && controller.class.module_parent == Admin
|
||||
end
|
||||
|
||||
def proposals_link
|
||||
[
|
||||
t("admin.menu.proposals"),
|
||||
admin_proposals_path,
|
||||
controller_name == "proposals",
|
||||
class: "proposals-link"
|
||||
]
|
||||
end
|
||||
|
||||
def debates_link
|
||||
[
|
||||
t("admin.menu.debates"),
|
||||
admin_debates_path,
|
||||
controller_name == "debates",
|
||||
class: "debates-link"
|
||||
]
|
||||
end
|
||||
|
||||
def polls_link
|
||||
[
|
||||
t("admin.menu.polls"),
|
||||
admin_polls_path,
|
||||
polls?,
|
||||
class: "polls-link"
|
||||
]
|
||||
end
|
||||
|
||||
def comments_link
|
||||
[
|
||||
t("admin.menu.comments"),
|
||||
admin_comments_path,
|
||||
controller_name == "comments",
|
||||
class: "comments-link"
|
||||
]
|
||||
end
|
||||
|
||||
def legislation_link
|
||||
[
|
||||
t("admin.menu.legislation"),
|
||||
admin_legislation_processes_path,
|
||||
controller.class.module_parent == Admin::Legislation,
|
||||
class: "legislation-link"
|
||||
]
|
||||
end
|
||||
|
||||
def budgets_link
|
||||
[
|
||||
t("admin.menu.budgets"),
|
||||
admin_budgets_path,
|
||||
budgets?,
|
||||
class: "budgets-link"
|
||||
]
|
||||
end
|
||||
|
||||
def booths_links
|
||||
link_to(t("admin.menu.title_booths"), "#", class: "booths-link") +
|
||||
link_list(
|
||||
officers_link,
|
||||
booths_link,
|
||||
booth_assignments_link,
|
||||
shifts_link,
|
||||
id: "booths_menu", class: ("is-active" if booths?)
|
||||
)
|
||||
end
|
||||
|
||||
def officers_link
|
||||
[
|
||||
t("admin.menu.poll_officers"),
|
||||
@@ -109,6 +195,26 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
]
|
||||
end
|
||||
|
||||
def signature_sheets_link
|
||||
[
|
||||
t("admin.menu.signature_sheets"),
|
||||
admin_signature_sheets_path,
|
||||
controller_name == "signature_sheets",
|
||||
class: "signature-sheets-link"
|
||||
]
|
||||
end
|
||||
|
||||
def messages_links
|
||||
link_to(t("admin.menu.messaging_users"), "#", class: "messages-link") +
|
||||
link_list(
|
||||
newsletters_link,
|
||||
admin_notifications_link,
|
||||
system_emails_link,
|
||||
emails_download_link,
|
||||
id: "messaging_users_menu", class: ("is-active" if messages_menu_active?)
|
||||
)
|
||||
end
|
||||
|
||||
def newsletters_link
|
||||
[
|
||||
t("admin.menu.newsletters"),
|
||||
@@ -141,6 +247,18 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
]
|
||||
end
|
||||
|
||||
def site_customization_links
|
||||
link_to(t("admin.menu.title_site_customization"), "#", class: "site-customization-link") +
|
||||
link_list(
|
||||
homepage_link,
|
||||
pages_link,
|
||||
banners_link,
|
||||
information_texts_link,
|
||||
documents_link,
|
||||
class: ("is-active" if customization? && controller.class.module_parent != Admin::Poll::Questions::Answers)
|
||||
)
|
||||
end
|
||||
|
||||
def homepage_link
|
||||
[
|
||||
t("admin.menu.site_customization.homepage"),
|
||||
@@ -181,6 +299,20 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
]
|
||||
end
|
||||
|
||||
def moderated_content_links
|
||||
link_to(t("admin.menu.title_moderated_content"), "#", class: "moderated-content-link") +
|
||||
link_list(
|
||||
(hidden_proposals_link if feature?(:proposals)),
|
||||
(hidden_debates_link if feature?(:debates)),
|
||||
(hidden_budget_investments_link if feature?(:budgets)),
|
||||
hidden_comments_link,
|
||||
hidden_proposal_notifications_link,
|
||||
hidden_users_link,
|
||||
activity_link,
|
||||
class: ("is-active" if moderated_content?)
|
||||
)
|
||||
end
|
||||
|
||||
def hidden_proposals_link
|
||||
[
|
||||
t("admin.menu.hidden_proposals"),
|
||||
@@ -237,6 +369,21 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
]
|
||||
end
|
||||
|
||||
def profiles_links
|
||||
link_to(t("admin.menu.title_profiles"), "#", class: "profiles-link") +
|
||||
link_list(
|
||||
administrators_link,
|
||||
organizations_link,
|
||||
officials_link,
|
||||
moderators_link,
|
||||
valuators_link,
|
||||
managers_link,
|
||||
(sdg_managers_link if feature?(:sdg)),
|
||||
users_link,
|
||||
class: ("is-active" if profiles?)
|
||||
)
|
||||
end
|
||||
|
||||
def administrators_link
|
||||
[
|
||||
t("admin.menu.administrators"),
|
||||
@@ -293,6 +440,29 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
]
|
||||
end
|
||||
|
||||
def stats_link
|
||||
[
|
||||
t("admin.menu.stats"),
|
||||
admin_stats_path,
|
||||
controller_name == "stats",
|
||||
class: "stats-link"
|
||||
]
|
||||
end
|
||||
|
||||
def settings_links
|
||||
link_to(t("admin.menu.title_settings"), "#", class: "settings-link") +
|
||||
link_list(
|
||||
settings_link,
|
||||
tenants_link,
|
||||
tags_link,
|
||||
geozones_link,
|
||||
images_link,
|
||||
content_blocks_link,
|
||||
local_census_records_link,
|
||||
class: ("is-active" if settings?)
|
||||
)
|
||||
end
|
||||
|
||||
def settings_link
|
||||
[
|
||||
t("admin.menu.settings"),
|
||||
@@ -351,6 +521,24 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
]
|
||||
end
|
||||
|
||||
def dashboard_links
|
||||
link_to(t("admin.menu.dashboard"), "#", class: "dashboard-link") +
|
||||
link_list(
|
||||
dashboard_actions_link,
|
||||
administrator_tasks_link,
|
||||
class: ("is-active" if dashboard?)
|
||||
)
|
||||
end
|
||||
|
||||
def machine_learning_link
|
||||
[
|
||||
t("admin.menu.machine_learning"),
|
||||
admin_machine_learning_path,
|
||||
controller_name == "machine_learning",
|
||||
class: "ml-link"
|
||||
]
|
||||
end
|
||||
|
||||
def administrator_tasks_link
|
||||
[
|
||||
t("admin.menu.administrator_tasks"),
|
||||
|
||||
Reference in New Issue
Block a user