diff --git a/Netdisco/Changes b/Netdisco/Changes index 3620ea35..cf4534da 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -22,6 +22,7 @@ * Don't store failed SNMP community in the database * [#51] Support DBD::Pg default for "host" field as local socket * [#58] Search by VLAN name now works + * Make "Not" option work for vlan number search in Device Ports 2.020002 - 2013-12-11 diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index 1693e624..ccff9d5b 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -21,12 +21,23 @@ get '/ajax/content/device/ports' => require_login sub { my $f = param('f'); if ($f) { if ($f =~ m/^\d+$/) { - $set = $set->search({ - -or => { - 'me.vlan' => $f, - 'port_vlans_tagged.vlan' => $f, - }, - }, { join => 'port_vlans_tagged' }); + if (param('invert')) { + $set = $set->search({ + 'me.vlan' => { '!=' => $f }, + 'port_vlans_tagged.vlan' => [ + '-or' => { '!=' => $f }, { '=' => undef } + ], + }, { join => 'port_vlans_tagged' }); + } + else { + $set = $set->search({ + -or => { + 'me.vlan' => $f, + 'port_vlans_tagged.vlan' => $f, + }, + }, { join => 'port_vlans_tagged' }); + } + return unless $set->count; } else {