[Rt-commit] rt branch, 5.0/search-navigation-menu-on-ticket-display, created. rt-5.0.0alpha1-27-gf73b0b8b77
Craig Kaiser
craig at bestpractical.com
Mon Mar 23 08:59:39 EDT 2020
The branch, 5.0/search-navigation-menu-on-ticket-display has been created
at f73b0b8b772d739ead95f28143a3ff26ac40a573 (commit)
- Log -----------------------------------------------------------------
commit f73b0b8b772d739ead95f28143a3ff26ac40a573
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 a6f62fe06e..0f211804c9 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -652,6 +652,7 @@ sub MaybeRejectPrivateComponentRequest {
sub InitializeMenu {
$HTML::Mason::Commands::m->notes('menu', RT::Interface::Web::Menu->new());
+ # $HTML::Mason::Commands::m->notes('search-results-page-menu', RT::Interface::Web::Menu->new());
$HTML::Mason::Commands::m->notes('page-menu', RT::Interface::Web::Menu->new());
$HTML::Mason::Commands::m->notes('page-widgets', RT::Interface::Web::Menu->new());
@@ -1894,6 +1895,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');
}
@@ -1917,7 +1922,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) {
@@ -1943,7 +1950,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 8852112603..b8b84a1c77 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -308,7 +308,7 @@ sub BuildMainNav {
}
}
-
+ my $search_results_page_menu;
if ( $request_path =~ m{^/Ticket/} ) {
if ( ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
my $id = $1;
@@ -432,21 +432,23 @@ sub BuildMainNav {
$HTML::Mason::Commands::session{"tickets"}->PrepForSerialization();
}
- my $search = $top->child('search')->child('tickets');
+ $HTML::Mason::Commands::m->notes('search-results-page-menu', RT::Interface::Web::Menu->new());
+ $search_results_page_menu = HTML::Mason::Commands::SearchResultsPageMenu();
+
# 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 );
}
}
}
@@ -553,6 +555,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 ) {
+ 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/NoAuth/css/elevator-light/AfterMenus b/share/html/NoAuth/css/elevator-light/AfterMenus
index fec221b478..ddc6556e30 100644
--- a/share/html/NoAuth/css/elevator-light/AfterMenus
+++ b/share/html/NoAuth/css/elevator-light/AfterMenus
@@ -50,9 +50,12 @@ var initMenus = function() {
jQuery("#app-nav.toplevel").addClass('sf-menu sf-js-enabled sf-shadow').superfish({ speed: 'fast' });
jQuery("#page-menu.toplevel").addClass('sf-menu sf-js-enabled sf-shadow').superfish({ speed: 'fast' }).supposition();
+ jQuery("#search-results-page-menu.toplevel").addClass('sf-menu sf-js-enabled sf-shadow').superfish({ speed: 'fast' }).supposition();
+
var originalOffset = jQuery("#page-menu").offset().top;
var floatMenu = function () {
jQuery("#page-menu").toggleClass("pinned", jQuery(document).scrollTop() > originalOffset);
+ jQuery("#search-results-page-menu").toggleClass("pinned", jQuery(document).scrollTop() > originalOffset);
};
floatMenu();
jQuery(window).scroll(floatMenu);
@@ -63,6 +66,7 @@ var initMenus = function() {
rebalanceOverflowMenu('#app-nav', '#li-overflow');
rebalanceOverflowMenu('#page-menu', '#li-page-overflow');
+ rebalanceOverflowMenu('#search-results-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 1ad1d1c685..58e4662a74 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 => SearchResultsPageMenu(), class => '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..240daacbb2 100644
--- a/share/static/css/elevator-light/nav.css
+++ b/share/static/css/elevator-light/nav.css
@@ -390,3 +390,61 @@ ul.toplevel.sf-menu > li > ul > li a.sf-with-ul:after {
min-width: 2em;
}
}
+
+#search-results-page-menu.sf-menu {
+ white-space: nowrap;
+ margin-bottom: 0;
+}
+
+#search-results-page-menu.sf-menu > li > span > a,
+#search-results-page-menu.sf-menu > li > a {
+ padding-top: .3em;
+ padding-bottom: .25em;
+ border-radius: 0;
+}
+
+#search-results-page-menu.sf-menu > li {
+ float: left;
+ border-color: #E0E6EC;
+ border-right-style: solid;
+ border-right-width: 1px;
+ border-left-style: solid;
+ border-left-width: 1px;
+}
+
+#search-results-page-menu.sf-menu a,
+#main-navigation .sf-menu a,
+#main-navigation .sf-menu a:hover {
+ padding-top: 0.5em;
+ padding-bottom: 0.5em;
+ border-radius: 0;
+ text-align: left;
+}
+
+#page-navigation #search-results-page-menu {
+ float: right;
+ width: auto;
+}
+
+#page-navigation #search-results-page-menu.pinned {
+ position: fixed;
+ top: 0;
+ right: 0;
+ left: auto;
+ width: auto;
+ margin-top: 0;
+ background: white;
+ border-left: 1px #aaa solid;
+ border-bottom: 1px #aaa solid;
+ border-radius: 0 0 0 5px;
+ box-shadow: 0 0 10px rgba(0,0,0,0.4);
+ /* stupid vendor prefixes */
+ -moz-border-radius: 0 0 0 5px;
+ -webkit-border-radius: 0 0 0 5px;
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,0.4);
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.4);
+}
+
+.search-results-page-menu-container {
+ padding-right: 5px;
+}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list