2022-12-22 21:45:29 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UserSidebarMixin
|
|
|
|
def sidebar_tags
|
2023-01-19 19:50:24 -06:00
|
|
|
topic_count_column = Tag.topic_count_column(scope)
|
|
|
|
|
2023-01-09 06:20:10 -06:00
|
|
|
object
|
|
|
|
.visible_sidebar_tags(scope)
|
2023-01-19 19:50:24 -06:00
|
|
|
.pluck(:name, topic_count_column, :pm_topic_count)
|
2022-12-22 21:45:29 -06:00
|
|
|
.reduce([]) do |tags, sidebar_tag|
|
2023-01-09 06:20:10 -06:00
|
|
|
tags.push(name: sidebar_tag[0], pm_only: sidebar_tag[1] == 0 && sidebar_tag[2] > 0)
|
2022-12-22 21:45:29 -06:00
|
|
|
end
|
|
|
|
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
|
|
|
|
object.category_sidebar_section_links.pluck(:linkable_id) & scope.allowed_category_ids
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_sidebar_category_ids?
|
|
|
|
sidebar_navigation_menu?
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar_list_destination
|
2023-01-09 06:20:10 -06:00
|
|
|
if object.user_option.sidebar_list_none_selected?
|
|
|
|
SiteSetting.default_sidebar_list_destination
|
|
|
|
else
|
|
|
|
object.user_option.sidebar_list_destination
|
|
|
|
end
|
2022-12-22 21:45:29 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_sidebar_list_destination?
|
|
|
|
sidebar_navigation_menu?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def sidebar_navigation_menu?
|
2023-01-12 16:47:58 -06:00
|
|
|
!SiteSetting.legacy_navigation_menu? || options[:enable_sidebar_param] == "1"
|
2022-12-22 21:45:29 -06:00
|
|
|
end
|
|
|
|
end
|