##// END OF EJS Templates
Extract generic formatting options to an helper....
Jean-Philippe Lang -
r12087:8578a46b357f
parent child
Show More
@@ -155,6 +155,34 module ApplicationHelper
155 end
155 end
156 end
156 end
157
157
158 # Helper that formats object for html or text rendering
159 def format_object(object, html=true)
160 case object.class.name
161 when 'Time'
162 format_time(object)
163 when 'Date'
164 format_date(object)
165 when 'Fixnum'
166 object.to_s
167 when 'Float'
168 sprintf "%.2f", object
169 when 'User'
170 html ? link_to_user(object) : object.to_s
171 when 'Project'
172 html ? link_to_project(object) : object.to_s
173 when 'Version'
174 html ? link_to(object.name, version_path(object)) : version.to_s
175 when 'TrueClass'
176 l(:general_text_Yes)
177 when 'FalseClass'
178 l(:general_text_No)
179 when 'Issue'
180 object.visible? && html ? link_to_issue(object) : "##{object.id}"
181 else
182 html ? h(object) : object.to_s
183 end
184 end
185
158 def wiki_page_path(page, options={})
186 def wiki_page_path(page, options={})
159 url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
187 url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
160 end
188 end
@@ -90,48 +90,22 module QueriesHelper
90 end
90 end
91
91
92 def column_value(column, issue, value)
92 def column_value(column, issue, value)
93 case value.class.name
93 case column.name
94 when 'String'
94 when :id
95 if column.name == :subject
95 link_to value, issue_path(issue)
96 link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
96 when :subject
97 elsif column.name == :description
97 link_to value, issue_path(issue)
98 issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
98 when :description
99 else
99 issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
100 h(value)
100 when :done_ratio
101 end
101 progress_bar(value, :width => '80px')
102 when 'Time'
102 when :relations
103 format_time(value)
104 when 'Date'
105 format_date(value)
106 when 'Fixnum'
107 if column.name == :id
108 link_to value, issue_path(issue)
109 elsif column.name == :done_ratio
110 progress_bar(value, :width => '80px')
111 else
112 value.to_s
113 end
114 when 'Float'
115 sprintf "%.2f", value
116 when 'User'
117 link_to_user value
118 when 'Project'
119 link_to_project value
120 when 'Version'
121 link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
122 when 'TrueClass'
123 l(:general_text_Yes)
124 when 'FalseClass'
125 l(:general_text_No)
126 when 'Issue'
127 value.visible? ? link_to_issue(value) : "##{value.id}"
128 when 'IssueRelation'
129 other = value.other_issue(issue)
103 other = value.other_issue(issue)
130 content_tag('span',
104 content_tag('span',
131 (l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
105 (l(value.label_for(issue)) + " " + link_to_issue(other, :subject => false, :tracker => false)).html_safe,
132 :class => value.css_classes_for(issue))
106 :class => value.css_classes_for(issue))
133 else
107 else
134 h(value)
108 format_object(value)
135 end
109 end
136 end
110 end
137
111
General Comments 0
You need to be logged in to leave comments. Login now