mirror of
https://gitlab.aachen.ccc.de/inventory/in.git
synced 2024-11-29 10:13:59 +01:00
fetch items from server before locally checking available IDs
This commit is contained in:
parent
ade2219469
commit
6b7c741658
1 changed files with 37 additions and 31 deletions
|
@ -3,11 +3,15 @@ const id = new URLSearchParams(window.location.search).get('id');
|
|||
|
||||
document.onreadystatechange = function() {
|
||||
if (document.readyState === 'interactive') {
|
||||
fetchItems(fillForm);
|
||||
}
|
||||
}
|
||||
|
||||
function fetchItems(cb) {
|
||||
fetch('/api/items').then(r => r.json()).then((data) => {
|
||||
items = data;
|
||||
fillForm();
|
||||
cb();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function fillForm() {
|
||||
|
@ -77,6 +81,7 @@ function save() {
|
|||
hidden: document.getElementById('hidden').checked,
|
||||
}
|
||||
|
||||
fetchItems(() => {
|
||||
if (item.id.includes('?')) {
|
||||
let n = 1;
|
||||
while (true) {
|
||||
|
@ -111,6 +116,7 @@ function save() {
|
|||
}).catch(error => {
|
||||
alert(`Error:\n${error}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function del() {
|
||||
|
|
Loading…
Reference in a new issue