From b3111c8d12072baf226978dfbdeec01d30f334ca Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 20 Jun 2019 11:28:26 -0400 Subject: [PATCH] added unlock_device() --- static/juice.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/static/juice.js b/static/juice.js index 308b5ec..4e0ecd3 100644 --- a/static/juice.js +++ b/static/juice.js @@ -73,7 +73,7 @@ function save_field(field) { let params = { device_id: device_id, sub_dev_id: sub_dev_id, - field: field.className, + field: field.classList[0], value: value }; let query = Object.keys(params) @@ -135,5 +135,18 @@ function lock_device(device) { } function unlock_device(device) { - console.log(device); + let fields = device.querySelectorAll('.editable'); + fields.forEach(function(field) { + let edit = document.createElement('span'); + edit.innerHTML = ''; + edit.className = 'edit font-awesome'; + edit.setAttribute('onclick', 'edit_field(this.parentElement)'); + field.appendChild(edit); + }); + device.querySelector('.id').querySelector('.unlock').remove(); + let lock = document.createElement('span'); + lock.innerHTML = ''; + lock.className = 'lock font-awesome'; + lock.setAttribute('onclick', 'lock_device(this.parentElement.parentElement)'); + device.querySelector('.id').appendChild(lock); }