mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add close/open poll buttons to poll UI.
This commit is contained in:
@@ -24,6 +24,18 @@
|
||||
{{/if}}
|
||||
</button>
|
||||
|
||||
{{#if poll.post.topic.details.can_edit}}
|
||||
<button {{action toggleClosePoll}} class="btn btn-small">
|
||||
{{#if poll.closed}}
|
||||
<i class="fa fa-unlock-alt"></i>
|
||||
{{i18n poll.open_poll}}
|
||||
{{else}}
|
||||
<i class="fa fa-lock"></i>
|
||||
{{i18n poll.close_poll}}
|
||||
{{/if}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
{{#if loading}}
|
||||
<i class="fa fa-spin fa-spinner"></i>
|
||||
{{/if}}
|
||||
|
||||
@@ -44,7 +44,6 @@ var Poll = Discourse.Model.extend({
|
||||
var PollController = Discourse.Controller.extend({
|
||||
poll: null,
|
||||
showResults: Em.computed.oneWay('poll.closed'),
|
||||
|
||||
disableRadio: Em.computed.any('poll.closed', 'loading'),
|
||||
|
||||
actions: {
|
||||
@@ -67,6 +66,18 @@ var PollController = Discourse.Controller.extend({
|
||||
|
||||
toggleShowResults: function() {
|
||||
this.set('showResults', !this.get('showResults'));
|
||||
},
|
||||
|
||||
toggleClosePoll: function() {
|
||||
this.set('loading', true);
|
||||
return Discourse.ajax("/poll/toggle_close", {
|
||||
type: "PUT",
|
||||
data: {post_id: this.get('poll.post.id')}
|
||||
}).then(function(topicJson) {
|
||||
this.set('poll.post.topic.title', topicJson.basic_topic.title);
|
||||
this.set('poll.post.topic.fancy_title', topicJson.basic_topic.title);
|
||||
this.set('loading', false);
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user