X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FHelpers%2FAutocomplete%2FGroups;h=720efc7d5aec6b238eee600393d08a6c87a44708;hp=e8baf5397abb2272b6946c92ff6cb7bf98fa43b1;hb=187086c479a09629b7d180eec513fb7657f4e291;hpb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500 diff --git a/rt/share/html/Helpers/Autocomplete/Groups b/rt/share/html/Helpers/Autocomplete/Groups index e8baf5397..720efc7d5 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-2018 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; }