Commit b9067fe7 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) reimplement alias nesting. closes https://github.com/opnsense/core/issues/372

(cherry picked from commit d714d27c)
parent 9fdfae84
...@@ -264,6 +264,8 @@ include("head.inc"); ...@@ -264,6 +264,8 @@ include("head.inc");
$(this).val(""); $(this).val("");
}); });
$(".act-removerow").click(removeRow); $(".act-removerow").click(removeRow);
// link typeahead to new item
$(".fld_detail").typeahead({ source: document.all_aliases[$("#typeSelect").val()] });
}); });
$(".act-removerow").click(removeRow); $(".act-removerow").click(removeRow);
...@@ -304,16 +306,39 @@ include("head.inc"); ...@@ -304,16 +306,39 @@ include("head.inc");
$("#detailsHeading1").html("<?=gettext("Port(s)");?>"); $("#detailsHeading1").html("<?=gettext("Port(s)");?>");
break; break;
} }
$(".fld_detail").typeahead("destroy");
$(".fld_detail").typeahead({ source: document.all_aliases[$("#typeSelect").val()] });
} }
$("#typeSelect").change(function(){ $("#typeSelect").change(function(){
toggleType(); toggleType();
}); });
// collect all known aliases per type
document.all_aliases = {};
$("#aliases > option").each(function(){
if (document.all_aliases[$(this).data('type')] == undefined) {
document.all_aliases[$(this).data('type')] = [];
}
document.all_aliases[$(this).data('type')].push($(this).val())
});
toggleType(); toggleType();
}); });
</script> </script>
<!-- push all available (nestable) aliases in a hidden select box -->
<select class="hidden" id="aliases">
<?php
if (!empty($config['aliases']['alias'])):
foreach ($config['aliases']['alias'] as $alias):
if ($alias['type'] == 'network' || $alias['type'] == 'host' || $alias['type'] == 'port'):?>
<option data-type="<?=$alias['type'];?>" value="<?=$alias['name'];?>"></option>
<?php
endif;
endforeach;
endif;
?>
</option>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
...@@ -421,15 +446,15 @@ include("head.inc"); ...@@ -421,15 +446,15 @@ include("head.inc");
<div style="cursor:pointer;" class="act-removerow btn btn-default btn-xs" alt="remove"><span class="glyphicon glyphicon-minus"></span></div> <div style="cursor:pointer;" class="act-removerow btn btn-default btn-xs" alt="remove"><span class="glyphicon glyphicon-minus"></span></div>
</td> </td>
<td> <td>
<input type="text" class="form-control" name="host_url[]" value="<?=$address;?>"/> <input type="text" class="fld_detail" name="host_url[]" value="<?=$address;?>"/>
</td> </td>
<td> <td>
<input type="text" class="form-control" name="detail[]" value="<?= isset($detail_desc[$addressid])?$detail_desc[$addressid]:"";?>"?> <input type="text" name="detail[]" value="<?= isset($detail_desc[$addressid])?$detail_desc[$addressid]:"";?>"?>
</td> </td>
<td> <td>
<?php if ($addressid ==0): <?php if ($addressid ==0):
?> ?>
<input type="text" class="form-control input-sm" id="updatefreq" name="updatefreq" value="<?=$pconfig['updatefreq'];?>" > <input type="text" class="input-sm" id="updatefreq" name="updatefreq" value="<?=$pconfig['updatefreq'];?>" >
<?php endif; <?php endif;
?> ?>
</td> </td>
......
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