-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5012 from consul/multiple_answers
Add poll questions that accept multiple answers per user
- Loading branch information
Showing
52 changed files
with
761 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(function() { | ||
"use strict"; | ||
App.AdminVotationTypesFields = { | ||
adjustForm: function() { | ||
if ($(this).val() === "unique") { | ||
$(".max-votes").hide(); | ||
$(".description-unique").show(); | ||
$(".description-multiple").hide(); | ||
$(".votation-type-max-votes").prop("disabled", true); | ||
} else { | ||
$(".max-votes").show(); | ||
$(".description-unique").hide(); | ||
$(".description-multiple").show(); | ||
$(".votation-type-max-votes").prop("disabled", false); | ||
} | ||
}, | ||
initialize: function() { | ||
$(".votation-type-vote-type").on("change", App.AdminVotationTypesFields.adjustForm).trigger("change"); | ||
} | ||
}; | ||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/components/admin/votation_types/fields_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="small-12 medium-6 column"> | ||
<%= form.enum_select :vote_type, {}, class: "votation-type-vote-type" %> | ||
</div> | ||
|
||
<div class="small-12 column"> | ||
<div class="callout primary"> | ||
<span class="description-unique"> | ||
<%= t("admin.polls.votation_type.unique_description") %> | ||
</span> | ||
<span class="description-multiple hidden"> | ||
<%= t("admin.polls.votation_type.multiple_description") %> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<div class="small-12 medium-6 column end"> | ||
<div class="max-votes"> | ||
<%= form.number_field :max_votes, min: 2, max: 999, class: "votation-type-max-votes" %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Admin::VotationTypes::FieldsComponent < ApplicationComponent | ||
attr_reader :form | ||
|
||
def initialize(form:) | ||
@form = form | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
app/components/polls/questions/read_more_answer_component.html.erb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
app/components/polls/questions/read_more_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<h2><%= question.title %></h2> | ||
<% question.answers_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> | ||
|
||
<div class="margin-top"> | ||
<% if answer.description.present? %> | ||
<div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short"> | ||
<%= wysiwyg(answer.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 %>" | ||
data-toggler="hide"> | ||
<%= t("polls.show.read_more", answer: answer.title) %> | ||
</button> | ||
<button type="button" id="read_less_<%= answer.id %>" | ||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>" | ||
data-toggler="hide" | ||
class="hide"> | ||
<%= t("polls.show.read_less", answer: answer.title) %> | ||
</button> | ||
</div> | ||
<% end %> | ||
<% if answer.images.any? %> | ||
<%= render "polls/gallery", answer: answer %> | ||
<% end %> | ||
<% if answer.documents.present? %> | ||
<div class="document-link"> | ||
<p> | ||
<span class="icon-document"></span> | ||
<strong><%= t("polls.show.documents") %></strong> | ||
</p> | ||
|
||
<% answer.documents.each do |document| %> | ||
<%= link_to document.title, | ||
document.attachment, | ||
target: "_blank", | ||
rel: "nofollow" %><br> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<% if answer.videos.present? %> | ||
<div class="video-link"> | ||
<p> | ||
<span class="icon-video"></span> | ||
<strong><%= t("polls.show.videos") %></strong> | ||
</p> | ||
|
||
<% answer.videos.each do |video| %> | ||
<%= link_to video.title, | ||
video.url, | ||
target: "_blank", | ||
rel: "nofollow" %><br> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Polls::Questions::ReadMoreComponent < ApplicationComponent | ||
with_collection_parameter :question | ||
attr_reader :question | ||
delegate :wysiwyg, to: :helpers | ||
|
||
def initialize(question:) | ||
@question = question | ||
end | ||
|
||
def render? | ||
question.answers_with_read_more? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Polls::AnswersController < ApplicationController | ||
load_and_authorize_resource :question, class: "::Poll::Question" | ||
load_and_authorize_resource :answer, class: "::Poll::Answer", | ||
through: :question, | ||
through_association: :answers | ||
|
||
def destroy | ||
@answer.destroy_and_remove_voter_participation | ||
|
||
respond_to do |format| | ||
format.html do | ||
redirect_to request.referer | ||
end | ||
format.js do | ||
render "polls/questions/answers" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.