templates.rb 708 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class Checklist::Templates < BaseQuery
  4. include Gql::Concerns::EnsuresChecklistFeatureActive
  5. description 'Fetch checklist templates'
  6. argument :only_active, Boolean, required: false, default_value: false, description: 'Fetch only active templates'
  7. type [Gql::Types::Checklist::TemplateType, { null: false }], null: false
  8. def self.authorize(_obj, ctx)
  9. ensure_checklist_feature_active!
  10. ctx.current_user.permissions?(['ticket.agent'])
  11. end
  12. def resolve(only_active:)
  13. only_active ? ::ChecklistTemplate.where(active: true) : ::ChecklistTemplate.all
  14. end
  15. end
  16. end