mirror of
https://github.com/discourse/discourse.git
synced 2025-03-29 04:55:42 +08: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");
|
||||
}),
|
||||
|
||||
parentCategoriesSorted: function() {
|
||||
let cats = this.get("parentCategories");
|
||||
if (this.siteSettings.fixed_category_positions) {
|
||||
return cats;
|
||||
}
|
||||
|
||||
return cats.sortBy("totalTopicCount").reverse();
|
||||
}.property("parentCategories"),
|
||||
|
||||
hidden: function() {
|
||||
return this.site.mobileView && !this.get("category");
|
||||
}.property("category"),
|
||||
|
@ -77,6 +77,17 @@ const Category = RestModel.extend({
|
||||
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() {
|
||||
const id = this.get("id");
|
||||
const url = id ? `/categories/${id}` : "/categories";
|
||||
|
@ -1,6 +1,9 @@
|
||||
{{category-drop
|
||||
{{
|
||||
category-drop
|
||||
category=firstCategory
|
||||
categories=parentCategories}}
|
||||
categories=parentCategoriesSorted
|
||||
countSubcategories=true
|
||||
}}
|
||||
|
||||
{{#if childCategories}}
|
||||
{{category-drop
|
||||
|
@ -31,15 +31,12 @@ createWidget("hamburger-category", {
|
||||
}
|
||||
|
||||
if (!this.currentUser) {
|
||||
let count = c.get("topic_count");
|
||||
let count;
|
||||
|
||||
if (c.get("show_subcategory_list")) {
|
||||
const subcats = c.get("subcategories");
|
||||
if (subcats) {
|
||||
subcats.forEach(s => {
|
||||
count += s.get("topic_count");
|
||||
});
|
||||
}
|
||||
count = c.get("totalTopicCount");
|
||||
} else {
|
||||
count = c.get("topic_count");
|
||||
}
|
||||
|
||||
results.push(h("b.topics-count", number(count)));
|
||||
|
@ -35,6 +35,7 @@ export default ComboBoxComponent.extend({
|
||||
this.get("rowComponentOptions").setProperties({
|
||||
hideParentCategory: this.get("subCategory"),
|
||||
allowUncategorized: true,
|
||||
countSubcategories: this.get("countSubcategories"),
|
||||
displayCategoryDescription: !(
|
||||
this.currentUser &&
|
||||
(this.currentUser.get("staff") || this.currentUser.trust_level > 0)
|
||||
|
@ -70,9 +70,13 @@ export default SelectKitRowComponent.extend({
|
||||
return category.get("parent_category_id");
|
||||
},
|
||||
|
||||
@computed("category.topic_count")
|
||||
topicCount(topicCount) {
|
||||
return `× ${topicCount}`.htmlSafe();
|
||||
@computed(
|
||||
"category.totalTopicCount",
|
||||
"category.topic_count",
|
||||
"options.countSubcategories"
|
||||
)
|
||||
topicCount(totalCount, topicCount, countSubcats) {
|
||||
return `× ${countSubcats ? totalCount : topicCount}`.htmlSafe();
|
||||
},
|
||||
|
||||
@computed("displayCategoryDescription", "category.description")
|
||||
|
Loading…
x
Reference in New Issue
Block a user