From ccbc708b5b2bcacfaf11e1ebc9f0159fe2628edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 25 Jun 2021 22:32:11 +0200 Subject: [PATCH] Simplify poll select options helper The `include_all` parameter was always used, and the option was redundant because we already had a prompt offering the same functionality. I guess one possible reason was users would want to filter by all polls, and having to click on "select a poll" to do so wasn't that intuitive. So we're using "All" as the prompt instead. --- app/helpers/polls_helper.rb | 7 +------ app/views/admin/poll/questions/_filter.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index b69a9368f..bf666d047 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -1,16 +1,11 @@ module PollsHelper - def poll_select_options(include_all = nil) + def poll_select_options options = @polls.map do |poll| [poll.name, current_path_with_query_params(poll_id: poll.id)] end - options << all_polls if include_all options_for_select(options, request.fullpath) end - def all_polls - [I18n.t("polls.all"), admin_questions_path] - end - def poll_dates(poll) if poll.starts_at.blank? || poll.ends_at.blank? I18n.t("polls.no_dates") diff --git a/app/views/admin/poll/questions/_filter.html.erb b/app/views/admin/poll/questions/_filter.html.erb index b3fca61c5..b1e988d8d 100644 --- a/app/views/admin/poll/questions/_filter.html.erb +++ b/app/views/admin/poll/questions/_filter.html.erb @@ -1,7 +1,7 @@ <%= form_tag "", method: :get do %> <%= label_tag :poll_id, t("admin.questions.index.filter_poll") %> <%= select_tag "poll_id", - poll_select_options(true), - prompt: t("admin.questions.index.select_poll"), + poll_select_options, + prompt: t("polls.all"), class: "js-location-changer" %> <% end %>