|
|
@ -713,6 +713,18 @@ class WorkPackage < ActiveRecord::Base |
|
|
|
return allowed |
|
|
|
return allowed |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cast_custom_value_with_meta(custom_value, custom_field=nil) |
|
|
|
|
|
|
|
return unless custom_value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
custom_field ||= custom_value.custom_field |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
custom_field_id: custom_field.id, |
|
|
|
|
|
|
|
field_format: custom_field.field_format, # TODO just return the cast value |
|
|
|
|
|
|
|
value: custom_field.field_format == 'user' ? custom_field.cast_value(custom_value.value).as_json(methods: :name) : custom_field.cast_value(custom_value.value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
# 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. |
|
|
|
# the method on the model so that it can be used in the rabl template. |
|
|
@ -722,20 +734,9 @@ class WorkPackage < ActiveRecord::Base |
|
|
|
|
|
|
|
|
|
|
|
def custom_values_display_data(field_names) |
|
|
|
def custom_values_display_data(field_names) |
|
|
|
field_names.map do |field_name| |
|
|
|
field_names.map do |field_name| |
|
|
|
custom_value_display(custom_values.find_by_custom_field_id(field_name.to_s.gsub('cf_',''))) |
|
|
|
get_cast_custom_value_with_meta(custom_values.find_by_custom_field_id(field_name.to_s.gsub('cf_',''))) |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def custom_value_display(custom_value) |
|
|
|
|
|
|
|
if !custom_value.nil? |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
custom_field_id: custom_value.custom_field.id, |
|
|
|
|
|
|
|
field_format: custom_value.custom_field.field_format, |
|
|
|
|
|
|
|
value: custom_value.value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
# End Custom Value Display Helper Methods |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected |
|
|
|
protected |
|
|
|
|
|
|
|
|
|
|
|