[Rt-commit] rt branch, 4.4/admin-users-and-groups-search-null, created. rt-4.4.4-64-gd93e09961
? sunnavy
sunnavy at bestpractical.com
Wed Sep 25 09:12:55 EDT 2019
The branch, 4.4/admin-users-and-groups-search-null has been created
at d93e0996175b8ed4e7eb13e63c411dad54dc0764 (commit)
- Log -----------------------------------------------------------------
commit 90b5decd502be2fb41657fb0b432318538fa2889
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Sep 25 20:52:44 2019 +0800
Support to search NULL(unset) values on user/group admin pages
We need to switch operator to "IS" or "IS NOT" for NULL values.
diff --git a/share/html/Admin/Groups/index.html b/share/html/Admin/Groups/index.html
index cef2ac9b9..c7def9688 100644
--- a/share/html/Admin/Groups/index.html
+++ b/share/html/Admin/Groups/index.html
@@ -126,6 +126,15 @@ push @groups, { field => $GroupField3, op => $GroupOp3, string => $GroupString3
if ( scalar @groups ) {
foreach my $group ( @groups ) {
+ if ( $group->{'string'} eq 'NULL' ) {
+ if ( $group->{'op'} =~ /!=|\bNOT\b/i ) {
+ $group->{'op'} = 'IS NOT';
+ }
+ else {
+ $group->{'op'} = 'IS';
+ }
+ }
+
if ( $group->{'field'} =~ /^CustomField-(\d+)/ ) {
$Groups->LimitCustomField(
CUSTOMFIELD => $1,
diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index 958041880..25835324e 100644
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -130,6 +130,15 @@ push @users_queries, { field => $UserField3, op => $UserOp3, string => $UserStri
if ( scalar @users_queries ) {
foreach my $user ( @users_queries ) {
+ if ( $user->{'string'} eq 'NULL' ) {
+ if ( $user->{'op'} =~ /!=|\bNOT\b/i ) {
+ $user->{'op'} = 'IS NOT';
+ }
+ else {
+ $user->{'op'} = 'IS';
+ }
+ }
+
if ( $user->{'field'} =~ /^CustomField-(\d+)/ ) {
$users->LimitCustomField(
CUSTOMFIELD => $1,
commit d93e0996175b8ed4e7eb13e63c411dad54dc0764
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Sep 25 20:57:35 2019 +0800
Tests NULL value searches on user/group admin pages
diff --git a/t/web/admin_groups.t b/t/web/admin_groups.t
index 4abd17f2c..cb2d9e25b 100644
--- a/t/web/admin_groups.t
+++ b/t/web/admin_groups.t
@@ -132,6 +132,25 @@ ok( $m->login(), 'logged in' );
$m->content_contains( $groups[2]->Name );
$m->content_lacks( $groups[0]->Name );
$m->content_lacks( $groups[3]->Name );
+
+ diag 'Test NULL value searches';
+ ok( $m->form_name( 'GroupsAdmin' ), 'found the filter admin groups form');
+ $m->select( GroupField => 'Name', GroupOp => 'LIKE' );
+ $m->field( GroupString => 'Group' );
+ $m->select( GroupField2 => 'CustomField: '.$cf_2->Name, GroupOp2 => 'is' );
+ $m->field( GroupString2 => 'NULL' );
+ $m->field( GroupString3 => '' );
+ $m->click( 'Go' );
+ $m->text_lacks( $_->Name ) for @groups[1..2];
+ $m->text_contains( $_->Name ) for @groups[0,3];
+
+ ok( $groups[0]->SetDescription('group1') );
+ $m->form_name( 'GroupsAdmin' );
+ $m->select( GroupField2 => 'Description', GroupOp2 => 'is' );
+ $m->field( GroupString2 => 'NULL' );
+ $m->click( 'Go' );
+ $m->text_lacks( $_->Name ) for $groups[0];
+ $m->text_contains( $_->Name ) for @groups[1..3];
}
diff --git a/t/web/admin_user.t b/t/web/admin_user.t
index ffc287e7a..552543e6e 100644
--- a/t/web/admin_user.t
+++ b/t/web/admin_user.t
@@ -132,6 +132,23 @@ $m->content_contains( $users[2]->Name );
$m->content_lacks( $users[0]->Name );
$m->content_lacks( $users[3]->Name );
+diag 'Test NULL value searches';
+$m->form_name( 'UsersAdmin' );
+$m->select( UserField2 => 'CustomField: '.$cf_2->Name, UserOp2 => 'is' );
+$m->field( UserString2 => 'NULL' );
+$m->field( UserString3 => '' );
+$m->click( 'Go' );
+$m->text_lacks( $_->Name ) for @users[1..2];
+$m->text_contains( $_->Name ) for @users[0,3];
+
+ok( $users[0]->SetRealName('user1') );
+$m->form_name( 'UsersAdmin' );
+$m->select( UserField2 => 'Real Name', UserOp2 => 'is' );
+$m->field( UserString2 => 'NULL' );
+$m->click( 'Go' );
+$m->text_lacks( $_->Name ) for $users[0];
+$m->text_contains( $_->Name ) for @users[1..3];
+
# TODO more /Admin/Users tests
done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list