|
@@ -1,5 +1,13 @@
|
|
|
{% extends "@SonataAdmin/CRUD/edit.html.twig" %}
|
|
|
|
|
|
+{% block stylesheets %}
|
|
|
+
|
|
|
+{{ parent() }}
|
|
|
+
|
|
|
+{% include "HostBundle::dhcp_options_style.html.twig" %}
|
|
|
+
|
|
|
+{% endblock stylesheets %}
|
|
|
+
|
|
|
{% block javascripts %}
|
|
|
|
|
|
{{ parent() }}
|
|
@@ -13,15 +21,15 @@ $(document).ready(function() {
|
|
|
{% if object.getFixedAddress() is not null or object.getFixedAddress() != "" %}
|
|
|
$fixedIP = "{{object.getFixedAddress()}}";
|
|
|
{% endif %}
|
|
|
-
|
|
|
+
|
|
|
{% if object.getHostType() is not null %}
|
|
|
$initHostTypeId = {{object.getHostType().getId()}};
|
|
|
{% endif %}
|
|
|
-
|
|
|
+
|
|
|
showHostField();
|
|
|
|
|
|
$("select[id$='hostType']").on('change', showHostField);
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
|
|
|
// Al seleccionar tipo Cablemodem oculto el campo Host
|
|
@@ -32,13 +40,13 @@ function showHostField()
|
|
|
var $hostTypeField = $("select[id$='hostType'] :selected");
|
|
|
var $hostField = $("div.form-group[id$='host']");
|
|
|
var $hostSelect = $("select[id$='host']");
|
|
|
-
|
|
|
+
|
|
|
if ($hostTypeField.html() === 'Cablemodem') {
|
|
|
if ($hostSelect.find("option[value='']").length == 0) {
|
|
|
$hostSelect.prepend('<option value=""></option>');
|
|
|
}
|
|
|
$hostSelect.val(null).trigger('change');
|
|
|
-
|
|
|
+
|
|
|
$hostField.hide();
|
|
|
} else {
|
|
|
if ($hostSelect.find("option[value='']").length) {
|
|
@@ -46,10 +54,10 @@ function showHostField()
|
|
|
}
|
|
|
var val = $hostSelect.find("option").first().attr('value');
|
|
|
$hostSelect.val(val).trigger('change');
|
|
|
-
|
|
|
+
|
|
|
$hostField.show();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
updateFixedIPs();
|
|
|
|
|
|
return false;
|
|
@@ -59,9 +67,9 @@ function updateFixedIPs()
|
|
|
{
|
|
|
var $hostTypeField = $("select[id$='hostType'] :selected");
|
|
|
var $hostTypeId = $hostTypeField.val();
|
|
|
-
|
|
|
+
|
|
|
var option = '<option value=""></option>';
|
|
|
-
|
|
|
+
|
|
|
if (($hostTypeId == $initHostTypeId) && $fixedIP != false) {
|
|
|
option = `<option value="${$fixedIP}" selected>${$fixedIP}</option>`;
|
|
|
$("div[id$='_fixed_address'] a span.select2-chosen").html($fixedIP);
|
|
@@ -74,14 +82,14 @@ function updateFixedIPs()
|
|
|
type: 'POST',
|
|
|
data: {id: $hostTypeId},
|
|
|
success: function(data) {
|
|
|
-
|
|
|
+
|
|
|
$('select[id$="_fixed_address"]').html(option);
|
|
|
if (data.ips) {
|
|
|
$.each(data.ips, function (index, value) {
|
|
|
$('select[id$="_fixed_address"]').append('<option value="' + value + '">' + value + '</option>');
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
});
|