list.rb 976 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, restrict_entities: false)
  8. clause = { user: user }
  9. clause[:app] = app if app
  10. clause[:callback] = taskbar_entities if restrict_entities
  11. Taskbar.where(clause).reorder(:prio)
  12. end
  13. def reorder_list(user, order)
  14. order.each do |relation|
  15. taskbar = Taskbar.find(relation[:id])
  16. next if taskbar.user_id != user.id
  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