From 4498c26ff7ccddec138810dbb523fe8929262913 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 23 Jan 2019 17:45:42 +0100 Subject: [PATCH] Create helper for active menus and show stats or results on poll subnav --- app/helpers/polls_helper.rb | 15 +++++++++++++++ app/views/polls/_poll_subnav.html.erb | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 0cb875dff..83200c621 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -49,4 +49,19 @@ module PollsHelper question.answers.where(author: current_user).any? { |vote| current_user.current_sign_in_at > vote.updated_at } end + def show_stats_or_results? + @poll.expired? && (@poll.results_enabled? || @poll.stats_enabled?) + end + + def results_menu? + controller_name == "polls" && action_name == "results" + end + + def stats_menu? + controller_name == "polls" && action_name == "stats" + end + + def info_menu? + controller_name == "polls" && action_name == "show" + end end diff --git a/app/views/polls/_poll_subnav.html.erb b/app/views/polls/_poll_subnav.html.erb index ff1e7434e..ec4f7590e 100644 --- a/app/views/polls/_poll_subnav.html.erb +++ b/app/views/polls/_poll_subnav.html.erb @@ -1,8 +1,9 @@ +<% if show_stats_or_results? %>