]> source.dussan.org Git - redmine.git/commitdiff
Merged r14554 (#20688).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Sep 2015 14:53:28 +0000 (14:53 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 12 Sep 2015 14:53:28 +0000 (14:53 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@14558 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
config/locales/en.yml
config/locales/fr.yml
test/functional/issues_controller_test.rb

index 8316f6b4bfe18784cef925a919fdca6840c49253..e21ccf618fbad880d24bdcdccc445bfc671a5513 100644 (file)
@@ -35,6 +35,10 @@ class IssueQuery < Query
     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"),
+    QueryColumn.new(:total_estimated_hours,
+      :sortable => "COALESCE((SELECT SUM(estimated_hours) FROM #{Issue.table_name} subtasks" +
+        " WHERE subtasks.root_id = #{Issue.table_name}.root_id AND subtasks.lft >= #{Issue.table_name}.lft AND subtasks.rgt <= #{Issue.table_name}.rgt), 0)",
+      :default_order => 'desc'),
     QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio", :groupable => true),
     QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
     QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
index 039df462f9fbe1e5e7354e31ccc9070f3cd4429c..b5aa9f2cf33cff369bc71dc7044426c3cc790092 100644 (file)
@@ -342,6 +342,7 @@ en:
   field_default_status: Default status
   field_users_visibility: Users visibility
   field_time_entries_visibility: Time logs visibility
+  field_total_estimated_hours: Total estimated time
 
   setting_app_title: Application title
   setting_app_subtitle: Application subtitle
index 3432514befbc2c21f893a15b5649a564d6f0fc0d..e97427533534856ec787d80f1c5c49fa16c2200a 100644 (file)
@@ -362,6 +362,7 @@ fr:
   field_default_status: Statut par défaut
   field_users_visibility: Visibilité des utilisateurs
   field_time_entries_visibility: Visibilité du temps passé
+  field_total_estimated_hours: Temps estimé total
 
   setting_app_title: Titre de l'application
   setting_app_subtitle: Sous-titre de l'application
index f642d582d4e2910e2926eadb13b8a2d04646debf..7b0cac6de50733fe577877aef7551a3fb3079917 100644 (file)
@@ -721,6 +721,13 @@ class IssuesControllerTest < ActionController::TestCase
     hours = assigns(:issues).collect(&:total_spent_hours)
     assert_equal hours.sort.reverse, hours
   end
+  
+  def test_index_sort_by_total_estimated_hours
+    get :index, :sort => 'total_estimated_hours:desc'
+    assert_response :success
+    hours = assigns(:issues).collect(&:total_estimated_hours)
+    assert_equal hours.sort.reverse, hours
+  end
 
   def test_index_sort_by_user_custom_field
     cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
@@ -862,6 +869,11 @@ class IssuesControllerTest < ActionController::TestCase
     assert_select 'table.issues tr#issue-3 td.total_spent_hours', :text => '1.00'
   end
 
+  def test_index_with_total_estimated_hours_column
+    get :index, :set_filter => 1, :c => %w(subject total_estimated_hours)
+    assert_select 'table.issues td.total_estimated_hours'
+  end
+
   def test_index_should_not_show_spent_hours_column_without_permission
     Role.anonymous.remove_permission! :view_time_entries
     get :index, :set_filter => 1, :c => %w(subject spent_hours)