2022-12-23 11:45:29 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UserSidebarMixin
|
2023-07-24 08:07:37 +08:00
|
|
|
include NavigationMenuTagsMixin
|
2023-01-20 09:50:24 +08:00
|
|
|
|
2023-07-24 08:07:37 +08:00
|
|
|
def sidebar_tags
|
|
|
|
serialize_tags(object.visible_sidebar_tags(scope))
|
2022-12-23 11:45:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def display_sidebar_tags
|
|
|
|
DiscourseTagging.filter_visible(Tag, scope).exists?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_display_sidebar_tags?
|
|
|
|
include_sidebar_tags?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_sidebar_tags?
|
|
|
|
SiteSetting.tagging_enabled && sidebar_navigation_menu?
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar_category_ids
|
2023-07-27 10:52:33 +08:00
|
|
|
object.secured_sidebar_category_ids(scope)
|
2022-12-23 11:45:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_sidebar_category_ids?
|
|
|
|
sidebar_navigation_menu?
|
|
|
|
end
|
|
|
|
|
2023-02-03 11:44:40 +08:00
|
|
|
def sidebar_sections
|
|
|
|
object
|
|
|
|
.sidebar_sections
|
|
|
|
.order(created_at: :asc)
|
|
|
|
.includes(sidebar_section_links: :linkable)
|
|
|
|
.map { |section| SidebarSectionSerializer.new(section, root: false) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_sidebar_sections?
|
|
|
|
sidebar_navigation_menu?
|
|
|
|
end
|
|
|
|
|
2022-12-23 11:45:29 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
def sidebar_navigation_menu?
|
2023-02-21 09:59:56 +08:00
|
|
|
!SiteSetting.legacy_navigation_menu? ||
|
|
|
|
%w[sidebar header_dropdown].include?(options[:navigation_menu_param])
|
2022-12-23 11:45:29 +08:00
|
|
|
end
|
|
|
|
end
|