[Rt-commit] rt branch, 4.4/ticket-timer, updated. rt-4.2.11-187-gff1fea1

Shawn Moore shawn at bestpractical.com
Mon Sep 21 19:36:16 EDT 2015


The branch, 4.4/ticket-timer has been updated
       via  ff1fea1fb617bb0e9b3263edd5bccac3f3706c76 (commit)
      from  67e030d6e7164edb69d44858d675fe15f6d9439b (commit)

Summary of changes:
 share/html/Helpers/AddTimeWorked | 23 ++++++++++++++++++-----
 share/html/Helpers/TicketTimer   | 35 ++++++++++++++++++++---------------
 share/static/css/base/misc.css   |  7 +++----
 3 files changed, 41 insertions(+), 24 deletions(-)

- Log -----------------------------------------------------------------
commit ff1fea1fb617bb0e9b3263edd5bccac3f3706c76
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Mon Sep 21 23:36:07 2015 +0000

    WIP

diff --git a/share/html/Helpers/AddTimeWorked b/share/html/Helpers/AddTimeWorked
index ba7a0f2..45bc267 100644
--- a/share/html/Helpers/AddTimeWorked
+++ b/share/html/Helpers/AddTimeWorked
@@ -55,14 +55,27 @@ $Ticket->Load( $id );
 
 my $minutes = int($seconds / 60);
 
-my $total_worked = $Ticket->TimeWorked + $minutes;
-
-if ($minutes < 60) {
-    $m->print(loc("Worked [quant,_1,minute,minutes]", $minutes));
+my $out;
+if ($minutes == 0) {
+    $out = loc("Worked [quant,_1,minute,minutes]", 0);
 }
 else {
-    $m->print(loc("Worked [quant,_1,hour,hours] ([quant,_2,minute,minutes])", sprintf("%.2f", $minutes / 60), $minutes));
+    my $total_worked = $Ticket->TimeWorked + $minutes;
+    my ($ok, $msg) = $Ticket->SetTimeWorked($total_worked);
+
+    if ($ok) {
+        if ($minutes < 60) {
+            $out = loc("Worked [quant,_1,minute,minutes]", $minutes);
+        }
+        else {
+            $out = loc("Worked [quant,_1,hour,hours] ([quant,_2,minute,minutes])", sprintf("%.2f", $minutes / 60), $minutes);
+        }
+    }
+    else {
+        $out = $msg;
+    }
 }
 
+$m->print($out);
 $m->abort;
 </%INIT>
diff --git a/share/html/Helpers/TicketTimer b/share/html/Helpers/TicketTimer
index 8f63c6b..112a771 100644
--- a/share/html/Helpers/TicketTimer
+++ b/share/html/Helpers/TicketTimer
@@ -69,9 +69,10 @@ jQuery( function() {
 
     var readout = jQuery('.readout');
     var playpause = jQuery('.playpause');
+    var playpause_img = playpause.find('img');
 
-    var pause_alt = playpause.attr('alt');
-    var unpause_alt = playpause.data('toggle-alt');
+    var pause_alt = playpause_img.attr('alt');
+    var unpause_alt = playpause_img.data('toggle-alt');
 
     var toHHMMSS = function (total) {
         var hours   = Math.floor(total / 3600);
@@ -98,33 +99,39 @@ jQuery( function() {
             // pause
             clearInterval(Interval);
             Interval = false;
-            playpause.attr('src', <% $unpause_img |n,j %>);
-            playpause.attr('alt', unpause_alt);
+            playpause_img.attr('src', <% $unpause_img |n,j %>);
+            playpause_img.attr('alt', unpause_alt);
         }
         else {
             // unpause
             Interval = setInterval(tick, 1000);
-            playpause.attr('src', <% $pause_img |n,j %>);
-            playpause.attr('alt', pause_alt);
+            playpause_img.attr('src', <% $pause_img |n,j %>);
+            playpause_img.attr('alt', pause_alt);
         }
+        return false;
     });
 
     jQuery('.submit-time').click(function () {
         clearInterval(Interval);
-        jQuery('.control-line img, .control-line .playpause-container').hide();
+        jQuery('.control-line a').hide();
 
         readout.text('<% loc("Submitting...") %>');
-        jQuery.get(<% $submit_url |n,j %>, {
+        var payload = {
             id: <% $Ticket->id %>,
             seconds: Seconds
-        }, function (data) {
+        };
+
+        jQuery.get(<% $submit_url |n,j %>, payload, function (data) {
             readout.text(data);
-            jQuery('.control-line .close-popup').removeClass('hidden');
+            jQuery('.control-line .close-popup').show().removeClass('hidden');
         });
+
+        return false;
     });
 
     jQuery('.close-popup').click(function () {
         window.close();
+        return false;
     });
 
     renderReadout(Seconds);
@@ -138,11 +145,9 @@ jQuery( function() {
     <div class="readout"></div>
 
     <div class="control-line">
-        <div class="playpause-container">
-            <img class="playpause" src="<% $pause_img %>" alt="<% loc('Pause Timer') %>" data-toggle-alt="<% loc('Unpause Timer') %>" />
-        </div>
-        <img class="submit-time" src="<% RT->Config->Get('WebPath') %>/static/images/stopwatch.png" alt="<% loc('Submit Timer') %>" />
-        <img class="close-popup hidden" src="<% RT->Config->Get('WebPath') %>/static/images/close.png" alt="<% loc('Close Window') %>" />
+        <a href="#" class="playpause"><img src="<% $pause_img %>" alt="<% loc('Pause Timer') %>" data-toggle-alt="<% loc('Unpause Timer') %>" /></a>
+        <a href="#" class="submit-time"><img src="<% RT->Config->Get('WebPath') %>/static/images/stopwatch.png" alt="<% loc('Submit Timer') %>" /></a>
+        <a href="#" class="close-popup hidden"><img src="<% RT->Config->Get('WebPath') %>/static/images/close.png" alt="<% loc('Close Window') %>" /></a>
     </div>
 
     <div class="extra"><&|/l, $now->AsString &>Started at [_1].</&></div>
diff --git a/share/static/css/base/misc.css b/share/static/css/base/misc.css
index 523b397..0492b48 100644
--- a/share/static/css/base/misc.css
+++ b/share/static/css/base/misc.css
@@ -109,13 +109,12 @@ textarea.messagebox, #cke_Content, #cke_UpdateContent {
     text-align: center;
 }
 
-.ticket-timer .control-line > div,
-.ticket-timer .control-line > img {
+.ticket-timer .control-line a {
     margin: 0 1em;
 }
 
 /* make sure play and pause icons have the same width */
-.ticket-timer .playpause-container {
+.ticket-timer .playpause {
     display: inline-block;
     text-align: center;
     height: 1.5em;
@@ -127,5 +126,5 @@ textarea.messagebox, #cke_Content, #cke_UpdateContent {
 }
 
 .ticket-timer > div {
-    margin-bottom: 0.5em;
+    margin-bottom: 0.4em;
 }

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


More information about the rt-commit mailing list