TWEAK: If show_subcategory_list is enabled, hide subcategories from

the site map.
This commit is contained in:
Robin Ward 2014-07-22 16:15:56 -04:00
parent b3c149de22
commit 7c0e723464
2 changed files with 9 additions and 9 deletions

View file

@ -18,14 +18,14 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
}.property(),
categories: function() {
if (Discourse.SiteSettings.allow_uncategorized_topics) {
return Discourse.Category.list();
} else {
// Exclude the uncategorized category if it's empty
return Discourse.Category.list().reject(function(c) {
return c.get('isUncategorizedCategory') && !Discourse.User.currentProp('staff');
});
}
var hideUncategorized = !Discourse.SiteSettings.allow_uncategorized_topics,
showSubcatList = Discourse.SiteSettings.show_subcategory_list,
isStaff = Discourse.User.currentProp('staff');
return Discourse.Category.list().reject(function(c) {
if (showSubcatList && c.get('parent_category_id')) { return true; }
if (hideUncategorized && c.get('isUncategorizedCategory') && !isStaff) { return true; }
return false;
});
}.property(),
actions: {

View file

@ -72,7 +72,7 @@ test("categories", function() {
var categoryListStub = ["category1", "category2"];
this.stub(Discourse.Category, "list").returns(categoryListStub);
equal(controller.get("categories"), categoryListStub, "returns the list of categories");
deepEqual(controller.get("categories"), categoryListStub, "returns the list of categories");
});
test("toggleMobleView", function() {