assets.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class CoreWorkflow
  3. module Assets
  4. extend ActiveSupport::Concern
  5. def assets(data)
  6. app_model_workflow = CoreWorkflow.to_app_model
  7. data[ app_model_workflow ] ||= {}
  8. return data if data[ app_model_workflow ][ id ]
  9. data = assets_object(data)
  10. assets_user(data)
  11. end
  12. end
  13. def assets_object(data)
  14. app_model_workflow = CoreWorkflow.to_app_model
  15. data[ app_model_workflow ][ id ] = attributes_with_association_ids
  16. data = assets_of_selector('condition_selected', data)
  17. data = assets_of_selector('condition_saved', data)
  18. assets_of_selector('perform', data)
  19. end
  20. def assets_user(data)
  21. app_model_user = User.to_app_model
  22. data[ app_model_user ] ||= {}
  23. %w[created_by_id updated_by_id].each do |local_user_id|
  24. next if !self[ local_user_id ]
  25. next if data[ app_model_user ][ self[ local_user_id ] ]
  26. user = User.lookup(id: self[ local_user_id ])
  27. next if !user
  28. data = user.assets(data)
  29. end
  30. data
  31. end
  32. end