Merge pull request #4279 from consul/link_list
Simplify generating lists of links
This commit is contained in:
@@ -117,7 +117,8 @@
|
|||||||
padding-left: $line-height / 2;
|
padding-left: $line-height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-active a {
|
&.is-active a,
|
||||||
|
&[aria-current] a {
|
||||||
background: $sidebar-hover;
|
background: $sidebar-hover;
|
||||||
border-left: 2px solid $sidebar-active;
|
border-left: 2px solid $sidebar-active;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<ul id="admin_menu" data-accordion-menu data-multi-open="true">
|
<ul id="admin_menu" data-accordion-menu data-multi-open="true">
|
||||||
<% if feature?(:proposals) %>
|
<% if feature?(:proposals) %>
|
||||||
<li>
|
<li class="<%= "is-active" if controller_name == "proposals" %>">
|
||||||
<%= link_to t("admin.menu.proposals"), admin_proposals_path, class: "proposals-link" %>
|
<%= link_to t("admin.menu.proposals"), admin_proposals_path, class: "proposals-link" %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -35,28 +35,13 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="booths-link"><%= t("admin.menu.title_booths") %></a>
|
<a href="#" class="booths-link"><%= t("admin.menu.title_booths") %></a>
|
||||||
<ul id="booths_menu" <%= "class=is-active" if booths? %>>
|
<%= link_list(
|
||||||
<li <%= "class=is-active" if %w[officers officer_assignments].include?(controller_name) %>>
|
officers_link,
|
||||||
<%= link_to t("admin.menu.poll_officers"), admin_officers_path %>
|
booths_link,
|
||||||
</li>
|
booth_assignments_link,
|
||||||
|
shifts_link,
|
||||||
<li <%= "class=is-active" if controller_name == "booths" &&
|
id: "booths_menu", class: ("is-active" if booths?)
|
||||||
action_name != "available" %>>
|
) %>
|
||||||
<%= link_to t("admin.menu.poll_booths"), admin_booths_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if (controller_name == "polls" &&
|
|
||||||
action_name == "booth_assignments") ||
|
|
||||||
controller_name == "booth_assignments" &&
|
|
||||||
action_name == "manage" %>>
|
|
||||||
<%= link_to t("admin.menu.poll_booth_assignments"), booth_assignments_admin_polls_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if %w[shifts booths].include?(controller_name) &&
|
|
||||||
%w[available new].include?(action_name) %>>
|
|
||||||
<%= link_to t("admin.menu.poll_shifts"), available_admin_booths_path %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<% if feature?(:signature_sheets) %>
|
<% if feature?(:signature_sheets) %>
|
||||||
@@ -67,120 +52,53 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="messages-link"><%= t("admin.menu.messaging_users") %></a>
|
<a href="#" class="messages-link"><%= t("admin.menu.messaging_users") %></a>
|
||||||
<ul id="messaging_users_menu" <%= "class=is-active" if messages_menu_active? %>>
|
<%= link_list(
|
||||||
<li <%= "class=is-active" if controller_name == "newsletters" %>>
|
newsletters_link,
|
||||||
<%= link_to t("admin.menu.newsletters"), admin_newsletters_path %>
|
admin_notifications_link,
|
||||||
</li>
|
system_emails_link,
|
||||||
<li <%= "class=is-active" if controller_name == "admin_notifications" %>>
|
emails_download_link,
|
||||||
<%= link_to t("admin.menu.admin_notifications"), admin_admin_notifications_path %>
|
id: "messaging_users_menu", class: ("is-active" if messages_menu_active?)
|
||||||
</li>
|
) %>
|
||||||
<li <%= "class=is-active" if controller_name == "system_emails" %>>
|
|
||||||
<%= link_to t("admin.menu.system_emails"), admin_system_emails_path %>
|
|
||||||
</li>
|
|
||||||
<li <%= "class=is-active" if controller_name == "emails_download" %>>
|
|
||||||
<%= link_to t("admin.menu.emails_download"), admin_emails_download_index_path %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="site-customization-link"><%= t("admin.menu.title_site_customization") %></a>
|
<a href="#" class="site-customization-link"><%= t("admin.menu.title_site_customization") %></a>
|
||||||
<ul <%= "class=is-active" if customization? &&
|
<%= link_list(
|
||||||
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
homepage_link,
|
||||||
|
pages_link,
|
||||||
<li <%= "class=is-active" if homepage? %>>
|
banners_link,
|
||||||
<%= link_to t("admin.menu.site_customization.homepage"), admin_homepage_path %>
|
information_texts_link,
|
||||||
</li>
|
documents_link,
|
||||||
|
class: ("is-active" if customization? && controller.class.parent != Admin::Poll::Questions::Answers)
|
||||||
<li <%= "class=is-active" if pages? || controller_name == "pages" %>>
|
) %>
|
||||||
<%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "banners" %>>
|
|
||||||
<%= link_to t("admin.menu.banner"), admin_banners_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "information_texts" %>>
|
|
||||||
<%= link_to t("admin.menu.site_customization.information_texts"), admin_site_customization_information_texts_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "documents" %>>
|
|
||||||
<%= link_to t("admin.menu.site_customization.documents"),
|
|
||||||
admin_site_customization_documents_path %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="moderated-content-link"><%= t("admin.menu.title_moderated_content") %></a>
|
<a href="#" class="moderated-content-link"><%= t("admin.menu.title_moderated_content") %></a>
|
||||||
<ul <%= "class=is-active" if moderated_content? %>>
|
<%= link_list(
|
||||||
<% if feature?(:proposals) %>
|
(hidden_proposals_link if feature?(:proposals)),
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_proposals" %>>
|
(hidden_debates_link if feature?(:debates)),
|
||||||
<%= link_to t("admin.menu.hidden_proposals"), admin_hidden_proposals_path %>
|
(hidden_budget_investments_link if feature?(:budgets)),
|
||||||
</li>
|
hidden_comments_link,
|
||||||
<% end %>
|
hidden_proposal_notifications_link,
|
||||||
|
hidden_users_link,
|
||||||
<% if feature?(:debates) %>
|
activity_link,
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_debates" %>>
|
class: ("is-active" if moderated_content?)
|
||||||
<%= link_to t("admin.menu.hidden_debates"), admin_hidden_debates_path %>
|
) %>
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if feature?(:budgets) %>
|
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_budget_investments" %>>
|
|
||||||
<%= link_to t("admin.menu.hidden_budget_investments"), admin_hidden_budget_investments_path %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_comments" %>>
|
|
||||||
<%= link_to t("admin.menu.hidden_comments"), admin_hidden_comments_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_proposal_notifications" %>>
|
|
||||||
<%= link_to t("admin.menu.hidden_proposal_notifications"), admin_hidden_proposal_notifications_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_users" %>>
|
|
||||||
<%= link_to t("admin.menu.hidden_users"), admin_hidden_users_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "activity" %>>
|
|
||||||
<%= link_to t("admin.menu.activity"), admin_activity_path %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="profiles-link"><%= t("admin.menu.title_profiles") %></a>
|
<a href="#" class="profiles-link"><%= t("admin.menu.title_profiles") %></a>
|
||||||
<ul <%= "class=is-active" if profiles? %>>
|
<%= link_list(
|
||||||
<li <%= "class=is-active" if controller_name == "administrators" %>>
|
administrators_link,
|
||||||
<%= link_to t("admin.menu.administrators"), admin_administrators_path %>
|
organizations_link,
|
||||||
</li>
|
officials_link,
|
||||||
|
moderators_link,
|
||||||
<li <%= "class=is-active" if controller_name == "organizations" %>>
|
valuators_link,
|
||||||
<%= link_to t("admin.menu.organizations"), admin_organizations_path %>
|
managers_link,
|
||||||
</li>
|
users_link,
|
||||||
|
class: ("is-active" if profiles?)
|
||||||
<li <%= "class=is-active" if controller_name == "officials" %>>
|
) %>
|
||||||
<%= link_to t("admin.menu.officials"), admin_officials_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "moderators" %>>
|
|
||||||
<%= link_to t("admin.menu.moderators"), admin_moderators_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "valuators" %>>
|
|
||||||
<%= link_to t("admin.menu.valuators"), admin_valuators_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "managers" %>>
|
|
||||||
<%= link_to t("admin.menu.managers"), admin_managers_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "users" %>>
|
|
||||||
<%= link_to t("admin.menu.users"), admin_users_path %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="<%= "is-active" if controller_name == "stats" %>">
|
<li class="<%= "is-active" if controller_name == "stats" %>">
|
||||||
@@ -189,45 +107,22 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="settings-link"><%= t("admin.menu.title_settings") %></a>
|
<a href="#" class="settings-link"><%= t("admin.menu.title_settings") %></a>
|
||||||
<ul <%= "class=is-active" if settings? %>>
|
<%= link_list(
|
||||||
<li <%= "class=is-active" if controller_name == "settings" %>>
|
settings_link,
|
||||||
<%= link_to t("admin.menu.settings"), admin_settings_path %>
|
tags_link,
|
||||||
</li>
|
geozones_link,
|
||||||
|
images_link,
|
||||||
<li <%= "class=is-active" if controller_name == "tags" %>>
|
content_blocks_link,
|
||||||
<%= link_to t("admin.menu.proposals_topics"), admin_tags_path %>
|
local_census_records_link,
|
||||||
</li>
|
class: ("is-active" if settings?)
|
||||||
|
) %>
|
||||||
<li <%= "class=is-active" if controller_name == "geozones" %>>
|
|
||||||
<%= link_to t("admin.menu.geozones"), admin_geozones_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "images" &&
|
|
||||||
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
|
||||||
<%= link_to t("admin.menu.site_customization.images"), admin_site_customization_images_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if controller_name == "content_blocks" %>>
|
|
||||||
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=is-active" if local_census_records? %>>
|
|
||||||
<%= link_to t("admin.menu.local_census_records"), admin_local_census_records_path %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="dashboard-link"><%= t("admin.menu.dashboard") %></a>
|
<a href="#" class="dashboard-link"><%= t("admin.menu.dashboard") %></a>
|
||||||
<ul <%= "class=is-active" if dashboard? %>>
|
<%= link_list(
|
||||||
<li <%= "class=is-active" if controller_name == "actions" %>>
|
dashboard_actions_link,
|
||||||
<%= link_to t("admin.menu.dashboard_actions"), admin_dashboard_actions_path %>
|
administrator_tasks_link,
|
||||||
</li>
|
class: ("is-active" if dashboard?)
|
||||||
|
) %>
|
||||||
<li <%= "class=is-active" if controller_name == "administrator_tasks" %>>
|
|
||||||
<%= link_to admin_dashboard_administrator_tasks_path do %>
|
|
||||||
<%= t("admin.menu.administrator_tasks") %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class Admin::MenuComponent < ApplicationComponent
|
class Admin::MenuComponent < ApplicationComponent
|
||||||
|
include LinkListHelper
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def moderated_content?
|
def moderated_content?
|
||||||
@@ -65,4 +67,284 @@ class Admin::MenuComponent < ApplicationComponent
|
|||||||
def messages_sections
|
def messages_sections
|
||||||
%w[newsletters emails_download admin_notifications system_emails]
|
%w[newsletters emails_download admin_notifications system_emails]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def officers_link
|
||||||
|
[
|
||||||
|
t("admin.menu.poll_officers"),
|
||||||
|
admin_officers_path,
|
||||||
|
%w[officers officer_assignments].include?(controller_name)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def booths_link
|
||||||
|
[
|
||||||
|
t("admin.menu.poll_booths"),
|
||||||
|
admin_booths_path,
|
||||||
|
controller_name == "booths" && action_name != "available"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def booth_assignments_link
|
||||||
|
[
|
||||||
|
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"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def shifts_link
|
||||||
|
[
|
||||||
|
t("admin.menu.poll_shifts"),
|
||||||
|
available_admin_booths_path,
|
||||||
|
%w[shifts booths].include?(controller_name) && %w[available new].include?(action_name)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def newsletters_link
|
||||||
|
[
|
||||||
|
t("admin.menu.newsletters"),
|
||||||
|
admin_newsletters_path,
|
||||||
|
controller_name == "newsletters"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def admin_notifications_link
|
||||||
|
[
|
||||||
|
t("admin.menu.admin_notifications"),
|
||||||
|
admin_admin_notifications_path,
|
||||||
|
controller_name == "admin_notifications"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def system_emails_link
|
||||||
|
[
|
||||||
|
t("admin.menu.system_emails"),
|
||||||
|
admin_system_emails_path,
|
||||||
|
controller_name == "system_emails"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def emails_download_link
|
||||||
|
[
|
||||||
|
t("admin.menu.emails_download"),
|
||||||
|
admin_emails_download_index_path,
|
||||||
|
controller_name == "emails_download"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def homepage_link
|
||||||
|
[
|
||||||
|
t("admin.menu.site_customization.homepage"),
|
||||||
|
admin_homepage_path,
|
||||||
|
homepage?
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def pages_link
|
||||||
|
[
|
||||||
|
t("admin.menu.site_customization.pages"),
|
||||||
|
admin_site_customization_pages_path,
|
||||||
|
pages? || controller_name == "pages"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def banners_link
|
||||||
|
[
|
||||||
|
t("admin.menu.banner"),
|
||||||
|
admin_banners_path,
|
||||||
|
controller_name == "banners"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def information_texts_link
|
||||||
|
[
|
||||||
|
t("admin.menu.site_customization.information_texts"),
|
||||||
|
admin_site_customization_information_texts_path,
|
||||||
|
controller_name == "information_texts"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def documents_link
|
||||||
|
[
|
||||||
|
t("admin.menu.site_customization.documents"),
|
||||||
|
admin_site_customization_documents_path,
|
||||||
|
controller_name == "documents"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_proposals_link
|
||||||
|
[
|
||||||
|
t("admin.menu.hidden_proposals"),
|
||||||
|
admin_hidden_proposals_path,
|
||||||
|
controller_name == "hidden_proposals"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_debates_link
|
||||||
|
[
|
||||||
|
t("admin.menu.hidden_debates"),
|
||||||
|
admin_hidden_debates_path,
|
||||||
|
controller_name == "hidden_debates"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_budget_investments_link
|
||||||
|
[
|
||||||
|
t("admin.menu.hidden_budget_investments"),
|
||||||
|
admin_hidden_budget_investments_path,
|
||||||
|
controller_name == "hidden_budget_investments"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_comments_link
|
||||||
|
[
|
||||||
|
t("admin.menu.hidden_comments"),
|
||||||
|
admin_hidden_comments_path,
|
||||||
|
controller_name == "hidden_comments"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_proposal_notifications_link
|
||||||
|
[
|
||||||
|
t("admin.menu.hidden_proposal_notifications"),
|
||||||
|
admin_hidden_proposal_notifications_path,
|
||||||
|
controller_name == "hidden_proposal_notifications"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_users_link
|
||||||
|
[
|
||||||
|
t("admin.menu.hidden_users"),
|
||||||
|
admin_hidden_users_path,
|
||||||
|
controller_name == "hidden_users"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def activity_link
|
||||||
|
[
|
||||||
|
t("admin.menu.activity"),
|
||||||
|
admin_activity_path,
|
||||||
|
controller_name == "activity"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def administrators_link
|
||||||
|
[
|
||||||
|
t("admin.menu.administrators"),
|
||||||
|
admin_administrators_path,
|
||||||
|
controller_name == "administrators"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def organizations_link
|
||||||
|
[
|
||||||
|
t("admin.menu.organizations"),
|
||||||
|
admin_organizations_path,
|
||||||
|
controller_name == "organizations"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def officials_link
|
||||||
|
[
|
||||||
|
t("admin.menu.officials"),
|
||||||
|
admin_officials_path,
|
||||||
|
controller_name == "officials"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def moderators_link
|
||||||
|
[
|
||||||
|
t("admin.menu.moderators"),
|
||||||
|
admin_moderators_path,
|
||||||
|
controller_name == "moderators"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def valuators_link
|
||||||
|
[
|
||||||
|
t("admin.menu.valuators"),
|
||||||
|
admin_valuators_path,
|
||||||
|
controller_name == "valuators"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def managers_link
|
||||||
|
[
|
||||||
|
t("admin.menu.managers"),
|
||||||
|
admin_managers_path,
|
||||||
|
controller_name == "managers"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def users_link
|
||||||
|
[
|
||||||
|
t("admin.menu.users"),
|
||||||
|
admin_users_path,
|
||||||
|
controller_name == "users"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def settings_link
|
||||||
|
[
|
||||||
|
t("admin.menu.settings"),
|
||||||
|
admin_settings_path,
|
||||||
|
controller_name == "settings"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def tags_link
|
||||||
|
[
|
||||||
|
t("admin.menu.proposals_topics"),
|
||||||
|
admin_tags_path,
|
||||||
|
controller_name == "tags"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def geozones_link
|
||||||
|
[
|
||||||
|
t("admin.menu.geozones"),
|
||||||
|
admin_geozones_path,
|
||||||
|
controller_name == "geozones"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def images_link
|
||||||
|
[
|
||||||
|
t("admin.menu.site_customization.images"),
|
||||||
|
admin_site_customization_images_path,
|
||||||
|
controller_name == "images" && controller.class.parent != Admin::Poll::Questions::Answers
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def content_blocks_link
|
||||||
|
[
|
||||||
|
t("admin.menu.site_customization.content_blocks"),
|
||||||
|
admin_site_customization_content_blocks_path,
|
||||||
|
controller_name == "content_blocks"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def local_census_records_link
|
||||||
|
[
|
||||||
|
t("admin.menu.local_census_records"),
|
||||||
|
admin_local_census_records_path,
|
||||||
|
local_census_records?
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def administrator_tasks_link
|
||||||
|
[
|
||||||
|
t("admin.menu.administrator_tasks"),
|
||||||
|
admin_dashboard_administrator_tasks_path,
|
||||||
|
controller_name == "administrator_tasks"
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def dashboard_actions_link
|
||||||
|
[
|
||||||
|
t("admin.menu.dashboard_actions"),
|
||||||
|
admin_dashboard_actions_path,
|
||||||
|
controller_name == "actions"
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<ul class="sdg-content-menu">
|
<%= link_list(
|
||||||
<li class="<%= "is-active" if sdg? %>">
|
[
|
||||||
<%= link_to t("sdg_management.menu.sdg_content"), sdg_management_goals_path, class: "goals-link" %>
|
t("sdg_management.menu.sdg_content"),
|
||||||
</li>
|
sdg_management_goals_path,
|
||||||
</ul>
|
sdg?,
|
||||||
|
class: "goals-link"
|
||||||
|
],
|
||||||
|
class: "sdg-content-menu"
|
||||||
|
) %>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class SDGManagement::MenuComponent < ApplicationComponent
|
class SDGManagement::MenuComponent < ApplicationComponent
|
||||||
|
include LinkListHelper
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sdg?
|
def sdg?
|
||||||
|
|||||||
13
app/helpers/link_list_helper.rb
Normal file
13
app/helpers/link_list_helper.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module LinkListHelper
|
||||||
|
def link_list(*links, **options)
|
||||||
|
return "" if links.compact.empty?
|
||||||
|
|
||||||
|
tag.ul(options) do
|
||||||
|
safe_join(links.compact.map do |text, url, current = false, **link_options|
|
||||||
|
tag.li(({ "aria-current": true } if current)) do
|
||||||
|
link_to text, url, link_options
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1 +0,0 @@
|
|||||||
<%= render "admin/menu" %>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<%= render "admin/menu" %>
|
|
||||||
@@ -1,41 +1,50 @@
|
|||||||
<ul id="admin_menu" data-accordion-menu>
|
<ul id="admin_menu" data-accordion-menu>
|
||||||
<li class="section-title">
|
<li class="section-title">
|
||||||
<a href="#" class="users-link"><%= t("management.menu.users") %></a>
|
<a href="#" class="users-link"><%= t("management.menu.users") %></a>
|
||||||
<ul class="is-active">
|
<%= link_list(
|
||||||
|
[
|
||||||
<li <%= "class=is-active" if menu_users? %>>
|
t("management.menu.select_user"),
|
||||||
<%= link_to t("management.menu.select_user"), management_document_verifications_path %>
|
management_document_verifications_path,
|
||||||
</li>
|
menu_users?
|
||||||
|
],
|
||||||
<% if managed_user.email %>
|
(
|
||||||
<li <%= "class=is-active" if menu_edit_password_email? %>>
|
[
|
||||||
<%= link_to t("management.account.menu.reset_password_email"), edit_password_email_management_account_path %>
|
t("management.account.menu.reset_password_email"),
|
||||||
</li>
|
edit_password_email_management_account_path,
|
||||||
<% end %>
|
menu_edit_password_email?
|
||||||
|
] if managed_user.email
|
||||||
<li <%= "class=is-active" if menu_edit_password_manually? %>>
|
),
|
||||||
<%= link_to t("management.account.menu.reset_password_manually"), edit_password_manually_management_account_path %>
|
[
|
||||||
</li>
|
t("management.account.menu.reset_password_manually"),
|
||||||
|
edit_password_manually_management_account_path,
|
||||||
<li <%= "class=is-active" if menu_create_proposal? %>>
|
menu_edit_password_manually?
|
||||||
<%= link_to t("management.menu.create_proposal"), new_management_proposal_path %>
|
],
|
||||||
</li>
|
[
|
||||||
|
t("management.menu.create_proposal"),
|
||||||
<li <%= "class=is-active" if menu_support_proposal? %>>
|
new_management_proposal_path,
|
||||||
<%= link_to t("management.menu.support_proposals"), management_proposals_path %>
|
menu_create_proposal?
|
||||||
</li>
|
],
|
||||||
|
[
|
||||||
<% if Setting["process.budgets"] %>
|
t("management.menu.support_proposals"),
|
||||||
<li <%= "class=is-active" if menu_create_investments? %>>
|
management_proposals_path,
|
||||||
<%= link_to t("management.menu.create_budget_investment"), create_investments_management_budgets_path %>
|
menu_support_proposal?
|
||||||
</li>
|
],
|
||||||
|
(
|
||||||
<li <%= "class=is-active" if menu_support_investments? %>>
|
[
|
||||||
<%= link_to t("management.menu.support_budget_investments"), support_investments_management_budgets_path %>
|
t("management.menu.create_budget_investment"),
|
||||||
</li>
|
create_investments_management_budgets_path,
|
||||||
<% end %>
|
menu_create_investments?
|
||||||
</li>
|
] if Setting["process.budgets"]
|
||||||
</ul>
|
),
|
||||||
|
(
|
||||||
|
[
|
||||||
|
t("management.menu.support_budget_investments"),
|
||||||
|
support_investments_management_budgets_path,
|
||||||
|
menu_support_investments?
|
||||||
|
] if Setting["process.budgets"]
|
||||||
|
),
|
||||||
|
class: "is-active"
|
||||||
|
) %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<% if Setting["process.budgets"] %>
|
<% if Setting["process.budgets"] %>
|
||||||
|
|||||||
@@ -1,35 +1,48 @@
|
|||||||
<ul id="moderation_menu">
|
<%= link_list(
|
||||||
<li>
|
[t("moderation.dashboard.index.title"), moderation_root_path],
|
||||||
<%= link_to t("moderation.dashboard.index.title"), moderation_root_path %>
|
(
|
||||||
</li>
|
[
|
||||||
|
t("moderation.menu.proposals"),
|
||||||
<% if feature?(:proposals) %>
|
moderation_proposals_path,
|
||||||
<li <%= "class=is-active" if controller_name == "proposals" %>>
|
controller_name == "proposals",
|
||||||
<%= link_to t("moderation.menu.proposals"), moderation_proposals_path, class: "proposals-link" %>
|
class: "proposals-link"
|
||||||
</li>
|
] if feature?(:proposals)
|
||||||
|
),
|
||||||
<li <%= "class=is-active" if controller_name == "proposal_notifications" %>>
|
(
|
||||||
<%= link_to t("moderation.menu.proposal_notifications"), moderation_proposal_notifications_path, class: "proposal-notifications-link" %>
|
[
|
||||||
</li>
|
t("moderation.menu.proposal_notifications"),
|
||||||
<% end %>
|
moderation_proposal_notifications_path,
|
||||||
|
controller_name == "proposal_notifications",
|
||||||
<% if feature?(:debates) %>
|
class: "proposal-notifications-link"
|
||||||
<li <%= "class=is-active" if controller_name == "debates" %>>
|
] if feature?(:proposals)
|
||||||
<%= link_to t("moderation.menu.flagged_debates"), moderation_debates_path, class: "debates-link" %>
|
),
|
||||||
</li>
|
(
|
||||||
<% end %>
|
[
|
||||||
|
t("moderation.menu.flagged_debates"),
|
||||||
<% if feature?(:budgets) %>
|
moderation_debates_path,
|
||||||
<li <%= "class=is-active" if controller_name == "investments" %>>
|
controller_name == "debates",
|
||||||
<%= link_to t("moderation.menu.flagged_investments"), moderation_budget_investments_path, class: "investments-link" %>
|
class: "debates-link"
|
||||||
</li>
|
] if feature?(:debates)
|
||||||
<% end %>
|
),
|
||||||
|
(
|
||||||
<li <%= "class=is-active" if controller_name == "comments" %>>
|
[
|
||||||
<%= link_to t("moderation.menu.flagged_comments"), moderation_comments_path, class: "comments-link" %>
|
t("moderation.menu.flagged_investments"),
|
||||||
</li>
|
moderation_budget_investments_path,
|
||||||
|
controller_name == "investments",
|
||||||
<li <%= "class=is-active" if controller_name == "users" %>>
|
class: "investments-link"
|
||||||
<%= link_to t("moderation.menu.users"), moderation_users_path, class: "users-link" %>
|
] if feature?(:budgets)
|
||||||
</li>
|
),
|
||||||
</ul>
|
[
|
||||||
|
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"
|
||||||
|
) %>
|
||||||
|
|||||||
@@ -1,34 +1,47 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<ul class="menu-pages" data-magellan>
|
<%= link_list(
|
||||||
<% if feature?(:debates) %>
|
(
|
||||||
<li>
|
[
|
||||||
<%= link_to t("pages.help.menu.debates"), "#debates", class: "button hollow expanded" %>
|
t("pages.help.menu.debates"),
|
||||||
</li>
|
"#debates",
|
||||||
<% end %>
|
class: "button hollow expanded"
|
||||||
<% if feature?(:proposals) %>
|
] if feature?(:debates)
|
||||||
<li>
|
),
|
||||||
<%= link_to t("pages.help.menu.proposals"), "#proposals", class: "button hollow expanded" %>
|
(
|
||||||
</li>
|
[
|
||||||
<% end %>
|
t("pages.help.menu.proposals"),
|
||||||
<% if feature?(:budgets) %>
|
"#proposals",
|
||||||
<li>
|
class: "button hollow expanded"
|
||||||
<%= link_to t("pages.help.menu.budgets"), "#budgets", class: "button hollow expanded" %>
|
] if feature?(:proposals)
|
||||||
</li>
|
),
|
||||||
<% end %>
|
(
|
||||||
<% if feature?(:polls) %>
|
[
|
||||||
<li>
|
t("pages.help.menu.budgets"),
|
||||||
<%= link_to t("pages.help.menu.polls"), "#polls", class: "button hollow expanded" %>
|
"#budgets",
|
||||||
</li>
|
class: "button hollow expanded"
|
||||||
<% end %>
|
] if feature?(:budgets)
|
||||||
<% if feature?(:legislation) %>
|
),
|
||||||
<li>
|
(
|
||||||
<%= link_to t("pages.help.menu.processes"), "#processes", class: "button hollow expanded" %>
|
[
|
||||||
</li>
|
t("pages.help.menu.polls"),
|
||||||
<% end %>
|
"#polls",
|
||||||
<li>
|
class: "button hollow expanded"
|
||||||
<%= link_to t("pages.help.menu.other"), "#other", class: "button hollow expanded" %>
|
] if feature?(:polls)
|
||||||
</li>
|
),
|
||||||
</ul>
|
(
|
||||||
|
[
|
||||||
|
t("pages.help.menu.processes"),
|
||||||
|
"#processes",
|
||||||
|
class: "button hollow expanded"
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
t("pages.help.menu.other"),
|
||||||
|
"#other",
|
||||||
|
class: "button hollow expanded"
|
||||||
|
],
|
||||||
|
class: "menu-pages", "data-magellan": true
|
||||||
|
) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
<nav class="admin-sidebar">
|
<%= link_list(
|
||||||
<ul id="valuation_menu">
|
[t("valuation.menu.title"), valuation_root_path],
|
||||||
<li>
|
[t("valuation.menu.budgets"), valuation_budgets_path, controller_name == "budget_investments", class: "budgets-link"],
|
||||||
<%= link_to t("valuation.menu.title"), valuation_root_path %>
|
id: "valuation_menu"
|
||||||
</li>
|
) %>
|
||||||
|
|
||||||
<% if feature?(:budgets) %>
|
|
||||||
<li <%= "class=is-active" if controller_name == "budget_investments" %>>
|
|
||||||
<%= link_to t("valuation.menu.budgets"), valuation_budgets_path, class: "budgets-link" %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
|
|||||||
72
spec/helpers/link_list_helper_spec.rb
Normal file
72
spec/helpers/link_list_helper_spec.rb
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe LinkListHelper do
|
||||||
|
describe "#link_list" do
|
||||||
|
it "returns an empty string with an empty list" do
|
||||||
|
expect(helper.link_list).to eq ""
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns nothing with a list of nil elements" do
|
||||||
|
expect(helper.link_list(nil, nil)).to eq ""
|
||||||
|
end
|
||||||
|
|
||||||
|
it "generates a list of links" do
|
||||||
|
list = helper.link_list(["Home", "/"], ["Info", "/info"], class: "menu")
|
||||||
|
|
||||||
|
expect(list).to eq '<ul class="menu"><li><a href="/">Home</a></li><li><a href="/info">Info</a></li></ul>'
|
||||||
|
expect(list).to be_html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
it "accepts options for links" do
|
||||||
|
render helper.link_list(["Home", "/", class: "root"], ["Info", "/info", id: "info"])
|
||||||
|
|
||||||
|
expect(page).to have_css "a", count: 2
|
||||||
|
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 "ignores nil entries" do
|
||||||
|
render helper.link_list(["Home", "/", class: "root"], nil, ["Info", "/info", id: "info"])
|
||||||
|
|
||||||
|
expect(page).to have_css "a", count: 2
|
||||||
|
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[aria-current='true']", 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[aria-current='true']", 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
|
||||||
|
|
||||||
|
def render(content)
|
||||||
|
@content = content
|
||||||
|
end
|
||||||
|
|
||||||
|
def page
|
||||||
|
Capybara::Node::Simple.new(content)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user