]> source.dussan.org Git - redmine.git/commitdiff
Show estimated time on the overview page as well as spent time (#30464).
authorGo MAEDA <maeda@farend.jp>
Tue, 22 Jan 2019 23:34:57 +0000 (23:34 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 22 Jan 2019 23:34:57 +0000 (23:34 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17838 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/views/projects/show.html.erb
test/functional/projects_controller_test.rb

index a43038a988c56b3386f8b024bfb5e42c29766853..1b88e5fc66905d1081d49a4bc9b0a90442f1e2b3 100644 (file)
@@ -158,6 +158,7 @@ class ProjectsController < ApplicationController
 
     if User.current.allowed_to_view_all_time_entries?(@project)
       @total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f
+      @total_estimated_hours = Issue.visible.where(cond).sum(:estimated_hours).to_f
     end
 
     @key = User.current.rss_key
index a36afeb6c45d40a8516755bf9afda1c4697cffae..923bc03e8b25f3bbd1b4d10ccb1499fe7dc6e089 100644 (file)
 
   <% if User.current.allowed_to?(:view_time_entries, @project) %>
   <div class="spent_time box">
-    <h3 class="icon icon-time"><%= l(:label_spent_time) %></h3>
-    <% if @total_hours.present? %>
-      <p><%= l_hours(@total_hours) %></p>
-    <% end %>
+    <h3 class="icon icon-time"><%= l(:label_time_tracking) %></h3>
+    <ul>
+      <% if @total_estimated_hours.present? %>
+        <li><%= l(:field_estimated_hours) %>: <%= l_hours(@total_estimated_hours) %>
+      <% end %>
+      <% if @total_hours.present? %>
+          <li><%= l(:label_spent_time) %>: <%= l_hours(@total_hours) %>
+      <% end %>
+    </ul>
     <p>
     <% if User.current.allowed_to?(:log_time, @project) %>
       <%= link_to l(:button_log_time), new_project_time_entry_path(@project) %> |
index e5b5eaaf425c3b36f310b4bba06fca5a92a84a87..16f42ac4dec614fb2803236d20d7257bd29d85af 100644 (file)
@@ -575,6 +575,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
     assert_select 'table.issue-report td.total a', :text => %r{\A[1-9]\d*\z}
   end
 
+  def test_show_should_spent_and_estimated_time
+    @request.session[:user_id] = 1
+    get :show, :params => {
+        :id => 'ecookbook'
+      }
+
+    assert_select 'div.spent_time.box>ul' do
+      assert_select '>li:nth-child(1)', :text => 'Estimated time: 203.50 hours'
+      assert_select '>li:nth-child(2)', :text => 'Spent time: 162.90 hours'
+    end
+  end
+
   def test_settings
     @request.session[:user_id] = 2 # manager
     get :settings, :params => {