@@ -22,14 +22,14 module QueriesHelper | |||
|
22 | 22 | end |
|
23 | 23 | |
|
24 | 24 | def column_header(column) |
|
25 | if column.sortable | |
|
26 | sort_header_tag(column.sortable, :caption => l("field_#{column.name}")) | |
|
27 | else | |
|
28 | content_tag('th', l("field_#{column.name}")) | |
|
29 | end | |
|
25 | column.sortable ? sort_header_tag(column.sortable, :caption => column.caption) : content_tag('th', column.caption) | |
|
30 | 26 | end |
|
31 | 27 | |
|
32 | 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 | 33 | value = issue.send(column.name) |
|
34 | 34 | if value.is_a?(Date) |
|
35 | 35 | format_date(value) |
@@ -43,3 +43,4 module QueriesHelper | |||
|
43 | 43 | end |
|
44 | 44 | end |
|
45 | 45 | end |
|
46 | end |
@@ -17,13 +17,33 | |||
|
17 | 17 | |
|
18 | 18 | class QueryColumn |
|
19 | 19 | attr_accessor :name, :sortable |
|
20 | include GLoc | |
|
20 | 21 | |
|
21 | 22 | def initialize(name, options={}) |
|
22 | 23 | self.name = name |
|
23 | 24 | self.sortable = options[:sortable] |
|
24 | 25 | end |
|
25 | 26 | |
|
26 | def default?; default end | |
|
27 | def caption | |
|
28 | l("field_#{name}") | |
|
29 | end | |
|
30 | end | |
|
31 | ||
|
32 | class QueryCustomFieldColumn < QueryColumn | |
|
33 | ||
|
34 | def initialize(custom_field) | |
|
35 | self.name = "cf_#{custom_field.id}".to_sym | |
|
36 | self.sortable = false | |
|
37 | @cf = custom_field | |
|
38 | end | |
|
39 | ||
|
40 | def caption | |
|
41 | @cf.name | |
|
42 | end | |
|
43 | ||
|
44 | def custom_field | |
|
45 | @cf | |
|
46 | end | |
|
27 | 47 | end |
|
28 | 48 | |
|
29 | 49 | class Query < ActiveRecord::Base |
@@ -203,7 +223,12 class Query < ActiveRecord::Base | |||
|
203 | 223 | end |
|
204 | 224 | |
|
205 | 225 | def available_columns |
|
206 | cols = Query.available_columns | |
|
226 | return @available_columns if @available_columns | |
|
227 | @available_columns = Query.available_columns | |
|
228 | @available_columns += (project ? | |
|
229 | project.custom_fields : | |
|
230 | IssueCustomField.find(:all, :conditions => {:is_for_all => true}) | |
|
231 | ).collect {|cf| QueryCustomFieldColumn.new(cf) } | |
|
207 | 232 | end |
|
208 | 233 | |
|
209 | 234 | def columns |
@@ -5,7 +5,7 | |||
|
5 | 5 | <table margin=0> |
|
6 | 6 | <tr> |
|
7 | 7 | <td><%= select_tag 'available_columns', |
|
8 |
options_for_select((query.available_columns - query.columns).collect {|column| [ |
|
|
8 | options_for_select((query.available_columns - query.columns).collect {|column| [column.caption, column.name]}), | |
|
9 | 9 | :multiple => true, :size => 10, :style => "width:150px" %> |
|
10 | 10 | </td> |
|
11 | 11 | <td align="center" valign="middle"> |
@@ -15,7 +15,7 | |||
|
15 | 15 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> |
|
16 | 16 | </td> |
|
17 | 17 | <td><%= select_tag 'query[column_names][]', |
|
18 |
options_for_select(@query.columns.collect {|column| [ |
|
|
18 | options_for_select(@query.columns.collect {|column| [column.caption, column.name]}), | |
|
19 | 19 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> |
|
20 | 20 | </td> |
|
21 | 21 | </tr> |
@@ -61,9 +61,9 | |||
|
61 | 61 | |
|
62 | 62 | <fieldset class="box"><legend><%= l(:setting_issue_list_default_columns) %></legend> |
|
63 | 63 | <%= hidden_field_tag 'settings[issue_list_default_columns][]', '' %> |
|
64 | <p><% Query.available_columns.each do |column| %> | |
|
64 | <p><% Query.new.available_columns.each do |column| %> | |
|
65 | 65 | <label><%= check_box_tag 'settings[issue_list_default_columns][]', column.name, Setting.issue_list_default_columns.include?(column.name.to_s) %> |
|
66 |
<%= |
|
|
66 | <%= column.caption %></label> | |
|
67 | 67 | <% end %></p> |
|
68 | 68 | </fieldset> |
|
69 | 69 |
General Comments 0
You need to be logged in to leave comments.
Login now