Commit 0a500666 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

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

(cherry picked from commit e660269e)
(cherry picked from commit d5ceec2a)
parent b9c53035
...@@ -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>
......
...@@ -478,9 +478,7 @@ function display_top_tabs(& $tab_array, $no_drop_down = false) ...@@ -478,9 +478,7 @@ function display_top_tabs(& $tab_array, $no_drop_down = false)
} else { } else {
$selected = ""; $selected = "";
} }
// Onclick in option will not work in some browser echo "<option class=\"top_tab\" value=\"{$ta[2]}\"{$selected}>{$ta['0']}</option>\n";
// echo "<option onclick=\"document.location='{$ta[2]}';\"{$selected}>{$ta['0']}</option>\n";
echo "<option value=\"{$ta[2]}\"{$selected}>{$ta['0']}</option>\n";
} }
echo "</select>\n<p>&nbsp;</p>"; echo "</select>\n<p>&nbsp;</p>";
echo "<script type=\"text/javascript\">"; echo "<script type=\"text/javascript\">";
...@@ -494,9 +492,9 @@ function display_top_tabs(& $tab_array, $no_drop_down = false) ...@@ -494,9 +492,9 @@ function display_top_tabs(& $tab_array, $no_drop_down = false)
$tabscounter = 0; $tabscounter = 0;
foreach ($tab_array as $ta) { foreach ($tab_array as $ta) {
if ($ta[1] == true) { if ($ta[1] == true) {
echo " <li class=\"active\"><a href=\"{$ta[2]}\" role=\"tab\">{$ta[0]}</a></li>\n"; echo " <li class=\"active\"><a class=\"top_tab\" href=\"{$ta[2]}\" role=\"tab\">{$ta[0]}</a></li>\n";
} else { } else {
echo " <li><a href=\"{$ta[2]}\" role=\"tab\">{$ta[0]}</a></li>\n"; echo " <li><a class=\"top_tab\" href=\"{$ta[2]}\" role=\"tab\">{$ta[0]}</a></li>\n";
} }
$tabscounter++; $tabscounter++;
} }
......
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