template_updates.rb 873 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class Checklist::TemplateUpdates < BaseSubscription
  4. include Gql::Concerns::EnsuresChecklistFeatureActive
  5. description 'Subscription for checklist template changes.'
  6. argument :only_active, Boolean, required: false, default_value: false, description: 'Fetch only active templates'
  7. field :checklist_templates, [Gql::Types::Checklist::TemplateType, { null: false }], description: 'Checklist templates'
  8. def self.authorize(_obj, ctx)
  9. ensure_checklist_feature_active!
  10. super
  11. end
  12. def authorized?(only_active:)
  13. context.current_user.permissions?('ticket.agent')
  14. end
  15. def update(only_active:)
  16. { checklist_templates: only_active ? ::ChecklistTemplate.where(active: true) : ::ChecklistTemplate.all }
  17. end
  18. end
  19. end