[Rt-commit] rt branch, 4.4/search-result-counts, created. rt-4.4.0-227-g517bf8f
Shawn Moore
shawn at bestpractical.com
Wed Jun 1 14:08:54 EDT 2016
The branch, 4.4/search-result-counts has been created
at 517bf8f8a0899fed92d889dd773020db1184c777 (commit)
- Log -----------------------------------------------------------------
commit 517bf8f8a0899fed92d889dd773020db1184c777
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Jun 1 17:28:08 2016 +0000
Display result count on ticket search portlets
This is guarded by a new config option, ShowSearchResultCount,
which is off by default (since we're in the midst of a stable series)
This has no performance implications since /Elements/CollectionList
won't repeat the FromSQL and CountAll work when $Collection and
$TotalFound are passed in.
Fixes: I#31757
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 76c337d..67b529f 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1335,6 +1335,14 @@ should the sort be ascending (ASC) or descending (DESC).
Set($DefaultSearchResultOrder, 'ASC');
+=item C<$ShowSearchResultCount>
+
+Display search result count on ticket lists. Defaults to 0 (hide them).
+
+=cut
+
+Set($ShowSearchResultCount, 0);
+
=item C<$DefaultSelfServiceSearchResultFormat>
C<$DefaultSelfServiceSearchResultFormat> is the default format of
diff --git a/share/html/Elements/ShowSearch b/share/html/Elements/ShowSearch
index c154bca..aa76c4e 100644
--- a/share/html/Elements/ShowSearch
+++ b/share/html/Elements/ShowSearch
@@ -47,6 +47,7 @@
%# END BPS TAGGED BLOCK }}}
<&|/Widgets/TitleBox,
title => loc(RT::SavedSearch->EscapeDescription($search->Description), $ProcessedSearchArg->{'Rows'}),
+ title_raw => $title_raw,
title_href => $query_link_url.$QueryString,
titleright => $customize ? loc('Edit') : '',
titleright_href => $customize,
@@ -60,6 +61,7 @@ my $SearchArg;
my $customize;
my $query_display_component = '/Elements/CollectionList';
my $query_link_url = RT->Config->Get('WebPath').'/Search/Results.html';
+my $show_count = 1;
if ($SavedSearch) {
my ( $container_object, $search_id ) = _parse_saved_search($SavedSearch);
@@ -81,6 +83,7 @@ if ($SavedSearch) {
$query_display_component
= '/Search/Elements/' . $SearchArg->{SearchType};
$query_link_url = RT->Config->Get('WebPath') . "/Search/$SearchArg->{SearchType}.html";
+ $ShowCount = 0;
} elsif ($ShowCustomize) {
$customize = RT->Config->Get('WebPath') . '/Search/Build.html?'
. $m->comp( '/Elements/QueryString',
@@ -128,6 +131,19 @@ foreach ( $SearchArg, $ProcessedSearchArg ) {
}
my $QueryString = '?' . $m->comp( '/Elements/QueryString', %$SearchArg );
+
+my $title_raw;
+if ($ShowCount) {
+ my $tickets = RT::Tickets->new( $session{'CurrentUser'} );
+ $tickets->FromSQL($ProcessedSearchArg->{Query});
+ my $count = $tickets->CountAll();
+
+ $title_raw = '<span class="results-count">' . loc('(Found [quant,_1,ticket,tickets])', $count) . '</span>';
+
+ # don't repeat the search in CollectionList
+ $ProcessedSearchArg->{Collection} = $tickets;
+ $ProcessedSearchArg->{TotalFound} = $count;
+}
</%init>
<%ARGS>
$Name => undef
@@ -136,5 +152,6 @@ $SavedSearch => undef
$IgnoreMissing => undef
$hideable => 1
$ShowCustomize => 1
+$ShowCount => RT->Config->Get('ShowSearchResultCount')
$HasResults => undef
</%ARGS>
diff --git a/share/static/css/base/collection.css b/share/static/css/base/collection.css
index d690192..a061999 100644
--- a/share/static/css/base/collection.css
+++ b/share/static/css/base/collection.css
@@ -14,3 +14,13 @@ table.collection td:first-child, table.collection th:first-child {
.collection-as-table .user a:visited {
color: inherit;
}
+
+.results-count {
+ font-size: smaller;
+}
+/* four nbsps. can't use margin- or padding-left since it makes a gap in
+ the <a> tag's underline on hover, and can't use regular spaces since they
+ collapse into one because it's HTML, and can't use because it's CSS */
+.results-count::before {
+ content: '\a0\a0\a0\a0';
+}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list