##// END OF EJS Templates
remove trailing white-spaces from app/helpers/queries_helper.rb....
Toshi MARUYAMA -
r6767:2230dfda51cd
parent child
Show More
@@ -1,100 +1,100
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module QueriesHelper
19
19
20 20 def operators_for_select(filter_type)
21 21 Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
22 22 end
23
23
24 24 def column_header(column)
25 25 column.sortable ? sort_header_tag(column.name.to_s, :caption => column.caption,
26 :default_order => column.default_order) :
26 :default_order => column.default_order) :
27 27 content_tag('th', h(column.caption))
28 28 end
29
29
30 30 def column_content(column, issue)
31 31 value = column.value(issue)
32
32
33 33 case value.class.name
34 34 when 'String'
35 35 if column.name == :subject
36 36 link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
37 37 else
38 38 h(value)
39 39 end
40 40 when 'Time'
41 41 format_time(value)
42 42 when 'Date'
43 43 format_date(value)
44 44 when 'Fixnum', 'Float'
45 45 if column.name == :done_ratio
46 46 progress_bar(value, :width => '80px')
47 47 else
48 48 h(value.to_s)
49 49 end
50 50 when 'User'
51 51 link_to_user value
52 52 when 'Project'
53 53 link_to_project value
54 54 when 'Version'
55 55 link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
56 56 when 'TrueClass'
57 57 l(:general_text_Yes)
58 58 when 'FalseClass'
59 59 l(:general_text_No)
60 60 when 'Issue'
61 61 link_to_issue(value, :subject => false)
62 62 else
63 63 h(value)
64 64 end
65 65 end
66 66
67 67 # Retrieve query from session or build a new query
68 68 def retrieve_query
69 69 if !params[:query_id].blank?
70 70 cond = "project_id IS NULL"
71 71 cond << " OR project_id = #{@project.id}" if @project
72 72 @query = Query.find(params[:query_id], :conditions => cond)
73 73 raise ::Unauthorized unless @query.visible?
74 74 @query.project = @project
75 75 session[:query] = {:id => @query.id, :project_id => @query.project_id}
76 76 sort_clear
77 77 else
78 78 if api_request? || params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)
79 79 # Give it a name, required to be valid
80 80 @query = Query.new(:name => "_")
81 81 @query.project = @project
82 82 if params[:fields] || params[:f]
83 83 @query.filters = {}
84 84 @query.add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v])
85 85 else
86 86 @query.available_filters.keys.each do |field|
87 87 @query.add_short_filter(field, params[field]) if params[field]
88 88 end
89 89 end
90 90 @query.group_by = params[:group_by]
91 91 @query.column_names = params[:c] || (params[:query] && params[:query][:column_names])
92 92 session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
93 93 else
94 94 @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
95 95 @query ||= Query.new(:name => "_", :project => @project, :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
96 96 @query.project = @project
97 97 end
98 98 end
99 99 end
100 100 end
General Comments 0
You need to be logged in to leave comments. Login now