Feature #35657 » 0001-Add-a-basic-and-incomplete-POC-implementation-of-tot.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
s
|
||
|
end
|
||
|
def spent_time_ratio_details(issue)
|
||
|
if issue.total_estimated_hours.present? && issue.total_estimated_hours > 0
|
||
|
if issue.total_spent_time_ratio == issue.spent_time_ratio
|
||
|
content_tag(
|
||
|
:span,
|
||
|
"#{issue.spent_time_ratio.to_s(:percentage, precision: 2)}",
|
||
|
class: "spent-time-ratio-value"
|
||
|
)
|
||
|
else
|
||
|
s = !issue.spent_time_ratio.nil? && (issue.spent_time_ratio > 0) ?
|
||
|
content_tag(
|
||
|
:span,
|
||
|
"#{issue.spent_time_ratio.to_s(:percentage, precision: 2)}",
|
||
|
class: "spent-time-ratio-value"
|
||
|
) :
|
||
|
""
|
||
|
label = l(:label_total)
|
||
|
value = content_tag(
|
||
|
:span,
|
||
|
"#{issue.total_spent_time_ratio.to_s(:percentage, precision: 2)}",
|
||
|
class: "total-spent-time-ratio-value"
|
||
|
)
|
||
|
s += " ("
|
||
|
s += label
|
||
|
s += ": "
|
||
|
s += value
|
||
|
s += ")"
|
||
|
s.html_safe
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
# Returns a link for adding a new subtask to the given issue
|
||
|
def link_to_new_subtask(issue)
|
||
|
link_to(l(:button_add), url_for_new_subtask(issue))
|
||
| app/helpers/queries_helper.rb | ||
|---|---|---|
|
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}"))
|
||
|
when :attachments
|
||
|
value.to_a.map {|a| format_object(a)}.join(" ").html_safe
|
||
|
when :spent_time_ratio, :total_spent_time_ratio
|
||
|
!value.nil? ? value.to_s(:percentage, precision: 2) : ''
|
||
|
else
|
||
|
format_object(value)
|
||
|
end
|
||
| app/models/issue.rb | ||
|---|---|---|
|
due_date.present? && (due_date < User.current.today) && !closed?
|
||
|
end
|
||
|
def overspent?
|
||
|
spent_time_ratio.present? && spent_time_ratio > 100
|
||
|
end
|
||
|
def total_overspent?
|
||
|
total_spent_time_ratio.present? && total_spent_time_ratio > 100
|
||
|
end
|
||
|
# Is the amount of work done less than it should for the due date
|
||
|
def behind_schedule?
|
||
|
return false if start_date.nil? || due_date.nil?
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def spent_time_ratio
|
||
|
if (estimated_hours.present? && estimated_hours > 0)
|
||
|
if (spent_hours.present? && spent_hours == 0)
|
||
|
0.to_f.round(2)
|
||
|
elsif (spent_hours.present? && spent_hours > 0)
|
||
|
spent_time_ratio = spent_hours.to_f / estimated_hours.to_f * 100.0
|
||
|
spent_time_ratio.round(2)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def total_spent_time_ratio
|
||
|
if (total_estimated_hours.present? && total_estimated_hours > 0)
|
||
|
if (total_spent_hours.present? && total_spent_hours == 0)
|
||
|
0.to_f.round(2)
|
||
|
elsif (total_spent_hours.present? && total_spent_hours > 0)
|
||
|
total_spent_time_ratio =
|
||
|
total_spent_hours.to_f / total_estimated_hours.to_f * 100.0
|
||
|
total_spent_time_ratio.round(2)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def relations
|
||
|
@relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort)
|
||
|
end
|
||
| ... | ... | |
|
s << ' parent' unless leaf?
|
||
|
s << ' private' if is_private?
|
||
|
s << ' behind-schedule' if behind_schedule?
|
||
|
if user.allowed_to?(:view_time_entries, project, :global => true)
|
||
|
s << ' overspent' if overspent?
|
||
|
s << ' total-overspent' if total_overspent?
|
||
|
end
|
||
|
if user.logged?
|
||
|
s << ' created-by-me' if author_id == user.id
|
||
|
s << ' assigned-to-me' if assigned_to_id == user.id
|
||
| app/models/issue_query.rb | ||
|---|---|---|
|
:default_order => 'desc',
|
||
|
:caption => :label_total_spent_time)
|
||
|
)
|
||
|
@available_columns.insert(
|
||
|
index + 2,
|
||
|
QueryColumn.new(:spent_time_ratio,
|
||
|
:caption => "Spent time ratio")
|
||
|
)
|
||
|
@available_columns.insert(
|
||
|
index + 3,
|
||
|
QueryColumn.new(:total_spent_time_ratio,
|
||
|
:caption => "Total spent time ratio")
|
||
|
)
|
||
|
end
|
||
|
if User.current.allowed_to?(:set_issues_private, nil, :global => true) ||
|
||
| ... | ... | |
|
if has_column?(:total_spent_hours)
|
||
|
Issue.load_visible_total_spent_hours(issues)
|
||
|
end
|
||
|
if has_column?(:spent_time_ratio)
|
||
|
Issue.load_visible_spent_hours(issues)
|
||
|
end
|
||
|
if has_column?(:total_spent_time_ratio)
|
||
|
Issue.load_visible_total_spent_hours(issues)
|
||
|
end
|
||
|
if has_column?(:last_updated_by)
|
||
|
Issue.load_visible_last_updated_by(issues)
|
||
|
end
|
||
| app/models/version.rb | ||
|---|---|---|
|
@spent_hours ||= TimeEntry.joins(:issue).where("#{Issue.table_name}.fixed_version_id = ?", id).sum(:hours).to_f
|
||
|
end
|
||
|
def spent_time_ratio
|
||
|
if (estimated_hours.present? && estimated_hours > 0)
|
||
|
if (spent_hours.present? && spent_hours == 0)
|
||
|
0.to_f.round(2)
|
||
|
elsif (spent_hours.present? && spent_hours > 0)
|
||
|
spent_time_ratio = spent_hours.to_f / estimated_hours.to_f * 100.0
|
||
|
spent_time_ratio.round(2)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def closed?
|
||
|
status == 'closed'
|
||
|
end
|
||
| app/views/issues/show.html.erb | ||
|---|---|---|
|
end
|
||
|
if User.current.allowed_to?(:view_time_entries, @project) && @issue.total_spent_hours > 0
|
||
|
rows.right l(:label_spent_time), issue_spent_hours_details(@issue), :class => 'spent-time'
|
||
|
if spent_time_ratio_details(@issue).present?
|
||
|
rows.right 'Spent time ratio', spent_time_ratio_details(@issue), :class => 'spent-time-ratio'
|
||
|
end
|
||
|
end
|
||
|
end %>
|
||
|
<%= render_half_width_custom_fields_rows(@issue) %>
|
||
| app/views/versions/show.html.erb | ||
|---|---|---|
|
<td class="total-hours"><%= link_to html_hours(l_hours(@version.spent_hours)),
|
||
|
project_time_entries_path(@version.project, :set_filter => 1, :"issue.fixed_version_id" => @version.id) %></td>
|
||
|
</tr>
|
||
|
<% if !@version.spent_time_ratio.nil? %>
|
||
|
<tr>
|
||
|
<th><%= 'Spent time ratio' %></th>
|
||
|
<% overspent_class = @version.spent_time_ratio > 100 ? 'overspent' : '' %>
|
||
|
<td class="spent-time-ratio <%= overspent_class %>"><%= @version.spent_time_ratio.to_s(:percentage, precision: 2) %></td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</table>
|
||
|
</fieldset>
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
table.list td.reorder {width:15%; white-space:nowrap; text-align:center; }
|
||
|
table.list table.progress td {padding-right:0px;}
|
||
|
table.list caption { text-align: left; padding: 0.5em 0.5em 0.5em 0; }
|
||
|
table.list tr.overdue td.due_date { color: #c22; }
|
||
|
table.list tr.overdue td.due_date,
|
||
|
table.list tr.overspent td.spent_time_ratio,
|
||
|
table.list tr.total-overspent td.total_spent_time_ratio,
|
||
|
div#version-summary td.spent-time-ratio.overspent { color: #c22; }
|
||
|
#role-permissions-trackers table.list th {white-space:normal;}
|
||
|
.table-list-cell {display: table-cell; vertical-align: top; padding:2px; }
|
||
| ... | ... | |
|
div.issue .attributes .attribute {padding-left:180px; clear:left; min-height: 1.8em;}
|
||
|
div.issue .attributes .attribute .label {width: 170px; margin-left:-180px; font-weight:bold; float:left; overflow:hidden; text-overflow: ellipsis;}
|
||
|
div.issue .attribute .value {overflow:auto; text-overflow: ellipsis;}
|
||
|
div.issue.overdue .due-date .value { color: #c22; }
|
||
|
div.issue.overdue .due-date .value,
|
||
|
div.issue.overspent .spent-time-ratio.attribute .value span.spent-time-ratio-value,
|
||
|
div.issue.total-overpent .spent-time-ratio.attribute .value, span.total-spent-time-ratio-value { color: #c22; }
|
||
|
body.controller-issues h2.inline-flex {padding-right: 0}
|
||
|
#issue_tree table.issues, #relations table.issues { border: 0; }
|
||
| ... | ... | |
|
div#version-summary { float:right; width:28%; margin-left: 16px; margin-bottom: 16px; background-color: #fff; }
|
||
|
div#version-summary fieldset { margin-bottom: 1em; }
|
||
|
div#version-summary fieldset.time-tracking table { width:100%; }
|
||
|
div#version-summary th, div#version-summary td.total-hours { text-align: right; }
|
||
|
div#version-summary th,
|
||
|
div#version-summary td.total-hours,
|
||
|
div#version-summary td.spent-time-ratio { text-align: right; }
|
||
|
table#time-report td.hours, table#time-report th.period, table#time-report th.total { text-align: right; padding-right: 0.5em; }
|
||
|
table#time-report tbody tr.subtotal { font-style: italic; color:#777;}
|
||
| ... | ... | |
|
ul.properties li {list-style-type:none;}
|
||
|
ul.properties li span {font-style:italic;}
|
||
|
.total-hours { font-size: 110%; font-weight: bold; }
|
||
|
.total-hours,
|
||
|
div#version-summary .spent-time-ratio { font-size: 110%; font-weight: bold; }
|
||
|
.total-hours span.hours-int { font-size: 120%; }
|
||
|
.autoscroll {overflow-x: auto; padding:1px; margin-bottom: 1.2em; position: relative;}
|
||