knowledge_base_visibility_class_helper.rb 910 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module KnowledgeBaseVisibilityClassHelper
  3. def visibility_class_name(object)
  4. return if !can_preview?
  5. suffix = case object
  6. when CanBePublished
  7. visiblity_class_suffix_can_be_published(object)
  8. when KnowledgeBase::Category
  9. visiblity_class_suffix_category(object)
  10. end
  11. "kb-item--#{suffix}" if suffix
  12. end
  13. def visiblity_class_suffix_can_be_published(object)
  14. state_suffix_map = {
  15. internal: 'internal',
  16. archived: 'archived',
  17. draft: 'not-published',
  18. }
  19. state_suffix_map[object.can_be_published_aasm.current_state]
  20. end
  21. def visiblity_class_suffix_category(object)
  22. return if object.public_content?
  23. if object.self_with_children_answers.only_internal.any?
  24. 'internal'
  25. else
  26. 'empty'
  27. end
  28. end
  29. end