@@ -85,6 +85,28 class QueryCustomFieldColumn < QueryColumn | |||||
85 | end |
|
85 | end | |
86 | end |
|
86 | end | |
87 |
|
87 | |||
|
88 | class QueryAssociationCustomFieldColumn < QueryCustomFieldColumn | |||
|
89 | ||||
|
90 | def initialize(association, custom_field) | |||
|
91 | super(custom_field) | |||
|
92 | self.name = "#{association}.cf_#{custom_field.id}".to_sym | |||
|
93 | # TODO: support sorting/grouping by association custom field | |||
|
94 | self.sortable = false | |||
|
95 | self.groupable = false | |||
|
96 | @association = association | |||
|
97 | end | |||
|
98 | ||||
|
99 | def value(object) | |||
|
100 | if assoc = object.send(@association) | |||
|
101 | super(assoc) | |||
|
102 | end | |||
|
103 | end | |||
|
104 | ||||
|
105 | def css_classes | |||
|
106 | @css_classes ||= "#{@association}_cf_#{@cf.id} #{@cf.field_format}" | |||
|
107 | end | |||
|
108 | end | |||
|
109 | ||||
88 | class Query < ActiveRecord::Base |
|
110 | class Query < ActiveRecord::Base | |
89 | class StatementInvalid < ::ActiveRecord::StatementInvalid |
|
111 | class StatementInvalid < ::ActiveRecord::StatementInvalid | |
90 | end |
|
112 | end |
@@ -100,6 +100,7 class TimeEntryQuery < Query | |||||
100 | return @available_columns if @available_columns |
|
100 | return @available_columns if @available_columns | |
101 | @available_columns = self.class.available_columns.dup |
|
101 | @available_columns = self.class.available_columns.dup | |
102 | @available_columns += TimeEntryCustomField.all.map {|cf| QueryCustomFieldColumn.new(cf) } |
|
102 | @available_columns += TimeEntryCustomField.all.map {|cf| QueryCustomFieldColumn.new(cf) } | |
|
103 | @available_columns += IssueCustomField.all.map {|cf| QueryAssociationCustomFieldColumn.new(:issue, cf) } | |||
103 | @available_columns |
|
104 | @available_columns | |
104 | end |
|
105 | end | |
105 |
|
106 |
@@ -528,6 +528,16 class TimelogControllerTest < ActionController::TestCase | |||||
528 | assert_equal [entry], assigns(:entries) |
|
528 | assert_equal [entry], assigns(:entries) | |
529 | end |
|
529 | end | |
530 |
|
530 | |||
|
531 | def test_index_with_issue_custom_field_column | |||
|
532 | issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'}) | |||
|
533 | entry = TimeEntry.generate!(:issue => issue, :hours => 2.5) | |||
|
534 | ||||
|
535 | get :index, :c => %w(project spent_on issue comments hours issue.cf_2) | |||
|
536 | assert_response :success | |||
|
537 | assert_include :'issue.cf_2', assigns(:query).column_names | |||
|
538 | assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field' | |||
|
539 | end | |||
|
540 | ||||
531 | def test_index_atom_feed |
|
541 | def test_index_atom_feed | |
532 | get :index, :project_id => 1, :format => 'atom' |
|
542 | get :index, :project_id => 1, :format => 'atom' | |
533 | assert_response :success |
|
543 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now