Skip to content

Commit

Permalink
Disable send button while procesing
Browse files Browse the repository at this point in the history
  • Loading branch information
gdpelican committed Aug 18, 2015
1 parent ba8e953 commit b036074
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions assets/javascripts/discourse/components/babble-composer.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default Ember.Component.extend({

textValidation: function() {
var validation = { ok: true }
if (Ember.isEmpty(this.get('text'))) {
if (this.get('processing') || Ember.isEmpty(this.get('text'))) {
var validation = { failed: true }
}

return Discourse.InputValidation.create(validation)
}.property('text'),
}.property('text', 'processing'),

submitDisabled: function() {
if (this.get('textValidation.failed')) return true
Expand All @@ -29,12 +29,15 @@ export default Ember.Component.extend({
actions: {
submit: function(context) {
var self = context || this;
self.set('processing', true)
Discourse.ajax("/babble/topic/post", {
type: 'POST',
data: { raw: self.get('text') }
}).then(function(data) {
Discourse.Babble.refresh(data)
})
.then(Discourse.Babble.refresh)
.finally(function() {
self.set('text', '')
self.set('processing', false)
});
}
}
Expand Down

0 comments on commit b036074

Please sign in to comment.