File tree Expand file tree Collapse file tree 3 files changed +56
-4
lines changed
Expand file tree Collapse file tree 3 files changed +56
-4
lines changed Original file line number Diff line number Diff line change @@ -6578,6 +6578,51 @@ sub GetPageLayout {
65786578 return ;
65796579}
65806580
6581+ =head2 GetPageLayoutShowHistory Object => $Object, Page => $Page
6582+
6583+ Returns the C<ShowHistory > value configured on the History widget in the page
6584+ layout for the given C<$Object > and C<$Page > , or C<undef > if the layout does
6585+ not override it.
6586+
6587+ =cut
6588+
6589+ sub GetPageLayoutShowHistory {
6590+ my %args = (
6591+ Object => ' ' ,
6592+ Page => ' Display' ,
6593+ @_ ,
6594+ );
6595+
6596+ my $config = GetPageLayout(%args );
6597+ return unless $config ;
6598+
6599+ my $content = ref $config eq ' HASH' ? $config -> {Content } : $config ;
6600+ return unless $content && ref $content eq ' ARRAY' ;
6601+
6602+ for my $item ( @$content ) {
6603+ next unless ref $item eq ' HASH' ;
6604+
6605+ if ( $item -> {Elements } ) {
6606+ for my $col ( @{ $item -> {Elements } } ) {
6607+ my @widgets = ref $col eq ' ARRAY' ? @$col : ($col );
6608+ for my $widget (@widgets ) {
6609+ if ( ref $widget eq ' HASH'
6610+ && ( $widget -> {Name } // ' ' ) eq ' History'
6611+ && defined $widget -> {ShowHistory } )
6612+ {
6613+ return $widget -> {ShowHistory };
6614+ }
6615+ }
6616+ }
6617+ }
6618+ elsif ( ( $item -> {Name } // ' ' ) eq ' History' && defined $item -> {ShowHistory } ) {
6619+ return $item -> {ShowHistory };
6620+ }
6621+ }
6622+
6623+ return ;
6624+ }
6625+
65816626=head2 GetAvailableWidgets Class => $Class, Page => $Page
65826627
65836628Returns a list of available widgets for the given C<$Class > and C<$Page > .
Original file line number Diff line number Diff line change 5454 </span>
5555 <div class="d-md-none"></div>
5656 <span class="new-messages-buttons">
57- % my $ShowHistory = RT->Config->Get( 'ShowHistory', $session{'CurrentUser'} );
57+ % my $ShowHistory = GetPageLayoutShowHistory(
58+ % Object => $Ticket, Page => $DisplayPath eq 'SelfService' ? 'SelfService Display' : 'Display'
59+ % ) // RT->Config->Get( 'ShowHistory', $session{'CurrentUser'} );
5860% my $url = RT->Config->Get('WebPath') . "/$DisplayPath/Display.html?id=" . $Ticket->id;
5961% if ( $ShowHistory eq 'click' ) {
6062% $url .= '&ShowHistory=1';
63+ % } elsif ( $ShowHistory eq 'page' ) {
64+ % $url .= '&ShowHistory=page';
6165% }
6266 <a
6367% if ( RT::Interface::Web::RequestENV('REQUEST_URI') eq $url ) { # URL doesn't change, no need to reload
Original file line number Diff line number Diff line change @@ -1787,12 +1787,15 @@ htmx.onLoad(function(elt) {
17871787 elt . querySelector ( 'a.jump-to-unread' ) ?. addEventListener ( 'click' , ( evt ) => {
17881788 const widget = document . querySelector ( '.htmx-load-widget[hx-get$="/Widgets/Display/History"]' ) ;
17891789 if ( widget ) {
1790+ const linkHref = evt . target . closest ( 'a' ) . getAttribute ( 'href' ) ;
1791+ const linkUrl = new URL ( linkHref , location . origin ) ;
1792+ const showHistory = linkUrl . searchParams . get ( 'ShowHistory' ) ;
17901793 // For paginated history, we need to reload widget if the specified txn is not on current page
1791- if ( RT . Config . ShowHistory === 'page' && widget . getAttribute ( 'data-hx-revealed' ) === 'true' ) {
1792- const matched = evt . target . getAttribute ( 'href' ) . match ( / # ( t x n - \d + ) $ / ) ;
1794+ if ( showHistory === 'page' && widget . getAttribute ( 'data-hx-revealed' ) === 'true' ) {
1795+ const matched = linkHref . match ( / # ( t x n - \d + ) $ / ) ;
17931796 if ( matched && ! document . querySelector ( '[name="' + matched [ 1 ] + '"]' ) ) {
17941797 // Update location first so widget can retrieve the txn id from hash in URL
1795- location . href = evt . target . getAttribute ( 'href' ) ;
1798+ location . href = linkHref ;
17961799 reloadElement ( widget , { "hx-vals" : JSON . stringify ( { id : ( new URLSearchParams ( location . search ) ) . get ( 'id' ) } ) } ) ;
17971800 }
17981801 }
You can’t perform that action at this time.
0 commit comments