From d5ceec2a4da2ae364abb3ffab0f423212bc492bd Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 6 Jun 2017 21:02:05 +0200 Subject: [PATCH] firewall_rules, keep category selection when changing tabs. closes https://github.com/opnsense/core/issues/1592 --- src/www/firewall_rules.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/www/firewall_rules.php b/src/www/firewall_rules.php index 07c73f7d3..c70a73d30 100644 --- a/src/www/firewall_rules.php +++ b/src/www/firewall_rules.php @@ -126,6 +126,11 @@ if (isset($_GET['if'])) { } else { $selected_if = "FloatingRules"; } +if (isset($_GET['category'])) { + $selected_category = !is_array($_GET['category']) ? array($_GET['category']) : $_GET['category']; +} else { + $selected_category = array(); +} include("head.inc"); @@ -233,7 +238,29 @@ $( document ).ready(function() { $(this).css("background-color", $("#fw_category").data('stripe_color')); } }); + + // hook into tab changes, keep selected category/categories when following link + $(".top_tab").each(function(){ + var add_link = ""; + if (selected_values.length > 0) { + add_link = "&" + $.param({'category': selected_values}); + } + if ($(this).is('A')) { + if ($(this).data('link') == undefined) { + // move link to data tag + $(this).data('link', $(this).attr('href')); + } + $(this).attr('href', $(this).data('link') + add_link); + } else if ($(this).is('OPTION')) { + if ($(this).data('link') == undefined) { + // move link to data tag + $(this).data('link', $(this).val()); + } + $(this).val($(this).data('link') + add_link); + } + }); }); + $("#fw_category").change(); // hide category search when not used if ($("#fw_category > option").length == 0) { @@ -650,7 +677,7 @@ $( document ).ready(function() { } } foreach ($categories as $category):?> - +