20221116134211_issue_2185_and_or_conditions.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue2185AndOrConditions < ActiveRecord::Migration[6.1]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. # Add prio preference to existing ticket settings.
  7. # Otherwise, the ordering on the same screen will be off.
  8. %w[ticket_hook ticket_hook_position ticket_last_contact_behaviour].each_with_index do |name, index|
  9. setting = Setting.find_by(name: name)
  10. setting[:preferences][:prio] = (index + 1) * 1000
  11. setting.save
  12. end
  13. # Create the new setting with correct prio.
  14. Setting.create_if_not_exists(
  15. title: 'Ticket Conditions Expert Mode',
  16. name: 'ticket_allow_expert_conditions',
  17. area: 'Ticket::Base',
  18. description: 'Defines if the ticket conditions editor supports complex logical expressions.',
  19. options: {
  20. form: [
  21. {
  22. display: '',
  23. null: true,
  24. name: 'ticket_allow_expert_conditions',
  25. tag: 'boolean',
  26. options: {
  27. true => 'yes',
  28. false => 'no',
  29. },
  30. },
  31. ],
  32. },
  33. state: false,
  34. preferences: {
  35. prio: 4000,
  36. permission: ['admin.ticket'],
  37. },
  38. frontend: true
  39. )
  40. end
  41. end