Simplify method names in admin menu component
We no longer need to use the `menu_` prefix, since now these methods aren't helper methods anymore, and so their names won't collide with other helpers.
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<% if feature?(:polls) %>
|
<% if feature?(:polls) %>
|
||||||
<li class="section-title <%= "is-active" if menu_polls? %>">
|
<li class="section-title <%= "is-active" if polls? %>">
|
||||||
<%= link_to admin_polls_path do %>
|
<%= link_to admin_polls_path do %>
|
||||||
<span class="icon-checkmark-circle"></span>
|
<span class="icon-checkmark-circle"></span>
|
||||||
<strong><%= t("admin.menu.polls") %></strong>
|
<strong><%= t("admin.menu.polls") %></strong>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if feature?(:budgets) %>
|
<% if feature?(:budgets) %>
|
||||||
<li class="section-title <%= "is-active" if menu_budgets? %>">
|
<li class="section-title <%= "is-active" if budgets? %>">
|
||||||
<%= link_to admin_budgets_path do %>
|
<%= link_to admin_budgets_path do %>
|
||||||
<span class="icon-budget"></span>
|
<span class="icon-budget"></span>
|
||||||
<strong><%= t("admin.menu.budgets") %></strong>
|
<strong><%= t("admin.menu.budgets") %></strong>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<span class="icon-box"></span>
|
<span class="icon-box"></span>
|
||||||
<strong><%= t("admin.menu.title_booths") %></strong>
|
<strong><%= t("admin.menu.title_booths") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul id="booths_menu" <%= "class=is-active" if menu_booths? %>>
|
<ul id="booths_menu" <%= "class=is-active" if booths? %>>
|
||||||
<li <%= "class=is-active" if %w[officers officer_assignments].include?(controller_name) %>>
|
<li <%= "class=is-active" if %w[officers officer_assignments].include?(controller_name) %>>
|
||||||
<%= link_to t("admin.menu.poll_officers"), admin_officers_path %>
|
<%= link_to t("admin.menu.poll_officers"), admin_officers_path %>
|
||||||
</li>
|
</li>
|
||||||
@@ -117,14 +117,14 @@
|
|||||||
<span class="icon-edit"></span>
|
<span class="icon-edit"></span>
|
||||||
<strong><%= t("admin.menu.title_site_customization") %></strong>
|
<strong><%= t("admin.menu.title_site_customization") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul <%= "class=is-active" if menu_customization? &&
|
<ul <%= "class=is-active" if customization? &&
|
||||||
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
||||||
|
|
||||||
<li <%= "class=is-active" if menu_homepage? %>>
|
<li <%= "class=is-active" if homepage? %>>
|
||||||
<%= link_to t("admin.menu.site_customization.homepage"), admin_homepage_path %>
|
<%= link_to t("admin.menu.site_customization.homepage"), admin_homepage_path %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li <%= "class=is-active" if menu_pages? || controller_name == "pages" %>>
|
<li <%= "class=is-active" if pages? || controller_name == "pages" %>>
|
||||||
<%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
|
<%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
<span class="icon-eye"></span>
|
<span class="icon-eye"></span>
|
||||||
<strong><%= t("admin.menu.title_moderated_content") %></strong>
|
<strong><%= t("admin.menu.title_moderated_content") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul <%= "class=is-active" if menu_moderated_content? %>>
|
<ul <%= "class=is-active" if moderated_content? %>>
|
||||||
<% if feature?(:proposals) %>
|
<% if feature?(:proposals) %>
|
||||||
<li <%= "class=is-active" if controller_name == "hidden_proposals" %>>
|
<li <%= "class=is-active" if controller_name == "hidden_proposals" %>>
|
||||||
<%= link_to t("admin.menu.hidden_proposals"), admin_hidden_proposals_path %>
|
<%= link_to t("admin.menu.hidden_proposals"), admin_hidden_proposals_path %>
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
<span class="icon-organizations"></span>
|
<span class="icon-organizations"></span>
|
||||||
<strong><%= t("admin.menu.title_profiles") %></strong>
|
<strong><%= t("admin.menu.title_profiles") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul <%= "class=is-active" if menu_profiles? %>>
|
<ul <%= "class=is-active" if profiles? %>>
|
||||||
<li <%= "class=is-active" if controller_name == "administrators" %>>
|
<li <%= "class=is-active" if controller_name == "administrators" %>>
|
||||||
<%= link_to t("admin.menu.administrators"), admin_administrators_path %>
|
<%= link_to t("admin.menu.administrators"), admin_administrators_path %>
|
||||||
</li>
|
</li>
|
||||||
@@ -232,7 +232,7 @@
|
|||||||
<span class="icon-settings"></span>
|
<span class="icon-settings"></span>
|
||||||
<strong><%= t("admin.menu.title_settings") %></strong>
|
<strong><%= t("admin.menu.title_settings") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul <%= "class=is-active" if menu_settings? %>>
|
<ul <%= "class=is-active" if settings? %>>
|
||||||
<li <%= "class=is-active" if controller_name == "settings" %>>
|
<li <%= "class=is-active" if controller_name == "settings" %>>
|
||||||
<%= link_to t("admin.menu.settings"), admin_settings_path %>
|
<%= link_to t("admin.menu.settings"), admin_settings_path %>
|
||||||
</li>
|
</li>
|
||||||
@@ -254,7 +254,7 @@
|
|||||||
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path %>
|
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li <%= "class=is-active" if submenu_local_census_records? %>>
|
<li <%= "class=is-active" if local_census_records? %>>
|
||||||
<%= link_to t("admin.menu.local_census_records"), admin_local_census_records_path %>
|
<%= link_to t("admin.menu.local_census_records"), admin_local_census_records_path %>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -264,7 +264,7 @@
|
|||||||
<span class="icon-check"></span>
|
<span class="icon-check"></span>
|
||||||
<strong><%= t("admin.menu.dashboard") %></strong>
|
<strong><%= t("admin.menu.dashboard") %></strong>
|
||||||
</a>
|
</a>
|
||||||
<ul <%= "class=is-active" if menu_dashboard? %>>
|
<ul <%= "class=is-active" if dashboard? %>>
|
||||||
<li <%= "class=is-active" if controller_name == "actions" %>>
|
<li <%= "class=is-active" if controller_name == "actions" %>>
|
||||||
<%= link_to t("admin.menu.dashboard_actions"), admin_dashboard_actions_path %>
|
<%= link_to t("admin.menu.dashboard_actions"), admin_dashboard_actions_path %>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class Admin::MenuComponent < ApplicationComponent
|
class Admin::MenuComponent < ApplicationComponent
|
||||||
private
|
private
|
||||||
|
|
||||||
def menu_moderated_content?
|
def moderated_content?
|
||||||
moderated_sections.include?(controller_name) && controller.class.parent != Admin::Legislation
|
moderated_sections.include?(controller_name) && controller.class.parent != Admin::Legislation
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -10,50 +10,50 @@ class Admin::MenuComponent < ApplicationComponent
|
|||||||
"hidden_budget_investments", "hidden_proposal_notifications"]
|
"hidden_budget_investments", "hidden_proposal_notifications"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_budgets?
|
def budgets?
|
||||||
controller_name.starts_with?("budget")
|
controller_name.starts_with?("budget")
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_polls?
|
def polls?
|
||||||
controller.class.parent == Admin::Poll::Questions::Answers ||
|
controller.class.parent == Admin::Poll::Questions::Answers ||
|
||||||
%w[polls active_polls recounts results questions answers].include?(controller_name) &&
|
%w[polls active_polls recounts results questions answers].include?(controller_name) &&
|
||||||
action_name != "booth_assignments"
|
action_name != "booth_assignments"
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_booths?
|
def booths?
|
||||||
%w[officers booths shifts booth_assignments officer_assignments].include?(controller_name) ||
|
%w[officers booths shifts booth_assignments officer_assignments].include?(controller_name) ||
|
||||||
controller_name == "polls" && action_name == "booth_assignments"
|
controller_name == "polls" && action_name == "booth_assignments"
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_profiles?
|
def profiles?
|
||||||
%w[administrators organizations officials moderators valuators managers users].include?(controller_name)
|
%w[administrators organizations officials moderators valuators managers users].include?(controller_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_settings?
|
def settings?
|
||||||
controllers_names = ["settings", "tags", "geozones", "images", "content_blocks",
|
controllers_names = ["settings", "tags", "geozones", "images", "content_blocks",
|
||||||
"local_census_records", "imports"]
|
"local_census_records", "imports"]
|
||||||
controllers_names.include?(controller_name) &&
|
controllers_names.include?(controller_name) &&
|
||||||
controller.class.parent != Admin::Poll::Questions::Answers
|
controller.class.parent != Admin::Poll::Questions::Answers
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_customization?
|
def customization?
|
||||||
["pages", "banners", "information_texts", "documents"].include?(controller_name) ||
|
["pages", "banners", "information_texts", "documents"].include?(controller_name) ||
|
||||||
menu_homepage? || menu_pages?
|
homepage? || pages?
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_homepage?
|
def homepage?
|
||||||
["homepage", "cards"].include?(controller_name) && params[:page_id].nil?
|
["homepage", "cards"].include?(controller_name) && params[:page_id].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_pages?
|
def pages?
|
||||||
["pages", "cards"].include?(controller_name) && params[:page_id].present?
|
["pages", "cards"].include?(controller_name) && params[:page_id].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def menu_dashboard?
|
def dashboard?
|
||||||
["actions", "administrator_tasks"].include?(controller_name)
|
["actions", "administrator_tasks"].include?(controller_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def submenu_local_census_records?
|
def local_census_records?
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user