diff --git a/app/assets/javascripts/discourse/models/composer.js.coffee b/app/assets/javascripts/discourse/models/composer.js.coffee index 5af4c0d3b..8f3295a8c 100644 --- a/app/assets/javascripts/discourse/models/composer.js.coffee +++ b/app/assets/javascripts/discourse/models/composer.js.coffee @@ -335,14 +335,16 @@ window.Discourse.Composer = Discourse.Model.extend saveDraft: -> - return if @disableDrafts + return if @get('disableDrafts') + return unless @get('reply') + return if @get('reply').length < Discourse.SiteSettings.min_post_length data = - reply: @get("reply"), - action: @get("action"), - title: @get("title"), - categoryName: @get("categoryName"), - postId: @get("post.id"), + reply: @get('reply'), + action: @get('action'), + title: @get('title'), + categoryName: @get('categoryName'), + postId: @get('post.id'), archetypeId: @get('archetypeId') metaData: @get('metaData') usernames: @get('targetUsernames') @@ -356,7 +358,14 @@ window.Discourse.Composer = Discourse.Model.extend ) resetDraftStatus: (-> - @set('draftStatus', null) + reply = @get('reply') + len = Discourse.SiteSettings.min_post_length + if !reply + @set('draftStatus', Em.String.i18n('composer.min_length.at_least', n: len)) + else if reply.length < len + @set('draftStatus', Em.String.i18n('composer.min_length.more', n: len - reply.length)) + else + @set('draftStatus', null) ).observes('reply','title') diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 0281b530f..3b403e250 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -244,6 +244,10 @@ en: saved_draft_tip: "saved" saved_local_draft_tip: "saved locally" + min_length: + at_least: "enter at least {{n}} characters" + more: "{{n}} to go..." + save_edit: "Save Edit" reply: "Reply" create_topic: "Create Topic"