]> source.dussan.org Git - redmine.git/commitdiff
Display time spent on the issue and the total time spent like estimated hours (#17550).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 May 2015 12:06:38 +0000 (12:06 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 May 2015 12:06:38 +0000 (12:06 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14273 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb
app/views/issues/show.html.erb
lib/redmine/i18n.rb

index a8dcdca915eef2098236cca4ee0faa4d5ff1ab0f..753f0fd4343f92eb9565d8ac2e9ddd7dcf1ec76d 100644 (file)
@@ -114,11 +114,27 @@ module IssuesHelper
   end
 
   def issue_estimated_hours_details(issue)
-    s = issue.estimated_hours.present? ? l_hours(issue.estimated_hours) : ""
-    unless issue.leaf? || issue.total_estimated_hours.nil?
-      s << " (#{l(:label_total)}: #{l_hours(issue.total_estimated_hours)})"
+    if issue.total_estimated_hours.present?
+      if issue.total_estimated_hours == issue.estimated_hours
+        l_hours_short(issue.estimated_hours)
+      else
+        s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : ""
+        s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})"
+        s.html_safe
+      end
+    end
+  end
+
+  def issue_spent_hours_details(issue)
+    if issue.total_spent_hours > 0
+      if issue.total_spent_hours == issue.spent_hours
+        link_to(l_hours_short(issue.spent_hours), issue_time_entries_path(issue))
+      else
+        s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : ""
+        s << " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), issue_time_entries_path(issue)})"
+        s.html_safe
+      end
     end
-    s.html_safe
   end
 
   # Returns an array of error messages for bulk edited issues
index d8219f9334b14a65b264b59dd744aef688579a98..2065ce3b311b851fb670c3d42fa80f3917c714cc 100644 (file)
@@ -63,7 +63,9 @@
     end
   end
   if User.current.allowed_to?(:view_time_entries, @project)
-    rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), issue_time_entries_path(@issue)) : "-"), :class => 'spent-time'
+    if @issue.total_spent_hours > 0
+      rows.right l(:label_spent_time), issue_spent_hours_details(@issue), :class => 'spent-time'
+    end
   end
 end %>
 <%= render_custom_fields_rows(@issue) %>
index 4422bbe139bd240c967a8189c16ce8f54f418fd1..0091186f40a69eb95867ef49cd5772d6b8fa331a 100644 (file)
@@ -48,6 +48,10 @@ module Redmine
       l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
     end
 
+    def l_hours_short(hours)
+      "%.2f h" % hours.to_f
+    end
+
     def ll(lang, str, value=nil)
       ::I18n.t(str.to_s, :value => value, :locale => lang.to_s.gsub(%r{(.+)\-(.+)$}) { "#{$1}-#{$2.upcase}" })
     end