Extract generic formatting options to an helper.
git-svn-id: http://svn.redmine.org/redmine/trunk@12319 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8a1f26617d
commit
8578a46b35
|
@ -155,6 +155,34 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
# Helper that formats object for html or text rendering
|
||||
def format_object(object, html=true)
|
||||
case object.class.name
|
||||
when 'Time'
|
||||
format_time(object)
|
||||
when 'Date'
|
||||
format_date(object)
|
||||
when 'Fixnum'
|
||||
object.to_s
|
||||
when 'Float'
|
||||
sprintf "%.2f", object
|
||||
when 'User'
|
||||
html ? link_to_user(object) : object.to_s
|
||||
when 'Project'
|
||||
html ? link_to_project(object) : object.to_s
|
||||
when 'Version'
|
||||
html ? link_to(object.name, version_path(object)) : version.to_s
|
||||
when 'TrueClass'
|
||||
l(:general_text_Yes)
|
||||
when 'FalseClass'
|
||||
l(:general_text_No)
|
||||
when 'Issue'
|
||||
object.visible? && html ? link_to_issue(object) : "##{object.id}"
|
||||
else
|
||||
html ? h(object) : object.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def wiki_page_path(page, options={})
|
||||
url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
|
||||
end
|
||||
|
|
|
@ -90,48 +90,22 @@ module QueriesHelper
|
|||
end
|
||||
|
||||
def column_value(column, issue, value)
|
||||
case value.class.name
|
||||
when 'String'
|
||||
if column.name == :subject
|
||||
link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
|
||||
elsif column.name == :description
|
||||
issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
|
||||
else
|
||||
h(value)
|
||||
end
|
||||
when 'Time'
|
||||
format_time(value)
|
||||
when 'Date'
|
||||
format_date(value)
|
||||
when 'Fixnum'
|
||||
if column.name == :id
|
||||
case column.name
|
||||
when :id
|
||||
link_to value, issue_path(issue)
|
||||
elsif column.name == :done_ratio
|
||||
when :subject
|
||||
link_to value, issue_path(issue)
|
||||
when :description
|
||||
issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
|
||||
when :done_ratio
|
||||
progress_bar(value, :width => '80px')
|
||||
else
|
||||
value.to_s
|
||||
end
|
||||
when 'Float'
|
||||
sprintf "%.2f", value
|
||||
when 'User'
|
||||
link_to_user value
|
||||
when 'Project'
|
||||
link_to_project value
|
||||
when 'Version'
|
||||
link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
|
||||
when 'TrueClass'
|
||||
l(:general_text_Yes)
|
||||
when 'FalseClass'
|
||||
l(:general_text_No)
|
||||
when 'Issue'
|
||||
value.visible? ? link_to_issue(value) : "##{value.id}"
|
||||
when 'IssueRelation'
|
||||
when :relations
|
||||
other = value.other_issue(issue)
|
||||
content_tag('span',
|
||||
(l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
|
||||
:class => value.css_classes_for(issue))
|
||||
else
|
||||
h(value)
|
||||
format_object(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue