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); }