FIX: Incorrect error message when post isn't long enough

This commit is contained in:
Robin Ward 2015-05-08 13:23:43 -04:00
parent 3830bb7d78
commit a93dfece70
2 changed files with 9 additions and 6 deletions

View File

@ -1,10 +1,12 @@
import StringBuffer from 'discourse/mixins/string-buffer';
import { iconHTML } from 'discourse/helpers/fa-icon'; 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'], classNameBindings: [':popup-tip', 'good', 'bad', 'shownAt::hide'],
animateAttribute: null, animateAttribute: null,
bouncePixels: 6, bouncePixels: 6,
bounceDelay: 100, bounceDelay: 100,
rerenderTriggers: ['validation.reason'],
click() { click() {
this.set('shownAt', false); this.set('shownAt', false);
@ -32,7 +34,7 @@ export default Ember.Component.extend({
} }
}.observes('shownAt'), }.observes('shownAt'),
render(buffer) { renderString(buffer) {
const reason = this.get('validation.reason'); const reason = this.get('validation.reason');
if (!reason) { return; } if (!reason) { return; }

View File

@ -564,10 +564,11 @@ const ComposerView = Discourse.View.extend(Ember.Evented, {
replyValidation: function() { replyValidation: function() {
const replyLength = this.get('model.replyLength'), const replyLength = this.get('model.replyLength'),
missingChars = this.get('model.missingReplyCharacters'); missingChars = this.get('model.missingReplyCharacters');
let reason; let reason;
if( replyLength < 1 ){ if (replyLength < 1) {
reason = I18n.t('composer.error.post_missing'); 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')}); reason = I18n.t('composer.error.post_length', {min: this.get('model.minimumPostLength')});
let tl = Discourse.User.currentProp("trust_level"); let tl = Discourse.User.currentProp("trust_level");
if (tl === 0 || tl === 1) { if (tl === 0 || tl === 1) {
@ -575,8 +576,8 @@ const ComposerView = Discourse.View.extend(Ember.Evented, {
} }
} }
if( reason ) { if (reason) {
return Discourse.InputValidation.create({ failed: true, reason: reason }); return Discourse.InputValidation.create({ failed: true, reason });
} }
}.property('model.reply', 'model.replyLength', 'model.missingReplyCharacters', 'model.minimumPostLength'), }.property('model.reply', 'model.replyLength', 'model.missingReplyCharacters', 'model.minimumPostLength'),