diff --git a/app/components/admin/menu_component.html.erb b/app/components/admin/menu_component.html.erb
index 8aceb6092..0f9b943fd 100644
--- a/app/components/admin/menu_component.html.erb
+++ b/app/components/admin/menu_component.html.erb
@@ -35,28 +35,29 @@
<%= t("admin.menu.title_booths") %>
-
+ <%= link_list(
+ [
+ t("admin.menu.poll_officers"),
+ admin_officers_path,
+ %w[officers officer_assignments].include?(controller_name)
+ ],
+ [
+ t("admin.menu.poll_booths"),
+ admin_booths_path,
+ controller_name == "booths" && action_name != "available"
+ ],
+ [
+ t("admin.menu.poll_booth_assignments"),
+ booth_assignments_admin_polls_path,
+ controller_name == "polls" && action_name == "booth_assignments" || controller_name == "booth_assignments" && action_name == "manage"
+ ],
+ [
+ t("admin.menu.poll_shifts"),
+ available_admin_booths_path,
+ %w[shifts booths].include?(controller_name) && %w[available new].include?(action_name)
+ ],
+ id: "booths_menu", class: ("is-active" if booths?)
+ ) %>
<% if feature?(:signature_sheets) %>
@@ -67,120 +68,151 @@
<%= t("admin.menu.messaging_users") %>
-
+ <%= link_list(
+ [
+ t("admin.menu.newsletters"),
+ admin_newsletters_path,
+ controller_name == "newsletters"
+ ],
+ [
+ t("admin.menu.admin_notifications"),
+ admin_admin_notifications_path,
+ controller_name == "admin_notifications"
+ ],
+ [
+ t("admin.menu.system_emails"),
+ admin_system_emails_path,
+ controller_name == "system_emails"
+ ],
+ [
+ t("admin.menu.emails_download"),
+ admin_emails_download_index_path,
+ controller_name == "emails_download"
+ ],
+ id: "messaging_users_menu", class: ("is-active" if messages_menu_active?)
+ ) %>
<%= t("admin.menu.title_site_customization") %>
- >
-
- - >
- <%= link_to t("admin.menu.site_customization.homepage"), admin_homepage_path %>
-
-
- - >
- <%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
-
-
- - >
- <%= link_to t("admin.menu.banner"), admin_banners_path %>
-
-
- - >
- <%= link_to t("admin.menu.site_customization.information_texts"), admin_site_customization_information_texts_path %>
-
-
- - >
- <%= link_to t("admin.menu.site_customization.documents"),
- admin_site_customization_documents_path %>
-
-
+ <%= link_list(
+ [
+ t("admin.menu.site_customization.homepage"),
+ admin_homepage_path,
+ homepage?
+ ],
+ [
+ t("admin.menu.site_customization.pages"),
+ admin_site_customization_pages_path,
+ pages? || controller_name == "pages"
+ ],
+ [
+ t("admin.menu.banner"),
+ admin_banners_path,
+ controller_name == "banners"
+ ],
+ [
+ t("admin.menu.site_customization.information_texts"),
+ admin_site_customization_information_texts_path,
+ controller_name == "information_texts"
+ ],
+ [
+ t("admin.menu.site_customization.documents"),
+ admin_site_customization_documents_path,
+ controller_name == "documents"
+ ],
+ class: ("is-active" if customization? && controller.class.parent != Admin::Poll::Questions::Answers)
+ ) %>
<%= t("admin.menu.title_moderated_content") %>
- >
- <% if feature?(:proposals) %>
- - >
- <%= link_to t("admin.menu.hidden_proposals"), admin_hidden_proposals_path %>
-
- <% end %>
-
- <% if feature?(:debates) %>
- - >
- <%= link_to t("admin.menu.hidden_debates"), admin_hidden_debates_path %>
-
- <% end %>
-
- <% if feature?(:budgets) %>
- - >
- <%= link_to t("admin.menu.hidden_budget_investments"), admin_hidden_budget_investments_path %>
-
- <% end %>
-
- - >
- <%= link_to t("admin.menu.hidden_comments"), admin_hidden_comments_path %>
-
-
- - >
- <%= link_to t("admin.menu.hidden_proposal_notifications"), admin_hidden_proposal_notifications_path %>
-
-
- - >
- <%= link_to t("admin.menu.hidden_users"), admin_hidden_users_path %>
-
-
- - >
- <%= link_to t("admin.menu.activity"), admin_activity_path %>
-
-
+ <%= link_list(
+ (
+ [
+ t("admin.menu.hidden_proposals"),
+ admin_hidden_proposals_path,
+ controller_name == "hidden_proposals"
+ ] if feature?(:proposals)
+ ),
+ (
+ [
+ t("admin.menu.hidden_debates"),
+ admin_hidden_debates_path,
+ controller_name == "hidden_debates"
+ ] if feature?(:debates)
+ ),
+ (
+ [
+ t("admin.menu.hidden_budget_investments"),
+ admin_hidden_budget_investments_path,
+ controller_name == "hidden_budget_investments"
+ ] if feature?(:budgets)
+ ),
+ [
+ t("admin.menu.hidden_comments"),
+ admin_hidden_comments_path,
+ controller_name == "hidden_comments"
+ ],
+ [
+ t("admin.menu.hidden_proposal_notifications"),
+ admin_hidden_proposal_notifications_path,
+ controller_name == "hidden_proposal_notifications"
+ ],
+ [
+ t("admin.menu.hidden_users"),
+ admin_hidden_users_path,
+ controller_name == "hidden_users"
+ ],
+ [
+ t("admin.menu.activity"),
+ admin_activity_path,
+ controller_name == "activity"
+ ],
+ class: ("is-active" if moderated_content?)
+ ) %>
<%= t("admin.menu.title_profiles") %>
- >
- - >
- <%= link_to t("admin.menu.administrators"), admin_administrators_path %>
-
-
- - >
- <%= link_to t("admin.menu.organizations"), admin_organizations_path %>
-
-
- - >
- <%= link_to t("admin.menu.officials"), admin_officials_path %>
-
-
- - >
- <%= link_to t("admin.menu.moderators"), admin_moderators_path %>
-
-
- - >
- <%= link_to t("admin.menu.valuators"), admin_valuators_path %>
-
-
- - >
- <%= link_to t("admin.menu.managers"), admin_managers_path %>
-
-
- - >
- <%= link_to t("admin.menu.users"), admin_users_path %>
-
-
+ <%= link_list(
+ [
+ t("admin.menu.administrators"),
+ admin_administrators_path,
+ controller_name == "administrators"
+ ],
+ [
+ t("admin.menu.organizations"),
+ admin_organizations_path,
+ controller_name == "organizations"
+ ],
+ [
+ t("admin.menu.officials"),
+ admin_officials_path,
+ controller_name == "officials"
+ ],
+ [
+ t("admin.menu.moderators"),
+ admin_moderators_path,
+ controller_name == "moderators"
+ ],
+ [
+ t("admin.menu.valuators"),
+ admin_valuators_path,
+ controller_name == "valuators"
+ ],
+ [
+ t("admin.menu.managers"),
+ admin_managers_path,
+ controller_name == "managers"
+ ],
+ [
+ t("admin.menu.users"),
+ admin_users_path,
+ controller_name == "users"
+ ],
+ class: ("is-active" if profiles?)
+ ) %>
">
@@ -189,45 +221,54 @@
<%= t("admin.menu.title_settings") %>
- >
- - >
- <%= link_to t("admin.menu.settings"), admin_settings_path %>
-
-
- - >
- <%= link_to t("admin.menu.proposals_topics"), admin_tags_path %>
-
-
- - >
- <%= link_to t("admin.menu.geozones"), admin_geozones_path %>
-
-
- - >
- <%= link_to t("admin.menu.site_customization.images"), admin_site_customization_images_path %>
-
-
- - >
- <%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path %>
-
-
- - >
- <%= link_to t("admin.menu.local_census_records"), admin_local_census_records_path %>
-
-
+ <%= link_list(
+ [
+ t("admin.menu.settings"),
+ admin_settings_path,
+ controller_name == "settings"
+ ],
+ [
+ t("admin.menu.proposals_topics"),
+ admin_tags_path,
+ controller_name == "tags"
+ ],
+ [
+ t("admin.menu.geozones"),
+ admin_geozones_path,
+ controller_name == "geozones"
+ ],
+ [
+ t("admin.menu.site_customization.images"),
+ admin_site_customization_images_path,
+ controller_name == "images" && controller.class.parent != Admin::Poll::Questions::Answers
+ ],
+ [
+ t("admin.menu.site_customization.content_blocks"),
+ admin_site_customization_content_blocks_path,
+ controller_name == "content_blocks"
+ ],
+ [
+ t("admin.menu.local_census_records"),
+ admin_local_census_records_path,
+ local_census_records?
+ ],
+ class: ("is-active" if settings?)
+ ) %>
<%= t("admin.menu.dashboard") %>
- >
- - >
- <%= link_to t("admin.menu.dashboard_actions"), admin_dashboard_actions_path %>
-
-
- - >
- <%= link_to admin_dashboard_administrator_tasks_path do %>
- <%= t("admin.menu.administrator_tasks") %>
- <% end %>
-
-
+ <%= link_list(
+ [
+ t("admin.menu.dashboard_actions"),
+ admin_dashboard_actions_path,
+ controller_name == "actions"
+ ],
+ [
+ t("admin.menu.administrator_tasks"),
+ admin_dashboard_administrator_tasks_path,
+ controller_name == "administrator_tasks"
+ ],
+ class: ("is-active" if dashboard?)
+ ) %>
diff --git a/app/components/admin/menu_component.rb b/app/components/admin/menu_component.rb
index 6b5fba296..7e4a70c88 100644
--- a/app/components/admin/menu_component.rb
+++ b/app/components/admin/menu_component.rb
@@ -1,4 +1,6 @@
class Admin::MenuComponent < ApplicationComponent
+ include LinkListHelper
+
private
def moderated_content?
diff --git a/app/components/sdg_management/menu_component.html.erb b/app/components/sdg_management/menu_component.html.erb
index bd5783962..f786d0733 100644
--- a/app/components/sdg_management/menu_component.html.erb
+++ b/app/components/sdg_management/menu_component.html.erb
@@ -1,5 +1,9 @@
-
+<%= link_list(
+ [
+ t("sdg_management.menu.sdg_content"),
+ sdg_management_goals_path,
+ sdg?,
+ class: "goals-link"
+ ],
+ class: "sdg-content-menu"
+) %>
diff --git a/app/components/sdg_management/menu_component.rb b/app/components/sdg_management/menu_component.rb
index 7c22e27c2..c594bd081 100644
--- a/app/components/sdg_management/menu_component.rb
+++ b/app/components/sdg_management/menu_component.rb
@@ -1,4 +1,6 @@
class SDGManagement::MenuComponent < ApplicationComponent
+ include LinkListHelper
+
private
def sdg?
diff --git a/app/helpers/link_list_helper.rb b/app/helpers/link_list_helper.rb
index 5c38bf042..2fdfab0a0 100644
--- a/app/helpers/link_list_helper.rb
+++ b/app/helpers/link_list_helper.rb
@@ -3,8 +3,8 @@ module LinkListHelper
return "" if links.compact.empty?
tag.ul(options) do
- safe_join(links.compact.map do |text, url, **link_options|
- tag.li do
+ safe_join(links.compact.map do |text, url, is_active = false, **link_options|
+ tag.li(class: ("is-active" if is_active)) do
link_to text, url, link_options
end
end)
diff --git a/app/views/management/_menu.html.erb b/app/views/management/_menu.html.erb
index 5078a8950..42fa308a0 100644
--- a/app/views/management/_menu.html.erb
+++ b/app/views/management/_menu.html.erb
@@ -1,41 +1,50 @@
+ <%= link_list(
+ [
+ t("management.menu.select_user"),
+ management_document_verifications_path,
+ menu_users?
+ ],
+ (
+ [
+ t("management.account.menu.reset_password_email"),
+ edit_password_email_management_account_path,
+ menu_edit_password_email?
+ ] if managed_user.email
+ ),
+ [
+ t("management.account.menu.reset_password_manually"),
+ edit_password_manually_management_account_path,
+ menu_edit_password_manually?
+ ],
+ [
+ t("management.menu.create_proposal"),
+ new_management_proposal_path,
+ menu_create_proposal?
+ ],
+ [
+ t("management.menu.support_proposals"),
+ management_proposals_path,
+ menu_support_proposal?
+ ],
+ (
+ [
+ t("management.menu.create_budget_investment"),
+ create_investments_management_budgets_path,
+ menu_create_investments?
+ ] if Setting["process.budgets"]
+ ),
+ (
+ [
+ t("management.menu.support_budget_investments"),
+ support_investments_management_budgets_path,
+ menu_support_investments?
+ ] if Setting["process.budgets"]
+ ),
+ class: "is-active"
+ ) %>
<% if Setting["process.budgets"] %>
diff --git a/app/views/moderation/_menu.html.erb b/app/views/moderation/_menu.html.erb
index f7ebe5e8f..3bcbb539e 100644
--- a/app/views/moderation/_menu.html.erb
+++ b/app/views/moderation/_menu.html.erb
@@ -1,35 +1,48 @@
-
+<%= link_list(
+ [t("moderation.dashboard.index.title"), moderation_root_path],
+ (
+ [
+ t("moderation.menu.proposals"),
+ moderation_proposals_path,
+ controller_name == "proposals",
+ class: "proposals-link"
+ ] if feature?(:proposals)
+ ),
+ (
+ [
+ t("moderation.menu.proposal_notifications"),
+ moderation_proposal_notifications_path,
+ controller_name == "proposal_notifications",
+ class: "proposal-notifications-link"
+ ] if feature?(:proposals)
+ ),
+ (
+ [
+ t("moderation.menu.flagged_debates"),
+ moderation_debates_path,
+ controller_name == "debates",
+ class: "debates-link"
+ ] if feature?(:debates)
+ ),
+ (
+ [
+ t("moderation.menu.flagged_investments"),
+ moderation_budget_investments_path,
+ controller_name == "investments",
+ class: "investments-link"
+ ] if feature?(:budgets)
+ ),
+ [
+ t("moderation.menu.flagged_comments"),
+ moderation_comments_path,
+ controller_name == "comments",
+ class: "comments-link"
+ ],
+ [
+ t("moderation.menu.users"),
+ moderation_users_path,
+ controller_name == "users",
+ class: "users-link"
+ ],
+ id: "moderation_menu"
+) %>
diff --git a/app/views/valuation/_menu.html.erb b/app/views/valuation/_menu.html.erb
index dddb16c35..a29fc1556 100644
--- a/app/views/valuation/_menu.html.erb
+++ b/app/views/valuation/_menu.html.erb
@@ -1,11 +1,5 @@
-
+<%= link_list(
+ [t("valuation.menu.title"), valuation_root_path],
+ [t("valuation.menu.budgets"), valuation_budgets_path, controller_name == "budget_investments", class: "budgets-link"],
+ id: "valuation_menu"
+) %>
diff --git a/spec/helpers/link_list_helper_spec.rb b/spec/helpers/link_list_helper_spec.rb
index a6c4af0b3..e7e238201 100644
--- a/spec/helpers/link_list_helper_spec.rb
+++ b/spec/helpers/link_list_helper_spec.rb
@@ -32,6 +32,32 @@ describe LinkListHelper do
expect(page).to have_css "a.root", count: 1, exact_text: "Home"
expect(page).to have_css "a#info", count: 1, exact_text: "Info"
end
+
+ it "accepts an optional condition to check the active element" do
+ render helper.link_list(
+ ["Home", "/", false],
+ ["Info", "/info", true],
+ ["Help", "/help"]
+ )
+
+ expect(page).to have_css "li", count: 3
+ expect(page).to have_css "li.is-active", count: 1, exact_text: "Info"
+ end
+
+ it "allows passing both the active condition and link options" do
+ render helper.link_list(
+ ["Home", "/", false, class: "root"],
+ ["Info", "/info", true, id: "info"],
+ ["Help", "/help", rel: "help"]
+ )
+
+ expect(page).to have_css "li", count: 3
+ expect(page).to have_css "li.is-active", count: 1, exact_text: "Info"
+
+ expect(page).to have_css "a.root", count: 1, exact_text: "Home"
+ expect(page).to have_css "a#info", count: 1, exact_text: "Info"
+ expect(page).to have_css "a[rel='help']", count: 1, exact_text: "Help"
+ end
end
attr_reader :content