[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.1-208-g1b59dd9
Shawn Moore
shawn at bestpractical.com
Wed Dec 28 13:19:45 EST 2016
The branch, 4.4-trunk has been updated
via 1b59dd9256c2f6264474251f1b542d25f7540832 (commit)
via 31217e45f2182c09f1bc6a4005ebfe11fdf2a2d3 (commit)
via 36876a3c49d045643188ac70a46da5d1c1128ef1 (commit)
via 49cb4d029f4a2c7c646fa07c41a0ff04dfb7fedf (commit)
via 8d0e8cf80f7047718f5f55cda7baf6a06b5152be (commit)
from d990b5de87e3db9c7fdb31794460b0b63dea3f5a (commit)
Summary of changes:
lib/RT/Tickets.pm | 53 +++++++++++++++++++++++++++++++++--
share/html/Search/Elements/PickBasics | 47 +++++++++++++++++++++++++++++--
t/ticket/search.t | 14 +++++++++
t/ticket/search_by_queue.t | 14 ++++++++-
t/web/cf_access.t | 1 +
t/web/query_builder_queue_limits.t | 4 +--
6 files changed, 126 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit 8d0e8cf80f7047718f5f55cda7baf6a06b5152be
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Dec 23 11:37:45 2016 -0500
Support LIKE and NOT LIKE searches on queue
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index a86f947..4ba3b98 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -104,7 +104,7 @@ __PACKAGE__->RegisterCustomFieldJoin(@$_) for
our %FIELD_METADATA = (
Status => [ 'STRING', ], #loc_left_pair
- Queue => [ 'ENUM' => 'Queue', ], #loc_left_pair
+ Queue => [ 'QUEUE' ], #loc_left_pair
Type => [ 'ENUM', ], #loc_left_pair
Creator => [ 'ENUM' => 'User', ], #loc_left_pair
LastUpdatedBy => [ 'ENUM' => 'User', ], #loc_left_pair
@@ -184,6 +184,7 @@ our %dispatch = (
LINK => \&_LinkLimit,
DATE => \&_DateLimit,
STRING => \&_StringLimit,
+ QUEUE => \&_QueueLimit,
TRANSFIELD => \&_TransLimit,
TRANSCONTENT => \&_TransContentLimit,
TRANSDATE => \&_TransDateLimit,
@@ -218,6 +219,12 @@ my %DefaultEA = (
'LIKE' => 'AND',
'NOT LIKE' => 'AND'
},
+ QUEUE => {
+ '=' => 'OR',
+ '!=' => 'AND',
+ 'LIKE' => 'OR',
+ 'NOT LIKE' => 'AND'
+ },
TRANSFIELD => 'AND',
TRANSDATE => 'AND',
LINK => 'OR',
@@ -706,6 +713,48 @@ sub _StringLimit {
);
}
+=head2 _QueueLimit
+
+Handle Queue field supporting both "is" and "match".
+
+Input should be a queue name or a partial string.
+
+=cut
+
+sub _QueueLimit {
+ my ($sb, $field, $op, $value, @rest ) = @_;
+
+ if ($op eq 'LIKE' || $op eq 'NOT LIKE') {
+ my $alias = $sb->{_sql_aliases}{queues} ||= $sb->Join(
+ ALIAS1 => 'main',
+ FIELD1 => 'Queue',
+ TABLE2 => 'Queues',
+ FIELD2 => 'id',
+ );
+
+ return $sb->Limit(
+ ALIAS => $alias,
+ FIELD => 'Name',
+ OPERATOR => $op,
+ VALUE => $value,
+ CASESENSITIVE => 0,
+ @rest,
+ );
+
+ }
+
+ my $o = RT::Queue->new( $sb->CurrentUser );
+ $o->Load($value);
+ $value = $o->Id || 0;
+ $sb->Limit(
+ FIELD => $field,
+ OPERATOR => $op,
+ VALUE => $value,
+ CASESENSITIVE => 0,
+ @rest,
+ );
+}
+
=head2 _TransDateLimit
Handle fields limiting based on Transaction Date.
@@ -1289,7 +1338,7 @@ sub OrderByCols {
next;
}
- if ( $meta->[0] eq 'ENUM' && ($meta->[1]||'') eq 'Queue' ) {
+ if ( $meta->[0] eq 'QUEUE' ) {
my $alias = $self->Join(
TYPE => 'LEFT',
ALIAS1 => 'main',
commit 49cb4d029f4a2c7c646fa07c41a0ff04dfb7fedf
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Dec 23 11:46:30 2016 -0500
Add matches and doesn't match options to query builder for queue
The additional javascript also toggles between a dropdown with
available queues for is/isn't and a text box for matches
and doesn't match.
diff --git a/share/html/Search/Elements/PickBasics b/share/html/Search/Elements/PickBasics
index 4a794b1..ab08bec 100644
--- a/share/html/Search/Elements/PickBasics
+++ b/share/html/Search/Elements/PickBasics
@@ -83,8 +83,8 @@ my @lines = (
Field => loc('Queue'),
Op => {
Type => 'component',
- Path => '/Elements/SelectBoolean',
- Arguments => { TrueVal=> '=', FalseVal => '!=' },
+ Path => '/Elements/SelectMatch',
+ Arguments => { Default => '=' },
},
Value => {
Type => 'component',
@@ -226,6 +226,49 @@ my @lines = (
$m->callback( Conditions => \@lines );
</%INIT>
+
+<script type="text/javascript">
+ jQuery(function() {
+
+ // move the actual value to a hidden value, and shadow the others
+ var hidden = jQuery('<input>').attr('type','hidden').attr('name','ValueOfQueue');
+
+ // change the selector's name, but preserve the values, we'll set value via js
+ var selector = jQuery("[name='ValueOfQueue']");
+
+ // rename the selector so we don't get an extra term in the query
+ selector[0].name = "";
+ selector.bind('change',function() {
+ hidden[0].value = selector[0].value;
+ });
+
+ // create a text input box and hide it for use with matches / doesn't match
+ // NB: if you give text a name it will add an additional term to the query!
+ var text = jQuery('<input>').attr('type','text');
+ text.hide();
+ text.bind('change',function() {
+ hidden[0].value = text[0].value;
+ });
+
+ // hook the op field so that we can swap between the two input types
+ var op = jQuery("[name='QueueOp']");
+ op.bind('change',function() {
+ if (op[0].value == "=" || op[0].value == "!=" ) {
+ text.hide();
+ selector.show();
+ hidden[0].value = selector[0].value;
+ } else {
+ text.show();
+ selector.hide();
+ hidden[0].value = text[0].value;
+ }
+ });
+
+ // add the fields to the DOM
+ selector.before(hidden);
+ selector.after(text);
+ });
+</script>
<%ARGS>
%queues => ()
</%ARGS>
commit 36876a3c49d045643188ac70a46da5d1c1128ef1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Dec 23 11:55:59 2016 -0500
Add QueueOp in tests to handle LIKE/NOT LIKE changes
diff --git a/t/web/cf_access.t b/t/web/cf_access.t
index 48ab5a2..059493e 100644
--- a/t/web/cf_access.t
+++ b/t/web/cf_access.t
@@ -223,6 +223,7 @@ $m->submit_form(
idOp => '=',
ValueOfid => $tid,
ValueOfQueue => 'General',
+ QueueOp => '=',
},
button => 'AddClause',
);
diff --git a/t/web/query_builder_queue_limits.t b/t/web/query_builder_queue_limits.t
index 6bbf333..c1f0a72 100644
--- a/t/web/query_builder_queue_limits.t
+++ b/t/web/query_builder_queue_limits.t
@@ -89,7 +89,7 @@ is_deeply(
diag "limit queue to foo";
$m->submit_form(
- fields => { ValueOfQueue => 'foo' },
+ fields => { ValueOfQueue => 'foo', QueueOp => '=' },
button => 'AddClause',
);
@@ -114,7 +114,7 @@ is_deeply(
diag "limit queue to general too";
$m->submit_form(
- fields => { ValueOfQueue => 'General' },
+ fields => { ValueOfQueue => 'General', QueueOp => '=' },
button => 'AddClause',
);
commit 31217e45f2182c09f1bc6a4005ebfe11fdf2a2d3
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Dec 23 13:53:36 2016 -0500
Add new queue LIKE and NOT LIKE tests
diff --git a/t/ticket/search.t b/t/ticket/search.t
index a43433f..dad94a1 100644
--- a/t/ticket/search.t
+++ b/t/ticket/search.t
@@ -150,11 +150,21 @@ is($tix->Count, 1, "matched identical subject")
or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("Queue LIKE '$queue' AND CF.SearchTest = 'foo1'");
+is($tix->Count, 1, "matched identical subject and LIKE Queue")
+ or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
+
+$tix = RT::Tickets->new(RT->SystemUser);
$tix->FromSQL("Queue = '$queue' AND CF.SearchTest LIKE 'foo1'");
is($tix->Count, 1, "matched LIKE subject")
or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("Queue LIKE '$queue' AND CF.SearchTest LIKE 'foo1'");
+is($tix->Count, 1, "matched LIKE queue and LIKE subject")
+ or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
+
+$tix = RT::Tickets->new(RT->SystemUser);
$tix->FromSQL("Queue = '$queue' AND CF.SearchTest = 'foo'");
is($tix->Count, 0, "IS a regexp match")
or diag "wrong results from SQL:\n". $tix->BuildSelectCountQuery;
@@ -272,6 +282,10 @@ $tix->FromSQL("(CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3') AND (CF.Search
is($tix->Count, 1, "(is cf1 or is cf1) and (is cf2 or is cf2)");
$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("(Queue LIKE '$queue') AND (CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3') AND (CF.SearchTest2 = 'bar1' OR CF.SearchTest2 = 'bar2')");
+is($tix->Count, 1, "(queue LIKE) and (is cf1 or is cf1) and (is cf2 or is cf2)");
+
+$tix = RT::Tickets->new(RT->SystemUser);
$tix->FromSQL("CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3' OR CF.SearchTest2 = 'bar1' OR CF.SearchTest2 = 'bar2'");
is($tix->Count, 3, "is cf1 or is cf1 or is cf2 or is cf2");
diff --git a/t/ticket/search_by_queue.t b/t/ticket/search_by_queue.t
index 0327152..d33042a 100644
--- a/t/ticket/search_by_queue.t
+++ b/t/ticket/search_by_queue.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use RT::Test nodata => 1, tests => 34;
+use RT::Test nodata => 1, tests => undef;
use RT::Ticket;
my $qa = RT::Test->load_or_create_queue( Name => 'Queue A' );
@@ -31,8 +31,20 @@ run_tests( \@tickets,
'Queue = "Bad Queue"' => { a1 => 0, a2 => 0, b1 => 0, b2 => 0 },
'Queue != "Bad Queue"' => { a1 => 1, a2 => 1, b1 => 1, b2 => 1 },
+
+ 'Queue LIKE "Queue A"' => { a1 => 1, a2 => 1, b1 => 0, b2 => 0 },
+ 'Queue LIKE "Queue B"' => { a1 => 0, a2 => 0, b1 => 1, b2 => 1 },
+ 'Queue LIKE "Bad Queue"' => { a1 => 0, a2 => 0, b1 => 0, b2 => 0 },
+ 'Queue LIKE "Queue"' => { a1 => 1, a2 => 1, b1 => 1, b2 => 1 },
+
+ 'Queue NOT LIKE "Queue B"' => { a1 => 1, a2 => 1, b1 => 0, b2 => 0 },
+ 'Queue NOT LIKE "Queue A"' => { a1 => 0, a2 => 0, b1 => 1, b2 => 1 },
+ 'Queue NOT LIKE "Bad Queue"' => { a1 => 1, a2 => 1, b1 => 1, b2 => 1 },
+ 'Queue NOT LIKE "Queue"' => { a1 => 0, a2 => 0, b1 => 0, b2 => 0 },
);
+done_testing;
+
sub run_tests {
my @tickets = @{ shift() };
my %test = @_;
commit 1b59dd9256c2f6264474251f1b542d25f7540832
Merge: d990b5d 31217e4
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Dec 28 18:18:38 2016 +0000
Merge branch '4.4-on-4.2/queue-like-search' into 4.4-trunk
diff --cc lib/RT/Tickets.pm
index 0207329,4ba3b98..590fe86
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@@ -105,8 -104,7 +105,8 @@@ __PACKAGE__->RegisterCustomFieldJoin(@$
our %FIELD_METADATA = (
Status => [ 'STRING', ], #loc_left_pair
+ SLA => [ 'STRING', ], #loc_left_pair
- Queue => [ 'ENUM' => 'Queue', ], #loc_left_pair
+ Queue => [ 'QUEUE' ], #loc_left_pair
Type => [ 'ENUM', ], #loc_left_pair
Creator => [ 'ENUM' => 'User', ], #loc_left_pair
LastUpdatedBy => [ 'ENUM' => 'User', ], #loc_left_pair
-----------------------------------------------------------------------
More information about the rt-commit
mailing list