mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: count subcategories in breadcrumbs
This commit is contained in:
parent
292e8a3756
commit
818bc10107
@ -15,6 +15,15 @@ export default Ember.Component.extend({
|
|||||||
return !c.get("parentCategory");
|
return !c.get("parentCategory");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
parentCategoriesSorted: function() {
|
||||||
|
let cats = this.get("parentCategories");
|
||||||
|
if (this.siteSettings.fixed_category_positions) {
|
||||||
|
return cats;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cats.sortBy("totalTopicCount").reverse();
|
||||||
|
}.property("parentCategories"),
|
||||||
|
|
||||||
hidden: function() {
|
hidden: function() {
|
||||||
return this.site.mobileView && !this.get("category");
|
return this.site.mobileView && !this.get("category");
|
||||||
}.property("category"),
|
}.property("category"),
|
||||||
|
@ -77,6 +77,17 @@ const Category = RestModel.extend({
|
|||||||
return topicCount > (this.get("num_featured_topics") || 2);
|
return topicCount > (this.get("num_featured_topics") || 2);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed("topic_count", "subcategories")
|
||||||
|
totalTopicCount(topicCount, subcats) {
|
||||||
|
let count = topicCount;
|
||||||
|
if (subcats) {
|
||||||
|
subcats.forEach(s => {
|
||||||
|
count += s.get("topic_count");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
},
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
const id = this.get("id");
|
const id = this.get("id");
|
||||||
const url = id ? `/categories/${id}` : "/categories";
|
const url = id ? `/categories/${id}` : "/categories";
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
{{category-drop
|
{{
|
||||||
|
category-drop
|
||||||
category=firstCategory
|
category=firstCategory
|
||||||
categories=parentCategories}}
|
categories=parentCategoriesSorted
|
||||||
|
countSubcategories=true
|
||||||
|
}}
|
||||||
|
|
||||||
{{#if childCategories}}
|
{{#if childCategories}}
|
||||||
{{category-drop
|
{{category-drop
|
||||||
|
@ -31,15 +31,12 @@ createWidget("hamburger-category", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.currentUser) {
|
if (!this.currentUser) {
|
||||||
let count = c.get("topic_count");
|
let count;
|
||||||
|
|
||||||
if (c.get("show_subcategory_list")) {
|
if (c.get("show_subcategory_list")) {
|
||||||
const subcats = c.get("subcategories");
|
count = c.get("totalTopicCount");
|
||||||
if (subcats) {
|
} else {
|
||||||
subcats.forEach(s => {
|
count = c.get("topic_count");
|
||||||
count += s.get("topic_count");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
results.push(h("b.topics-count", number(count)));
|
results.push(h("b.topics-count", number(count)));
|
||||||
|
@ -35,6 +35,7 @@ export default ComboBoxComponent.extend({
|
|||||||
this.get("rowComponentOptions").setProperties({
|
this.get("rowComponentOptions").setProperties({
|
||||||
hideParentCategory: this.get("subCategory"),
|
hideParentCategory: this.get("subCategory"),
|
||||||
allowUncategorized: true,
|
allowUncategorized: true,
|
||||||
|
countSubcategories: this.get("countSubcategories"),
|
||||||
displayCategoryDescription: !(
|
displayCategoryDescription: !(
|
||||||
this.currentUser &&
|
this.currentUser &&
|
||||||
(this.currentUser.get("staff") || this.currentUser.trust_level > 0)
|
(this.currentUser.get("staff") || this.currentUser.trust_level > 0)
|
||||||
|
@ -70,9 +70,13 @@ export default SelectKitRowComponent.extend({
|
|||||||
return category.get("parent_category_id");
|
return category.get("parent_category_id");
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("category.topic_count")
|
@computed(
|
||||||
topicCount(topicCount) {
|
"category.totalTopicCount",
|
||||||
return `× ${topicCount}`.htmlSafe();
|
"category.topic_count",
|
||||||
|
"options.countSubcategories"
|
||||||
|
)
|
||||||
|
topicCount(totalCount, topicCount, countSubcats) {
|
||||||
|
return `× ${countSubcats ? totalCount : topicCount}`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("displayCategoryDescription", "category.description")
|
@computed("displayCategoryDescription", "category.description")
|
||||||
|
Loading…
Reference in New Issue
Block a user