mirror of
https://gitlab.aachen.ccc.de/inventory/in.git
synced 2024-11-25 16:53: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,12 +3,16 @@ 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() {
|
||||
const item = items[id];
|
||||
|
@ -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