Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 6a577d88ca71bbba660176d3870ba1c80cf79000 Mon Sep 17 00:00:00 2001
- From: root <root@vpslpiot.(none)>
- Date: Tue, 18 Nov 2014 13:18:07 +0100
- Subject: [PATCH] Added hours human readable format on lists
- ---
- app/helpers/queries_helper.rb | 5 +++++
- app/views/my/blocks/_timelog.html.erb | 6 +++---
- lib/redmine/i18n.rb | 6 +++++-
- 3 files changed, 13 insertions(+), 4 deletions(-)
- diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
- index 9324a9d..76208f0 100644
- --- a/app/helpers/queries_helper.rb
- +++ b/app/helpers/queries_helper.rb
- @@ -99,6 +99,11 @@ module QueriesHelper
- issue.description? ? content_tag('div', textilizable(issue, :description), :class => "wiki") : ''
- when :done_ratio
- progress_bar(value, :width => '80px')
- + when :estimated_hours
- + l_hours(value)
- + when :spent_hours
- + l_hours(value)
- +
- when :relations
- other = value.other_issue(issue)
- content_tag('span',
- diff --git a/app/views/my/blocks/_timelog.html.erb b/app/views/my/blocks/_timelog.html.erb
- index fbd83c3..d474d03 100644
- --- a/app/views/my/blocks/_timelog.html.erb
- +++ b/app/views/my/blocks/_timelog.html.erb
- @@ -8,7 +8,7 @@ entries_by_day = entries.group_by(&:spent_on)
- %>
- <div class="total-hours">
- -<p><%= l(:label_total_time) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
- +<p><%= l(:label_total) %>: <%= l_hours(entries.sum(&:hours)) %></p>
- </div>
- <% if entries.any? %>
- @@ -25,7 +25,7 @@ entries_by_day = entries.group_by(&:spent_on)
- <tr class="odd">
- <td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
- <td colspan="2"></td>
- - <td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
- + <td class="hours"><em><%= l_hours(entries_by_day[day].sum(&:hours)) %></em></td>
- <td></td>
- </tr>
- <% entries_by_day[day].each do |entry| -%>
- @@ -33,7 +33,7 @@ entries_by_day = entries.group_by(&:spent_on)
- <td class="activity"><%=h entry.activity %></td>
- <td class="subject"><%=h entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
- <td class="comments"><%=h entry.comments %></td>
- - <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
- + <td class="hours"><%= l_hours(entry.hours) %></td>
- <td class="buttons">
- <% if entry.editable_by?(@user) -%>
- <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
- diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
- index 11be1b6..1140a68 100644
- --- a/lib/redmine/i18n.rb
- +++ b/lib/redmine/i18n.rb
- @@ -45,7 +45,11 @@ module Redmine
- def l_hours(hours)
- hours = hours.to_f
- - l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
- + hours_part = hours.truncate
- + minutes_part = ((hours - hours_part) * 60).round
- + "#{hours_part}h #{minutes_part}m"
- +
- +
- end
- def ll(lang, str, value=nil)
- --
- 1.7.10.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement