add(ui/ux): create a request manually from the import dialog
This commit is contained in:
+28
-7
@@ -861,6 +861,7 @@ function splitMergedItem(i) {
|
||||
// ---- quick request from a scanned file ----
|
||||
let quickItemIndex = null;
|
||||
let quickEpisode = null;
|
||||
let lastSeries = "";
|
||||
|
||||
// "017 - Titel", "Folge 17: Titel", "[003] Titel" -> episode number + rest.
|
||||
// A bare number without a separator ("100 Stunden") or without a leading zero is
|
||||
@@ -901,6 +902,10 @@ function openQuickDialog(i) {
|
||||
$("#quick-file").textContent = (item.rel_dir ? item.rel_dir + "/" : "") + item.name;
|
||||
$("#quick-episode").textContent = number != null ? `Folge ${number} — nicht mitgesucht` : "";
|
||||
$("#quick-q").value = cleanFileName(rest);
|
||||
$("#quick-m-title").value = cleanFileName(rest);
|
||||
$("#quick-m-volume").value = number ?? "";
|
||||
$("#quick-m-series").value = lastSeries;
|
||||
$("#quick-manual").open = false;
|
||||
$("#quick-library").innerHTML =
|
||||
libOptions(item.media_type) || "<option value=''>— keine Library —</option>";
|
||||
$("#quick-results").innerHTML = "";
|
||||
@@ -987,17 +992,13 @@ $("#quick-search-form").addEventListener("submit", (e) => {
|
||||
});
|
||||
$("#quick-close").addEventListener("click", () => $("#quick-dialog").close());
|
||||
|
||||
async function pickQuickResult(r) {
|
||||
// create the request and wire it to the scanned entry the dialog was opened for
|
||||
async function requestAndConnect(body) {
|
||||
const libId = $("#quick-library").value;
|
||||
if (!libId) { toast("Erst eine Library für diesen Typ anlegen", true); return; }
|
||||
const i = quickItemIndex;
|
||||
try {
|
||||
const req = await createRequest({
|
||||
library_id: parseInt(libId),
|
||||
title: r.title, authors: r.authors, narrator: r.narrator || "",
|
||||
external_id: r.external_id, volume: r.volume ?? quickEpisode,
|
||||
year: r.year, series: r.series, cover_url: r.cover_url,
|
||||
});
|
||||
const req = await createRequest({ library_id: parseInt(libId), ...body });
|
||||
setLastLib(scanItems[i].media_type, libId);
|
||||
missingReqs.push(req);
|
||||
scanItems[i].request_id = req.id;
|
||||
@@ -1009,6 +1010,26 @@ async function pickQuickResult(r) {
|
||||
} catch (err) { toast(err.message, true); }
|
||||
}
|
||||
|
||||
function pickQuickResult(r) {
|
||||
return requestAndConnect({
|
||||
title: r.title, authors: r.authors, narrator: r.narrator || "",
|
||||
external_id: r.external_id, volume: r.volume ?? quickEpisode,
|
||||
year: r.year, series: r.series, cover_url: r.cover_url,
|
||||
});
|
||||
}
|
||||
|
||||
// live shows, box sets and fan releases are not in the Audible catalogue at all
|
||||
$("#quick-m-submit").addEventListener("click", () => {
|
||||
const title = $("#quick-m-title").value.trim();
|
||||
if (!title) { toast("Titel angeben", true); return; }
|
||||
const volume = $("#quick-m-volume").value;
|
||||
return requestAndConnect({
|
||||
title,
|
||||
series: (lastSeries = $("#quick-m-series").value.trim()),
|
||||
volume: volume ? parseInt(volume) : null,
|
||||
});
|
||||
});
|
||||
|
||||
// ---- import execution (batched, with progress) ----
|
||||
const IMPORT_BATCH_SIZE = 20;
|
||||
|
||||
|
||||
@@ -204,6 +204,15 @@
|
||||
></label>
|
||||
<div id="quick-open-requests"></div>
|
||||
<div id="quick-results" class="cards"></div>
|
||||
<details id="quick-manual">
|
||||
<summary>Nicht bei Audible? Manuell anlegen</summary>
|
||||
<div class="bar wrap">
|
||||
<label>Titel <input id="quick-m-title" /></label>
|
||||
<label>Serie <input id="quick-m-series" placeholder="optional" /></label>
|
||||
<label>Folge/Band <input id="quick-m-volume" type="number" min="0" /></label>
|
||||
</div>
|
||||
<button type="button" id="quick-m-submit">Anlegen & verbinden</button>
|
||||
</details>
|
||||
<div class="row">
|
||||
<button type="button" id="quick-close" class="secondary">
|
||||
Schließen
|
||||
|
||||
Reference in New Issue
Block a user