[Rt-commit] rt branch 5.0/jump-to-unread-on-click created. rt-5.0.3-85-g7f0bf2c157

BPS Git Server git at git.bestpractical.com
Tue Nov 29 20:30:34 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/jump-to-unread-on-click has been created
        at  7f0bf2c1573e015851c8cb3f6b038d473fd07895 (commit)

- Log -----------------------------------------------------------------
commit 7f0bf2c1573e015851c8cb3f6b038d473fd07895
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Aug 19 06:28:49 2022 +0800

    Prettify "Show ticket history" a bit by rendering it like a button

diff --git a/share/html/Ticket/Elements/ClickToShowHistory b/share/html/Ticket/Elements/ClickToShowHistory
index bb69237fc8..59103719c0 100644
--- a/share/html/Ticket/Elements/ClickToShowHistory
+++ b/share/html/Ticket/Elements/ClickToShowHistory
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <div id="deferred_ticket_history">
     <& /Widgets/TitleBoxStart, title => loc('History') &>
-        <a class="show-ticket-history" href="<% $display %>"><% loc('Show ticket history') %></a>
+        <a class="show-ticket-history btn btn-primary button" href="<% $display %>"><% loc('Show ticket history') %></a>
     <& /Widgets/TitleBoxEnd &>
 </div>
 

commit 39c72c9aa3063eab9a46835ff88ef60d9cd43f85
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Aug 19 06:19:56 2022 +0800

    Automatically load history for unread messages with on click setting
    
    With the "click" option set for ticket history, a new message may not be
    loaded initially when displaying a ticket. If the "Jump to Unread"
    button is clicked, trigger the "click" of "Show ticket history" to load
    history and jump to the corresponding transaction.
    
    This also fixes another related issue that when the page has anchor to
    some transaction id, browser didn't automatically jump after user clicks
    "Show ticket history".

diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 930f5bb083..7b07d5488d 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -383,7 +383,7 @@ $COLUMN_MAP = {
 
             my $link = RT->Config->Get('WebPath');
             $link .= $session{'CurrentUser'}->Privileged ? '/Ticket/Display.html?id=' : '/SelfService/Display.html?id=';
-            $link .= $self->id . '&MarkAsSeen=1&Anchor=txn-' . $first_unread->id;
+            $link .= $self->id . '&MarkAsSeen=1&ShowHistory=1&Anchor=txn-' . $first_unread->id;
 
             my $title = loc("Jump to Unread & Mark as Seen");
             return \( '<a data-toggle="tooltip" data-original-title="' . $title . '" href="' . $link . '"><b>' ),
diff --git a/share/html/SelfService/Display.html b/share/html/SelfService/Display.html
index 84a46f38be..07f7dd8294 100644
--- a/share/html/SelfService/Display.html
+++ b/share/html/SelfService/Display.html
@@ -162,7 +162,7 @@ MaybeRedirectForResults(
     Actions   => \@results,
     Path      => '/SelfService/Display.html',
     Anchor    => $ARGS{'Anchor'},
-    Arguments => { 'id' => $Ticket->id },
+    Arguments => { 'id' => $Ticket->id, exists $ARGS{ShowHistory} ? ( ShowHistory => $ARGS{ShowHistory} ) : () },
 );
 
 my $LinkBasicsTitle = $Ticket->CurrentUserHasRight('ModifyTicket')
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 78642411ba..87264acd03 100644
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -258,7 +258,7 @@ MaybeRedirectForResults(
         : (Path      => "/Ticket/Display.html")
     ,
     Anchor    => $ARGS{'Anchor'},
-    Arguments => { id => $TicketObj->id },
+    Arguments => { id => $TicketObj->id, exists $ARGS{ShowHistory} ? ( ShowHistory => $ARGS{ShowHistory} ) : () },
 );
 
 my $transactions;
diff --git a/share/html/Ticket/Elements/ClickToShowHistory b/share/html/Ticket/Elements/ClickToShowHistory
index 3cf39400e4..bb69237fc8 100644
--- a/share/html/Ticket/Elements/ClickToShowHistory
+++ b/share/html/Ticket/Elements/ClickToShowHistory
@@ -47,9 +47,38 @@
 %# END BPS TAGGED BLOCK }}}
 <div id="deferred_ticket_history">
     <& /Widgets/TitleBoxStart, title => loc('History') &>
-        <a href="<% $display %>" onclick="jQuery('#deferred_ticket_history').text(<% loc('Loading...') |n,j%>).load(<% $url |n,j %>); return false;" ><% loc('Show ticket history') %></a>
+        <a class="show-ticket-history" href="<% $display %>"><% loc('Show ticket history') %></a>
     <& /Widgets/TitleBoxEnd &>
 </div>
+
+<script type="text/javascript">
+jQuery(function(){
+    jQuery('#deferred_ticket_history a.show-ticket-history').click(function() {
+        jQuery('#deferred_ticket_history').text(<% loc('Loading...') |n,j%>).load(<% $url |n,j %>, function() {
+            if ( window.location.hash.match(/#txn-\d+/) ) {
+                var hash = window.location.hash;
+                // Refresh anchor so browser can jump to it accordingly
+                window.location.hash = '';
+                window.location.hash = hash;
+            }
+        });
+        return false;
+    });
+
+    // Catch clicks on unread messages buttons and load history automatically
+    jQuery('.new-messages-buttons > a').on('click', function (e) {
+        var link = jQuery(this);
+        if ( link[0].hash ) {
+            jQuery('#deferred_ticket_history a.show-ticket-history').click();
+        }
+        return true;
+    });
+
+% if ( $DECODED_ARGS->{ShowHistory} ) {
+    jQuery('#deferred_ticket_history a.show-ticket-history').click();
+% }
+});
+</script>
 <%ARGS>
 $Ticket
 </%ARGS>
diff --git a/share/html/Ticket/Elements/ShowUpdateStatus b/share/html/Ticket/Elements/ShowUpdateStatus
index cd0b3a76d6..a5d36d699f 100644
--- a/share/html/Ticket/Elements/ShowUpdateStatus
+++ b/share/html/Ticket/Elements/ShowUpdateStatus
@@ -58,7 +58,7 @@
         <div class="d-sm-none mt-1"></div>
         <a class="button btn btn-primary btn-sm" href="<% RT->Config->Get('WebPath') ."/$DisplayPath/Display.html?id=". $Ticket->id. "&MarkAsSeen=1" |n %>"><&|/l&>Mark as Seen</&></a>
         <div class="d-sm-none mt-1"></div>
-        <a class="button btn btn-primary btn-sm" href="<% RT->Config->Get('WebPath') ."/$DisplayPath/Display.html?id=". $Ticket->id ."&MarkAsSeen=1&Anchor=txn-" . $txn->id |n %>"><&|/l&>Jump & Mark as Seen</&></a>
+        <a class="button btn btn-primary btn-sm" href="<% RT->Config->Get('WebPath') ."/$DisplayPath/Display.html?id=". $Ticket->id ."&MarkAsSeen=1&ShowHistory=1&Anchor=txn-" . $txn->id |n %>"><&|/l&>Jump & Mark as Seen</&></a>
       </span>
     </div>
   </div>

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list