Skip to content

Commit 73fffe5

Browse files
committed
Bug 1149384 - implement time tracking interface
1 parent 35b33fe commit 73fffe5

File tree

6 files changed

+111
-3
lines changed

6 files changed

+111
-3
lines changed

extensions/BugModal/lib/ActivityStream.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ sub _add_comments_to_stream {
167167
next if $comment->type == CMT_HAS_DUPE;
168168
my $author_id = $comment->author->id;
169169
next if $comment->is_private && !($user->is_insider || $user->id == $author_id);
170-
next if $comment->body eq '' && ($comment->work_time - 0) != 0 && !$user->is_timetracker;
170+
next if $comment->body eq '' && ($comment->work_time - 0) != 0 && $user->is_timetracker;
171171

172172
# treeherder is so spammy we hide its comments by default
173173
if ($author_id == $treeherder_id) {

extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
PROCESS activity_header activities=change_set.activity id=change_set.id;
4949
END;
5050

51-
IF change_set.comment;
51+
IF change_set.comment != "";
5252
PROCESS comment_body comment=change_set.comment;
5353
END;
5454
FOREACH activity IN change_set.activity;

extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,90 @@
10541054
[% END %]
10551055
[% END %]
10561056

1057+
[%# === timetracking === %]
1058+
[% IF user.is_timetracker %]
1059+
[%
1060+
PROCESS bug/time.html.tmpl;
1061+
sub = [];
1062+
IF bug.estimated_time > 0;
1063+
estimated_time = PROCESS formattimeunit time_unit = bug.estimated_time;
1064+
sub.push("Estimated: $estimated_time");
1065+
END;
1066+
IF bug.remaining_time > 0;
1067+
remaining_time = PROCESS formattimeunit time_unit = bug.remaining_time;
1068+
sub.push("Remaining: $remaining_time");
1069+
END;
1070+
IF bug.deadline;
1071+
sub.push("Deadline: " _ bug.deadline);
1072+
END;
1073+
%]
1074+
[% WRAPPER bug_modal/module.html.tmpl
1075+
title = "Time Tracking"
1076+
collapsed = 1
1077+
no_collapse_persist = 1
1078+
subtitle = sub
1079+
%]
1080+
[% WRAPPER fields_lhs %]
1081+
[% estimated_time = PROCESS formattimeunit time_unit = bug.estimated_time %]
1082+
[% INCLUDE bug_modal/field.html.tmpl
1083+
field = bug_fields.estimated_time
1084+
field_type = constants.FIELD_TYPE_FREETEXT
1085+
value = estimated_time
1086+
hide_on_view = 0
1087+
short_width = 1
1088+
%]
1089+
[% current_estimate = PROCESS formattimeunit time_unit = (bug.actual_time + bug.remaining_time) %]
1090+
[% INCLUDE bug_modal/field.html.tmpl
1091+
label = "Current Est"
1092+
value = current_estimate
1093+
view_only = 1
1094+
%]
1095+
[% hours_worked = PROCESS formattimeunit time_unit = bug.actual_time %]
1096+
[% WRAPPER bug_modal/field.html.tmpl
1097+
field_type = constants.FIELD_TYPE_FREETEXT
1098+
label = "Hours Worked"
1099+
name = "work_time"
1100+
value = '0.0'
1101+
short_width = 1
1102+
%]
1103+
[% PROCESS formattimeunit time_unity = bug.actual_time %]
1104+
[% END %]
1105+
[% hours_left = PROCESS formattimeunit time_unit = bug.remaining_time %]
1106+
[% INCLUDE bug_modal/field.html.tmpl
1107+
field = bug_fields.remaining_time
1108+
field_type = constants.FIELD_TYPE_FREETEXT
1109+
value = hours_left
1110+
short_width = 1
1111+
%]
1112+
[% END %]
1113+
1114+
[% WRAPPER fields_rhs %]
1115+
[% percentage_complete = PROCESS calculatepercentage act = bug.actual_time rem = bug.remaining_time %]
1116+
[% INCLUDE bug_modal/field.html.tmpl
1117+
label = "% Complete"
1118+
value = percentage_complete
1119+
view_only = 1
1120+
%]
1121+
[% time_gain = PROCESS formattimeunit time_unit = bug.estimated_time - (bug.actual_time + bug.remaining_time) %]
1122+
[% INCLUDE bug_modal/field.html.tmpl
1123+
label = "Gain"
1124+
value = time_gain
1125+
view_only = 1
1126+
%]
1127+
[% INCLUDE bug_modal/field.html.tmpl
1128+
field = bug_fields.deadline
1129+
field_type = constants.FIELD_TYPE_DATE
1130+
value = bug.deadline
1131+
%]
1132+
<div>
1133+
<a href="summarize_time.cgi?id=[% bug.bug_id FILTER none %]&amp;do_depends=1">
1134+
Summarize time (including time for [% terms.bugs %]
1135+
blocking this [% terms.bug %])</a>
1136+
</div>
1137+
[% END %]
1138+
[% END %]
1139+
[% END %]
1140+
10571141
[%# === extensions which are modules === %]
10581142

10591143
[% Hook.process('module') %]

extensions/BugModal/template/en/default/bug_modal/header.html.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"extensions/BugModal/web/bug_modal.css",
6767
"skins/custom/bug_groups.css",
6868
"js/jquery/plugins/datetimepicker/datetimepicker.css",
69-
"js/jquery/plugins/contextMenu/contextMenu.css",
69+
"js/jquery/plugins/contextMenu/contextMenu.css"
7070
);
7171

7272
IF user.in_group('canconfirm');
@@ -99,6 +99,7 @@
9999
id: [% user.id FILTER none %],
100100
login: '[% user.login FILTER js %]',
101101
is_insider: [% user.is_insider ? "true" : "false" %],
102+
is_timetracker: [% user.is_timetracker ? "true" : "false" %],
102103
can_tag: [% user.can_tag_comments ? "true" : "false" %],
103104
settings: {
104105
quote_replies: '[% user.settings.quote_replies.value FILTER js %]',
@@ -112,6 +113,10 @@
112113
BUGZILLA.constant.min_comment_tag_length = [% constants.MIN_COMMENT_TAG_LENGTH FILTER none %];
113114
BUGZILLA.constant.max_comment_tag_length = [% constants.MAX_COMMENT_TAG_LENGTH FILTER none %];
114115
[% END %]
116+
117+
[% IF user.is_timetracker %]
118+
BUGZILLA.remaining_time = [% bug.remaining_time FILTER js %]; // holds the original value
119+
[% END %]
115120
[% END %]
116121

117122
[% Hook.process("end") %]

extensions/BugModal/web/bug_modal.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ a.activity-ref {
109109
background: #eee;
110110
padding: 2px 5px;
111111
cursor: pointer;
112+
-webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
113+
-moz-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
114+
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
112115
}
113116

114117
.module-header:hover {
@@ -158,6 +161,9 @@ a.activity-ref {
158161
.module-content {
159162
padding: 2px 5px;
160163
background: #fff;
164+
-webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
165+
-moz-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
166+
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
161167
}
162168

163169
.module .field {

extensions/BugModal/web/bug_modal.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,19 @@ $(function() {
949949
$('#' + id).datetimepicker('show');
950950
});
951951

952+
// timetracking
953+
$('#work_time').change(function() {
954+
// subtracts time spent from remaining time
955+
// prevent negative values if work_time > fRemainingTime
956+
var new_time = Math.max(BUGZILLA.remaining_time - $('#work_time').val(), 0.0);
957+
// get upto 2 decimal places
958+
$('#remaining_time').val(Math.round((new_time * 100)/100).toFixed(1));
959+
});
960+
$('#remaining_time').change(function() {
961+
// if the remaining time is changed manually, update BUGZILLA.remaining_time
962+
BUGZILLA.remaining_time = $('#remaining_time').val();
963+
});
964+
952965
// new bug button
953966
$.contextMenu({
954967
selector: '#new-bug-btn',

0 commit comments

Comments
 (0)