[Rt-commit] rt branch, 5.0/search-navigation-menu-on-ticket-display, created. rt-5.0.0alpha1-218-g75cc90bbcc

Craig Kaiser craig at bestpractical.com
Mon May 4 14:05:13 EDT 2020


The branch, 5.0/search-navigation-menu-on-ticket-display has been created
        at  75cc90bbcc8e59ab3083f804a7adf086212f504d (commit)

- Log -----------------------------------------------------------------
commit 75cc90bbcc8e59ab3083f804a7adf086212f504d
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon Mar 16 16:23:34 2020 -0400

    Add search navigation menu to ticket display page

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 987b4c890b..e685be5b86 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1900,6 +1900,10 @@ sub Menu {
     return $HTML::Mason::Commands::m->notes('menu');
 }
 
+sub SearchResultsPageMenu {
+    return $HTML::Mason::Commands::m->notes('search-results-page-menu');
+}
+
 sub PageMenu {
     return $HTML::Mason::Commands::m->notes('page-menu');
 }
@@ -1923,7 +1927,9 @@ sub RenderMenu {
     $res .= '<ul';
     $res .= ' id="'. $interp->apply_escapes($id, 'h') .'"'
         if $id;
-    $res .= ' class="toplevel"' if $toplevel;
+    my $class = $args{class} // '';
+    $class .= ' toplevel' if $toplevel;
+    $res .= " class='$class'";
     $res .= ">\n";
 
     for my $child ($menu->children) {
@@ -1949,7 +1955,7 @@ sub RenderMenu {
             if ( $tmp = $child->class ) {
                 $res .= ' '. $interp->apply_escapes($tmp, 'h');
             }
-            $res .= ' btn' if ( defined $id && $id eq 'page-menu' );
+            $res .= ' btn' if ( defined $id && ( $id eq 'page-menu' || $id eq 'search-results-page-menu' ) );
             $res .= '"';
 
             my $path = $child->path;
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 613f4b903a..47ce892aee 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -321,6 +321,7 @@ sub BuildMainNav {
     }
 
 
+    my $search_results_page_menu;
     if ( $request_path =~ m{^/Ticket/} ) {
         if ( ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
             my $id  = $1;
@@ -451,21 +452,22 @@ sub BuildMainNav {
                         $HTML::Mason::Commands::session{"tickets"}->PrepForSerialization();
                     }
 
-                    my $search = $top->child('search')->child('tickets');
+                    $search_results_page_menu = $HTML::Mason::Commands::m->notes('search-results-page-menu', RT::Interface::Web::Menu->new());
+
                     # Don't display prev links if we're on the first ticket
                     if ( $item_map->{$id}->{prev} ) {
-                        $search->child( first =>
-                            title => '<< ' . loc('First'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{first});
-                        $search->child( prev =>
-                            title => '< ' . loc('Prev'),   class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{prev});
+                        $search_results_page_menu->child( first =>
+                            title => '<< ' . loc('First'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{first}, sort_order => 1 );
+                        $search_results_page_menu->child( prev =>
+                            title => '< ' . loc('Prev'),   class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{prev}, sort_order => 2 );
                     }
                     # Don't display next links if we're on the last ticket
                     if ( $item_map->{$id}->{next} ) {
-                        $search->child( next =>
-                            title => loc('Next') . ' >',  class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{next});
+                        $search_results_page_menu->child( next =>
+                            title => loc('Next') . ' >',  class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{next}, sort_order => 3 );
                         if ( $item_map->{last} ) {
-                            $search->child( last =>
-                                title => loc('Last') . ' >>', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{last});
+                            $search_results_page_menu->child( last =>
+                                title => loc('Last') . ' >>', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{last}, sort_order => 4 );
                         }
                     }
                 }
@@ -583,6 +585,11 @@ sub BuildMainNav {
         {
             $current_search_menu = $search->child( current_search => title => loc('Current Search') );
             $current_search_menu->path("/Search/Results.html$args") if $has_query;
+
+            if ( $search_results_page_menu && $has_query ) {
+                my $page_current_search = $search_results_page_menu->child( current_search => title => loc('< Back to search'), sort_order => -1 );
+                $page_current_search->path("/Search/Results.html$args") if $has_query;
+            }
         }
         else {
             $current_search_menu = $page;
diff --git a/share/html/Elements/PageLayout b/share/html/Elements/PageLayout
index 998aba06bf..4edf216286 100644
--- a/share/html/Elements/PageLayout
+++ b/share/html/Elements/PageLayout
@@ -51,7 +51,7 @@
 
 % if ( $show_menu ) {
 <div id="main-navigation"><& /Elements/Menu, menu => Menu(), id => 'app-nav' &></div>
-<div id="page-navigation" class="btn-group page-nav-shadow"><& /Elements/Menu, menu => PageMenu(), id => 'page-menu', 'parent_id' => 'page' &></div>
+<div id="page-navigation" class="btn-group page-nav-shadow"><& /Elements/Menu, menu => PageMenu(), id => 'page-menu', class => 'page-menu', 'parent_id' => 'page' &></div>
 % }
 <div id="topactions"><& /Elements/WidgetBar, menu => PageWidgets() &></div>
 
diff --git a/share/html/NoAuth/css/elevator-light/AfterMenus b/share/html/NoAuth/css/elevator-light/AfterMenus
index 735960281d..189429c5cc 100644
--- a/share/html/NoAuth/css/elevator-light/AfterMenus
+++ b/share/html/NoAuth/css/elevator-light/AfterMenus
@@ -50,9 +50,9 @@ var initMenus = function() {
     jQuery("#app-nav.toplevel").addClass('sf-menu sf-js-enabled sf-shadow').superfish({ speed: 'fast' }).supposition();
     jQuery("#page-menu.toplevel").addClass('sf-menu sf-js-enabled sf-shadow').superfish({ speed: 'fast' }).supposition();
 
-    var originalOffset = jQuery("#page-menu").offset().top;
+    var originalOffset = jQuery(".page-menu").offset().top;
     var floatMenu      = function () {
-        jQuery("#page-menu").toggleClass("pinned", jQuery(document).scrollTop() > originalOffset);
+        jQuery(".page-menu").toggleClass("pinned", jQuery(document).scrollTop() > originalOffset);
     };
     floatMenu();
     jQuery(window).scroll(floatMenu);
@@ -62,7 +62,7 @@ var initMenus = function() {
     jQuery('#li-page-overflow-will_be_deleted').remove();
 
     rebalanceOverflowMenu('#app-nav', '#li-overflow');
-    rebalanceOverflowMenu('#page-menu', '#li-page-overflow');
+    rebalanceOverflowMenu('.page-menu', '#li-page-overflow');
 };
 
 // If everything is loaded, init NOW.  Otherwise, defer to DOM ready.
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index f6293e20bd..a96322d59b 100644
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -66,9 +66,13 @@ my $initial_label = $HideUnsetFields ? $show_label : $hide_label;
 my $url = "?HideUnsetFields=" . ($HideUnsetFields ? 0 : 1) . ";id=$ARGS{id}";
 my $url_html = $m->interp->apply_escapes($url, 'h');
 
+my $search_menu = $m->scomp( '/Elements/Menu', menu => HTML::Mason::Commands::SearchResultsPageMenu(), class => 'page-menu btn-group page-nav-shadow sf-menu sf-js-enabled sf-shadow', id => 'search-results-page-menu', 'parent_id' => 'page' ) || '';
 my $alt = loc('Edit');
 my $titleright = qq{
 <div class="btn-group dropdown">
+  <div class="search-results-page-menu-container">
+    $search_menu
+  </div>
   <a id="metadata-dropdown" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
     <span class="fas fa-cog icon-bordered fa-2x" alt="$alt" data-toggle="tooltip" data-placement="top" data-original-title="$alt"></span>
   </a>
diff --git a/share/static/css/elevator-light/nav.css b/share/static/css/elevator-light/nav.css
index 8c5315abff..1b7b840ce4 100644
--- a/share/static/css/elevator-light/nav.css
+++ b/share/static/css/elevator-light/nav.css
@@ -82,7 +82,7 @@ ul.sf-menu li {
     text-color: #000;
 }
 
-#page-menu.sf-menu a,
+.page-menu.sf-menu a,
 #main-navigation .sf-menu a,
 #main-navigation .sf-menu a:hover {
     padding-top: 0.5em;
@@ -117,7 +117,7 @@ ul.sf-menu li {
     border-bottom: none;
 }
 
-#page-navigation #page-menu {
+#page-navigation .page-menu {
     float: right;
     width: auto;
 }
@@ -133,7 +133,7 @@ ul.sf-menu li {
 
 /* Pin page menu to top left corner once you scroll past it */
 
-#page-navigation #page-menu.pinned {
+#page-navigation .page-menu.pinned {
     position: fixed;
     top: 0;
     right: 0;
@@ -152,8 +152,8 @@ ul.sf-menu li {
     -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.4);
 }
 
-#page-menu.pinned li:hover ul,
-#page-menu.pinned li.sfHover ul {
+.page-menu.pinned li:hover ul,
+.page-menu.pinned li.sfHover ul {
     border-left: 1px #aaa solid;
     border-right: 1px #aaa solid;
     z-index: -1 !important; /* relative to current stacking context */
@@ -164,8 +164,8 @@ ul.sf-menu li {
 
 /* round off the corner of the first menu item so it matches the container */
 
-#page-menu.pinned > li:first-of-type,
-#page-menu.pinned > li:first-of-type > a {
+.page-menu.pinned > li:first-of-type,
+.page-menu.pinned > li:first-of-type > a {
     border-radius: 0 0 0 5px;
     -moz-border-radius: 0 0 0 5px;
     -webkit-border-radius: 0 0 0 5px;
@@ -296,45 +296,45 @@ ul.sf-menu li {
     display: block
 }
 
-#page-menu.toplevel {
+.page-menu.toplevel {
     display: none
 }
 
-#page-menu.toplevel.sf-menu {
+.page-menu.toplevel.sf-menu {
     display: block
 }
 
 /* be overly specific to defeat specificity */
 #app-nav.sf-menu > li#li-overflow,
-#page-menu.sf-menu > li#li-page-overflow {
+.page-menu.sf-menu > li#li-page-overflow {
     display: none;
 }
 #app-nav.sf-menu > li#li-overflow.has-overflow,
-#page-menu.sf-menu > li#li-page-overflow.has-overflow {
+.page-menu.sf-menu > li#li-page-overflow.has-overflow {
     display: inline-block;
 }
 
 /* these two rules prevent the menus from wrapping, so that our overflow
    calculations can work */
 #app-nav.sf-menu > li,
-#page-menu.sf-menu > li {
+.page-menu.sf-menu > li {
     float: none;
     display: inline-block;
 }
 #app-nav.sf-menu,
-#page-menu.sf-menu {
+.page-menu.sf-menu {
     white-space: nowrap;
     margin-bottom: 0;
 }
 
-#page-menu.sf-menu > li > span > a,
-#page-menu.sf-menu > li > a {
+.page-menu.sf-menu > li > span > a,
+.page-menu.sf-menu > li > a {
     padding-top: .3em;
     padding-bottom: .25em;
     border-radius: 0;
 }
 
-#page-menu.sf-menu > li {
+.page-menu.sf-menu > li {
     float: left;
     border-color: #E0E6EC;
     border-right-style: solid;
@@ -390,3 +390,7 @@ ul.toplevel.sf-menu > li > ul > li a.sf-with-ul:after {
         min-width: 2em;
     }
 }
+
+.search-results-page-menu-container {
+    padding-right: 5px;
+}

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


More information about the rt-commit mailing list