Commit d5ceec2a authored by Ad Schellevis's avatar Ad Schellevis

firewall_rules, keep category selection when changing tabs. closes...

firewall_rules, keep category selection when changing tabs. closes https://github.com/opnsense/core/issues/1592
parent e660269e
...@@ -126,6 +126,11 @@ if (isset($_GET['if'])) { ...@@ -126,6 +126,11 @@ if (isset($_GET['if'])) {
} else { } else {
$selected_if = "FloatingRules"; $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"); include("head.inc");
...@@ -233,7 +238,29 @@ $( document ).ready(function() { ...@@ -233,7 +238,29 @@ $( document ).ready(function() {
$(this).css("background-color", $("#fw_category").data('stripe_color')); $(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 // hide category search when not used
if ($("#fw_category > option").length == 0) { if ($("#fw_category > option").length == 0) {
...@@ -650,7 +677,7 @@ $( document ).ready(function() { ...@@ -650,7 +677,7 @@ $( document ).ready(function() {
} }
} }
foreach ($categories as $category):?> foreach ($categories as $category):?>
<option value="<?=$category;?>"><?=$category;?></option> <option value="<?=$category;?>" <?=in_array($category, $selected_category) ? "selected=\"selected\"" : "" ;?>><?=$category;?></option>
<?php <?php
endforeach;?> endforeach;?>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment