From 0d6bd5207d21de97c864d181b51b8ac41f20beb0 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Tue, 25 Jun 2024 13:15:40 -0500 Subject: [PATCH] DEV: Indicate whether categories are missing on categories page (#27608) --- .../discourse/app/components/parent-category-row.hbs | 12 ++++++++++++ .../javascripts/discourse/app/models/category.js | 5 +++++ 2 files changed, 17 insertions(+) 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}} {{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}} {{/if}} 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));