SHARE
TWEET

Redmine Time Work Patch

lpiotrowski Nov 22nd, 2014 189 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From 6a577d88ca71bbba660176d3870ba1c80cf79000 Mon Sep 17 00:00:00 2001
  2. From: root <root@vpslpiot.(none)>
  3. Date: Tue, 18 Nov 2014 13:18:07 +0100
  4. Subject: [PATCH] Added hours human readable format on lists
  5.  
  6. ---
  7. app/helpers/queries_helper.rb         |    5 +++++
  8.  app/views/my/blocks/_timelog.html.erb |    6 +++---
  9.  lib/redmine/i18n.rb                   |    6 +++++-
  10.  3 files changed, 13 insertions(+), 4 deletions(-)
  11.  
  12. diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
  13. index 9324a9d..76208f0 100644
  14. --- a/app/helpers/queries_helper.rb
  15. +++ b/app/helpers/queries_helper.rb
  16. @@ -99,6 +99,11 @@ module QueriesHelper
  17.        issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
  18.      when :done_ratio
  19.        progress_bar(value, :width => '80px')
  20. +    when :estimated_hours
  21. +      l_hours(value)
  22. +    when :spent_hours
  23. +      l_hours(value)
  24. +
  25.      when :relations
  26.        other = value.other_issue(issue)
  27.        content_tag('span',
  28. diff --git a/app/views/my/blocks/_timelog.html.erb b/app/views/my/blocks/_timelog.html.erb
  29. index fbd83c3..d474d03 100644
  30. --- a/app/views/my/blocks/_timelog.html.erb
  31. +++ b/app/views/my/blocks/_timelog.html.erb
  32. @@ -8,7 +8,7 @@ entries_by_day = entries.group_by(&:spent_on)
  33.  %>
  34.  
  35.  <div class="total-hours">
  36. -<p><%= l(:label_total_time) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
  37. +<p><%= l(:label_total) %>: <%= l_hours(entries.sum(&:hours)) %></p>
  38.  </div>
  39.  
  40.  <% if entries.any? %>
  41. @@ -25,7 +25,7 @@ entries_by_day = entries.group_by(&:spent_on)
  42.      <tr class="odd">
  43.      <td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
  44.      <td colspan="2"></td>
  45. -    <td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
  46. +    <td class="hours"><em><%= l_hours(entries_by_day[day].sum(&:hours)) %></em></td>
  47.      <td></td>
  48.      </tr>
  49.      <% entries_by_day[day].each do |entry| -%>
  50. @@ -33,7 +33,7 @@ entries_by_day = entries.group_by(&:spent_on)
  51.      <td class="activity"><%=h entry.activity %></td>
  52.      <td class="subject"><%=h entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
  53.      <td class="comments"><%=h entry.comments %></td>
  54. -    <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
  55. +    <td class="hours"><%= l_hours(entry.hours) %></td>
  56.      <td class="buttons">
  57.      <% if entry.editable_by?(@user) -%>
  58.          <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
  59. diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
  60. index 11be1b6..1140a68 100644
  61. --- a/lib/redmine/i18n.rb
  62. +++ b/lib/redmine/i18n.rb
  63. @@ -45,7 +45,11 @@ module Redmine
  64.  
  65.      def l_hours(hours)
  66.        hours = hours.to_f
  67. -      l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
  68. +      hours_part = hours.truncate
  69. +      minutes_part = ((hours - hours_part) * 60).round
  70. +      "#{hours_part}h #{minutes_part}m"
  71. +
  72. +
  73.      end
  74.  
  75.      def ll(lang, str, value=nil)
  76. --
  77. 1.7.10.4
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top