[Bps-public-commit] rt-extension-timetracking branch, auto-time-tracking2, created. 0.21-4-gfd9824c

Jim Brandt jbrandt at bestpractical.com
Thu May 13 17:13:36 EDT 2021


The branch, auto-time-tracking2 has been created
        at  fd9824c91b7cbf27d4c5855e8891720ebced0bef (commit)

- Log -----------------------------------------------------------------
commit fd9824c91b7cbf27d4c5855e8891720ebced0bef
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu May 13 17:12:24 2021 -0400

    Retain running time if inline edit forms are submitted
    
    Also, show minutes instead of the units dropdown since the
    auto timer works in minutes only and not hours.

diff --git a/html/Callbacks/RT-Extension-TimeTracking/Ticket/Display.html/Initial b/html/Callbacks/RT-Extension-TimeTracking/Ticket/Display.html/Initial
index 3a8e139..0b04ca8 100644
--- a/html/Callbacks/RT-Extension-TimeTracking/Ticket/Display.html/Initial
+++ b/html/Callbacks/RT-Extension-TimeTracking/Ticket/Display.html/Initial
@@ -1,4 +1,16 @@
 <%init>
+return unless $ARGSRef->{'id'};
+my $TicketObj = LoadTicket($ARGSRef->{'id'});
+
+if ( $ARGSRef->{'RunningTimeWorked'} ) {
+    my $time = $ARGSRef->{'RunningTimeWorked'};
+
+    # Should be in MM:SS format, convert to minutes
+    # TODO: would be nice to keep the seconds
+    my ($min, $sec) = split /:/, $time;
+    $session{'RunningTimeWorked' . $TicketObj->Id} = $min;
+}
+
 # Trim off seconds that may have been added by the auto timer
 if ( $ARGSRef->{'UpdateTimeWorked'} and $ARGSRef->{'UpdateTimeWorked'} =~ /(\d+)\:\d\d$/ ) {
     $ARGSRef->{'UpdateTimeWorked'} = int($1);
diff --git a/html/Callbacks/RT-Extension-TimeTracking/Ticket/Elements/ShowBasics/EndOfList b/html/Callbacks/RT-Extension-TimeTracking/Ticket/Elements/ShowBasics/EndOfList
index d4c9364..97721e9 100644
--- a/html/Callbacks/RT-Extension-TimeTracking/Ticket/Elements/ShowBasics/EndOfList
+++ b/html/Callbacks/RT-Extension-TimeTracking/Ticket/Elements/ShowBasics/EndOfList
@@ -1,5 +1,4 @@
 <%init>
-
 my $time_worked;
 if ( $TicketObj->TimeWorked ) {
     $time_worked = {};
@@ -32,6 +31,13 @@ my $cf_name = 'Object-RT::Transaction--CustomField-'
 my $today = RT::Date->new($session{CurrentUser});
 $today->SetToNow();
 
+# Restore the time if we had a running timer
+my $running_key = 'RunningTimeWorked' . $TicketObj->Id;
+if ( $session{$running_key} && !$ARGS{UpdateTimeWorked} ) {
+    $ARGS{UpdateTimeWorked} = $session{$running_key};
+    delete $session{$running_key};
+}
+
 </%init>
 <div class="add-time form-row">
   <div class="col-3 label input"><&|/l&>Add to time</&> <&|/l&>worked:</&></div>
@@ -46,7 +52,7 @@ $today->SetToNow();
           <input name="UpdateTimeWorked" type="text" value="<% $ARGS{UpdateTimeWorked} || '' %>" size="5" class="form-control" />
         </div>
         <div class="col-auto">
-          <& /Elements/SelectTimeUnits, Name => 'UpdateTimeWorked-TimeUnits', Default => $ARGS{'UpdateTimeWorked-TimeUnits'} || 'minutes' &>
+          <input type="text" name="UpdateTimeWorked-TimeUnits" disabled="disabled" value="minutes" class="form-control" size="5" />
         </div>
         <div class="col-auto">
           <input type="submit" class="btn btn-primary form-control" value="<% loc('Add') %>">
@@ -102,6 +108,13 @@ jQuery(document).ready(function() {
         clearInterval(timeTrackerTimer)
     })
 
+    jQuery('input[type="submit"][value="Save"').click(function() {
+        jQuery("<input />").attr("type", "hidden")
+                  .attr("name", "RunningTimeWorked")
+                  .attr("value", jQuery('input[name="UpdateTimeWorked"]').val())
+                  .appendTo(".inline-edit");
+    })
+
     var fn = function() {
         // Time in minutes for submission
         // Round down to be consistent with RTs ticket timer

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list