Skip to content

Commit

Permalink
Merge branch '5.0/txn-search-remove-duplicate-type-criteria' into 5.0…
Browse files Browse the repository at this point in the history
…-trunk
  • Loading branch information
cbrandtbuffalo committed Nov 20, 2023
2 parents 6809d3f + 863714d commit 892a190
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
15 changes: 10 additions & 5 deletions lib/RT/Interface/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5810,11 +5810,16 @@ sub PreprocessTransactionSearchQuery {

my @limits;
if ( $args{ObjectType} eq 'RT::Ticket' ) {
@limits = (
q{TicketType = 'ticket'},
qq{ObjectType = '$args{ObjectType}'},
$args{Query} =~ /^\s*\(.*\)$/ ? $args{Query} : "($args{Query})"
);
if ( $args{Query} !~ /^TicketType = 'ticket' AND ObjectType = '$args{ObjectType}' AND (.+)/ ) {
@limits = (
q{TicketType = 'ticket'},
qq{ObjectType = '$args{ObjectType}'},
$args{Query} =~ /^\s*\(.*\)$/ ? $args{Query} : "($args{Query})"
);
}
else {
@limits = $args{Query};
}
}
else {
# Other ObjectTypes are not supported for now
Expand Down
3 changes: 2 additions & 1 deletion lib/RT/Interface/Web/QueryBuilder/Tree.pm
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ sub __LinearizeTree {

$str .= $key ." ". $op . " " . $value;
}
$str =~ s/^\s+|\s+$//;
$str =~ s/^\s+//;
$str =~ s/\s+$//;

push @$list, {
NODE => $node,
Expand Down
9 changes: 7 additions & 2 deletions t/web/search_txns.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ diag "Query builder";

$m->follow_link_ok( { id => 'page-results' } );
$m->title_is('Found 3 transactions');
$m->get_ok($m->uri . '&RowsPerPage=1');
$m->follow_link_ok( { text => '2' } );
$m->follow_link_ok( { text => '3' } );

$m->follow_link_ok( { text => 'Edit Search' }, 'Build Query' );
my $form = $m->form_name('BuildQuery');
is($form->find_input('Query')->value, qq{TicketType = 'ticket' AND ObjectType = 'RT::Ticket' AND ( TicketId = 1 )});

$m->back;
$m->form_name('BuildQuery');
$m->field( TypeOp => '=' );
$m->field( ValueOfType => 'Create' );
$m->click('AddClause');
Expand Down

0 comments on commit 892a190

Please sign in to comment.