bugfix edit_field() on sub_devices
This commit is contained in:
parent
1a6b3ca5f6
commit
3434fb8f96
|
@ -5,8 +5,8 @@ function load() {
|
|||
|
||||
Object.entries(init_state).forEach(([device_id, sub_devs]) => {
|
||||
let device = document.querySelector('#' + device_id);
|
||||
Object.entries(sub_devs).forEach(([sub_dev_id, state]) => {
|
||||
let sub_dev = device.querySelector('.' + sub_dev_id);
|
||||
Object.entries(sub_devs).forEach(([sub_device_id, state]) => {
|
||||
let sub_dev = device.querySelector('.' + sub_device_id);
|
||||
let svg = sub_dev.querySelector('object').getSVGDocument().firstElementChild;
|
||||
if (state) {
|
||||
svg.classList.remove('off');
|
||||
|
@ -175,7 +175,7 @@ function toggle_outlet(svg) {
|
|||
function save_field(field) {
|
||||
let value = field.firstElementChild.value;
|
||||
let device_id = field.parentElement.id;
|
||||
let sub_dev_id;
|
||||
let sub_device_id;
|
||||
if (field.parentElement.className.includes('sub_device')) {
|
||||
sub_device_id = field.parentElement.children[0].textContent;
|
||||
device_id = field.parentElement.parentElement.parentElement.id;
|
||||
|
@ -184,7 +184,7 @@ function save_field(field) {
|
|||
}
|
||||
let data = {
|
||||
device_id: device_id,
|
||||
sub_dev_id: sub_dev_id,
|
||||
sub_device_id: sub_device_id,
|
||||
field: field.classList[0],
|
||||
value: value
|
||||
};
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
<div class="ip_address editable"><span class="field_value">{{ device.ip_address }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)"></span>{% endif %}</div>
|
||||
<div class="sub_devices">
|
||||
{% if device.type == 'RelayDevice' %}
|
||||
{% for sub_dev in device.sub_devices %}
|
||||
<div class="sub_device {{ sub_dev.type }} {{ sub_dev.id }}">
|
||||
<div class="id">{{ sub_dev.id }}</div>
|
||||
{% for sub_device in device.sub_devices %}
|
||||
<div class="sub_device {{ sub_device.type }} {{ sub_device.id }}">
|
||||
<div class="id">{{ sub_device.id }}</div>
|
||||
<object class="outlet_image" aria-label="Outlet Image" data="/static/outlet.svg"></object>
|
||||
<div class="description editable"><span class="field_value">{{ sub_dev.description }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)"></span>{% endif %}</div>
|
||||
<div class="description editable"><span class="field_value">{{ sub_device.description }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)"></span>{% endif %}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% elif device.type == 'LightStrip' %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user