edit.rb 955 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 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. initialValue: object.organization_ids,
  18. options: ::Organization.where(id: object.organization_ids).each_with_object([]) do |organization, options|
  19. options << {
  20. value: organization.id,
  21. label: organization.name,
  22. organization: {
  23. active: organization.active,
  24. }
  25. }
  26. end,
  27. }
  28. end
  29. end