Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add poll questions that accept multiple answers per user #5012

Merged
merged 17 commits into from
Oct 18, 2022
Merged

Conversation

Senen
Copy link
Member

@Senen Senen commented Oct 13, 2022

References

This PR includes the multiple questions part of the original PR:

This PR depends on:

Objectives

Add a new type of question where the users can select multiple answers.

Visual Changes

Check original PR screenshots related to multiple answers.

The only difference for questions with multiple answers is that now buttons are disabled when the user reaches the maximum of answers allowed.

Captura de Pantalla 2022-10-14 a las 11 31 28

@Senen Senen self-assigned this Oct 13, 2022
@javierm javierm added this to Reviewing in Consul Democracy Oct 13, 2022
spec/factories/polls.rb Outdated Show resolved Hide resolved
spec/factories/polls.rb Outdated Show resolved Hide resolved
@Senen Senen force-pushed the multiple_answers branch 2 times, most recently from 6cbe3c2 to e5dc702 Compare October 14, 2022 10:32
Consul Democracy automation moved this from Reviewing to Testing Oct 14, 2022
app/assets/javascripts/votations.js Outdated Show resolved Hide resolved
app/assets/javascripts/votations.js Outdated Show resolved Hide resolved
app/assets/javascripts/votations.js Outdated Show resolved Hide resolved
app/assets/javascripts/votations.js Outdated Show resolved Hide resolved
app/assets/javascripts/votations.js Outdated Show resolved Hide resolved
db/dev_seeds/polls.rb Outdated Show resolved Hide resolved
db/dev_seeds/polls.rb Outdated Show resolved Hide resolved
db/dev_seeds/polls.rb Outdated Show resolved Hide resolved
spec/factories/polls.rb Outdated Show resolved Hide resolved
spec/system/admin/poll/questions_spec.rb Outdated Show resolved Hide resolved
@javierm javierm moved this from Testing to Doing in Consul Democracy Oct 17, 2022
@Senen Senen force-pushed the multiple_answers branch 2 times, most recently from 0700282 to fce3acb Compare October 17, 2022 17:10
@Senen
Copy link
Member Author

Senen commented Oct 17, 2022

Hi @javierm, thanks for the review. I think I applied all the suggestions 👌🏼 . The only thing I kept the same is the text mentioned in your comment: #discussion_r996903531. Not sure what to do about it 🤔

@Senen Senen moved this from Doing to Reviewing in Consul Democracy Oct 17, 2022
<p>
<strong><%= t("admin.polls.votation_type.title") %></strong>
<br>
<%= VotationType.human_attribute_name("votation_type/vote_type.#{@question.vote_type}") %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify this line a bit:

Suggested change
<%= VotationType.human_attribute_name("votation_type/vote_type.#{@question.vote_type}") %>
<%= VotationType.human_attribute_name("vote_type.#{@question.vote_type}") %>

@@ -10,16 +10,18 @@ def already_answered?(answer)
user_answers.find_by(answer: answer.title).present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can now reuse the new method 🤔.

Suggested change
user_answers.find_by(answer: answer.title).present?
user_answer(answer).present?

method: :delete,
remote: true,
title: t("poll_questions.show.voted", answer: question_answer.title),
class: "button answered expand",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the expand class do anything? 🤔 Since it isn't present in the button to remove the question, I guess it's a typo.

Suggested change
class: "button answered expand",
class: "button answered",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Removed.

Senen and others added 6 commits October 18, 2022 11:04
Now we can remove answers we should provide a way of removing voting.
The `reload` method added to max_votes validation is needed because the
author gets here with some changes because of the around_action
`switch_locale`, which adds some changes to the current user record and
therefore, the lock method raises an exception when trying to lock it
requiring us to save or discard those record changes.
Consul Democracy automation moved this from Reviewing to Testing Oct 18, 2022
Base automatically changed from refactor_public_polls to master October 18, 2022 11:24
@Senen Senen merged commit 0b8cd15 into master Oct 18, 2022
Consul Democracy automation moved this from Testing to Release 1.6.0 Oct 18, 2022
@Senen Senen deleted the multiple_answers branch October 18, 2022 11:25
@javierm javierm added the Polls label Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants