diff --git a/app/views/custom_fields/formats/_bool.html.erb b/app/views/custom_fields/formats/_bool.html.erb
index 25c464fb9..81aa64afe 100644
--- a/app/views/custom_fields/formats/_bool.html.erb
+++ b/app/views/custom_fields/formats/_bool.html.erb
@@ -1,2 +1,3 @@
<%= f.select :default_value, [[]]+@custom_field.possible_values_options %>
+<%= f.text_field :url_pattern, :size => 50, :label => :label_link_values_to %>
<%= edit_tag_style_tag f %>
diff --git a/app/views/custom_fields/formats/_date.html.erb b/app/views/custom_fields/formats/_date.html.erb
index 807a9269e..df3ba0789 100644
--- a/app/views/custom_fields/formats/_date.html.erb
+++ b/app/views/custom_fields/formats/_date.html.erb
@@ -1,2 +1,3 @@
<%= f.text_field(:default_value, :size => 10) %>
<%= calendar_for('custom_field_default_value') %>
+<%= f.text_field :url_pattern, :size => 50, :label => :label_link_values_to %>
diff --git a/app/views/custom_fields/formats/_list.html.erb b/app/views/custom_fields/formats/_list.html.erb
index 9bbd6a243..675bbbf8d 100644
--- a/app/views/custom_fields/formats/_list.html.erb
+++ b/app/views/custom_fields/formats/_list.html.erb
@@ -3,4 +3,5 @@
<%= l(:text_custom_field_possible_values_info) %>
<%= f.text_field(:default_value) %>
+<%= f.text_field :url_pattern, :size => 50, :label => :label_link_values_to %>
<%= edit_tag_style_tag f %>
diff --git a/app/views/custom_fields/formats/_numeric.html.erb b/app/views/custom_fields/formats/_numeric.html.erb
index 06187485d..cc0c798a6 100644
--- a/app/views/custom_fields/formats/_numeric.html.erb
+++ b/app/views/custom_fields/formats/_numeric.html.erb
@@ -1,2 +1,3 @@
<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
<%= f.text_field(:default_value) %>
+<%= f.text_field :url_pattern, :size => 50, :label => :label_link_values_to %>
diff --git a/app/views/custom_fields/formats/_string.html.erb b/app/views/custom_fields/formats/_string.html.erb
index 0c71243a8..08aac8eb2 100644
--- a/app/views/custom_fields/formats/_string.html.erb
+++ b/app/views/custom_fields/formats/_string.html.erb
@@ -1,3 +1,4 @@
<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
-<%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %>
+<%= f.check_box :text_formatting, {:label => :setting_text_formatting, :data => {:disables => '#custom_field_url_pattern'}}, 'full', '' %>
<%= f.text_field(:default_value) %>
+<%= f.text_field :url_pattern, :size => 50, :label => :label_link_values_to %>
diff --git a/config/locales/ar.yml b/config/locales/ar.yml
index 215e561c0..9a68117e2 100644
--- a/config/locales/ar.yml
+++ b/config/locales/ar.yml
@@ -1105,3 +1105,4 @@ ar:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/az.yml b/config/locales/az.yml
index 8d8c224e2..5afad2267 100644
--- a/config/locales/az.yml
+++ b/config/locales/az.yml
@@ -1202,3 +1202,4 @@ az:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/bg.yml b/config/locales/bg.yml
index 07e2bbc49..e3e7787b1 100644
--- a/config/locales/bg.yml
+++ b/config/locales/bg.yml
@@ -1102,3 +1102,4 @@ bg:
description_date_from: Въведете начална дата
description_date_to: Въведете крайна дата
text_repository_identifier_info: 'Позволени са малки букви (a-z), цифри, тирета и _.
Промяна след създаването му не е възможна.'
+ label_link_values_to: Link values to URL
diff --git a/config/locales/bs.yml b/config/locales/bs.yml
index 728c750a1..e410cc245 100644
--- a/config/locales/bs.yml
+++ b/config/locales/bs.yml
@@ -1118,3 +1118,4 @@ bs:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/ca.yml b/config/locales/ca.yml
index a2c4aed0e..3ff81dbe1 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -1107,3 +1107,4 @@ ca:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index ae432c915..171a00a2c 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -1108,3 +1108,4 @@ cs:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/da.yml b/config/locales/da.yml
index cdf583db0..9d4275616 100644
--- a/config/locales/da.yml
+++ b/config/locales/da.yml
@@ -1122,3 +1122,4 @@ da:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/de.yml b/config/locales/de.yml
index abb4a541b..8fa1a36fb 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -1117,3 +1117,4 @@ de:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/el.yml b/config/locales/el.yml
index 92f9f5e6a..4840b020e 100644
--- a/config/locales/el.yml
+++ b/config/locales/el.yml
@@ -1105,3 +1105,4 @@ el:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml
index 68aff0083..b42e20a2b 100644
--- a/config/locales/en-GB.yml
+++ b/config/locales/en-GB.yml
@@ -1107,3 +1107,4 @@ en-GB:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/en.yml b/config/locales/en.yml
index bbfea75c3..f9b459577 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -907,6 +907,7 @@ en:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
button_login: Login
button_submit: Submit
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 7fc39bef3..8673d7691 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -1140,3 +1140,4 @@ es:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/et.yml b/config/locales/et.yml
index bebbc3622..73fa299d9 100644
--- a/config/locales/et.yml
+++ b/config/locales/et.yml
@@ -1118,3 +1118,4 @@ et:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/eu.yml b/config/locales/eu.yml
index ecde2cf33..693041bd7 100644
--- a/config/locales/eu.yml
+++ b/config/locales/eu.yml
@@ -1106,3 +1106,4 @@ eu:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/fa.yml b/config/locales/fa.yml
index 780a525ba..ed110679c 100644
--- a/config/locales/fa.yml
+++ b/config/locales/fa.yml
@@ -1107,3 +1107,4 @@ fa:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/fi.yml b/config/locales/fi.yml
index 162325eea..e8834331a 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -1126,3 +1126,4 @@ fi:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 48217e7f1..29bb08428 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -883,6 +883,7 @@ fr:
label_only: seulement
label_drop_down_list: liste déroulante
label_checkboxes: cases à cocher
+ label_link_values_to: Lier les valeurs vers l'URL
button_login: Connexion
button_submit: Soumettre
diff --git a/config/locales/gl.yml b/config/locales/gl.yml
index 904a47e12..8278cd89d 100644
--- a/config/locales/gl.yml
+++ b/config/locales/gl.yml
@@ -1116,3 +1116,4 @@ gl:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/he.yml b/config/locales/he.yml
index 3178a5eaf..f5c8ee126 100644
--- a/config/locales/he.yml
+++ b/config/locales/he.yml
@@ -1110,3 +1110,4 @@ he:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/hr.yml b/config/locales/hr.yml
index b3931178f..568fbe602 100644
--- a/config/locales/hr.yml
+++ b/config/locales/hr.yml
@@ -1106,3 +1106,4 @@ hr:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/hu.yml b/config/locales/hu.yml
index b462b3ba9..444f57a56 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -1124,3 +1124,4 @@
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/id.yml b/config/locales/id.yml
index c7e434b24..5e6b316d4 100644
--- a/config/locales/id.yml
+++ b/config/locales/id.yml
@@ -1109,3 +1109,4 @@ id:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/it.yml b/config/locales/it.yml
index dfa525ff2..8e00f9b83 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -1104,3 +1104,4 @@ it:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index f13280f97..0455100f4 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1132,3 +1132,4 @@ ja:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 07cacddc0..85f71ae3f 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -1154,3 +1154,4 @@ ko:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/lt.yml b/config/locales/lt.yml
index 4f6789069..2772fc1a7 100644
--- a/config/locales/lt.yml
+++ b/config/locales/lt.yml
@@ -1164,3 +1164,4 @@ lt:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/lv.yml b/config/locales/lv.yml
index 30bd5fe1a..525bd0473 100644
--- a/config/locales/lv.yml
+++ b/config/locales/lv.yml
@@ -1099,3 +1099,4 @@ lv:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/mk.yml b/config/locales/mk.yml
index d9e42393c..15bbd5dd5 100644
--- a/config/locales/mk.yml
+++ b/config/locales/mk.yml
@@ -1105,3 +1105,4 @@ mk:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/mn.yml b/config/locales/mn.yml
index 28e045783..222702f19 100644
--- a/config/locales/mn.yml
+++ b/config/locales/mn.yml
@@ -1106,3 +1106,4 @@ mn:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 156ac86fd..6a48cc131 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -1084,3 +1084,4 @@ nl:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/no.yml b/config/locales/no.yml
index 255fca3c5..85d427637 100644
--- a/config/locales/no.yml
+++ b/config/locales/no.yml
@@ -1095,3 +1095,4 @@
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
index e097ab059..443dbd20b 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -1127,3 +1127,4 @@ pl:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index 4637ece0f..e7754b2c3 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -1125,3 +1125,4 @@ pt-BR:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index 5038bdfb8..d3a69a419 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -1111,3 +1111,4 @@ pt:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/ro.yml b/config/locales/ro.yml
index 0d1307750..1248330cb 100644
--- a/config/locales/ro.yml
+++ b/config/locales/ro.yml
@@ -1100,3 +1100,4 @@ ro:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index c19da11bd..cf1f7f287 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -1214,3 +1214,4 @@ ru:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/sk.yml b/config/locales/sk.yml
index 388d1a168..cf1d03979 100644
--- a/config/locales/sk.yml
+++ b/config/locales/sk.yml
@@ -1095,3 +1095,4 @@ sk:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/sl.yml b/config/locales/sl.yml
index 4e5263a4d..6b4da564a 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -1105,3 +1105,4 @@ sl:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/sq.yml b/config/locales/sq.yml
index fc829f5f3..74bac035f 100644
--- a/config/locales/sq.yml
+++ b/config/locales/sq.yml
@@ -1101,3 +1101,4 @@ sq:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml
index 4650a8c45..0a4de3267 100644
--- a/config/locales/sr-YU.yml
+++ b/config/locales/sr-YU.yml
@@ -1107,3 +1107,4 @@ sr-YU:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/sr.yml b/config/locales/sr.yml
index 7e103c4ea..8008086b1 100644
--- a/config/locales/sr.yml
+++ b/config/locales/sr.yml
@@ -1106,3 +1106,4 @@ sr:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/sv.yml b/config/locales/sv.yml
index 90d6be24c..73bf3aefc 100644
--- a/config/locales/sv.yml
+++ b/config/locales/sv.yml
@@ -1143,3 +1143,4 @@ sv:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/th.yml b/config/locales/th.yml
index e97c22aa5..c490b213a 100644
--- a/config/locales/th.yml
+++ b/config/locales/th.yml
@@ -1102,3 +1102,4 @@ th:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/tr.yml b/config/locales/tr.yml
index 59a792401..40e9d22ea 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -1114,3 +1114,4 @@ tr:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/uk.yml b/config/locales/uk.yml
index aa9a3ec9e..87c96a616 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -1100,3 +1100,4 @@ uk:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/vi.yml b/config/locales/vi.yml
index ef43b4aaa..482ef8f91 100644
--- a/config/locales/vi.yml
+++ b/config/locales/vi.yml
@@ -1158,3 +1158,4 @@ vi:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml
index 241f29c0c..636351bf9 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -1185,3 +1185,4 @@
description_date_from: 輸入起始日期
description_date_to: 輸入結束日期
text_repository_identifier_info: '僅允許使用小寫英文字母 (a-z), 阿拉伯數字, 虛線與底線。
一旦儲存之後, 代碼便無法再次被更改。'
+ label_link_values_to: Link values to URL
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 51f757ab3..a3b8ef1d6 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -1106,3 +1106,4 @@ zh:
label_only: only
label_drop_down_list: drop-down list
label_checkboxes: checkboxes
+ label_link_values_to: Link values to URL
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb
index 799fcf610..d0e2e4d7c 100644
--- a/lib/redmine/field_format.rb
+++ b/lib/redmine/field_format.rb
@@ -80,6 +80,8 @@ module Redmine
CustomField.store_accessor :format_store, *args
end
+ field_attributes :url_pattern
+
def name
self.class.format_name
end
@@ -144,9 +146,45 @@ module Redmine
end
def formatted_value(view, custom_field, value, customized=nil, html=false)
- cast_value(custom_field, value, customized)
+ casted = cast_value(custom_field, value, customized)
+ if custom_field.url_pattern.present?
+ texts_and_urls = Array.wrap(casted).map do |single_value|
+ text = view.format_object(single_value, false).to_s
+ url = url_from_pattern(custom_field, single_value, customized)
+ [text, url]
+ end
+ links = texts_and_urls.sort_by(&:first).map {|text, url| view.link_to text, url}
+ links.join(', ').html_safe
+ else
+ casted
+ end
end
+ # Returns an URL generated with the custom field URL pattern
+ # and variables substitution:
+ # %value% => the custom field value
+ # %id% => id of the customized object
+ # %project_id% => id of the project of the customized object if defined
+ # %project_identifier% => identifier of the project of the customized object if defined
+ # %m1%, %m2%... => capture groups matches of the custom field regexp if defined
+ def url_from_pattern(custom_field, value, customized)
+ url = custom_field.url_pattern.to_s.dup
+ url.gsub!('%value%') {value.to_s}
+ url.gsub!('%id%') {customized.id.to_s}
+ url.gsub!('%project_id%') {(customized.respond_to?(:project) ? customized.project.try(:id) : nil).to_s}
+ url.gsub!('%project_identifier%') {(customized.respond_to?(:project) ? customized.project.try(:identifier) : nil).to_s}
+ if custom_field.regexp.present?
+ url.gsub!(%r{%m(\d+)%}) do
+ m = $1.to_i
+ if matches ||= value.to_s.match(Regexp.new(custom_field.regexp))
+ matches[m].to_s
+ end
+ end
+ end
+ url
+ end
+ protected :url_from_pattern
+
def edit_tag(view, tag_id, tag_name, custom_value, options={})
view.text_field_tag(tag_name, custom_value.value, options.merge(:id => tag_id))
end
@@ -236,8 +274,14 @@ module Redmine
field_attributes :text_formatting
def formatted_value(view, custom_field, value, customized=nil, html=false)
- if html && custom_field.text_formatting == 'full'
- view.textilizable(value, :object => customized)
+ if html
+ if custom_field.url_pattern.present?
+ super
+ elsif custom_field.text_formatting == 'full'
+ view.textilizable(value, :object => customized)
+ else
+ value.to_s
+ end
else
value.to_s
end
@@ -280,23 +324,11 @@ module Redmine
add 'link'
self.searchable_supported = false
self.form_partial = 'custom_fields/formats/link'
- field_attributes :url_pattern
def formatted_value(view, custom_field, value, customized=nil, html=false)
if html
if custom_field.url_pattern.present?
- url = custom_field.url_pattern.to_s.dup
- url.gsub!('%value%') {value.to_s}
- url.gsub!('%id%') {customized.id.to_s}
- url.gsub!('%project_id%') {(customized.respond_to?(:project) ? customized.project.try(:id) : nil).to_s}
- url.gsub!('%project_identifier%') {(customized.respond_to?(:project) ? customized.project.try(:identifier) : nil).to_s}
- if custom_field.regexp.present?
- url.gsub!(%r{%m(\d+)%}) do
- m = $1.to_i
- matches ||= value.to_s.match(Regexp.new(custom_field.regexp))
- matches[m].to_s if matches
- end
- end
+ url = url_from_pattern(custom_field, value, customized)
else
url = value.to_s
unless url =~ %r{\A[a-z]+://}i
diff --git a/test/unit/lib/redmine/field_format/list_format_test.rb b/test/unit/lib/redmine/field_format/list_format_test.rb
index 738b27302..187895ebe 100644
--- a/test/unit/lib/redmine/field_format/list_format_test.rb
+++ b/test/unit/lib/redmine/field_format/list_format_test.rb
@@ -116,6 +116,27 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase
end
end
+ def test_field_with_url_pattern_should_link_value
+ field = IssueCustomField.new(:field_format => 'list', :url_pattern => 'http://localhost/%value%')
+ formatted = field.format.formatted_value(self, field, 'foo', Issue.new, true)
+ assert_equal 'foo', formatted
+ assert formatted.html_safe?
+ end
+
+ def test_field_with_url_pattern_and_multiple_values_should_link_values
+ field = IssueCustomField.new(:field_format => 'list', :url_pattern => 'http://localhost/%value%')
+ formatted = field.format.formatted_value(self, field, ['foo', 'bar'], Issue.new, true)
+ assert_equal 'bar, foo', formatted
+ assert formatted.html_safe?
+ end
+
+ def test_field_with_url_pattern_should_not_link_blank_value
+ field = IssueCustomField.new(:field_format => 'list', :url_pattern => 'http://localhost/%value%')
+ formatted = field.format.formatted_value(self, field, '', Issue.new, true)
+ assert_equal '', formatted
+ assert formatted.html_safe?
+ end
+
def test_edit_tag_with_check_box_style_and_multiple_should_select_current_values
field = IssueCustomField.new(:field_format => 'list', :possible_values => ['Foo', 'Bar', 'Baz'], :is_required => false,
:multiple => true, :edit_tag_style => 'check_box')