Skip to content

Commit

Permalink
Avoid duplicates of TicketType/ObjectType criteria for txn searches
Browse files Browse the repository at this point in the history
The duplicates could happen when you navigate pages on txn search result
page.
  • Loading branch information
sunnavy committed Nov 16, 2023
1 parent 16991a0 commit 2be1b0f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 10 additions & 5 deletions lib/RT/Interface/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5806,11 +5806,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
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 2be1b0f

Please sign in to comment.