-
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.
Add Admin changes to create Poll:Questions with votation type
- Loading branch information
1 parent
7c9c50f
commit 23d3683
Showing
16 changed files
with
485 additions
and
16 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
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,45 @@ | ||
App.Votations = | ||
|
||
checkMaxVotes: -> | ||
if $("#votation_type_enum_type").val() == "0" | ||
$(".js-max_votes").hide() | ||
$("#max_votes").attr(disabled: true) | ||
else | ||
$(".js-max_votes").show() | ||
$("#max_votes").attr(disabled: false) | ||
|
||
checkPrioritization: -> | ||
if $("#votation_type_enum_type").val() == "2" | ||
$(".js-prioritization_type").show() | ||
$("#prioritization_type").attr(disabled: false) | ||
else | ||
$(".js-prioritization_type").hide() | ||
$("#prioritization_type").attr(disabled: true) | ||
|
||
checkMaxGroups: -> | ||
if $("#votation_type_enum_type").val() == "7" || $("#votation_type_enum_type").val() == "8" | ||
$(".js-max_group_votes").show() | ||
$("#max_groups_answers").attr(disabled: false) | ||
else | ||
$(".js-max_group_votes").hide() | ||
$("#max_groups_answers").attr(disabled: true) | ||
|
||
setTraduction: (response) -> | ||
console.log response | ||
$(".js-description_text").text(response["traduction"]) | ||
|
||
updateChecks: () -> | ||
App.Votations.checkMaxVotes() | ||
App.Votations.checkPrioritization() | ||
App.Votations.checkMaxGroups() | ||
|
||
initialize: -> | ||
App.Votations.updateChecks() | ||
$("#votation_type_enum_type").on | ||
change: -> | ||
App.Votations.updateChecks() | ||
url = "/admin/get_options_traductions.json" | ||
params = { enum_type: $("#votation_type_enum_type").val() } | ||
$.get(url, params, (response) -> App.Votations.setTraduction response, "json") | ||
|
||
false |
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
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
40 changes: 40 additions & 0 deletions
40
app/views/admin/poll/results/_votation_types_results.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,40 @@ | ||
<div class="polls-results-stats"> | ||
|
||
<div class="row margin"> | ||
<div class="small-12 medium-3 column"> | ||
<p><strong><%= t("polls.show.results.title") %></strong></p> | ||
<ul class="menu vertical"> | ||
<%- @poll.questions.each do |question| %> | ||
<li><%= link_to question.title, "##{question.title.parameterize}" %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
|
||
<div class="small-12 medium-9 column"> | ||
<%- @poll.questions.each do |question| %> | ||
<h3 id="<%= question.title.parameterize %>"><%= question.title %></h3> | ||
<table id="question_<%= question.id %>_results_table"> | ||
<tbody> | ||
<%- question.question_answers.visibles.each do |answer| %> | ||
<tr scope="col" <%= answer.most_voted? ? "class=win" : "" %>> | ||
<td> | ||
<% if answer.most_voted %> | ||
<span class="show-for-sr"><%= t("polls.show.results.most_voted_answer") %></span> | ||
<% end %> | ||
<%= answer.title %> | ||
</td> | ||
<td id="answer_<%= answer.id %>_result" <%= answer.most_voted? ? "class=win" : "" %>> | ||
<%= answer.total_votes %> | ||
<% unless question.enum_type == "positive_negative_open" %> | ||
(<%= answer.total_votes_percentage.round(2) %>%) | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<% end %> | ||
|
||
</div> | ||
</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
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.