summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-02-23 10:53:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-02-23 10:53:21 +0000
commit9b1ebd6808d260a95eff38c2a93ec2c1b7ed8183 (patch)
tree63f1b433deebd1590299380157c87dbb54e59c48 /app/models/query.rb
parentd1244b31a4c2c6f8a5625f92506f7e281fb1cc00 (diff)
downloadredmine-9b1ebd6808d260a95eff38c2a93ec2c1b7ed8183.tar.gz
redmine-9b1ebd6808d260a95eff38c2a93ec2c1b7ed8183.zip
Refactor: makes issue id a regular QueryColumn.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11447 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index cd1b9c386..db6ca07a5 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -28,11 +28,12 @@ class QueryColumn
end
self.default_order = options[:default_order]
@inline = options.key?(:inline) ? options[:inline] : true
- @caption_key = options[:caption] || "field_#{name}"
+ @caption_key = options[:caption] || "field_#{name}".to_sym
+ @frozen = options[:frozen]
end
def caption
- l(@caption_key)
+ @caption_key.is_a?(Symbol) ? l(@caption_key) : @caption_key
end
# Returns true if the column is sortable, otherwise false
@@ -48,6 +49,10 @@ class QueryColumn
@inline
end
+ def frozen?
+ @frozen
+ end
+
def value(object)
object.send name
end
@@ -382,9 +387,10 @@ class Query < ActiveRecord::Base
def columns
# preserve the column_names order
- (has_default_columns? ? default_columns_names : column_names).collect do |name|
+ cols = (has_default_columns? ? default_columns_names : column_names).collect do |name|
available_columns.find { |col| col.name == name }
end.compact
+ available_columns.select(&:frozen?) | cols
end
def inline_columns