]> source.dussan.org Git - redmine.git/commitdiff
Adds Version.fields_for_order_statement.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 24 Jul 2012 16:32:39 +0000 (16:32 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 24 Jul 2012 16:32:39 +0000 (16:32 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10072 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
app/models/version.rb

index b2d0189065425778fd86937820c73154d1598b9c..5e76b17fe3d42b47e0a798892b6342e93fb739ae 100644 (file)
@@ -141,7 +141,7 @@ class Query < ActiveRecord::Base
     QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
     QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
     QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
-    QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
+    QueryColumn.new(:fixed_version, :sortable => lambda {Version.fields_for_order_statement}, :default_order => 'desc', :groupable => true),
     QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
     QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
     QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
index 600b9813a130a418464e18c779cc9edd18340210..bb0e7ec4248fb2e8d095b1665e83ad64096cfe6d 100644 (file)
@@ -184,6 +184,11 @@ class Version < ActiveRecord::Base
     end
   end
 
+  def self.fields_for_order_statement(table=nil)
+    table ||= table_name
+    %w(effective_date name).map {|field| "#{table}.#{field}"}
+  end
+
   # Returns the sharings that +user+ can set the version to
   def allowed_sharings(user = User.current)
     VERSION_SHARINGS.select do |s|