queries_helper.rb

sunday walker, 2008-02-11 14:16

Download (1.89 KB)

 
1
# redMine - project management software
2
# Copyright (C) 2006-2007  Jean-Philippe Lang
3
#
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.
17

    
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
      value = issue.total(column.name)
35
      if value.is_a?(Date)
36
        format_date(value)
37
      elsif value.is_a?(Time)
38
        format_time(value)
39
      else
40
        case column.name
41
        when :subject
42
        h((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') +
43
          link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
44
        when :done_ratio
45
          progress_bar(value, :width => '80px')
46
        else
47
          h(value)
48
        end
49
      end
50
    end
51
  end
52
end