Index: app/helpers/queries_helper.rb
===================================================================
--- app/helpers/queries_helper.rb (revision 2552)
+++ app/helpers/queries_helper.rb (working copy)
@@ -30,7 +30,7 @@
def column_content(column, issue)
if column.is_a?(QueryCustomFieldColumn)
cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
- show_value(cv)
+ show_value_plain(cv)
else
value = issue.send(column.name)
if value.is_a?(Date)
Index: app/helpers/timelog_helper.rb
===================================================================
--- app/helpers/timelog_helper.rb (revision 2552)
+++ app/helpers/timelog_helper.rb (working copy)
@@ -93,7 +93,7 @@
entry.hours.to_s.gsub('.', decimal_separator),
entry.comments
]
- fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
+ fields += custom_fields.collect {|f| show_value_plain(entry.custom_value_for(f)) }
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
end
Index: app/helpers/custom_fields_helper.rb
===================================================================
--- app/helpers/custom_fields_helper.rb (revision 2552)
+++ app/helpers/custom_fields_helper.rb (working copy)
@@ -61,12 +61,34 @@
def custom_field_tag_with_label(name, custom_value)
custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
end
+
+ # Return a clean URL for a given custom field value
+ def url_format(custom_value)
+ url = custom_value.custom_field.url.strip
+ return false unless url.length > 0
- # Return a string used to display a custom value
+ formatted_value = format_value(custom_value.value, custom_value.custom_field.field_format)
+ while (url.sub!(/__VALUE__/, h(formatted_value.strip)))
+ end
+ return url
+ end
+
+ # Return a formatted string used to display a custom value (including link if URL defined on custom_field)
def show_value(custom_value)
return "" unless custom_value
- format_value(custom_value.value, custom_value.custom_field.field_format)
+ formatted_value = format_value(custom_value.value, custom_value.custom_field.field_format)
+ if (value = url_format(custom_value))
+ return link_to formatted_value, value, :target=>'_blank'
+ else
+ return h(format_value(custom_value.value, custom_value.custom_field.field_format))
+ end
end
+
+ # Return an escaped string used to display a custom value
+ def show_value_plain(custom_value)
+ return "" unless custom_value
+ return h(format_value(custom_value.value, custom_value.custom_field.field_format))
+ end
# Return a string used to display a custom value
def format_value(value, field_format)
Index: app/views/custom_fields/_form.rhtml
===================================================================
--- app/views/custom_fields/_form.rhtml (revision 2552)
+++ app/views/custom_fields/_form.rhtml (working copy)
@@ -8,6 +8,7 @@
p_regexp = $("custom_field_regexp");
p_values = $("custom_field_possible_values");
p_searchable = $("custom_field_searchable");
+ p_url = $("custom_field_url");
p_default = $("custom_field_default_value");
p_default.setAttribute('type','text');
@@ -65,6 +66,8 @@
:rows => 15 %>
<%= l(:text_custom_field_possible_values_info) %>
<%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %>
+<%= f.text_field :url, :size => 60 %>
+
<%= l(:text_custom_field_url_info) %>