FIX: two-column poll

This commit is contained in:
Régis Hanol
2015-05-04 22:29:45 +02:00
parent a2d8cd501c
commit 90c05ff045
6 changed files with 191 additions and 85 deletions

View File

@ -4,9 +4,6 @@ export default Em.Controller.extend({
isRandom : Em.computed.equal("poll.order", "random"),
isClosed: Em.computed.equal("poll.status", "closed"),
// immediately shows the results when the user has already voted
showResults: Em.computed.gt("vote.length", 0),
// shows the results when
// - poll is closed
// - topic is archived/closed
@ -50,6 +47,20 @@ export default Em.Controller.extend({
return max;
}.property("poll.max", "poll.options.length"),
votersText: function() {
return I18n.t("poll.voters", { count: this.get("poll.voters") });
}.property("poll.voters"),
totalVotes: function() {
return _.reduce(this.get("poll.options"), function(total, o) {
return total + parseInt(o.get("votes"), 10);
}, 0);
}.property("poll.options.@each.votes"),
totalVotesText: function() {
return I18n.t("poll.total_votes", { count: this.get("totalVotes") });
}.property("totalVotes"),
multipleHelpText: function() {
const options = this.get("poll.options.length"),
min = this.get("min"),