initial commit
[gitredmine.git] / app / helpers / queries_helper.rb
blob6e5511f08ef968569b78523f313acaef31831f83
1 # redMine - project management software
2 # Copyright (C) 2006-2007  Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 module QueriesHelper
19   
20   def operators_for_select(filter_type)
21     Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
22   end
23   
24   def column_header(column)
25     column.sortable ? sort_header_tag(column.sortable, :caption => column.caption) : content_tag('th', column.caption)
26   end
27   
28   def column_content(column, issue)
29     if column.is_a?(QueryCustomFieldColumn)
30       cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
31       show_value(cv)
32     else
33       value = issue.send(column.name)
34       if value.is_a?(Date)
35         format_date(value)
36       elsif value.is_a?(Time)
37         format_time(value)
38       elsif column.name == :subject
39         ((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') +
40           link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
41       else
42         h(value)
43       end
44     end
45   end
46 end