]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1149384 - implement time tracking interface
authorDavid Lawrence <dkl@mozilla.com>
Fri, 20 May 2016 17:17:18 +0000 (17:17 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Fri, 20 May 2016 17:17:18 +0000 (17:17 +0000)
extensions/BugModal/lib/ActivityStream.pm
extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
extensions/BugModal/web/bug_modal.css
extensions/BugModal/web/bug_modal.js

index 0bd88e623890ff9a189d49ac70c6613c7567b008..86fa6bb3b706f1f743acc2ceaae6f6869a4f04a2 100644 (file)
@@ -167,7 +167,7 @@ sub _add_comments_to_stream {
         next if $comment->type == CMT_HAS_DUPE;
         my $author_id = $comment->author->id;
         next if $comment->is_private && !($user->is_insider || $user->id == $author_id);
-        next if $comment->body eq '' && ($comment->work_time - 0) != 0 && !$user->is_timetracker;
+        next if $comment->body eq '' && ($comment->work_time - 0) != 0 && $user->is_timetracker;
 
         # treeherder is so spammy we hide its comments by default
         if ($author_id == $treeherder_id) {
index 0fe644584fc91ec44a75c8f086749627eeecabbe..9efd601e93a159bf32749b57143d9de67347c982 100644 (file)
@@ -48,7 +48,7 @@
       PROCESS activity_header activities=change_set.activity id=change_set.id;
     END;
 
-    IF change_set.comment;
+    IF change_set.comment != "";
       PROCESS comment_body comment=change_set.comment;
     END;
     FOREACH activity IN change_set.activity;
index 06b6c801d5d183bcb057b30dee9c07b1e9eda131..9ed5f28b7346341232286c7a0e45b3ec3be5a6fd 100644 (file)
   [% END %]
 [% END %]
 
+[%# === timetracking === %]
+[% IF user.is_timetracker %]
+  [%
+    PROCESS bug/time.html.tmpl;
+    sub = [];
+    IF bug.estimated_time > 0;
+      estimated_time = PROCESS formattimeunit time_unit = bug.estimated_time;
+      sub.push("Estimated: $estimated_time");
+    END;
+    IF bug.remaining_time > 0;
+      remaining_time = PROCESS formattimeunit time_unit = bug.remaining_time;
+      sub.push("Remaining: $remaining_time");
+    END;
+    IF bug.deadline;
+      sub.push("Deadline: " _ bug.deadline);
+    END;
+  %]
+  [% WRAPPER bug_modal/module.html.tmpl
+    title     = "Time Tracking"
+    collapsed = 1
+    no_collapse_persist = 1
+    subtitle = sub
+  %]
+    [% WRAPPER fields_lhs %]
+      [% estimated_time = PROCESS formattimeunit time_unit = bug.estimated_time %]
+      [% INCLUDE bug_modal/field.html.tmpl
+         field        = bug_fields.estimated_time
+         field_type   = constants.FIELD_TYPE_FREETEXT
+         value        = estimated_time
+         hide_on_view = 0
+         short_width  = 1
+      %]
+      [% current_estimate = PROCESS formattimeunit time_unit = (bug.actual_time + bug.remaining_time) %]
+      [% INCLUDE bug_modal/field.html.tmpl
+         label = "Current Est"
+         value = current_estimate
+         view_only = 1
+      %]
+      [% hours_worked = PROCESS formattimeunit time_unit = bug.actual_time %]
+      [% WRAPPER bug_modal/field.html.tmpl
+         field_type  = constants.FIELD_TYPE_FREETEXT
+         label       = "Hours Worked"
+         name        = "work_time"
+         value       = '0.0'
+         short_width = 1
+      %]
+        [% PROCESS formattimeunit time_unity = bug.actual_time %]
+      [% END %]
+      [% hours_left = PROCESS formattimeunit time_unit = bug.remaining_time %]
+      [% INCLUDE bug_modal/field.html.tmpl
+         field       = bug_fields.remaining_time
+         field_type  = constants.FIELD_TYPE_FREETEXT
+         value       = hours_left
+         short_width = 1
+      %]
+    [% END %]
+
+    [% WRAPPER fields_rhs %]
+      [% percentage_complete = PROCESS calculatepercentage act = bug.actual_time rem = bug.remaining_time %]
+      [% INCLUDE bug_modal/field.html.tmpl
+         label     = "% Complete"
+         value     = percentage_complete
+         view_only = 1
+      %]
+      [% time_gain = PROCESS formattimeunit  time_unit = bug.estimated_time - (bug.actual_time + bug.remaining_time) %]
+      [% INCLUDE bug_modal/field.html.tmpl
+         label = "Gain"
+         value = time_gain
+         view_only = 1
+      %]
+      [% INCLUDE bug_modal/field.html.tmpl
+         field      = bug_fields.deadline
+         field_type = constants.FIELD_TYPE_DATE
+         value      = bug.deadline
+      %]
+      <div>
+        <a href="summarize_time.cgi?id=[% bug.bug_id FILTER none %]&amp;do_depends=1">
+          Summarize time (including time for [% terms.bugs %]
+          blocking this [% terms.bug %])</a>
+      </div>
+    [% END %]
+  [% END %]
+[% END %]
+
 [%# === extensions which are modules === %]
 
 [% Hook.process('module') %]
index 48064f06c6ee8f6da43f94065028c52499e9a701..e32f4c546da78334c1cb6e71d9808794ed7821bb 100644 (file)
@@ -66,7 +66,7 @@
     "extensions/BugModal/web/bug_modal.css",
     "skins/custom/bug_groups.css",
     "js/jquery/plugins/datetimepicker/datetimepicker.css",
-    "js/jquery/plugins/contextMenu/contextMenu.css",
+    "js/jquery/plugins/contextMenu/contextMenu.css"
   );
 
   IF user.in_group('canconfirm');
@@ -99,6 +99,7 @@
     id: [% user.id FILTER none %],
     login: '[% user.login FILTER js %]',
     is_insider: [% user.is_insider ? "true" : "false" %],
+    is_timetracker: [% user.is_timetracker ? "true" : "false" %],
     can_tag: [% user.can_tag_comments ? "true" : "false" %],
     settings: {
       quote_replies: '[% user.settings.quote_replies.value FILTER js %]',
     BUGZILLA.constant.min_comment_tag_length = [% constants.MIN_COMMENT_TAG_LENGTH FILTER none %];
     BUGZILLA.constant.max_comment_tag_length = [% constants.MAX_COMMENT_TAG_LENGTH FILTER none %];
   [% END %]
+
+  [% IF user.is_timetracker %]
+    BUGZILLA.remaining_time = [% bug.remaining_time FILTER js %]; // holds the original value
+  [% END %]
 [% END %]
 
 [% Hook.process("end") %]
index 0a589b050bb6d5c116f0914e3946246587c34889..88ffadc9e47a58555697bf8dabb49a404972d777 100644 (file)
@@ -109,6 +109,9 @@ a.activity-ref {
     background: #eee;
     padding: 2px 5px;
     cursor: pointer;
+    -webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
+    -moz-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
+    box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
 }
 
 .module-header:hover {
@@ -158,6 +161,9 @@ a.activity-ref {
 .module-content {
     padding: 2px 5px;
     background: #fff;
+    -webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
+    -moz-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
+    box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
 }
 
 .module .field {
index 6c10c6fb0860d22b162e1e3d1ab8f6d7da6d7053..6c72eb24923990e0ec9085ca85c665138bb00169 100644 (file)
@@ -949,6 +949,19 @@ $(function() {
             $('#' + id).datetimepicker('show');
         });
 
+    // timetracking
+    $('#work_time').change(function() {
+        // subtracts time spent from remaining time
+        // prevent negative values if work_time > fRemainingTime
+        var new_time = Math.max(BUGZILLA.remaining_time - $('#work_time').val(), 0.0);
+        // get upto 2 decimal places
+        $('#remaining_time').val(Math.round((new_time * 100)/100).toFixed(1));
+    });
+    $('#remaining_time').change(function() {
+        // if the remaining time is changed manually, update BUGZILLA.remaining_time
+        BUGZILLA.remaining_time = $('#remaining_time').val();
+    });
+
     // new bug button
     $.contextMenu({
         selector: '#new-bug-btn',