Commit 443ddcdd authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(firewall, alias) hide already used aliases. closes https://github.com/opnsense/core/issues/1042

(cherry picked from commit c52dbf2c)
parent d4ce3797
...@@ -291,6 +291,29 @@ include("head.inc"); ...@@ -291,6 +291,29 @@ include("head.inc");
$(this).parent().parent().remove(); $(this).parent().parent().remove();
} }
} }
/**
* link alias typeahead to input, only return items not already on this form.
*/
function addFieldTypeAhead() {
$(".fld_detail").typeahead({
source: document.all_aliases[$("#typeSelect").val()],
matcher: function(item){
var used = false;
$(".fld_detail").each(function(){
if (item == $(this).val()) {
used = true;
}
});
if (used) {
return false;
} else {
return ~item.toLowerCase().indexOf(this.query)
}
}
});
}
// add new detail record // add new detail record
$("#addNew").click(function(){ $("#addNew").click(function(){
// copy last row and reset values // copy last row and reset values
...@@ -300,7 +323,7 @@ include("head.inc"); ...@@ -300,7 +323,7 @@ include("head.inc");
}); });
$(".act-removerow").click(removeRow); $(".act-removerow").click(removeRow);
// link typeahead to new item // link typeahead to new item
$(".fld_detail").typeahead({ source: document.all_aliases[$("#typeSelect").val()] }); addFieldTypeAhead();
// link geoip list to new item // link geoip list to new item
$(".geoip_list").change(function(){ $(".geoip_list").change(function(){
$(this).parent().find('input').val($(this).val()); $(this).parent().find('input').val($(this).val());
...@@ -364,7 +387,7 @@ include("head.inc"); ...@@ -364,7 +387,7 @@ include("head.inc");
break; break;
} }
$(".fld_detail").typeahead("destroy"); $(".fld_detail").typeahead("destroy");
$(".fld_detail").typeahead({ source: document.all_aliases[$("#typeSelect").val()] }); addFieldTypeAhead();
} }
$("#typeSelect").change(function(){ $("#typeSelect").change(function(){
......
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