Add Site Setting allow_uncategorized_topics. Uncheck it to force people to choose a category for all new topics.

This commit is contained in:
Neil Lalonde
2013-05-24 16:49:08 -04:00
parent 1313c0f094
commit d26b87bd3c
9 changed files with 33 additions and 9 deletions

View File

@ -42,6 +42,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
if( composer.get('cantSubmitPost') ) {
this.set('view.showTitleTip', true);
this.set('view.showCategoryTip', true);
this.set('view.showReplyTip', true);
return;
}
@ -336,6 +337,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
this.set('content', null);
this.set('view.content', null);
this.set('view.showTitleTip', false);
this.set('view.showCategoryTip', false);
this.set('view.showReplyTip', false);
},

View File

@ -172,8 +172,10 @@ Discourse.Composer = Discourse.Model.extend({
// reply is always required
if (this.get('replyLength') < Discourse.SiteSettings.min_post_length) return true;
if (!Discourse.SiteSettings.allow_uncategorized_topics && !this.get('categoryName')) return true;
return false;
}.property('loading', 'editTitle', 'titleLength', 'targetUsernames', 'replyLength'),
}.property('loading', 'editTitle', 'titleLength', 'targetUsernames', 'replyLength', 'categoryName'),
// The text for the save button
saveText: function() {

View File

@ -39,7 +39,10 @@
</div>
{{#unless content.creatingPrivateMessage}}
{{view Discourse.ComboboxViewCategory valueAttribute="name" contentBinding="categories" valueBinding="content.categoryName"}}
<div class="category-input">
{{view Discourse.ComboboxViewCategory valueAttribute="name" contentBinding="categories" valueBinding="content.categoryName" showUncategorized="true"}}
{{popupInputTip validation=view.categoryValidation show=view.showCategoryTip}}
</div>
{{#if content.archetype.hasOptions}}
<button class='btn' {{action showOptions}}>{{i18n topic.options}}</button>
{{/if}}

View File

@ -7,12 +7,15 @@
@module Discourse
**/
Discourse.ComboboxViewCategory = Discourse.ComboboxView.extend({
none: 'category.none',
classNames: ['combobox category-combobox'],
overrideWidths: true,
dataAttributes: ['name', 'color', 'text_color', 'description', 'topic_count'],
valueBinding: Ember.Binding.oneWay('source'),
none: function() {
if (Discourse.SiteSettings.allow_uncategorized_topics || this.get('showUncategorized')) return 'category.none';
}.property('showUncategorized'),
template: function(text, templateData) {
if (!templateData.color) return text;
var result = "<span class='badge-category' style='background-color: #" + templateData.color + '; color: #' +

View File

@ -384,6 +384,12 @@ Discourse.ComposerView = Discourse.View.extend({
}
}.property('content.title'),
categoryValidation: function() {
if( !Discourse.SiteSettings.allow_uncategorized_topics && !this.get('content.categoryName')) {
return Discourse.InputValidation.create({ failed: true, reason: Em.String.i18n('composer.error.category_missing') });
}
}.property('content.categoryName'),
replyValidation: function() {
var reply = this.get('content.reply'), reason;
if( !reply || reply.length < 1 ){

View File

@ -322,14 +322,19 @@
bottom: 8px;
}
}
.title-input {
.title-input, .category-input {
position: relative;
display: inline;
.popup-tip {
width: 300px;
left: -8px;
margin-top: 8px;
}
}
.title-input .popup-tip {
width: 300px;
left: -8px;
margin-top: 8px;
}
.category-input .popup-tip {
width: 240px;
left: 432px;
top: -7px;
}
}

View File

@ -35,6 +35,7 @@ class SiteSetting < ActiveRecord::Base
client_setting(:max_post_length, 16000)
client_setting(:min_topic_title_length, 15)
client_setting(:max_topic_title_length, 255)
client_setting(:allow_uncategorized_topics, true)
client_setting(:min_search_term_length, 3)
client_setting(:flush_timings_secs, 5)
client_setting(:supress_reply_directly_below, true)