edit.rb 997 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class FormUpdater::Updater::User::Edit < FormUpdater::Updater
  3. include FormUpdater::Concerns::ChecksCoreWorkflow
  4. core_workflow_screen 'edit'
  5. def object_type
  6. ::User
  7. end
  8. def resolve
  9. if meta[:initial] && object && object.organization_ids.present?
  10. result['organization_ids'] = organization_ids
  11. end
  12. super
  13. end
  14. private
  15. def organization_ids
  16. {
  17. value: object.organization_ids,
  18. options: ::Organization.where(id: object.organization_ids).each_with_object([]) do |organization, options|
  19. options << {
  20. # TODO: needs to be aligned during the autocomplete query implementation
  21. value: organization.id,
  22. label: organization.name,
  23. organization: {
  24. active: organization.active,
  25. }
  26. }
  27. end,
  28. }
  29. end
  30. end