And that is that! Target number support is in.
This commit is contained in:
parent
2845d340da
commit
dc3482f887
1 changed files with 36 additions and 0 deletions
|
|
@ -175,6 +175,42 @@ dtlist.style.height = height;
|
||||||
dtlist.style.maxHeight = height;
|
dtlist.style.maxHeight = height;
|
||||||
dtlist.style.minHeight = height;
|
dtlist.style.minHeight = height;
|
||||||
|
|
||||||
|
document.querySelectorAll('.dt-target').forEach((el) => {
|
||||||
|
el.addEventListener('change', async (ev) => {
|
||||||
|
const num = ev.target.value;
|
||||||
|
const id = ev.target.parentElement.dataset.invId;
|
||||||
|
|
||||||
|
let res, data;
|
||||||
|
try {
|
||||||
|
const res = await fetch(`{{ url_for('crudkit.devicetype.rest_list') }}${id}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json'
|
||||||
|
},
|
||||||
|
credentials: 'same-origin',
|
||||||
|
body: JSON.stringify({target: num})
|
||||||
|
});
|
||||||
|
|
||||||
|
const ct = res.headers.get('Content-Type') || '';
|
||||||
|
if (ct.includes('application/json')) {
|
||||||
|
data = await res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.status !== 200) {
|
||||||
|
const msg = data?.error || `Create failed (${res.status})`;
|
||||||
|
toastMessage(msg, 'danger');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
toastMessage('Network error setting target number', 'danger');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toastMessage('Updated target number.', 'success');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener('click', (ev) => {
|
document.addEventListener('click', (ev) => {
|
||||||
const addButton = document.getElementById('add-devicetype');
|
const addButton = document.getElementById('add-devicetype');
|
||||||
const editButton = document.getElementById('edit-devicetype');
|
const editButton = document.getElementById('edit-devicetype');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue