Move link methods from view to component
This way the view is not as hard to read as it was.
This commit is contained in:
@@ -36,26 +36,10 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#" class="booths-link"><%= t("admin.menu.title_booths") %></a>
|
<a href="#" class="booths-link"><%= t("admin.menu.title_booths") %></a>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
[
|
officers_link,
|
||||||
t("admin.menu.poll_officers"),
|
booths_link,
|
||||||
admin_officers_path,
|
booth_assignments_link,
|
||||||
%w[officers officer_assignments].include?(controller_name)
|
shifts_link,
|
||||||
],
|
|
||||||
[
|
|
||||||
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?)
|
id: "booths_menu", class: ("is-active" if booths?)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
@@ -69,26 +53,10 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#" class="messages-link"><%= t("admin.menu.messaging_users") %></a>
|
<a href="#" class="messages-link"><%= t("admin.menu.messaging_users") %></a>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
[
|
newsletters_link,
|
||||||
t("admin.menu.newsletters"),
|
admin_notifications_link,
|
||||||
admin_newsletters_path,
|
system_emails_link,
|
||||||
controller_name == "newsletters"
|
emails_download_link,
|
||||||
],
|
|
||||||
[
|
|
||||||
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?)
|
id: "messaging_users_menu", class: ("is-active" if messages_menu_active?)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
@@ -96,31 +64,11 @@
|
|||||||
<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>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
[
|
homepage_link,
|
||||||
t("admin.menu.site_customization.homepage"),
|
pages_link,
|
||||||
admin_homepage_path,
|
banners_link,
|
||||||
homepage?
|
information_texts_link,
|
||||||
],
|
documents_link,
|
||||||
[
|
|
||||||
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)
|
class: ("is-active" if customization? && controller.class.parent != Admin::Poll::Questions::Answers)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
@@ -128,47 +76,13 @@
|
|||||||
<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>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
(
|
(hidden_proposals_link if feature?(:proposals)),
|
||||||
[
|
(hidden_debates_link if feature?(:debates)),
|
||||||
t("admin.menu.hidden_proposals"),
|
(hidden_budget_investments_link if feature?(:budgets)),
|
||||||
admin_hidden_proposals_path,
|
hidden_comments_link,
|
||||||
controller_name == "hidden_proposals"
|
hidden_proposal_notifications_link,
|
||||||
] if feature?(:proposals)
|
hidden_users_link,
|
||||||
),
|
activity_link,
|
||||||
(
|
|
||||||
[
|
|
||||||
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?)
|
class: ("is-active" if moderated_content?)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
@@ -176,41 +90,13 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#" class="profiles-link"><%= t("admin.menu.title_profiles") %></a>
|
<a href="#" class="profiles-link"><%= t("admin.menu.title_profiles") %></a>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
[
|
administrators_link,
|
||||||
t("admin.menu.administrators"),
|
organizations_link,
|
||||||
admin_administrators_path,
|
officials_link,
|
||||||
controller_name == "administrators"
|
moderators_link,
|
||||||
],
|
valuators_link,
|
||||||
[
|
managers_link,
|
||||||
t("admin.menu.organizations"),
|
users_link,
|
||||||
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?)
|
class: ("is-active" if profiles?)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
@@ -222,52 +108,20 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#" class="settings-link"><%= t("admin.menu.title_settings") %></a>
|
<a href="#" class="settings-link"><%= t("admin.menu.title_settings") %></a>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
[
|
settings_link,
|
||||||
t("admin.menu.settings"),
|
tags_link,
|
||||||
admin_settings_path,
|
geozones_link,
|
||||||
controller_name == "settings"
|
images_link,
|
||||||
],
|
content_blocks_link,
|
||||||
[
|
local_census_records_link,
|
||||||
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?)
|
class: ("is-active" if settings?)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="dashboard-link"><%= t("admin.menu.dashboard") %></a>
|
<a href="#" class="dashboard-link"><%= t("admin.menu.dashboard") %></a>
|
||||||
<%= link_list(
|
<%= link_list(
|
||||||
[
|
dashboard_actions_link,
|
||||||
t("admin.menu.dashboard_actions"),
|
administrator_tasks_link,
|
||||||
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?)
|
class: ("is-active" if dashboard?)
|
||||||
) %>
|
) %>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -67,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
|
||||||
|
|||||||
Reference in New Issue
Block a user