fix(metadata): get series from api
This commit is contained in:
+41
-17
@@ -159,6 +159,7 @@ $("#search-form").addEventListener("submit", async (e) => {
|
||||
<strong>${esc(r.title)}</strong>
|
||||
<span>${esc(r.authors)}</span>
|
||||
${r.narrator ? `<span class="muted">🎙 ${esc(r.narrator)}</span>` : ""}
|
||||
${r.series && r.media_type ? `<span class="muted">📚 ${esc(r.series)}${r.volume != null ? " #" + r.volume : ""}</span>` : ""}
|
||||
<span class="muted">${r.year ?? ""} ${r.external_id ? "· " + esc(r.external_id) : ""}</span>
|
||||
${type === "comic" ? `<input type="number" min="0" placeholder="Band" class="volume" data-vol="${i}">` : ""}
|
||||
<div class="row">
|
||||
@@ -184,7 +185,7 @@ $("#search-form").addEventListener("submit", async (e) => {
|
||||
title: r.title, authors: r.authors, narrator: r.narrator || "",
|
||||
external_id: r.external_id,
|
||||
year: r.year, series: r.series, cover_url: r.cover_url,
|
||||
volume: volInput && volInput.value ? parseInt(volInput.value) : null,
|
||||
volume: volInput && volInput.value ? parseInt(volInput.value) : (r.volume ?? null),
|
||||
}),
|
||||
});
|
||||
setLastLib(type, libId);
|
||||
@@ -368,28 +369,50 @@ function openDetail(id, status) {
|
||||
img.hidden = !r.cover_url;
|
||||
$("#detail-nocover").hidden = !!r.cover_url;
|
||||
if (r.cover_url) img.src = r.cover_url;
|
||||
$("#detail-retag").hidden = !(r.status === "imported" && r.media_type === "audiobook");
|
||||
$("#detail-dialog").showModal();
|
||||
}
|
||||
|
||||
async function saveDetail(form) {
|
||||
await api("/api/requests/" + detailRequest.id, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
library_id: parseInt(form.library_id.value),
|
||||
title: form.title.value,
|
||||
authors: form.authors.value,
|
||||
narrator: form.narrator.value,
|
||||
series: form.series.value,
|
||||
volume: form.volume.value ? parseInt(form.volume.value) : null,
|
||||
year: form.year.value ? parseInt(form.year.value) : null,
|
||||
external_id: form.external_id.value,
|
||||
cover_url: detailRequest.cover_url || "",
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
$("#detail-retag").addEventListener("click", async () => {
|
||||
if (!detailRequest) return;
|
||||
const btn = $("#detail-retag");
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner"></span> Tagge…';
|
||||
try {
|
||||
await saveDetail($("#detail-form"));
|
||||
const res = await api(`/api/requests/${detailRequest.id}/retag`, { method: "POST" });
|
||||
toast(`${res.files} Datei(en) neu getaggt`);
|
||||
$("#detail-dialog").close();
|
||||
loadRequests(detailRequest.status);
|
||||
} catch (err) { toast(err.message, true); }
|
||||
finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = "Speichern & neu taggen";
|
||||
}
|
||||
});
|
||||
|
||||
$("#detail-form").addEventListener("submit", async (e) => {
|
||||
if (e.submitter && e.submitter.value === "cancel") return;
|
||||
if (!detailRequest) return;
|
||||
const form = e.target;
|
||||
try {
|
||||
await api("/api/requests/" + detailRequest.id, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
library_id: parseInt(form.library_id.value),
|
||||
title: form.title.value,
|
||||
authors: form.authors.value,
|
||||
narrator: form.narrator.value,
|
||||
series: form.series.value,
|
||||
volume: form.volume.value ? parseInt(form.volume.value) : null,
|
||||
year: form.year.value ? parseInt(form.year.value) : null,
|
||||
external_id: form.external_id.value,
|
||||
cover_url: detailRequest.cover_url || "",
|
||||
}),
|
||||
});
|
||||
await saveDetail(e.target);
|
||||
toast("Anfrage gespeichert");
|
||||
loadRequests(detailRequest.status);
|
||||
} catch (err) { toast(err.message, true); }
|
||||
@@ -603,6 +626,7 @@ async function runQuickSearch() {
|
||||
<strong>${esc(r.title)}</strong>
|
||||
<span>${esc(r.authors)}</span>
|
||||
${r.narrator ? `<span class="muted">🎙 ${esc(r.narrator)}</span>` : ""}
|
||||
${r.series && r.media_type ? `<span class="muted">📚 ${esc(r.series)}${r.volume != null ? " #" + r.volume : ""}</span>` : ""}
|
||||
<span class="muted">${r.year ?? ""}</span>
|
||||
<div class="row"><button data-pick="${j}">Anfragen & verbinden</button></div>
|
||||
</div>
|
||||
@@ -634,7 +658,7 @@ async function pickQuickResult(r) {
|
||||
body: JSON.stringify({
|
||||
library_id: parseInt(libId),
|
||||
title: r.title, authors: r.authors, narrator: r.narrator || "",
|
||||
external_id: r.external_id,
|
||||
external_id: r.external_id, volume: r.volume ?? null,
|
||||
year: r.year, series: r.series, cover_url: r.cover_url,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -246,6 +246,9 @@
|
||||
<p class="muted mono" id="detail-path"></p>
|
||||
<div class="row">
|
||||
<button value="cancel" class="secondary">Abbrechen</button>
|
||||
<button type="button" id="detail-retag" class="secondary" hidden>
|
||||
Speichern & neu taggen
|
||||
</button>
|
||||
<button value="ok" id="detail-save">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user