knowledge_base_visibility_note_helper.rb 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module KnowledgeBaseVisibilityNoteHelper
  3. def visibility_note(object)
  4. return if !can_preview?
  5. text = visibility_text(object)
  6. return if text.nil?
  7. render 'knowledge_base/public/visibility_note', text: text
  8. end
  9. def visibility_text(object)
  10. case object
  11. when CanBePublished
  12. visiblity_text_can_be_published(object)
  13. when KnowledgeBase::Category
  14. visiblity_text_category(object)
  15. end
  16. end
  17. def visiblity_text_can_be_published(object)
  18. state_text_map = {
  19. internal: 'internal',
  20. archived: 'archived',
  21. draft: 'not published',
  22. }
  23. state_text_map[object.can_be_published_aasm.current_state]
  24. end
  25. def visiblity_text_category(object)
  26. return if object.public_content?
  27. if object.self_with_children_answers.only_internal.any?
  28. 'hidden, visible only internally'
  29. else
  30. 'hidden, no published answers'
  31. end
  32. end
  33. end