FIX: Make sure model is updated when polls change.

This commit is contained in:
Guo Xiang Tan 2016-06-08 14:41:43 +08:00
parent dd3ddce448
commit 7aac5baeed
No known key found for this signature in database
GPG key ID: 19C321C8952B0F72

View file

@ -1,4 +1,5 @@
import computed from "ember-addons/ember-computed-decorators"; import computed from "ember-addons/ember-computed-decorators";
import { observes } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({ export default Ember.Controller.extend({
isMultiple: Ember.computed.equal("poll.type", "multiple"), isMultiple: Ember.computed.equal("poll.type", "multiple"),
@ -15,6 +16,11 @@ export default Ember.Controller.extend({
showResultsDisabled: Em.computed.equal("poll.voters", 0), showResultsDisabled: Em.computed.equal("poll.voters", 0),
hideResultsDisabled: Em.computed.or("isClosed", "post.topic.archived"), hideResultsDisabled: Em.computed.or("isClosed", "post.topic.archived"),
@observes("post.polls")
_updatePoll() {
this.set("model", this.get("post.pollsObject")[this.get("model.name")]);
},
@computed("model", "vote", "model.voters", "model.options", "model.status") @computed("model", "vote", "model.voters", "model.options", "model.status")
poll(poll, vote) { poll(poll, vote) {
if (poll) { if (poll) {