Fixed implementation of disabled color selection

This commit is contained in:
Andy Teijelo Pérez 2015-11-07 23:32:11 -05:00
parent cd231a1faa
commit 319c578ba9
2 changed files with 29 additions and 23 deletions

View file

@ -98,7 +98,7 @@ ff:ff:ff:ff:ff:fe,10.6.122.95
00:23:54:8c:65:13,10.6.122.96,set:client0023548c6513 00:23:54:8c:65:13,10.6.122.96,set:client0023548c6513
ff:ff:ff:ff:ff:fe,10.6.122.97 ff:ff:ff:ff:ff:fe,10.6.122.97
ff:ff:ff:ff:ff:fe,10.6.122.98 ff:ff:ff:ff:ff:fe,10.6.122.98
# {"color": "purple", "reserved-by": "Zelda"} # {"color": "red", "reserved-by": "Zelda"}
ff:ff:ff:ff:ff:fe,10.6.122.99 ff:ff:ff:ff:ff:fe,10.6.122.99
ff:ff:ff:ff:ff:fe,10.6.122.100 ff:ff:ff:ff:ff:fe,10.6.122.100
# {"reserved-by": "Andy"} # {"reserved-by": "Andy"}

View file

@ -12,25 +12,27 @@
</div> </div>
{% if meta.locked %} {% if meta.locked %}
<div class="alert alert-warning"><i class="fa fa-lock"></i> Esta dirección está reservada por <i>Ilúvatar</i></div> <div class="row">
<div class="alert alert-warning"><i class="fa fa-lock"></i> Esta dirección está reservada por <i>Ilúvatar</i></div>
</div>
{% endif %} {% endif %}
<div class="row"> <div class="row">
<form class="form-horizontal" method="POST"> <form class="form-horizontal" method="POST">
{% if meta.locked %} {% if meta.locked %}
<fieldset disabled> <fieldset id="whole-fieldset" disabled>
{% endif %} {% endif %}
<div class="form-group"> <div class="form-group">
<div class="col-xs-11"> <div class="col-xs-11">
<input type="checkbox" id="reserved" name="reserved" <input type="checkbox" id="reserved" name="reserved"
{% if meta.reserved_by -%} {% if meta.reserved_by -%}
checked="checked" checked="checked"
{%- endif -%}> {%- endif -%}>
<label for="reserved">Etiqueta:</label> <label for="reserved">Etiqueta:</label>
<div class="row"> <fieldset id="label-fieldset" disabled>
<fieldset id="label-fieldset" disabled> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
<input type="text" class="form-control" <input type="text" class="form-control"
id="reserved-by" name="reserved-by" id="reserved-by" name="reserved-by"
@ -39,19 +41,19 @@
{%- endif -%} {%- endif -%}
/> />
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">
{% set meta_color = "black" %} {% set meta_color = "black" %}
{% if meta.color %}{% set meta_color = meta.color %}{% endif %} {% if meta.color %}{% set meta_color = meta.color %}{% endif %}
{% for color in valid_colors %} {% for color in valid_colors %}
<span class="color-sample c-{{ color }} <span class="color-sample c-{{ color }}
{%- if color == meta_color %} selected{% endif -%}" {%- if color == meta_color %} selected{% endif -%}"
{%- if color != 'black' %} data-color="{{ color }}"{% endif %} {%- if color != 'black' %} data-color="{{ color }}"{% endif %}
><i class="fa fa-square"></i></span> ><i class="fa fa-square"></i></span>
{% endfor %} {% endfor %}
<input type="hidden" id="label-color" name="label-color" value=""/> <input type="hidden" id="label-color" name="label-color" value=""/>
</div>
</div> </div>
</div>
</fieldset> </fieldset>
</div> </div>
</div> </div>
@ -132,7 +134,11 @@
$("#dhcp-specific-fieldset").prop("disabled", !$("#dhcp-client-specific").prop("checked")); $("#dhcp-specific-fieldset").prop("disabled", !$("#dhcp-client-specific").prop("checked"));
}) })
$(".color-sample").click(function() { $(".color-sample").click(function() {
if ($("#label-fieldset").prop("disabled")) var disabled = false;
$(this).parents("fieldset").each(function() {
disabled = $(this).prop("disabled") || disabled;
});
if (disabled)
return; return;
$(".color-sample").removeClass("selected"); $(".color-sample").removeClass("selected");
$(this).addClass("selected"); $(this).addClass("selected");