From a4eef0c7caa4b8dbfdc37b2d5310a2fb7b23714e Mon Sep 17 00:00:00 2001 From: Stephen Beaver Date: Thu, 28 Jan 2016 12:49:28 -0500 Subject: [PATCH] Adjest separators on rule move or delete --- src/usr/local/www/firewall_rules.php | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/usr/local/www/firewall_rules.php b/src/usr/local/www/firewall_rules.php index 4e1304af96..0e3db1ddec 100644 --- a/src/usr/local/www/firewall_rules.php +++ b/src/usr/local/www/firewall_rules.php @@ -220,6 +220,17 @@ if ($_GET['act'] == "del") { delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']); } unset($a_filter[$_GET['id']]); + + // Update the separators + $a_separators = &$config['filter']['separator'][$if]; + + for ($idx=0; isset($a_separators['sep' . $idx]); $idx++ ) { + $seprow = substr($a_separators['sep' . $idx]['row']['0'], 2); + if ($seprow >= $_GET['id']) { + $a_separators['sep' . $idx]['row']['0'] = 'fr' . ($seprow - 1); + } + } + if (write_config()) { mark_subsystem_dirty('filter'); } @@ -239,10 +250,20 @@ if (isset($_POST['del_x'])) { $deleted = false; if (is_array($_POST['rule']) && count($_POST['rule'])) { + $a_separators = &$config['filter']['separator'][$if]; + foreach ($_POST['rule'] as $rulei) { delete_nat_association($a_filter[$rulei]['associated-rule-id']); unset($a_filter[$rulei]); $deleted = true; + + // Update the separators + for ($idx=0; isset($a_separators['sep' . $idx]); $idx++ ) { + $seprow = substr($a_separators['sep' . $idx]['row']['0'], 2); + if ($seprow >= $rulei) { + $a_separators['sep' . $idx]['row']['0'] = 'fr' . ($seprow - 1); + } + } } if ($deleted) { @@ -861,6 +882,7 @@ events.push(function() { cursor: 'grabbing', update: function(event, ui) { $('#order-store').removeAttr('disabled'); + reindex_rules(ui.item.parent('tbody'), ui.item.index); dirty = true; } }); @@ -991,6 +1013,18 @@ events.push(function() { }); } + function reindex_rules(section, startingat) { + var row = 0; + + section.find('tr').each(function() { + if(this.id) { +// $(this).attr("id", bumpStringInt($(this).attr("id"))); + $(this).attr("id", "fr" + row); + row++; + } + }) + } + function handle_colors() { $('[id^=sepclr]').prop("type", "button");