UpdateTimeLeft: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
(No difference)

Latest revision as of 15:39, 6 April 2016

What this is

The patch below provides two distinct improvements to the default RT interface (3.4.1):

  • Ticket Update interface (/reply, comment/) now contains both Time Worked and Time Left fields, instead of just Time Worked field. This makes it easier to keep Time Left field up to date.
  • The above interface is augmented with a javascript event handler that automatically calculates the new value for Time Left when Time Worked is updated. If Time Worked -field is manually changed, the event handler is disabled.

These changes facilitate the following use case:

  1. Create ticket with Time Left = 200 minutes
  2. Work 100 minutes, half way through, enter Ticket Update interface
    1. Notice how Time Left field contains value 200
    2. Now enter the Time Worked: 100
    3. Move the keyboard focus away from the Time Worked entry (click on another field, use Tab...)
    4. Notice how Time Left is updated to new value: 100 minutes
    5. Jot down a message, Update Ticket

How to install

  1. Read the /Modifying Mason components/ -section in CleanlyCustomizeRT
  2. Copy stock share/html/Ticket/Update.html to local/html/Ticket/Update.html
  3. Apply the patch below (see man patch for more information)
  4. Restart Apache

Patch against stock RT 3.4.1 Ticket/Update.html

--- /opt/rt3/share/html/Ticket/Update.html      2005-02-01 16:20:40.000000000 +0200
+++ /opt/rt3/local/html/Ticket/Update.html      2005-12-02 08:54:09.029946568 +0200
@@ -48,6 +48,25 @@
    Ticket => $TicketObj,
    Title=> $title &>

+<script language="JavaScript">
+var originalTimeLeft = parseInt( "<% $TicketObj->TimeLeft %>" )
+var TimeLeftLocked = false
+function updateTimeLeft() {
+       if( TimeLeftLocked == false ) {
+               var newTimeLeft =  originalTimeLeft - document.TicketUpdate.UpdateTimeWorked.value
+               if( newTimeLeft < 0 ) {
+                       document.TicketUpdate.TimeLeft.value = 0
+               }
+               else {
+                       document.TicketUpdate.TimeLeft.value = newTimeLeft
+               }
+       }
+}
+function lockTimeLeft() {
+       TimeLeftLocked = true
+}
+</script>
+
 <FORM ACTION="Update.html" NAME="TicketUpdate"
       METHOD=POST enctype="multipart/form-data">
<input type="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction} %>">
@@ -61,7 +80,7 @@
<& /Elements/SelectStatus, Name=>"Status", DefaultLabel => loc("[_1] (Unchanged)", loc($TicketObj->Status)), Default => $ARGS{'Status'} || ($TicketObj->Status eq $DefaultStatus ? undef : $DefaultStatus)&>
<&|/l&>Owner</&>:
<& /Elements/SelectOwner, Name=>"Owner", DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Name()), QueueObj => $TicketObj->QueueObj, TicketObj => $TicketObj, Default => $ARGS{'Owner'} &>
-<&|/l&>Worked</&>: <input size=4 name="UpdateTimeWorked" value="<% $ARGS{UpdateTimeWorked}%>"> <&|/l&>minutes</&></td></tr>
+<&|/l&>Worked</&>, Left: <input size=4 name="UpdateTimeWorked" value="<% $ARGS{UpdateTimeWorked}%>" onblur="updateTimeLeft()"> <input size=4 name="TimeLeft" value="<% $TicketObj->TimeLeft %>" onchange="lockTimeLeft()"><&|/l&>minutes</&></td></tr>
% my $skip;
<& /Elements/Callback, _CallbackName => 'BeforeUpdateType', skip => \$skip, %ARGS &>
% if (!$skip) {