add(chore): bulk requests
This commit is contained in:
+31
-12
@@ -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;
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
<label>Autor(en) <input name="authors" /></label>
|
||||
<label>Serie <input name="series" /></label>
|
||||
<label>Band <input name="volume" type="number" min="0" /></label>
|
||||
<label
|
||||
>bis Band (Bulk, optional)
|
||||
<input name="volume_to" type="number" min="0" />
|
||||
<span class="muted"
|
||||
>Legt pro Band/Folge eine Anfrage an, z.B. 1 bis 300</span
|
||||
>
|
||||
</label>
|
||||
<label>Jahr <input name="year" type="number" /></label>
|
||||
<label>ISBN/ID <input name="external_id" /></label>
|
||||
<label
|
||||
@@ -84,6 +91,10 @@
|
||||
<section id="view-import" hidden>
|
||||
<div class="bar">
|
||||
<button id="scan-btn">Download-Ordner scannen</button>
|
||||
<label class="muted"
|
||||
><input type="checkbox" id="split-dirs" /> Ordner als Einzeldateien
|
||||
behandeln (z.B. Folgen-Sammlungen)</label
|
||||
>
|
||||
<span id="scan-info" class="muted"></span>
|
||||
</div>
|
||||
<table id="import-table" hidden>
|
||||
|
||||
Reference in New Issue
Block a user