Change composer error message when title is too long or too short, and make sure the submit button is 'disabled' when title is too long

This commit is contained in:
Neil Lalonde 2013-05-24 17:08:54 -04:00
parent e2774cc2df
commit ada79260b3
3 changed files with 9 additions and 4 deletions

View File

@ -164,7 +164,9 @@ Discourse.Composer = Discourse.Model.extend({
// - creating a new topic
// - editing the 1st post
// - creating a private message
if (this.get('editTitle') && this.get('titleLength') < Discourse.SiteSettings.min_topic_title_length) return true;
if (this.get('editTitle') &&
(this.get('titleLength') < Discourse.SiteSettings.min_topic_title_length ||
this.get('titleLength') > Discourse.SiteSettings.max_topic_title_length) ) return true;
// Need at least one user when sending a private message
if (this.get('creatingPrivateMessage') && (this.get('targetUsernames').trim() + ',').indexOf(',') === 0) return true;

View File

@ -375,8 +375,10 @@ Discourse.ComposerView = Discourse.View.extend({
var title = this.get('content.title'), reason;
if( !title || title.length < 1 ){
reason = Em.String.i18n('composer.error.title_missing');
} else if( title.length < Discourse.SiteSettings.min_topic_title_length || title.length > Discourse.SiteSettings.max_topic_title_length ) {
reason = Em.String.i18n('composer.error.title_length', {min: Discourse.SiteSettings.min_topic_title_length, max: Discourse.SiteSettings.max_topic_title_length})
} else if( title.length < Discourse.SiteSettings.min_topic_title_length ) {
reason = Em.String.i18n('composer.error.title_too_short', {min: Discourse.SiteSettings.min_topic_title_length})
} else if( title.length > Discourse.SiteSettings.max_topic_title_length ) {
reason = Em.String.i18n('composer.error.title_too_long', {max: Discourse.SiteSettings.max_topic_title_length})
}
if( reason ) {

View File

@ -340,7 +340,8 @@ en:
error:
title_missing: "Title is required."
title_length: "Title needs between {{min}} and {{max}} characters."
title_too_short: "Title must be at least {{min}} characters long."
title_too_long: "Title must be less than {{max}} characters long."
post_missing: "Post can't be empty."
post_length: "Post must be at least {{min}} characters long."
category_missing: "You must choose a category."