[Rt-commit] rt branch, owner-autocomplete, updated. rt-3.8.8-489-g87bb32c

Thomas Sibley trs at bestpractical.com
Thu Aug 19 20:42:31 EDT 2010


The branch, owner-autocomplete has been updated
       via  87bb32ce0138a1b88cd8257b83337da092f5703c (commit)
      from  ed9e5bdab1c74575fd92eeaa849214b7fcec407f (commit)

Summary of changes:
 share/html/Helpers/Autocomplete/Owners |    6 ++++++
 share/html/Helpers/Autocomplete/Users  |    2 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit 87bb32ce0138a1b88cd8257b83337da092f5703c
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Aug 19 20:44:03 2010 -0400

    Implement a maximum number of autocomplete results returned
    
    By default this is 10, but we can specify it as a query param when
    autocompleting.

diff --git a/share/html/Helpers/Autocomplete/Owners b/share/html/Helpers/Autocomplete/Owners
index 94a942d..84c64ab 100644
--- a/share/html/Helpers/Autocomplete/Owners
+++ b/share/html/Helpers/Autocomplete/Owners
@@ -52,6 +52,7 @@
 $return => 'Name'
 $limit => undef
 $term => undef
+$max => 10
 </%ARGS>
 <%INIT>
 require JSON;
@@ -88,6 +89,7 @@ foreach my $spec (map { [split /\-/, $_, 2] } split /\|/, $limit) {
     }
 
     my $Users = RT::Users->new( $session{CurrentUser} );
+    $Users->RowsPerPage( $max );
 
     # Limit by our autocomplete term BEFORE we limit to OwnTicket because that
     # does a funky union hack
@@ -127,12 +129,16 @@ my @users = sort { lc $a->[1] cmp lc $b->[1] }
                  values %user_uniq_hash;
 
 my @suggestions;
+my $count = 1;
+
 for my $tuple ( @users ) {
+    last if $count > $max;
     my $formatted = $tuple->[1];
     $formatted =~ s/\n//g;
     push @suggestions, {
         label => $formatted,
         value => $tuple->[0]->$return
     };
+    $count++;
 }
 </%INIT>
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index bc11c5d..bbf1f00 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -52,6 +52,7 @@
 $return => ''
 $term => undef
 $delim => undef
+$max => 10
 </%ARGS>
 <%INIT>
 require JSON;
@@ -86,6 +87,7 @@ my @fields = @{ RT->Config->Get('UserAutocompleteFields')
                 || [qw(EmailAddress Name RealName)] };
 
 my $users = RT::Users->new( $CurrentUser );
+$users->RowsPerPage( $max );
 
 for (@fields) {
     $users->Limit(

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


More information about the Rt-commit mailing list