Partial Match option when searching on device port name

This commit is contained in:
Oliver Gorwits
2013-03-02 15:24:48 +00:00
parent a94b5a913d
commit 26c5014479
4 changed files with 28 additions and 3 deletions

View File

@@ -50,7 +50,7 @@ ajax '/ajax/content/search/node' => sub {
}
else {
if (param('partial')) {
$node = "\%$node\%";
$node = "\%$node\%" if $node !~ m/%/;
}
elsif (setting('domain_suffix')) {
$node .= setting('domain_suffix')

View File

@@ -15,10 +15,17 @@ ajax '/ajax/content/search/port' => sub {
my $set;
if ($q =~ m/^\d+$/) {
$set = schema('netdisco')->resultset('DevicePort')->search({vlan => $q});
$set = schema('netdisco')->resultset('DevicePort')
->search({vlan => $q});
}
else {
$set = schema('netdisco')->resultset('DevicePort')->search({name => $q});
my $query = $q;
if (param('partial')) {
$q = "\%$q\%" if $q !~ m/%/;
$query = { -ilike => $q };
}
$set = schema('netdisco')->resultset('DevicePort')
->search({name => $query});
}
return unless $set->count;