list.rb 922 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. # User taskbar list actions.
  3. module Taskbar::List
  4. extend ActiveSupport::Concern
  5. included do
  6. class << self
  7. def list(user, app: nil)
  8. clause = { user: user }
  9. clause[:app] = app if app
  10. Taskbar.where(clause).reorder(:prio)
  11. end
  12. def reorder_list(user, order)
  13. order.each do |relation|
  14. taskbar = Taskbar.find(relation[:id])
  15. next if taskbar.user_id != user.id
  16. taskbar.skip_trigger = true
  17. taskbar.update!(prio: relation[:prio])
  18. end
  19. trigger_list_update(user, 'desktop')
  20. end
  21. def trigger_list_update(user, app)
  22. user_id = Gql::ZammadSchema.id_from_internal_id('User', user.id)
  23. Gql::Subscriptions::User::Current::TaskbarItem::ListUpdates.trigger(nil, arguments: { user_id:, app: })
  24. end
  25. end
  26. end
  27. end