20210921112300_issue_3751_missing_workflow_screens.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue3751MissingWorkflowScreens < ActiveRecord::Migration[6.0]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. fix_organization_screens_create
  6. fix_user_screens_create
  7. end
  8. def fix_organization_screens_create
  9. %w[name shared domain_assignment active].each do |name|
  10. field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'Organization'))
  11. next if field.blank?
  12. field.screens['create'] ||= {}
  13. field.screens['create']['-all-'] ||= {}
  14. field.screens['create']['-all-']['null'] = false
  15. field.save
  16. end
  17. end
  18. def fix_user_screens_create
  19. %w[firstname lastname active].each do |name|
  20. field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'User'))
  21. next if field.blank?
  22. field.screens['create'] ||= {}
  23. field.screens['create']['-all-'] ||= {}
  24. field.screens['create']['-all-']['null'] = false
  25. field.save
  26. end
  27. end
  28. end