[Rt-commit] rt branch, 4.4/keyboard-shortcut-correspond, created. rt-4.4.2-74-g52961517f

Craig Kaiser craig at bestpractical.com
Tue May 8 12:08:32 EDT 2018


The branch, 4.4/keyboard-shortcut-correspond has been created
        at  52961517f4713e0884bdcc99afe67ceed406293c (commit)

- Log -----------------------------------------------------------------
commit 52961517f4713e0884bdcc99afe67ceed406293c
Author: craig Kaiser <craig at bestpractical.com>
Date:   Mon Apr 23 09:37:18 2018 -0400

    Add keyboard shortcuts for reply and comment
    
    If the user is on a ticket page where the action link for reply or
    comment is available, then they should be able to use the keyboard
    shortcuts 'r' and 'c'.

diff --git a/share/html/Elements/ShortcutHelp b/share/html/Elements/ShortcutHelp
index 41180a279..7cbc4df02 100644
--- a/share/html/Elements/ShortcutHelp
+++ b/share/html/Elements/ShortcutHelp
@@ -46,8 +46,10 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%args>
-$show_search      => 0
-$show_bulk_update => 0
+$show_bulk_update     => 0
+$show_search          => 0
+$show_ticket_reply    => 0
+$show_ticket_comment  => 0
 </%args>
 
 <div class="keyboard-shortcuts">
@@ -115,4 +117,29 @@ $show_bulk_update => 0
 
 % }
 
+% if ($show_ticket_reply || $show_ticket_comment) {
+    <div class="titlebox">
+        <div class="titlebox-title">
+            <span class="left"><&|/l&>Ticket Display</&></span>
+            <span class="right-empty"></span>
+        </div>
+        <div class="titlebox-content">
+            <hr class="clear">
+            <table>
+%   if ( $show_ticket_reply ) {
+                <tr>
+                    <td class="key-column"><span class="keyboard-shortcuts-key">r</span></td>
+                    <td><&|/l&>Reply To Current Ticket</&></td>
+                </tr>
+%   }
+%   if ( $show_ticket_comment ) {
+                <tr>
+                    <td class="key-column"><span class="keyboard-shortcuts-key">c</span></td>
+                    <td><&|/l&>Comment On Current Ticket</&></td>
+                </tr>
+%   }
+            </table>
+        </div>
+    </div>
+% }
 </div>
diff --git a/share/html/Helpers/ShortcutHelp b/share/html/Helpers/ShortcutHelp
index b9e71fd7d..21cdacf51 100644
--- a/share/html/Helpers/ShortcutHelp
+++ b/share/html/Helpers/ShortcutHelp
@@ -46,8 +46,10 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%args>
-$show_search      => 0
-$show_bulk_update => 0
+$show_search         => 0
+$show_bulk_update    => 0
+$show_ticket_reply   => 0
+$show_ticket_comment => 0
 </%args>
 <& /Elements/ShortcutHelp, %ARGS &>
 % $m->abort;
diff --git a/share/html/SelfService/Helpers/ShortcutHelp b/share/html/SelfService/Helpers/ShortcutHelp
index b9e71fd7d..ab0a77671 100644
--- a/share/html/SelfService/Helpers/ShortcutHelp
+++ b/share/html/SelfService/Helpers/ShortcutHelp
@@ -48,6 +48,8 @@
 <%args>
 $show_search      => 0
 $show_bulk_update => 0
+$show_ticket_reply => 0
+$show_ticket_comment => 0
 </%args>
 <& /Elements/ShortcutHelp, %ARGS &>
 % $m->abort;
diff --git a/share/static/js/keyboard-shortcuts.js b/share/static/js/keyboard-shortcuts.js
index a7b4cf54f..3faf69cd3 100644
--- a/share/static/js/keyboard-shortcuts.js
+++ b/share/static/js/keyboard-shortcuts.js
@@ -34,10 +34,14 @@ jQuery(function() {
 
         var is_search = jQuery('body#comp-Search-Results').length > 0;
         var is_bulk_update = jQuery('body#comp-Search-Bulk').length > 0;
+        var is_ticket_reply = jQuery('a#page-actions-reply').length > 0;
+        var is_ticket_comment = jQuery('a#page-actions-comment').length > 0;
 
         var url = RT.Config.WebHomePath + '/Helpers/ShortcutHelp' +
                   '?show_search=' + ( is_search || is_bulk_update ? '1' : '0' ) +
-                  '&show_bulk_update=' + ( is_bulk_update ? '1' : '0' );
+                  '&show_bulk_update=' + ( is_bulk_update ? '1' : '0' ) +
+                  '&show_ticket_reply=' + ( is_ticket_reply ? '1' : '0' ) +
+                  '&show_ticket_comment=' + ( is_ticket_comment ? '1' : '0' );
 
         jQuery.ajax({
             url: url,
@@ -151,3 +155,22 @@ jQuery(function() {
     Mousetrap.bind('x', toggleTicketCheckbox);
 });
 
+jQuery(function() {
+    // Only load these shortcuts if on ticket display page
+    var ticket_reply = jQuery('a#page-actions-reply');
+    var ticket_comment = jQuery('a#page-actions-comment');
+    if (!ticket_reply.length && !ticket_comment.length) return;
+
+    var replyToTicket = function() {
+        if (!ticket_reply.length) return;
+        window.location.href = ticket_reply.attr('href');
+    };
+
+    var commentOnTicket = function() {
+        if (!ticket_comment.length) return;
+        window.location.href = ticket_comment.attr('href');
+    };
+
+    Mousetrap.bind('r', replyToTicket);
+    Mousetrap.bind('c', commentOnTicket);
+});

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


More information about the rt-commit mailing list