Fixed that Link custom fields are not displayed as links on the issue list (#16496).

git-svn-id: http://svn.redmine.org/redmine/trunk@13054 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-04-06 11:11:52 +00:00
parent 5b8a96472f
commit 22b2a1f699
3 changed files with 38 additions and 24 deletions

View File

@ -158,7 +158,10 @@ module ApplicationHelper
end
# Helper that formats object for html or text rendering
def format_object(object, html=true)
def format_object(object, html=true, &block)
if block_given?
object = yield object
end
case object.class.name
when 'Array'
object.map {|o| format_object(o, html)}.join(', ').html_safe
@ -188,7 +191,7 @@ module ApplicationHelper
if f.nil? || f.is_a?(String)
f
else
format_object(f, html)
format_object(f, html, &block)
end
else
object.value.to_s

View File

@ -18,6 +18,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module QueriesHelper
include ApplicationHelper
def filters_options_for_select(query)
options_for_select(filters_options(query))
end
@ -81,7 +83,7 @@ module QueriesHelper
end
def column_content(column, issue)
value = column.value(issue)
value = column.value_object(issue)
if value.is_a?(Array)
value.collect {|v| column_value(column, issue, v)}.compact.join(', ').html_safe
else
@ -110,7 +112,7 @@ module QueriesHelper
end
def csv_content(column, issue)
value = column.value(issue)
value = column.value_object(issue)
if value.is_a?(Array)
value.collect {|v| csv_value(column, issue, v)}.compact.join(', ')
else
@ -119,22 +121,16 @@ module QueriesHelper
end
def csv_value(column, issue, value)
case value.class.name
when 'Time'
format_time(value)
when 'Date'
format_date(value)
when 'Float'
sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
when 'IssueRelation'
other = value.other_issue(issue)
l(value.label_for(issue)) + " ##{other.id}"
when 'TrueClass'
l(:general_text_Yes)
when 'FalseClass'
l(:general_text_No)
else
value.to_s
format_object(value, false) do |value|
case value.class.name
when 'Float'
sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
when 'IssueRelation'
other = value.other_issue(issue)
l(value.label_for(issue)) + " ##{other.id}"
else
value
end
end
end

View File

@ -57,6 +57,10 @@ class QueryColumn
object.send name
end
def value_object(object)
object.send name
end
def css_classes
name
end
@ -80,10 +84,21 @@ class QueryCustomFieldColumn < QueryColumn
@cf
end
def value(object)
def value_object(object)
if custom_field.visible_by?(object.project, User.current)
cv = object.custom_values.select {|v| v.custom_field_id == @cf.id}.collect {|v| @cf.cast_value(v.value)}
cv.size > 1 ? cv.sort {|a,b| a.to_s <=> b.to_s} : cv.first
cv = object.custom_values.select {|v| v.custom_field_id == @cf.id}
cv.size > 1 ? cv.sort {|a,b| a.value.to_s <=> b.value.to_s} : cv.first
else
nil
end
end
def value(object)
raw = value_object(object)
if raw.is_a?(Array)
raw.map {|r| @cf.cast_value(r.value)}
elsif raw
@cf.cast_value(raw.value)
else
nil
end
@ -105,7 +120,7 @@ class QueryAssociationCustomFieldColumn < QueryCustomFieldColumn
@association = association
end
def value(object)
def value_object(object)
if assoc = object.send(@association)
super(assoc)
end