A platform for community discussion. Free, open, simple.
DEV: Allow the creation of sub-sub-categories
Daniel Waterworth2f5adbe1f49c
diff --git a/app/assets/javascripts/discourse/components/edit-category-general.js.es6 b/app/assets/javascripts/discourse/components/edit-category-general.js.es6index bdcdf440dc3..9d3e548a20a 100644--- a/app/assets/javascripts/discourse/components/edit-category-general.js.es6+++ b/app/assets/javascripts/discourse/components/edit-category-general.js.es6@@ -61,7 +61,7 @@ export default buildCategoryPanel("general", {parentCategories() {return this.site.get("categoriesList")- .filter(c => !c.get("parentCategory"));+ .filter(c => c.level + 1 < Discourse.SiteSettings.max_category_nesting);},@discourseComputed(diff --git a/app/assets/javascripts/discourse/models/category.js.es6 b/app/assets/javascripts/discourse/models/category.js.es6index 1b442db7c54..9bb56c276e3 100644--- a/app/assets/javascripts/discourse/models/category.js.es6+++ b/app/assets/javascripts/discourse/models/category.js.es6@@ -60,6 +60,11 @@ const Category = RestModel.extend({return [...(parentAncestors || []), this];},+ @discourseComputed("parentCategory.level")+ level(parentLevel) {+ return (parentLevel || -1) + 1;+ },+@discourseComputed("notification_level")isMuted(notificationLevel) {return notificationLevel === NotificationLevels.MUTED;diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbsindex 5f0720e838e..1c30b0c7623 100644--- a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs+++ b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs@@ -22,7 +22,7 @@value=category.parent_category_idexcludeCategoryId=category.idcategories=parentCategories- allowSubCategories=false+ allowSubCategories=trueallowUncategorized=false}}{{/if}}</section>diff --git a/app/models/category.rb b/app/models/category.rbindex 25aeff75fcc..5af5eabac34 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -13,7 +13,6 @@ class Category < ActiveRecord::Baseinclude AnonCacheInvalidatorinclude HasDestroyedWebHook- MAX_NESTING = 2 # category + subcategoryREQUIRE_TOPIC_APPROVAL = 'require_topic_approval'REQUIRE_REPLY_APPROVAL = 'require_reply_approval'NUM_AUTO_BUMP_DAILY = 'num_auto_bump_daily'@@ -329,7 +328,7 @@ class Category < ActiveRecord::Base# This is used in a validation so has to produce accurate results before the# record has been saved- def height_of_ancestors(max_height = MAX_NESTING)+ def height_of_ancestors(max_height = SiteSetting.max_category_nesting)parent_id = self.parent_category_idreturn max_height if parent_id == id@@ -357,7 +356,7 @@ class Category < ActiveRecord::Base# This is used in a validation so has to produce accurate results before the# record has been saved- def depth_of_descendants(max_depth = MAX_NESTING)+ def depth_of_descendants(max_depth = SiteSetting.max_category_nesting)parent_id = self.parent_category_idreturn max_depth if parent_id == id@@ -390,7 +389,7 @@ class Category < ActiveRecord::Baseerrors.add(:base, I18n.t("category.errors.self_parent")) if parent_category_id == idtotal_depth = height_of_ancestors + 1 + depth_of_descendants- errors.add(:base, I18n.t("category.errors.depth")) if total_depth > MAX_NESTING+ errors.add(:base, I18n.t("category.errors.depth")) if total_depth > SiteSetting.max_category_nestingendenddiff --git a/config/site_settings.yml b/config/site_settings.ymlindex 103194d78a7..9d1f045f0c7 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -240,6 +240,12 @@ basic:- box- bullet- none+ max_category_nesting:+ client: true+ default: 2+ min: 2+ max: 3+ hidden: trueenable_mobile_theme:client: truedefault: true