X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FHelpers%2FAutocomplete%2FGroups;h=20d0cabb86fae49b05555eb1be3ec0b0ec1b81dc;hb=44dd00a3ff974a17999e86e64488e996edc71e3c;hp=e8baf5397abb2272b6946c92ff6cb7bf98fa43b1;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7;p=freeside.git diff --git a/rt/share/html/Helpers/Autocomplete/Groups b/rt/share/html/Helpers/Autocomplete/Groups index e8baf5397..20d0cabb8 100644 --- a/rt/share/html/Helpers/Autocomplete/Groups +++ b/rt/share/html/Helpers/Autocomplete/Groups @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -45,12 +45,12 @@ %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} -% $r->content_type('application/json'); +% $r->content_type('application/json; charset=utf-8'); <% JSON( \@suggestions ) |n %> % $m->abort; <%ARGS> $term => undef -$max => 10 +$max => undef $exclude => '' $op => 'LIKE' @@ -66,6 +66,9 @@ $m->abort unless $CurrentUser->Privileged; # Sanity check the operator $op = 'LIKE' unless $op =~ /^(?:LIKE|(?:START|END)SWITH|=|!=)$/i; +$m->callback( CallbackName => 'ModifyMaxResults', max => \$max ); +$max //= 10; + my $groups = RT::Groups->new( $CurrentUser ); $groups->RowsPerPage( $max ); $groups->LimitToUserDefinedGroups(); @@ -73,16 +76,19 @@ $groups->Limit( FIELD => 'Name', OPERATOR => $op, VALUE => $term, + CASESENSITIVE => 0, ); # Exclude groups we don't want foreach (split /\s*,\s*/, $exclude) { - $groups->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!='); + $groups->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=', ENTRYAGGREGATOR => 'AND'); } my @suggestions; while ( my $group = $groups->Next ) { - push @suggestions, $group->Name; + my $suggestion = { id => $group->Id, label => $group->Name, value => $group->Name }; + $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, group => $group ); + push @suggestions, $suggestion; }