mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Switch the awkward poll.post.poll_details.closed to poll.closed.
This commit is contained in:
parent
668a5ff526
commit
edbbf7ffbb
@ -1,12 +1,13 @@
|
|||||||
var Poll = Discourse.Model.extend({
|
var Poll = Discourse.Model.extend({
|
||||||
post: null,
|
post: null,
|
||||||
options: [],
|
options: [],
|
||||||
|
closed: false,
|
||||||
|
|
||||||
postObserver: function() {
|
postObserver: function() {
|
||||||
this.updateOptionsFromJson(this.get('post.poll_details'));
|
this.updateFromJson(this.get('post.poll_details'));
|
||||||
}.observes('post.poll_details'),
|
}.observes('post.poll_details'),
|
||||||
|
|
||||||
updateOptionsFromJson: function(json) {
|
updateFromJson: function(json) {
|
||||||
var selectedOption = json["selected"];
|
var selectedOption = json["selected"];
|
||||||
|
|
||||||
var options = [];
|
var options = [];
|
||||||
@ -18,6 +19,8 @@ var Poll = Discourse.Model.extend({
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
this.set('options', options);
|
this.set('options', options);
|
||||||
|
|
||||||
|
this.set('closed', json.closed);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveVote: function(option) {
|
saveVote: function(option) {
|
||||||
@ -29,16 +32,16 @@ var Poll = Discourse.Model.extend({
|
|||||||
type: "PUT",
|
type: "PUT",
|
||||||
data: {post_id: this.get('post.id'), option: option}
|
data: {post_id: this.get('post.id'), option: option}
|
||||||
}).then(function(newJSON) {
|
}).then(function(newJSON) {
|
||||||
this.updateOptionsFromJson(newJSON);
|
this.updateFromJson(newJSON);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var PollController = Discourse.Controller.extend({
|
var PollController = Discourse.Controller.extend({
|
||||||
poll: null,
|
poll: null,
|
||||||
showResults: Em.computed.oneWay('poll.post.poll_details.closed'),
|
showResults: Em.computed.oneWay('poll.closed'),
|
||||||
|
|
||||||
disableRadio: Em.computed.any('poll.post.poll_details.closed', 'loading'),
|
disableRadio: Em.computed.any('poll.closed', 'loading'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
selectOption: function(option) {
|
selectOption: function(option) {
|
||||||
@ -80,7 +83,7 @@ function initializePollView(self) {
|
|||||||
var pollDetails = post.get('poll_details');
|
var pollDetails = post.get('poll_details');
|
||||||
|
|
||||||
var poll = Poll.create({post: post});
|
var poll = Poll.create({post: post});
|
||||||
poll.updateOptionsFromJson(pollDetails);
|
poll.updateFromJson(pollDetails);
|
||||||
|
|
||||||
var pollController = PollController.create({
|
var pollController = PollController.create({
|
||||||
poll: poll,
|
poll: poll,
|
||||||
|
Loading…
Reference in New Issue
Block a user