diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 930dd524c82..9966dbd1882 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -358,6 +358,24 @@ sub BuildMainNav {
}
}
+ my $timer_list = $HTML::Mason::Commands::session{'CurrentUser'}{'timers'};
+ if( keys %{ $timer_list } ) {
+ my $timers = $top->child( 'timers' =>
+ title => loc('Timers'),
+ escape_title => 0,
+ path => '/',
+ sort_order => 100,
+ );
+ if( my @tickets = sort keys %{ $timer_list } ) {
+ foreach my $id( @tickets ) {
+ my $timed_ticket = RT::Ticket->new( $current_user );
+ $timed_ticket->Load($id);
+
+ my $description = "$id - " . $timed_ticket->Subject;
+ $timers->child( "ticket_$id" => title => $description, path => "/Ticket/Display.html?id=$id" );
+ }
+ }
+ }
my $search_results_page_menu;
if ( $request_path =~ m{^/Ticket/} ) {
diff --git a/share/html/Helpers/AddTimeWorked b/share/html/Helpers/AddTimeWorked
index db89ae92b8e..6fecf2f5a56 100644
--- a/share/html/Helpers/AddTimeWorked
+++ b/share/html/Helpers/AddTimeWorked
@@ -92,6 +92,9 @@ else {
}
}
+delete $session{'CurrentUser'}{'timers'}{$id};
+$session{'i'}++;
+
$r->content_type('application/json; charset=utf-8');
$m->print(JSON({ ok => $ok, msg => $msg }));
$m->abort;
diff --git a/share/html/Helpers/StopTimer b/share/html/Helpers/StopTimer
new file mode 100644
index 00000000000..ae7664a6662
--- /dev/null
+++ b/share/html/Helpers/StopTimer
@@ -0,0 +1,9 @@
+<%ARGS>
+$id
+%ARGS>
+<%INIT>
+RT->Logger->debug( "Stopping timer for Ticket $id" );
+delete $session{'CurrentUser'}{'timers'}{$id};
+$session{'i'}++;
+$m->abort;
+%INIT>
diff --git a/share/html/Helpers/TicketTimer b/share/html/Helpers/TicketTimer
index 747c6fbcb67..c337f274e6d 100644
--- a/share/html/Helpers/TicketTimer
+++ b/share/html/Helpers/TicketTimer
@@ -56,6 +56,10 @@ my $Now = RT::Date->new($session{'CurrentUser'});
$Now->SetToNow;
my $SubmitURL = RT->Config->Get('WebPath') . '/Helpers/AddTimeWorked';
+
+my $CancelURL = RT->Config->Get('WebPath') . '/Helpers/StopTimer';
+$session{'CurrentUser'}{'timers'}{$id} = 1;
+$session{'i'}++;
%INIT>
<& /Elements/Header, Title => loc('Timer for #[_1]: [_2]', $Ticket->Id, $Ticket->Subject), RichText => 0, ShowBar => 0, ShowTitle => 0 &>
@@ -155,7 +159,6 @@ jQuery( function() {
if (Response.ok) {
Readout.addClass('response');
Readout.text(Response.msg);
- jQuery('.control-line .close-popup').removeClass('hidden');
}
else {
RenderSubmitError(Response.msg);
@@ -170,8 +173,22 @@ jQuery( function() {
});
jQuery('.close-popup').click(function () {
- window.close();
- return false;
+ var Payload = { id: <% $Ticket->id %> };
+
+ jQuery.ajax({
+ url: <% $CancelURL |n,j %>,
+ data: Payload,
+ timeout: 30000, /* 30 seconds */
+ // The window closes before the ajax call happens if we close the window outside the callbacks
+ success: function (Response) {
+ window.close();
+ return false;
+ },
+ error: function (xhr, reason) {
+ window.close();
+ return false;
+ }
+ });
});
Tick();
@@ -193,7 +210,7 @@ jQuery( function() {
-
+
<& /Elements/MessageBox,
diff --git a/share/html/Ticket/Elements/PopupTimerLink b/share/html/Ticket/Elements/PopupTimerLink
index 11b56abb81f..43c867ffc49 100644
--- a/share/html/Ticket/Elements/PopupTimerLink
+++ b/share/html/Ticket/Elements/PopupTimerLink
@@ -51,7 +51,24 @@ $id
<%INIT>
my $url = RT->Config->Get('WebPath') . "/Helpers/TicketTimer?id=" . $id;
my $alt = loc('Open Timer');
+my $CancelURL = RT->Config->Get('WebPath') . '/Helpers/StopTimer';
%INIT>
-
+
+