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
|
||||||
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={})
|
def wiki_page_path(page, options={})
|
||||||
url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
|
url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,48 +90,22 @@ module QueriesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def column_value(column, issue, value)
|
def column_value(column, issue, value)
|
||||||
case value.class.name
|
case column.name
|
||||||
when 'String'
|
when :id
|
||||||
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
|
|
||||||
link_to value, issue_path(issue)
|
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')
|
progress_bar(value, :width => '80px')
|
||||||
else
|
when :relations
|
||||||
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'
|
|
||||||
other = value.other_issue(issue)
|
other = value.other_issue(issue)
|
||||||
content_tag('span',
|
content_tag('span',
|
||||||
(l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
|
(l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
|
||||||
:class => value.css_classes_for(issue))
|
:class => value.css_classes_for(issue))
|
||||||
else
|
else
|
||||||
h(value)
|
format_object(value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue