diff --git a/static/app.js b/static/app.js index d5969ca..fef8863 100644 --- a/static/app.js +++ b/static/app.js @@ -182,18 +182,36 @@ $("#manual-form").addEventListener("submit", async (e) => { const data = Object.fromEntries(new FormData(e.target)); if (!data.library_id) { toast("Keine Library gewählt", true); return; } try { - await api("/api/requests", { - method: "POST", - body: JSON.stringify({ - library_id: parseInt(data.library_id), - title: data.title, authors: data.authors, series: data.series, - external_id: data.external_id, - year: data.year ? parseInt(data.year) : null, - volume: data.volume ? parseInt(data.volume) : null, - }), - }); + if (data.volume_to) { + if (!data.volume) { + toast("Für Bulk bitte Start-Band angeben", true); + return; + } + const created = await api("/api/requests/bulk", { + method: "POST", + body: JSON.stringify({ + library_id: parseInt(data.library_id), + series: data.series || data.title, authors: data.authors, + volume_from: parseInt(data.volume), + volume_to: parseInt(data.volume_to), + year: data.year ? parseInt(data.year) : null, + }), + }); + toast(`${created.length} Anfragen angelegt`); + } else { + await api("/api/requests", { + method: "POST", + body: JSON.stringify({ + library_id: parseInt(data.library_id), + title: data.title, authors: data.authors, series: data.series, + external_id: data.external_id, + year: data.year ? parseInt(data.year) : null, + volume: data.volume ? parseInt(data.volume) : null, + }), + }); + toast("Anfrage angelegt"); + } e.target.reset(); - toast("Anfrage angelegt"); } catch (err) { toast(err.message, true); } }); @@ -241,8 +259,9 @@ let missingReqs = []; $("#scan-btn").addEventListener("click", async () => { $("#scan-info").textContent = "Scanne…"; try { + const split = $("#split-dirs").checked; const [scan, reqs] = await Promise.all([ - api("/api/import/scan"), + api("/api/import/scan?split_dirs=" + split), api("/api/requests?status=missing"), ]); scanItems = scan.items; diff --git a/static/index.html b/static/index.html index e6462f1..57190c3 100644 --- a/static/index.html +++ b/static/index.html @@ -48,6 +48,13 @@ +