summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-12 13:09:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-12 13:09:06 +0000
commite18d0e268de5a3eee897eac3072c3d3dc37405d1 (patch)
treeb433b889bd31ed31aec02bae2053a8d87db17edf /app/models/query.rb
parenta9e81b6b847078d0eac673a4bbaebb5274231231 (diff)
downloadredmine-e18d0e268de5a3eee897eac3072c3d3dc37405d1.tar.gz
redmine-e18d0e268de5a3eee897eac3072c3d3dc37405d1.zip
Makes issue custom fields available as timelog columns (#1766).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11174 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index 97a635c10..5094cc3a9 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -85,6 +85,28 @@ class QueryCustomFieldColumn < QueryColumn
end
end
+class QueryAssociationCustomFieldColumn < QueryCustomFieldColumn
+
+ def initialize(association, custom_field)
+ super(custom_field)
+ self.name = "#{association}.cf_#{custom_field.id}".to_sym
+ # TODO: support sorting/grouping by association custom field
+ self.sortable = false
+ self.groupable = false
+ @association = association
+ end
+
+ def value(object)
+ if assoc = object.send(@association)
+ super(assoc)
+ end
+ end
+
+ def css_classes
+ @css_classes ||= "#{@association}_cf_#{@cf.id} #{@cf.field_format}"
+ end
+end
+
class Query < ActiveRecord::Base
class StatementInvalid < ::ActiveRecord::StatementInvalid
end