2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-06-04 03:40:48 +00:00
|
|
|
module KnowledgeBaseVisibilityClassHelper
|
|
|
|
def visibility_class_name(object)
|
2022-02-24 11:15:19 +00:00
|
|
|
return if !can_preview?
|
2019-06-04 03:40:48 +00:00
|
|
|
|
|
|
|
suffix = case object
|
|
|
|
when CanBePublished
|
|
|
|
visiblity_class_suffix_can_be_published(object)
|
|
|
|
when KnowledgeBase::Category
|
|
|
|
visiblity_class_suffix_category(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
"kb-item--#{suffix}" if suffix
|
|
|
|
end
|
|
|
|
|
|
|
|
def visiblity_class_suffix_can_be_published(object)
|
2020-07-13 12:46:08 +00:00
|
|
|
state_suffix_map = {
|
|
|
|
internal: 'internal',
|
|
|
|
archived: 'archived',
|
|
|
|
draft: 'not-published',
|
|
|
|
}
|
|
|
|
state_suffix_map[object.can_be_published_aasm.current_state]
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visiblity_class_suffix_category(object)
|
|
|
|
return if object.public_content?
|
|
|
|
|
|
|
|
if object.self_with_children_answers.only_internal.any?
|
|
|
|
'internal'
|
|
|
|
else
|
|
|
|
'empty'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|