Skip to content

Commit

Permalink
Redmine #5994 Standardize source port button
Browse files Browse the repository at this point in the history
in firewall_rules_edit
1) Put some common code fragments into show_source_port_range() and use code that actually successfully changes the button text Display/Hide. Around line 1808.
2) Make the button itself be hidden when a protocol is selected that does not use source port range (as well as the source port fields being hidden) - line 1908-1909
3) When the user re-selects a protocol that can use source port range, unhide the button and set the button text and hide/unhide of source port fields appropriately depending on the run-time values in the source port fields - line 1900-1905

This standardizes the behavior of the source port Advanced button.

I will do the other general advanced button separately.
  • Loading branch information
Phil Davis committed Mar 16, 2016
1 parent a6caf5f commit 770e3f4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/usr/local/www/firewall_rules_edit.php
Expand Up @@ -1363,7 +1363,7 @@ function build_if_list() {
if ($type == 'src') {
$section->addInput(new Form_Button(
'btnsrcadv',
'Show advanced',
'Display Advanced',
null,
'fa-cog'
))->addClass('btn-info');
Expand Down Expand Up @@ -1744,7 +1744,7 @@ function build_if_list() {
var portsenabled = 1;
var editenabled = 1;
var optionsvisible = 0;
var srcportsvisible = 0;
var srcportsvisible = false;

function ext_change() {

Expand Down Expand Up @@ -1805,6 +1805,13 @@ function ext_change() {

function show_source_port_range() {
hideClass('srcprtr', !srcportsvisible);

if (srcportsvisible) {
text = "<?=gettext('Hide Advanced');?>";
} else {
text = "<?=gettext('Display Advanced');?>";
}
$('#btnsrcadv').html('<i class="fa fa-cog"></i> ' + text);
}

function typesel_change() {
Expand Down Expand Up @@ -1890,14 +1897,19 @@ function proto_change() {

if ($('#proto').find(":selected").index() <= 2) {
hideClass('dstprtr', false);
hideClass('srcprtr', !srcportsvisible);
$("#btnsrcadv").prop('value', srcportsvisible ? 'Hide advanced':'Show advanced');
hideInput('btnsrcadv', false);
if (($('#srcbeginport').val() == "any") && ($('#srcendport').val() == "any")) {
srcportsvisible = false;
} else {
srcportsvisible = true;
}
} else {
hideClass('srcprtr', true);
hideClass('dstprtr', true);
srcportsvisible = 0;
$("#btnsrcadv").prop('value', srcportsvisible ? 'Hide advanced':'Show advanced');
hideInput('btnsrcadv', true);
srcportsvisible = false;
}

show_source_port_range();
}

function src_rep_change() {
Expand All @@ -1921,7 +1933,6 @@ function dst_rep_change() {
<?php if ((!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any")): ?>
srcportsvisible = true;
show_source_port_range();
hideInput('btnsrcadv', true);
<?php endif; ?>

// Make it a regular button, not a submit
Expand All @@ -1937,7 +1948,6 @@ function dst_rep_change() {
$('#btnsrcadv').click(function() {
srcportsvisible = !srcportsvisible;
show_source_port_range();
$("#btnsrcadv").prop('value', srcportsvisible ? 'Hide advanced':'Show advanced');
});

$('#srcendport').on('change', function() {
Expand Down

0 comments on commit 770e3f4

Please sign in to comment.