Extract methods in admin menu component
Now that there's no naming confict with the helper method used in the ProposalsDashboardHelper, we can easily simplify the view, moving the logic to the Ruby class.
This commit is contained in:
@@ -89,13 +89,12 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% messages_sections = %w[newsletters emails_download admin_notifications system_emails] %>
|
|
||||||
<li class="section-title">
|
<li class="section-title">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<span class="icon-zip"></span>
|
<span class="icon-zip"></span>
|
||||||
<strong><%= t("admin.menu.messaging_users") %></strong>
|
<strong><%= t("admin.menu.messaging_users") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul id="messaging_users_menu" <%= "class=is-active" if messages_sections.include?(controller_name) %>>
|
<ul id="messaging_users_menu" <%= "class=is-active" if messages_menu_active? %>>
|
||||||
<li <%= "class=is-active" if controller_name == "newsletters" %>>
|
<li <%= "class=is-active" if controller_name == "newsletters" %>>
|
||||||
<%= link_to t("admin.menu.newsletters"), admin_newsletters_path %>
|
<%= link_to t("admin.menu.newsletters"), admin_newsletters_path %>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -57,4 +57,12 @@ class Admin::MenuComponent < ApplicationComponent
|
|||||||
controller_name == "local_census_records" ||
|
controller_name == "local_census_records" ||
|
||||||
(controller_name == "imports" && controller.class.parent == Admin::LocalCensusRecords)
|
(controller_name == "imports" && controller.class.parent == Admin::LocalCensusRecords)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def messages_menu_active?
|
||||||
|
messages_sections.include?(controller_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def messages_sections
|
||||||
|
%w[newsletters emails_download admin_notifications system_emails]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user