FIX: Show category list on subcategory page if it has subcategories too (#8768)

The category list was displayed only for top level categories, which
had no parent.
This commit is contained in:
Dan Ungureanu 2020-01-22 20:27:30 +02:00 committed by GitHub
parent b63d146128
commit c7a8bbd6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -13,7 +13,10 @@ export function addCategorySortCriteria(criteria) {
export default buildCategoryPanel("settings", {
emailInEnabled: setting("email_in"),
showPositionInput: setting("fixed_category_positions"),
isParentCategory: empty("category.parent_category_id"),
@discourseComputed("category.isParent", "category.parent_category_id")
isParentCategory(isParent, parentCategoryId) {
return isParent || !parentCategoryId;
},
showSubcategoryListStyle: and(
"category.show_subcategory_list",
"isParentCategory"

View File

@ -65,6 +65,11 @@ const Category = RestModel.extend({
return (parentLevel || -1) + 1;
},
@discourseComputed("subcategories")
isParent(subcategories) {
return subcategories && subcategories.length > 0;
},
@discourseComputed("subcategories")
isGrandParent(subcategories) {
return (

View File

@ -9,7 +9,6 @@ import PermissionType from "discourse/models/permission-type";
import CategoryList from "discourse/models/category-list";
import Category from "discourse/models/category";
import { Promise, all } from "rsvp";
import { isNone } from "@ember/utils";
// A helper function to create a category route with parameters
export default (filterArg, params) => {
@ -88,10 +87,8 @@ export default (filterArg, params) => {
_createSubcategoryList(category) {
this._categoryList = null;
if (
isNone(category.get("parentCategory")) &&
category.get("show_subcategory_list")
) {
if (category.isParent && category.show_subcategory_list) {
return CategoryList.listForParent(this.store, category).then(
list => (this._categoryList = list)
);