Hides sidebar menus if officer has no shifts assigned
This commit is contained in:
@@ -4,4 +4,12 @@ module OfficersHelper
|
||||
truncate([officer.name, officer.email].compact.join(' - '), length: 100)
|
||||
end
|
||||
|
||||
end
|
||||
def vote_collection_shift?
|
||||
current_user.poll_officer.officer_assignments.where(date: Time.current.to_date).any?
|
||||
end
|
||||
|
||||
def final_recount_shift?
|
||||
current_user.poll_officer.officer_assignments.final.where(date: Time.current.to_date).any?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
<div class="admin-sidebar" data-equalizer-watch>
|
||||
<ul id="officing_menu">
|
||||
<% if vote_collection_shift? %>
|
||||
<li <%= "class=is-active" if controller_name == "voters" %>>
|
||||
<%= link_to new_officing_residence_path do %>
|
||||
<span class="icon-user"></span>
|
||||
<%= t("officing.menu.voters") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<li <%= "class=is-active" if controller_name == "voters" %>>
|
||||
<%= link_to new_officing_residence_path do %>
|
||||
<span class="icon-user"></span>
|
||||
<%= t("officing.menu.voters") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=is-active" if ["results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
|
||||
<%= link_to final_officing_polls_path do %>
|
||||
<span class="icon-user"></span>
|
||||
<%= t("officing.menu.total_recounts") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% if final_recount_shift? %>
|
||||
<li <%= "class=is-active" if ["results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
|
||||
<%= link_to final_officing_polls_path do %>
|
||||
<span class="icon-user"></span>
|
||||
<%= t("officing.menu.total_recounts") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end%>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -2,4 +2,10 @@
|
||||
<h2><%= t("officing.dashboard.index.title") %></h2>
|
||||
|
||||
<p><%= t("officing.dashboard.index.info") %></p>
|
||||
|
||||
<% unless final_recount_shift? && vote_collection_shift? %>
|
||||
<div class="callout warning">
|
||||
<%= t("officing.dashboard.index.no_shifts") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user