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)

View File

@ -343,6 +343,7 @@ en:
title_length: "Title needs between {{min}} and {{max}} characters."
post_missing: "Post can't be empty."
post_length: "Post must be at least {{min}} characters long."
category_missing: "You must choose a category."
save_edit: "Save Edit"
reply_original: "Reply on Original Topic"

View File

@ -417,6 +417,7 @@ en:
min_topic_title_length: "Minimum topic title length in characters"
max_topic_title_length: "Maximum topic title length in characters"
min_search_term_length: "Minimum search term length in characters"
allow_uncategorized_topics: "Allow topics to be created without a category"
allow_duplicate_topic_titles: "Allow topics with identical titles"
unique_posts_mins: "How many minutes before a user can make a post with the same content again"
enforce_global_nicknames: "Enforce global nickname uniqueness (WARNING: only change this during initial setup)"