list.rb 884 B

123456789101112131415161718192021222324252627282930313233343536
  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.update!(prio: relation[:prio])
  17. end
  18. trigger_list_update(user, 'desktop')
  19. end
  20. def trigger_list_update(user, app)
  21. user_id = Gql::ZammadSchema.id_from_internal_id('User', user.id)
  22. Gql::Subscriptions::User::Current::TaskbarItem::ListUpdates.trigger(nil, arguments: { user_id:, app: })
  23. end
  24. end
  25. end
  26. end