assets.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Taskbar
  3. module Assets
  4. extend ActiveSupport::Concern
  5. def assets(data)
  6. return data if assets_added_to?(data)
  7. app_model = Taskbar.to_app_model
  8. if !data[ app_model ]
  9. data[ app_model ] = {}
  10. end
  11. return data if data[ app_model ][ id ]
  12. data[ app_model ][ id ] = attributes_with_association_ids
  13. assets_content(data)
  14. data
  15. end
  16. def assets_content(data)
  17. return if state.blank?
  18. return if !key.starts_with?('TicketCreateScreen')
  19. assets_user(data)
  20. assets_state(data)
  21. assets_priority(data)
  22. assets_group(data)
  23. end
  24. def assets_user(data)
  25. User.find_by(id: state[:owner_id])&.assets(data)
  26. User.find_by(id: state[:customer_id])&.assets(data)
  27. end
  28. def assets_state(data)
  29. Ticket::State.find_by(id: state[:state_id])&.assets(data)
  30. end
  31. def assets_priority(data)
  32. Ticket::Priority.find_by(id: state[:priority_id])&.assets(data)
  33. end
  34. def assets_group(data)
  35. Group.find_by(id: state[:group_id])&.assets(data)
  36. end
  37. end
  38. end