update.rb 940 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::Current::TaskbarItem::Update < BaseMutation
  4. description 'Update a taskbar item of the currently logged-in user'
  5. argument :id, GraphQL::Types::ID, required: true, loads: Gql::Types::User::TaskbarItemType, as: :taskbar_item, description: 'The taskbar item ID'
  6. argument :input, Gql::Types::Input::User::TaskbarItemInputType, required: true, description: 'The taskbar item parameters.'
  7. field :taskbar_item, Gql::Types::User::TaskbarItemType, description: 'The updated taskbar item.'
  8. def resolve(taskbar_item:, input:)
  9. preferences = taskbar_item.preferences || {}
  10. preferences[:dirty] = input[:dirty].presence || false
  11. input.delete(:dirty)
  12. hash = input.to_h.merge(
  13. preferences: preferences
  14. )
  15. taskbar_item.update!(hash)
  16. { taskbar_item: }
  17. end
  18. end
  19. end