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
This commit is contained in:
Jean-Philippe Lang 2008-04-01 22:42:10 +00:00
parent 043cb37b16
commit 467f74510e
7 changed files with 24 additions and 10 deletions

View File

@ -45,7 +45,10 @@ class TimelogController < ApplicationController
:label => :label_tracker}, :label => :label_tracker},
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id", 'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
:klass => Enumeration, :klass => Enumeration,
:label => :label_activity} :label => :label_activity},
'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
:klass => Issue,
:label => :label_issue}
} }
@criterias = params[:criterias] || [] @criterias = params[:criterias] || []
@ -196,7 +199,7 @@ private
render_404 render_404
end 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 def retrieve_date_range
@free_period = false @free_period = false
@from, @to = nil, nil @from, @to = nil, nil

View File

@ -237,4 +237,8 @@ class Issue < ActiveRecord::Base
yield yield
end end
end end
def to_s
"#{tracker} ##{id}: #{subject}"
end
end end

View File

@ -1,5 +1,6 @@
<table class="list time-entries"> <table class="list time-entries">
<thead> <thead>
<tr>
<%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %> <%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %>
<%= sort_header_tag('user_id', :caption => l(:label_member)) %> <%= sort_header_tag('user_id', :caption => l(:label_member)) %>
<%= sort_header_tag('activity_id', :caption => l(:label_activity)) %> <%= sort_header_tag('activity_id', :caption => l(:label_activity)) %>
@ -8,6 +9,7 @@
<th><%= l(:field_comments) %></th> <th><%= l(:field_comments) %></th>
<%= sort_header_tag('hours', :caption => l(:field_hours)) %> <%= sort_header_tag('hours', :caption => l(:field_hours)) %>
<th></th> <th></th>
</tr>
</thead> </thead>
<tbody> <tbody>
<% entries.each do |entry| -%> <% entries.each do |entry| -%>
@ -35,5 +37,5 @@
</td> </td>
</tr> </tr>
<% end -%> <% end -%>
</tbdoy> </tbody>
</table> </table>

View File

@ -28,3 +28,5 @@
<span><%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %></span> <span><%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %></span>
</p> </p>
<% end %> <% end %>
<% html_title l(:label_spent_time), l(:label_details) %>

View File

@ -7,12 +7,11 @@
<% form_remote_tag(:url => {}, :update => 'content') do %> <% form_remote_tag(:url => {}, :update => 'content') do %>
<% @criterias.each do |criteria| %> <% @criterias.each do |criteria| %>
<%= hidden_field_tag 'criterias[]', criteria %> <%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
<% end %> <% end %>
<%= hidden_field_tag 'project_id', params[:project_id] %> <%= hidden_field_tag 'project_id', params[:project_id] %>
<%= render :partial => 'date_range' %> <%= render :partial => 'date_range' %>
</p>
</fieldset>
<p><%= l(:label_details) %>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'], <p><%= l(:label_details) %>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'],
[l(:label_month), 'month'], [l(:label_month), 'month'],
[l(:label_week), 'week']], @columns), [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]}), <%= 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();", :onchange => "this.form.onsubmit();",
:style => 'width: 200px', :style => 'width: 200px',
:id => nil,
:disabled => (@criterias.length >= 3)) %> :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'}, <%= 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' %></p> :class => 'icon icon-reload' %></p>
@ -36,10 +36,10 @@
<thead> <thead>
<tr> <tr>
<% @criterias.each do |criteria| %> <% @criterias.each do |criteria| %>
<th width="15%"><%= l(@available_criterias[criteria][:label]) %></th> <th><%= l(@available_criterias[criteria][:label]) %></th>
<% end %> <% end %>
<% @periods.each do |period| %> <% @periods.each do |period| %>
<th width="<%= ((100 - @criterias.length * 15 - 15 ) / @periods.length).to_i %>%"><%= period %></th> <th class="period" width="<%= (40 / @periods.length).to_i %>%"><%= period %></th>
<% end %> <% end %>
</tr> </tr>
</thead> </thead>
@ -57,3 +57,6 @@
</table> </table>
<% end %> <% end %>
<% end %> <% end %>
<% html_title l(:label_spent_time), l(:label_report) %>

View File

@ -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 fieldset { margin-bottom: 1em; }
div#version-summary .total-hours { text-align: right; } 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 { font-style: italic; color: #777; }
table#time-report tbody tr.last-level { font-style: normal; color: #555; } 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; } table#time-report tbody tr.total { font-style: normal; font-weight: bold; color: #555; background-color:#EEEEEE; }

View File

@ -80,7 +80,7 @@ class TimelogControllerTest < Test::Unit::TestCase
end end
def test_report_all_time def test_report_all_time
get :report, :project_id => 1, :criterias => ['project'] get :report, :project_id => 1, :criterias => ['project', 'issue']
assert_response :success assert_response :success
assert_template 'report' assert_template 'report'
assert_not_nil assigns(:total_hours) assert_not_nil assigns(:total_hours)