mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
FIX: Make subcategories page more like categories (#29240)
The subcategories page was not paginated and it was using the subcategory style from the category settings. The same page style should be used for categories and subcategories page.
This commit is contained in:
parent
23c486799f
commit
c1f078cacf
|
@ -36,6 +36,7 @@ const globalComponents = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class CategoriesDisplay extends Component {
|
export default class CategoriesDisplay extends Component {
|
||||||
|
@service router;
|
||||||
@service siteSettings;
|
@service siteSettings;
|
||||||
@service site;
|
@service site;
|
||||||
|
|
||||||
|
@ -69,7 +70,10 @@ export default class CategoriesDisplay extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
get categoriesComponent() {
|
get categoriesComponent() {
|
||||||
if (this.args.parentCategory) {
|
if (
|
||||||
|
this.args.parentCategory &&
|
||||||
|
this.router.currentRouteName === "discovery.category"
|
||||||
|
) {
|
||||||
return this.#componentForSubcategories;
|
return this.#componentForSubcategories;
|
||||||
} else {
|
} else {
|
||||||
return this.#globalComponent;
|
return this.#globalComponent;
|
||||||
|
|
|
@ -133,22 +133,15 @@ class CategoryList
|
||||||
|
|
||||||
def find_categories
|
def find_categories
|
||||||
query = Category.includes(CategoryList.included_associations).secured(@guardian)
|
query = Category.includes(CategoryList.included_associations).secured(@guardian)
|
||||||
|
|
||||||
query =
|
|
||||||
query.where(
|
|
||||||
"categories.parent_category_id = ?",
|
|
||||||
@options[:parent_category_id].to_i,
|
|
||||||
) if @options[:parent_category_id].present?
|
|
||||||
|
|
||||||
query = self.class.order_categories(query)
|
query = self.class.order_categories(query)
|
||||||
|
|
||||||
|
if @options[:parent_category_id].present? || @guardian.can_lazy_load_categories?
|
||||||
|
query = query.where(parent_category_id: @options[:parent_category_id])
|
||||||
|
end
|
||||||
|
|
||||||
page = [1, @options[:page].to_i].max
|
page = [1, @options[:page].to_i].max
|
||||||
if @guardian.can_lazy_load_categories? && @options[:parent_category_id].blank?
|
if @guardian.can_lazy_load_categories?
|
||||||
query =
|
query = query.limit(CATEGORIES_PER_PAGE).offset((page - 1) * CATEGORIES_PER_PAGE)
|
||||||
query
|
|
||||||
.where(parent_category_id: nil)
|
|
||||||
.limit(CATEGORIES_PER_PAGE)
|
|
||||||
.offset((page - 1) * CATEGORIES_PER_PAGE)
|
|
||||||
elsif page > 1
|
elsif page > 1
|
||||||
# Pagination is supported only when lazy load is enabled. If it is not,
|
# Pagination is supported only when lazy load is enabled. If it is not,
|
||||||
# everything is returned on page 1.
|
# everything is returned on page 1.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user