Refactored a bit.

pull/1065/head
Richard 11 years ago
parent 958bbab729
commit c383aa080a
  1. 17
      app/models/work_package.rb

@ -716,19 +716,19 @@ class WorkPackage < ActiveRecord::Base
end end
# Begin Custom Value Display Helper Methods # Begin Custom Value Display Helper Methods
# TODO RS: This probably isn't the right place for display helpers. It's convenient though to have
# the method on the model so that it can be used in the rabl template.
def get_custom_value_display_data(custom_field) def get_custom_value_display_data(custom_field)
custom_value = custom_values.find_by_custom_field_id(custom_field.id) display_custom_value(custom_values.find_by_custom_field_id(custom_field.id))
if !custom_value.nil?
{
custom_field_id: custom_field.id,
field_format: custom_field.field_format,
value: custom_value.value
}
end
end end
def custom_values_display_data def custom_values_display_data
custom_values.map do |custom_value| custom_values.map do |custom_value|
display_custom_value(custom_value)
end
end
def display_custom_value(custom_value)
if !custom_value.nil? if !custom_value.nil?
{ {
custom_field_id: custom_value.custom_field.id, custom_field_id: custom_value.custom_field.id,
@ -737,7 +737,6 @@ class WorkPackage < ActiveRecord::Base
} }
end end
end end
end
# End Custom Value Display Helper Methods # End Custom Value Display Helper Methods
protected protected

Loading…
Cancel
Save