prevent locking while edit_field is open

This commit is contained in:
iou1name 2019-06-20 11:59:37 -04:00
parent b3111c8d12
commit b942ab8e71
3 changed files with 12 additions and 10 deletions

View File

@ -80,6 +80,7 @@ nav span:hover {
.edit, .save, .lock, .unlock { .edit, .save, .lock, .unlock {
font-size: 0.8em; font-size: 0.8em;
color: dimgrey; color: dimgrey;
margin-left: 0.4em;
} }
.edit:hover, .save:hover, .lock:hover, .unlock:hover { .edit:hover, .save:hover, .lock:hover, .unlock:hover {

View File

@ -122,6 +122,7 @@ function new_device() {
} }
function lock_device(device) { function lock_device(device) {
if (device.querySelector('.save')) { return; }
let fields = device.querySelectorAll('.editable'); let fields = device.querySelectorAll('.editable');
fields.forEach(function(field) { fields.forEach(function(field) {
field.querySelector('.edit').remove(); field.querySelector('.edit').remove();

View File

@ -18,16 +18,16 @@
<div id="devices"> <div id="devices">
{% for device in network %} {% for device in network %}
<div class="device {{ device.type }}" id="{{ device.id }}"> <div class="device {{ device.type }}" id="{{ device.id }}">
<div class="id editable"><span class="field_value">{{ device.id }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span> <span class="lock font-awesome" onclick="lock_device(this.parentElement.parentElement)">&#xe803;</span></div> <div class="id editable"><span class="field_value">{{ device.id }}</span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span><span class="lock font-awesome" onclick="lock_device(this.parentElement.parentElement)">&#xe803;</span></div>
<div class="description editable"><span class="field_value">{{ device.description }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description editable"><span class="field_value">{{ device.description }}</span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location editable"><span class="field_value">{{ device.location }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="location editable"><span class="field_value">{{ device.location }}</span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="ip_address editable"><span class="field_value">{{ device.ip_address }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="ip_address editable"><span class="field_value">{{ device.ip_address }}</span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="sub_devices"> <div class="sub_devices">
{% for sub_dev in device.sub_devices %} {% for sub_dev in device.sub_devices %}
<div class="sub_device {{ sub_dev.type }}" id="{{ sub_dev.id }}"> <div class="sub_device {{ sub_dev.type }}" id="{{ sub_dev.id }}">
<div class="id">{{ sub_dev.id }}</div> <div class="id">{{ sub_dev.id }}</div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" data="/static/outlet.svg"></object>
<div class="description editable"><span class="field_value">{{ sub_dev.description }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description editable"><span class="field_value">{{ sub_dev.description }}</span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
@ -38,19 +38,19 @@
<template id="RelayDevice_template"> <template id="RelayDevice_template">
<div class="device RelayDevice" id=""> <div class="device RelayDevice" id="">
<div class="id"></div> <div class="id"></div>
<div class="description"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="location"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="ip_address"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="ip_address"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="sub_devices"> <div class="sub_devices">
<div class="sub_device RelayOutlet" id="OUT0"> <div class="sub_device RelayOutlet" id="OUT0">
<div class="id">OUT0</div> <div class="id">OUT0</div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" data="/static/outlet.svg"></object>
<div class="description"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
<div class="sub_device RelayOutlet" id="OUT2"> <div class="sub_device RelayOutlet" id="OUT2">
<div class="id">OUT2</div> <div class="id">OUT2</div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" data="/static/outlet.svg"></object>
<div class="description"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
</div> </div>
</div> </div>