Rename variables describing poll options as answers
Since we've renamed the class to `Option`, having variables, methods and texts refering to it as `answer` was confusing.
This commit is contained in:
@@ -89,7 +89,7 @@ class Admin::ActionComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def default_path
|
||||
if %i[answers configure destroy preview show].include?(action.to_sym)
|
||||
if %i[configure destroy options preview show].include?(action.to_sym)
|
||||
namespaced_polymorphic_path(namespace, record)
|
||||
else
|
||||
namespaced_polymorphic_path(namespace, record, { action: action }.merge(request.query_parameters))
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<%= render Admin::AllowedTableActionsComponent.new(question) do |actions| %>
|
||||
<%= actions.action(:answers, text: t("admin.polls.show.edit_answers")) %>
|
||||
<%= actions.action(:options, text: t("admin.polls.show.edit_answers")) %>
|
||||
<% end %>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
title: t("poll_questions.show.vote_answer", answer: question_option.title),
|
||||
class: "button secondary hollow",
|
||||
"aria-pressed": false,
|
||||
disabled: disable_answer?(question_option) %>
|
||||
disabled: disable_option?(question_option) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% elsif !user_signed_in? %>
|
||||
|
||||
@@ -18,7 +18,7 @@ class Polls::Questions::OptionsComponent < ApplicationComponent
|
||||
user_answers.find_by(answer: question_option.title)
|
||||
end
|
||||
|
||||
def disable_answer?(question_option)
|
||||
def disable_option?(question_option)
|
||||
question.multiple? && user_answers.count == question.max_votes
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<% if question.options_with_read_more? %>
|
||||
<div>
|
||||
<p><%= t("poll_questions.read_more_about") %></p>
|
||||
<p><%= answers_read_more_links %></p>
|
||||
<p><%= options_read_more_links %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -5,9 +5,9 @@ class Polls::Questions::QuestionComponent < ApplicationComponent
|
||||
@question = question
|
||||
end
|
||||
|
||||
def answers_read_more_links
|
||||
safe_join(question.options_with_read_more.map do |answer|
|
||||
link_to answer.title, "#answer_#{answer.id}"
|
||||
def options_read_more_links
|
||||
safe_join(question.options_with_read_more.map do |option|
|
||||
link_to option.title, "#answer_#{option.id}"
|
||||
end, ", ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
<h2><%= question.title %></h2>
|
||||
<% question.options_with_read_more.each do |answer| %>
|
||||
<div class="small-12 medium-6 column end answer <%= cycle("first", "") %>" id="answer_<%= answer.id %>">
|
||||
<h3><%= answer.title %></h3>
|
||||
<% question.options_with_read_more.each do |option| %>
|
||||
<div class="small-12 medium-6 column end answer <%= cycle("first", "") %>" id="answer_<%= option.id %>">
|
||||
<h3><%= option.title %></h3>
|
||||
|
||||
<div class="margin-top">
|
||||
<% if answer.description.present? %>
|
||||
<div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short">
|
||||
<%= wysiwyg(answer.description) %>
|
||||
<% if option.description.present? %>
|
||||
<div id="answer_description_<%= option.id %>" class="answer-description short" data-toggler="short">
|
||||
<%= wysiwyg(option.description) %>
|
||||
</div>
|
||||
<div class="read-more">
|
||||
<button type="button" id="read_more_<%= answer.id %>"
|
||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||
<button type="button" id="read_more_<%= option.id %>"
|
||||
data-toggle="answer_description_<%= option.id %> read_more_<%= option.id %> read_less_<%= option.id %>"
|
||||
data-toggler="hide">
|
||||
<%= t("polls.show.read_more", answer: answer.title) %>
|
||||
<%= t("polls.show.read_more", answer: option.title) %>
|
||||
</button>
|
||||
<button type="button" id="read_less_<%= answer.id %>"
|
||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||
<button type="button" id="read_less_<%= option.id %>"
|
||||
data-toggle="answer_description_<%= option.id %> read_more_<%= option.id %> read_less_<%= option.id %>"
|
||||
data-toggler="hide"
|
||||
class="hide">
|
||||
<%= t("polls.show.read_less", answer: answer.title) %>
|
||||
<%= t("polls.show.read_less", answer: option.title) %>
|
||||
</button>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.images.any? %>
|
||||
<%= render "polls/gallery", answer: answer %>
|
||||
<% if option.images.any? %>
|
||||
<%= render "polls/gallery", option: option %>
|
||||
<% end %>
|
||||
|
||||
<% if answer.documents.present? %>
|
||||
<% if option.documents.present? %>
|
||||
<div class="document-link">
|
||||
<p>
|
||||
<strong><%= t("polls.show.documents") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.documents.each do |document| %>
|
||||
<% option.documents.each do |document| %>
|
||||
<%= render Documents::DocumentComponent.new(document) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.videos.present? %>
|
||||
<% if option.videos.present? %>
|
||||
<div class="video-link">
|
||||
<p>
|
||||
<span class="icon-video"></span>
|
||||
<strong><%= t("polls.show.videos") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.videos.each do |video| %>
|
||||
<% option.videos.each do |video| %>
|
||||
<%= link_to video.title,
|
||||
video.url,
|
||||
rel: "nofollow" %><br>
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
<table id="question_<%= question.id %>_results_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<%- question.question_options.each do |answer| %>
|
||||
<th scope="col" class="<%= answer_styles(answer) %>">
|
||||
<% if most_voted_answer?(answer) %>
|
||||
<%- question.question_options.each do |option| %>
|
||||
<th scope="col" class="<%= option_styles(option) %>">
|
||||
<% if most_voted_option?(option) %>
|
||||
<span class="show-for-sr"><%= t("polls.show.results.most_voted_answer") %></span>
|
||||
<% end %>
|
||||
<%= answer.title %>
|
||||
<%= option.title %>
|
||||
</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<%- question.question_options.each do |answer| %>
|
||||
<td id="answer_<%= answer.id %>_result" class="<%= answer_styles(answer) %>">
|
||||
<%= answer.total_votes %>
|
||||
(<%= answer.total_votes_percentage.round(2) %>%)
|
||||
<%- question.question_options.each do |option| %>
|
||||
<td id="answer_<%= option.id %>_result" class="<%= option_styles(option) %>">
|
||||
<%= option.total_votes %>
|
||||
(<%= option.total_votes_percentage.round(2) %>%)
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -5,11 +5,11 @@ class Polls::Results::QuestionComponent < ApplicationComponent
|
||||
@question = question
|
||||
end
|
||||
|
||||
def answer_styles(answer)
|
||||
"win" if most_voted_answer?(answer)
|
||||
def option_styles(option)
|
||||
"win" if most_voted_option?(option)
|
||||
end
|
||||
|
||||
def most_voted_answer?(answer)
|
||||
answer.id == question.most_voted_option_id
|
||||
def most_voted_option?(option)
|
||||
option.id == question.most_voted_option_id
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user