diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-11-23 10:50:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-11-23 10:50:41 +0000 |
commit | 8578a46b357f5d17b61dc545e6ec10036d7a9c9e (patch) | |
tree | 034173353b9cd1420c9542e76af01b557aacb3f1 /app/helpers | |
parent | 8a1f26617d23584e4ded0717c0f6ca4da559efee (diff) | |
download | redmine-8578a46b357f5d17b61dc545e6ec10036d7a9c9e.tar.gz redmine-8578a46b357f5d17b61dc545e6ec10036d7a9c9e.zip |
Extract generic formatting options to an helper.
git-svn-id: http://svn.redmine.org/redmine/trunk@12319 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 28 | ||||
-rw-r--r-- | app/helpers/queries_helper.rb | 48 |
2 files changed, 39 insertions, 37 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7bee2117e..bb9121031 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 429dcdad2..108012fd8 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -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 - link_to value, issue_path(issue) - elsif column.name == :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' + case column.name + when :id + link_to value, issue_path(issue) + 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') + 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 |