Просмотр исходного кода

Merge pull request #4022 from hSaria/4010-interface-ip-filter

Fixes #4010: Fixes IP addresses table when filtering interfaces
Jeremy Stretch 6 лет назад
Родитель
Сommit
12cf69f7e1
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      netbox/project-static/js/interface_toggles.js

+ 9 - 4
netbox/project-static/js/interface_toggles.js

@@ -2,9 +2,9 @@
 $('button.toggle-ips').click(function() {
 $('button.toggle-ips').click(function() {
     var selected = $(this).attr('selected');
     var selected = $(this).attr('selected');
     if (selected) {
     if (selected) {
-        $('#interfaces_table tr.ipaddresses').hide();
+        $('#interfaces_table tr.interface:visible + tr.ipaddresses').hide();
     } else {
     } else {
-        $('#interfaces_table tr.ipaddresses').show();
+        $('#interfaces_table tr.interface:visible + tr.ipaddresses').show();
     }
     }
     $(this).attr('selected', !selected);
     $(this).attr('selected', !selected);
     $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
     $(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
@@ -14,17 +14,22 @@ $('button.toggle-ips').click(function() {
 // Inteface filtering
 // Inteface filtering
 $('input.interface-filter').on('input', function() {
 $('input.interface-filter').on('input', function() {
     var filter = new RegExp(this.value);
     var filter = new RegExp(this.value);
+    var interface;
 
 
-    for (interface of $(this).closest('div.panel').find('tbody > tr')) {
+    for (interface of $('#interfaces_table > tbody > tr.interface')) {
         // Slice off 'interface_' at the start of the ID
         // Slice off 'interface_' at the start of the ID
-        if (filter && filter.test(interface.id.slice(10))) {
+        if (filter.test(interface.id.slice(10))) {
             // Match the toggle in case the filter now matches the interface
             // Match the toggle in case the filter now matches the interface
             $(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
             $(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
             $(interface).show();
             $(interface).show();
+            if ($('button.toggle-ips').attr('selected')) {
+                $(interface).next('tr.ipaddresses').show();
+            }
         } else {
         } else {
             // Uncheck to prevent actions from including it when it doesn't match
             // Uncheck to prevent actions from including it when it doesn't match
             $(interface).find('input:checkbox[name=pk]').prop('checked', false);
             $(interface).find('input:checkbox[name=pk]').prop('checked', false);
             $(interface).hide();
             $(interface).hide();
+            $(interface).next('tr.ipaddresses').hide();
         }
         }
     }
     }
 });
 });