summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-25 12:06:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-25 12:06:38 +0000
commit31bffaa053fc4f3d96224a4d93b465d4eab92395 (patch)
tree5b5eba1e7e29683b7426548da5ba76c2519d11e7
parent481f70d12537333206199b4a8d2891218959f4ad (diff)
downloadredmine-31bffaa053fc4f3d96224a4d93b465d4eab92395.tar.gz
redmine-31bffaa053fc4f3d96224a4d93b465d4eab92395.zip
Display time spent on the issue and the total time spent like estimated hours (#17550).
git-svn-id: http://svn.redmine.org/redmine/trunk@14273 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/issues_helper.rb24
-rw-r--r--app/views/issues/show.html.erb4
-rw-r--r--lib/redmine/i18n.rb4
3 files changed, 27 insertions, 5 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index a8dcdca91..753f0fd43 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -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
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index d8219f933..2065ce3b3 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -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) %>
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
index 4422bbe13..0091186f4 100644
--- a/lib/redmine/i18n.rb
+++ b/lib/redmine/i18n.rb
@@ -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