[Rt-commit] rt branch, 4.4/principals-autocomplete-callbacks, created. rt-4.4.4-507-gc9752bde56
? sunnavy
sunnavy at bestpractical.com
Thu Jun 3 14:08:08 EDT 2021
The branch, 4.4/principals-autocomplete-callbacks has been created
at c9752bde56e64d6d2ded4e8f9e6a649f76c079a8 (commit)
- Log -----------------------------------------------------------------
commit a53753b385995789a880cc14ef28938185672739
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 4 01:35:11 2021 +0800
Pass term and args to ModifyUsersLimit so it can behave differently based on it
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index a41c194ef7..cb2c008340 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -107,7 +107,7 @@ $users->SimpleSearch( Privileged => $privileged,
# the returned field using that operator
$op ? ( Fields => { $return => $op } ) : (),
);
-$m->callback( CallbackName => "ModifyUsersLimit", Users => $users );
+$m->callback( CallbackName => "ModifyUsersLimit", Users => $users, Term => $term, ARGSRef => \%ARGS );
my @suggestions;
while ( my $user = $users->Next ) {
commit 05950dd46639761dde9fb4b1cd79b5815210e5ab
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..24b5bdf1ef 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, Term => $term, ARGSRef => \%ARGS );
my @suggestions;
commit c9752bde56e64d6d2ded4e8f9e6a649f76c079a8
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..b66e98b67d 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, Term => $term, ARGSRef => \%ARGS, CallbackPage => '/Helpers/Autocomplete/Users' );
+$m->callback( CallbackName => "ModifyUsersLimit", Users => $users, Term => $term, ARGSRef => \%ARGS );
(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, Term => $term, ARGSRef => \%ARGS, CallbackPage => '/Helpers/Autocomplete/Groups' );
+$m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups, Term => $term, ARGSRef => \%ARGS );
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