FEATURE: Add public type to polls.

This commit is contained in:
Guo Xiang Tan
2016-06-07 18:55:01 +08:00
parent 7aac5baeed
commit 8ecde35df3
17 changed files with 322 additions and 30 deletions

View File

@ -6,6 +6,7 @@ export default Ember.Controller.extend({
isNumber: Ember.computed.equal("poll.type", "number"),
isRandom : Ember.computed.equal("poll.order", "random"),
isClosed: Ember.computed.equal("poll.status", "closed"),
pollsVoters: Ember.computed.alias("post.polls_voters"),
// shows the results when
// - poll is closed
@ -145,8 +146,16 @@ export default Ember.Controller.extend({
options: this.get("selectedOptions"),
}
}).then(results => {
this.setProperties({ vote: results.vote, showResults: true });
this.set("model", Em.Object.create(results.poll));
const poll = results.poll;
const votes = results.vote;
const currentUser = this.currentUser;
this.setProperties({ vote: votes, showResults: true });
this.set("model", Em.Object.create(poll));
if (poll.public) {
this.get("pollsVoters")[currentUser.get("id")] = currentUser;
}
}).catch(() => {
bootbox.alert(I18n.t("poll.error_while_casting_votes"));
}).finally(() => {