Skip to content

A platform for community discussion. Free, open, simple.

DEV: Indicate whether categories are missing on categories page (#27608)

Daniel Waterworth0d6bd5207d21
diff --git a/app/assets/javascripts/discourse/app/components/parent-category-row.hbs b/app/assets/javascripts/discourse/app/components/parent-category-row.hbs
index 83e3f2b06a9..11e58c209c9 100644
--- a/app/assets/javascripts/discourse/app/components/parent-category-row.hbs
+++ b/app/assets/javascripts/discourse/app/components/parent-category-row.hbs
@@ -40,6 +40,12 @@
@listType={{this.listType}}
/>
{{/each}}
+ {{#if (gt this.category.unloadedSubcategoryCount 0)}}
+ {{i18n
+ "category_row.subcategory_count"
+ count=this.category.unloadedSubcategoryCount
+ }}
+ {{/if}}
</tbody>
</table>
{{else if this.category.subcategories}}
@@ -50,6 +56,12 @@
@listType={{this.listType}}
/>
{{/each}}
+ {{#if (gt this.category.unloadedSubcategoryCount 0)}}
+ {{i18n
+ "category_row.subcategory_count"
+ count=this.category.unloadedSubcategoryCount
+ }}
+ {{/if}}
</div>
{{/if}}
</td>
diff --git a/app/assets/javascripts/discourse/app/models/category.js b/app/assets/javascripts/discourse/app/models/category.js
index b9861b0c29a..44080ed62f7 100644
--- a/app/assets/javascripts/discourse/app/models/category.js
+++ b/app/assets/javascripts/discourse/app/models/category.js
@@ -491,6 +491,11 @@ export default class Category extends RestModel {
return this.site.categories.filterBy("parent_category_id", this.id);
}
+ @computed("subcategories")
+ get unloadedSubcategoryCount() {
+ return this.subcategory_count - this.subcategories.length;
+ }
+
@computed("subcategory_list")
get serializedSubcategories() {
return this.subcategory_list?.map((c) => Category.create(c));