[Rt-commit] rt branch, 4.4/principals-autocomplete-callbacks, created. rt-4.4.4-504-gf3db8aca81
? sunnavy
sunnavy at bestpractical.com
Wed Jun 2 15:57:13 EDT 2021
The branch, 4.4/principals-autocomplete-callbacks has been created
at f3db8aca81a7dd4787d893bab1a4d03e29c07bda (commit)
- Log -----------------------------------------------------------------
commit 7ceb56ed2fcfe3341822632cbc166caf972231c6
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jun 3 02:51:28 2021 +0800
Add ModifyGroupsLimit callback for Groups autocomplete
This is mirrored from Users autocomplete
diff --git a/share/html/Helpers/Autocomplete/Groups b/share/html/Helpers/Autocomplete/Groups
index e991aa5fd9..183e1207ad 100644
--- a/share/html/Helpers/Autocomplete/Groups
+++ b/share/html/Helpers/Autocomplete/Groups
@@ -83,6 +83,7 @@ $groups->Limit(
foreach (split /\s*,\s*/, $exclude) {
$groups->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=', ENTRYAGGREGATOR => 'AND');
}
+$m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups );
my @suggestions;
commit f3db8aca81a7dd4787d893bab1a4d03e29c07bda
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jun 3 02:54:43 2021 +0800
Sync callbacks of Users/Groups autcomplete to Principals
Principals autocomplete is a combination of Users/Groups autcomplete.
As we switched from Users to Principals for role inputs, respecting
existing callbacks helps back compatibility as customized code relying
on them won't need migration.
Here we respect not-confliting ones, including "ModifyUsersLimit",
"ModifyGroupsLimit" and "ModifySuggestion".
The "Initial" callback is not 100% compatible with the one in Users as
it doesn't have "$return" argument, and since it touches request
arguments which affects both users and groups, calling "Initial"
callback in Users here is not quite appropriate.
diff --git a/share/html/Helpers/Autocomplete/Principals b/share/html/Helpers/Autocomplete/Principals
index c018d7ce8c..ded3a982ac 100644
--- a/share/html/Helpers/Autocomplete/Principals
+++ b/share/html/Helpers/Autocomplete/Principals
@@ -58,6 +58,12 @@ $include_nobody => 0
$include_system => 0
</%ARGS>
<%INIT>
+$m->callback(
+ CallbackName => 'Initial',
+ TermRef => \$term,
+ DelimRef => \$delim,
+ ExcludeRef => \$exclude,
+);
$m->abort unless defined $term
and length $term;
@@ -95,6 +101,8 @@ $users->SimpleSearch( Privileged => $privileged,
Max => $max,
Exclude => \@exclude,
);
+$m->callback( CallbackName => "ModifyUsersLimit", Users => $users, CallbackPage => '/Helpers/Autocomplete/Users' );
+$m->callback( CallbackName => "ModifyUsersLimit", Users => $users );
(my $group_term = $term) =~ s/^\s*group\s*:\s*//i;
my $groups = RT::Groups->new( $CurrentUser );
@@ -111,11 +119,19 @@ $groups->Limit(
foreach (@exclude) {
$groups->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=', ENTRYAGGREGATOR => 'AND');
}
+$m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups, CallbackPage => '/Helpers/Autocomplete/Groups' );
+$m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups );
my @suggestions;
while ( my $user = $users->Next ) {
my $suggestion = { id => $user->id, label => $user->Format, value => $user->EmailAddress || $user->Name };
+ $m->callback(
+ CallbackName => "ModifySuggestion",
+ suggestion => $suggestion,
+ user => $user,
+ CallbackPage => '/Helpers/Autocomplete/Users',
+ );
$m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, user => $user );
push @suggestions, $suggestion;
}
@@ -128,6 +144,12 @@ while ( my $group = $groups->Next ) {
my $value = $delim && $label =~ $delim ? 'group:' . $group->id : $label;
my $suggestion = { id => $group->id, label => $label, value => $value };
+ $m->callback(
+ CallbackName => "ModifySuggestion",
+ suggestion => $suggestion,
+ group => $group,
+ CallbackPage => '/Helpers/Autocomplete/Groups',
+ );
$m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, group => $group );
push @suggestions, $suggestion;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list