From 467f74510e44d2c0821fad691a71bc0292b8944c Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang
Date: Tue, 1 Apr 2008 22:42:10 +0000
Subject: [PATCH] Time report can be done at issue level (closes #970) +
timelog views xhtml validation.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1319 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
app/controllers/timelog_controller.rb | 7 +++++--
app/models/issue.rb | 4 ++++
app/views/timelog/_list.rhtml | 4 +++-
app/views/timelog/details.rhtml | 2 ++
app/views/timelog/report.rhtml | 13 ++++++++-----
public/stylesheets/application.css | 2 +-
test/functional/timelog_controller_test.rb | 2 +-
7 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index 7e2b5587..e617d380 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -45,7 +45,10 @@ class TimelogController < ApplicationController
:label => :label_tracker},
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
:klass => Enumeration,
- :label => :label_activity}
+ :label => :label_activity},
+ 'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
+ :klass => Issue,
+ :label => :label_issue}
}
@criterias = params[:criterias] || []
@@ -196,7 +199,7 @@ private
render_404
end
- # Retreive the date range based on predefined ranges or specific from/to param dates
+ # Retrieves the date range based on predefined ranges or specific from/to param dates
def retrieve_date_range
@free_period = false
@from, @to = nil, nil
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 1d25a460..d6fcf53f 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -237,4 +237,8 @@ class Issue < ActiveRecord::Base
yield
end
end
+
+ def to_s
+ "#{tracker} ##{id}: #{subject}"
+ end
end
diff --git a/app/views/timelog/_list.rhtml b/app/views/timelog/_list.rhtml
index 67e3c67d..189f4f5e 100644
--- a/app/views/timelog/_list.rhtml
+++ b/app/views/timelog/_list.rhtml
@@ -1,5 +1,6 @@
+
<%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
<%= sort_header_tag('user_id', :caption => l(:label_member)) %>
<%= sort_header_tag('activity_id', :caption => l(:label_activity)) %>
@@ -8,6 +9,7 @@
<%= l(:field_comments) %> |
<%= sort_header_tag('hours', :caption => l(:field_hours)) %>
|
+
<% entries.each do |entry| -%>
@@ -35,5 +37,5 @@
<% end -%>
-
+
diff --git a/app/views/timelog/details.rhtml b/app/views/timelog/details.rhtml
index f1e80da1..a0810fbd 100644
--- a/app/views/timelog/details.rhtml
+++ b/app/views/timelog/details.rhtml
@@ -28,3 +28,5 @@
<%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %>
<% end %>
+
+<% html_title l(:label_spent_time), l(:label_details) %>
diff --git a/app/views/timelog/report.rhtml b/app/views/timelog/report.rhtml
index 2e08e588..92d0e878 100644
--- a/app/views/timelog/report.rhtml
+++ b/app/views/timelog/report.rhtml
@@ -7,12 +7,11 @@
<% form_remote_tag(:url => {}, :update => 'content') do %>
<% @criterias.each do |criteria| %>
- <%= hidden_field_tag 'criterias[]', criteria %>
+ <%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
<% end %>
<%= hidden_field_tag 'project_id', params[:project_id] %>
<%= render :partial => 'date_range' %>
-
-
+
<%= l(:label_details) %>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'],
[l(:label_month), 'month'],
[l(:label_week), 'week']], @columns),
@@ -21,6 +20,7 @@
<%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l(@available_criterias[k][:label]), k]}),
:onchange => "this.form.onsubmit();",
:style => 'width: 200px',
+ :id => nil,
:disabled => (@criterias.length >= 3)) %>
<%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :date_from => @date_from, :date_to => @date_to, :period => @columns}, :update => 'content'},
:class => 'icon icon-reload' %>
@@ -36,10 +36,10 @@
<% @criterias.each do |criteria| %>
- <%= l(@available_criterias[criteria][:label]) %> |
+ <%= l(@available_criterias[criteria][:label]) %> |
<% end %>
<% @periods.each do |period| %>
- <%= period %> |
+ <%= period %> |
<% end %>
@@ -57,3 +57,6 @@
<% end %>
<% end %>
+
+<% html_title l(:label_spent_time), l(:label_report) %>
+
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 3d614fe1..69e89b0e 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -183,7 +183,7 @@ div#version-summary { float:right; width:380px; margin-left: 16px; margin-bottom
div#version-summary fieldset { margin-bottom: 1em; }
div#version-summary .total-hours { text-align: right; }
-table#time-report td.hours { text-align: right; padding-right: 0.5em; }
+table#time-report td.hours, table#time-report th.period { text-align: right; padding-right: 0.5em; }
table#time-report tbody tr { font-style: italic; color: #777; }
table#time-report tbody tr.last-level { font-style: normal; color: #555; }
table#time-report tbody tr.total { font-style: normal; font-weight: bold; color: #555; background-color:#EEEEEE; }
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 9ca1a6cb..c55d5248 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -80,7 +80,7 @@ class TimelogControllerTest < Test::Unit::TestCase
end
def test_report_all_time
- get :report, :project_id => 1, :criterias => ['project']
+ get :report, :project_id => 1, :criterias => ['project', 'issue']
assert_response :success
assert_template 'report'
assert_not_nil assigns(:total_hours)