reset_order.rb 936 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::Current::Overview::ResetOrder < BaseMutation
  4. description 'Reset the overview sorting for the current user'
  5. field :success, Boolean, null: false, description: 'Was the reset successful?'
  6. field :overviews, [Gql::Types::OverviewType], null: true, description: 'List of overview sortings for the user'
  7. def self.authorize(_obj, ctx)
  8. ctx.current_user.permissions?('user_preferences.overview_sorting')
  9. end
  10. def resolve
  11. ActiveRecord::Base.transaction do
  12. ::User::OverviewSorting.where(user: context.current_user).destroy_all
  13. end
  14. Gql::Subscriptions::User::Current::OverviewOrderingUpdates
  15. .trigger_by(context.current_user)
  16. {
  17. success: true,
  18. overviews: Service::User::Overview::List.new(context.current_user).execute
  19. }
  20. end
  21. end
  22. end