mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 07:53:46 +08:00
c95ffb98ef
At this moment, this feature is under a site setting named lazy_load_categories. In the future, categories will no longer be preloaded through site data. This commit add information about categories in topic list and ensures that data is used to display topic list items. Parent categories are serialized too because they are necessary to render {{category-link}}.
33 lines
709 B
Ruby
33 lines
709 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TopicCategorySerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:name,
|
|
:color,
|
|
:text_color,
|
|
:slug,
|
|
:description_text,
|
|
:read_restricted,
|
|
:parent_category_id
|
|
|
|
def include_parent_category_id?
|
|
parent_category_id
|
|
end
|
|
|
|
def name
|
|
if object.uncategorized?
|
|
I18n.t("uncategorized_category_name", locale: SiteSetting.default_locale)
|
|
else
|
|
object.name
|
|
end
|
|
end
|
|
|
|
def description_text
|
|
if object.uncategorized?
|
|
I18n.t("category.uncategorized_description", locale: SiteSetting.default_locale)
|
|
else
|
|
object.description_text
|
|
end
|
|
end
|
|
end
|