@@ -22,24 +22,25 module QueriesHelper | |||||
22 | end |
|
22 | end | |
23 |
|
23 | |||
24 | def column_header(column) |
|
24 | def column_header(column) | |
25 | if column.sortable |
|
25 | column.sortable ? sort_header_tag(column.sortable, :caption => column.caption) : content_tag('th', column.caption) | |
26 | sort_header_tag(column.sortable, :caption => l("field_#{column.name}")) |
|
|||
27 | else |
|
|||
28 | content_tag('th', l("field_#{column.name}")) |
|
|||
29 | end |
|
|||
30 | end |
|
26 | end | |
31 |
|
27 | |||
32 | def column_content(column, issue) |
|
28 | def column_content(column, issue) | |
33 | value = issue.send(column.name) |
|
29 | if column.is_a?(QueryCustomFieldColumn) | |
34 | if value.is_a?(Date) |
|
30 | cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id} | |
35 |
|
|
31 | show_value(cv) | |
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 |
|
32 | else | |
42 | h(value) |
|
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 | |||
43 | end |
|
44 | end | |
44 | end |
|
45 | end | |
45 | end |
|
46 | end |
@@ -17,13 +17,33 | |||||
17 |
|
17 | |||
18 | class QueryColumn |
|
18 | class QueryColumn | |
19 | attr_accessor :name, :sortable |
|
19 | attr_accessor :name, :sortable | |
|
20 | include GLoc | |||
20 |
|
21 | |||
21 | def initialize(name, options={}) |
|
22 | def initialize(name, options={}) | |
22 | self.name = name |
|
23 | self.name = name | |
23 | self.sortable = options[:sortable] |
|
24 | self.sortable = options[:sortable] | |
24 | end |
|
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 | end |
|
47 | end | |
28 |
|
48 | |||
29 | class Query < ActiveRecord::Base |
|
49 | class Query < ActiveRecord::Base | |
@@ -203,7 +223,12 class Query < ActiveRecord::Base | |||||
203 | end |
|
223 | end | |
204 |
|
224 | |||
205 | def available_columns |
|
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 | end |
|
232 | end | |
208 |
|
233 | |||
209 | def columns |
|
234 | def columns |
@@ -5,7 +5,7 | |||||
5 | <table margin=0> |
|
5 | <table margin=0> | |
6 | <tr> |
|
6 | <tr> | |
7 | <td><%= select_tag 'available_columns', |
|
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 | :multiple => true, :size => 10, :style => "width:150px" %> |
|
9 | :multiple => true, :size => 10, :style => "width:150px" %> | |
10 | </td> |
|
10 | </td> | |
11 | <td align="center" valign="middle"> |
|
11 | <td align="center" valign="middle"> | |
@@ -15,7 +15,7 | |||||
15 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> |
|
15 | onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" /> | |
16 | </td> |
|
16 | </td> | |
17 | <td><%= select_tag 'query[column_names][]', |
|
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 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> |
|
19 | :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %> | |
20 | </td> |
|
20 | </td> | |
21 | </tr> |
|
21 | </tr> |
@@ -61,9 +61,9 | |||||
61 |
|
61 | |||
62 | <fieldset class="box"><legend><%= l(:setting_issue_list_default_columns) %></legend> |
|
62 | <fieldset class="box"><legend><%= l(:setting_issue_list_default_columns) %></legend> | |
63 | <%= hidden_field_tag 'settings[issue_list_default_columns][]', '' %> |
|
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 | <label><%= check_box_tag 'settings[issue_list_default_columns][]', column.name, Setting.issue_list_default_columns.include?(column.name.to_s) %> |
|
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 | <% end %></p> |
|
67 | <% end %></p> | |
68 | </fieldset> |
|
68 | </fieldset> | |
69 |
|
69 |
General Comments 0
You need to be logged in to leave comments.
Login now