select.rb 970 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class CoreWorkflow::Result::Select < CoreWorkflow::Result::Backend
  3. def run
  4. return if skip?
  5. @result_object.result[:select][field] = select_value
  6. @result_object.payload['params'][field] = @result_object.result[:select][field]
  7. set_rerun
  8. mark_restricted
  9. true
  10. end
  11. def skip?
  12. return true if select_value.nil?
  13. return true if params_set?
  14. return true if select_set?
  15. false
  16. end
  17. def select_value
  18. @select_value ||= Array(@perform_config['select']).reject { |v| @result_object.result[:restrict_values][field].exclude?(v) }
  19. return @select_value if multiple?
  20. @select_value.first
  21. end
  22. def params_set?
  23. @result_object.payload['params'][field] && select_value == @result_object.payload['params'][field]
  24. end
  25. def select_set?
  26. @result_object.result[:select][field] && select_value == @result_object.result[:select][field]
  27. end
  28. end