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.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
Reference in New Issue
Block a user