From a93dfece7039637eca1fe46dc5ef601fb514d39e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 8 May 2015 13:23:43 -0400 Subject: [PATCH] FIX: Incorrect error message when post isn't long enough --- .../discourse/components/popup-input-tip.js.es6 | 6 ++++-- app/assets/javascripts/discourse/views/composer.js.es6 | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/popup-input-tip.js.es6 b/app/assets/javascripts/discourse/components/popup-input-tip.js.es6 index db5b690802f..5c276aa9077 100644 --- a/app/assets/javascripts/discourse/components/popup-input-tip.js.es6 +++ b/app/assets/javascripts/discourse/components/popup-input-tip.js.es6 @@ -1,10 +1,12 @@ +import StringBuffer from 'discourse/mixins/string-buffer'; import { iconHTML } from 'discourse/helpers/fa-icon'; -export default Ember.Component.extend({ +export default Ember.Component.extend(StringBuffer, { classNameBindings: [':popup-tip', 'good', 'bad', 'shownAt::hide'], animateAttribute: null, bouncePixels: 6, bounceDelay: 100, + rerenderTriggers: ['validation.reason'], click() { this.set('shownAt', false); @@ -32,7 +34,7 @@ export default Ember.Component.extend({ } }.observes('shownAt'), - render(buffer) { + renderString(buffer) { const reason = this.get('validation.reason'); if (!reason) { return; } diff --git a/app/assets/javascripts/discourse/views/composer.js.es6 b/app/assets/javascripts/discourse/views/composer.js.es6 index e76962a56bc..5ab6235850c 100644 --- a/app/assets/javascripts/discourse/views/composer.js.es6 +++ b/app/assets/javascripts/discourse/views/composer.js.es6 @@ -564,10 +564,11 @@ const ComposerView = Discourse.View.extend(Ember.Evented, { replyValidation: function() { const replyLength = this.get('model.replyLength'), missingChars = this.get('model.missingReplyCharacters'); + let reason; - if( replyLength < 1 ){ + if (replyLength < 1) { reason = I18n.t('composer.error.post_missing'); - } else if( missingChars > 0 ) { + } else if (missingChars > 0) { reason = I18n.t('composer.error.post_length', {min: this.get('model.minimumPostLength')}); let tl = Discourse.User.currentProp("trust_level"); if (tl === 0 || tl === 1) { @@ -575,8 +576,8 @@ const ComposerView = Discourse.View.extend(Ember.Evented, { } } - if( reason ) { - return Discourse.InputValidation.create({ failed: true, reason: reason }); + if (reason) { + return Discourse.InputValidation.create({ failed: true, reason }); } }.property('model.reply', 'model.replyLength', 'model.missingReplyCharacters', 'model.minimumPostLength'),