feat(request): custom titles and remount blank request tab
Allow movie/TV requests without a TMDB match via a Custom form, and remount the embedded Request UI when the home tab opens empty. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2eed62390b
commit
7044023d98
12 files changed
+312
-33
No files matched your search
@@ -22,6 +22,7 @@
|
||||
<h1 class="req-title">Request</h1>
|
||||
<nav class="req-tabs" aria-label="Request views">
|
||||
<button type="button" class="req-tab active" data-view="search">Search</button>
|
||||
<button type="button" class="req-tab" data-view="custom">Custom</button>
|
||||
<button type="button" class="req-tab" data-view="mine">My requests</button>
|
||||
<button type="button" class="req-tab req-hidden" data-view="admin" data-role="admin-tab">Admin queue</button>
|
||||
</nav>
|
||||
@@ -30,7 +31,7 @@
|
||||
<p class="req-message req-hidden" data-role="global-message"></p>
|
||||
<section data-role="search-view">
|
||||
<div class="req-search-row">
|
||||
<input data-role="search-input" type="search" placeholder="Search movies or TV shows" autocomplete="off" />
|
||||
<input data-role="search-input" type="search" placeholder="Search movies or TV shows on TMDB" autocomplete="off" />
|
||||
<div class="req-type-toggle" role="group" aria-label="Media type">
|
||||
<button type="button" class="req-type-btn active" data-type="multi">All</button>
|
||||
<button type="button" class="req-type-btn" data-type="movie">Movies</button>
|
||||
@@ -42,6 +43,28 @@
|
||||
<div class="req-grid" data-role="results"></div>
|
||||
<div class="req-detail req-hidden" data-role="detail"></div>
|
||||
</section>
|
||||
<section class="req-hidden" data-role="custom-view">
|
||||
<p class="req-muted">Can’t find it on TMDB? Submit a custom movie or TV request for the admin to review.</p>
|
||||
<form class="req-custom-form" data-role="custom-form">
|
||||
<label class="req-field">
|
||||
<span>Title</span>
|
||||
<input data-role="custom-title" type="text" maxlength="200" required placeholder="Exact title" autocomplete="off" />
|
||||
</label>
|
||||
<div class="req-type-toggle" role="group" aria-label="Custom media type">
|
||||
<button type="button" class="req-type-btn active" data-role="custom-type" data-type="movie">Movie</button>
|
||||
<button type="button" class="req-type-btn" data-role="custom-type" data-type="tv">TV</button>
|
||||
</div>
|
||||
<label class="req-field">
|
||||
<span>Year (optional)</span>
|
||||
<input data-role="custom-year" type="number" min="1870" max="2100" placeholder="e.g. 2024" />
|
||||
</label>
|
||||
<label class="req-field">
|
||||
<span>Notes (optional)</span>
|
||||
<textarea data-role="custom-notes" rows="3" maxlength="1000" placeholder="Links, alternate titles, quality, seasons…"></textarea>
|
||||
</label>
|
||||
<button type="submit" class="req-btn primary" data-role="custom-submit">Submit custom request</button>
|
||||
</form>
|
||||
</section>
|
||||
<section class="req-hidden" data-role="mine-view">
|
||||
<div class="req-list" data-role="mine-list"></div>
|
||||
</section>
|
||||
@@ -163,6 +186,8 @@
|
||||
};
|
||||
}
|
||||
|
||||
const tmdbId = Number(item.tmdbId ?? item.TmdbId ?? 0);
|
||||
const isCustom = !!(item.isCustom ?? item.IsCustom) || tmdbId <= 0;
|
||||
return {
|
||||
id: item.id ?? item.Id ?? "",
|
||||
mediaType: item.mediaType || item.MediaType || "",
|
||||
@@ -174,7 +199,10 @@
|
||||
requestedByName: item.requestedByName || item.RequestedByName || "Unknown",
|
||||
createdAtUtc: item.createdAtUtc || item.CreatedAtUtc || null,
|
||||
status: item.status ?? item.Status,
|
||||
adminNote: item.adminNote || item.AdminNote || null
|
||||
adminNote: item.adminNote || item.AdminNote || null,
|
||||
notes: item.notes || item.Notes || null,
|
||||
isCustom,
|
||||
tmdbId
|
||||
};
|
||||
}
|
||||
|
||||
@@ -198,6 +226,7 @@
|
||||
function createController(root) {
|
||||
const state = {
|
||||
mediaType: "multi",
|
||||
customMediaType: "movie",
|
||||
status: null,
|
||||
isAdmin: false,
|
||||
detail: null,
|
||||
@@ -213,10 +242,16 @@
|
||||
searchMeta: root.querySelector('[data-role="search-meta"]'),
|
||||
results: root.querySelector('[data-role="results"]'),
|
||||
detail: root.querySelector('[data-role="detail"]'),
|
||||
customForm: root.querySelector('[data-role="custom-form"]'),
|
||||
customTitle: root.querySelector('[data-role="custom-title"]'),
|
||||
customYear: root.querySelector('[data-role="custom-year"]'),
|
||||
customNotes: root.querySelector('[data-role="custom-notes"]'),
|
||||
customSubmit: root.querySelector('[data-role="custom-submit"]'),
|
||||
mineList: root.querySelector('[data-role="mine-list"]'),
|
||||
adminList: root.querySelector('[data-role="admin-list"]'),
|
||||
adminTab: root.querySelector('[data-role="admin-tab"]'),
|
||||
searchView: root.querySelector('[data-role="search-view"]'),
|
||||
customView: root.querySelector('[data-role="custom-view"]'),
|
||||
mineView: root.querySelector('[data-role="mine-view"]'),
|
||||
adminView: root.querySelector('[data-role="admin-view"]')
|
||||
};
|
||||
@@ -246,6 +281,7 @@
|
||||
tab.classList.toggle("active", tab.dataset.view === view);
|
||||
});
|
||||
els.searchView.classList.toggle("req-hidden", view !== "search");
|
||||
els.customView.classList.toggle("req-hidden", view !== "custom");
|
||||
els.mineView.classList.toggle("req-hidden", view !== "mine");
|
||||
els.adminView.classList.toggle("req-hidden", view !== "admin");
|
||||
if (view === "mine" || (view === "admin" && state.isAdmin)) {
|
||||
@@ -546,10 +582,11 @@
|
||||
<article class="req-list-item">
|
||||
${img ? `<img src="${escapeHtml(img)}" alt="" />` : "<div></div>"}
|
||||
<div>
|
||||
<p class="req-card-title">${escapeHtml(item.title)}</p>
|
||||
<p class="req-card-title">${escapeHtml(item.title)}${item.isCustom ? ' <span class="req-badge custom">Custom</span>' : ""}</p>
|
||||
<p class="req-muted">${escapeHtml(item.mediaType)}${item.year ? ` · ${escapeHtml(item.year)}` : ""}${seasons ? ` · ${escapeHtml(seasons)}` : ""}</p>
|
||||
<p class="req-muted">Requested by ${escapeHtml(item.requestedByName)} · ${escapeHtml(formatRequestDate(item.createdAtUtc))}</p>
|
||||
<span class="req-badge ${statusClass(item.status)}">${escapeHtml(status)}</span>
|
||||
${item.notes ? `<p class="req-muted">Notes: ${escapeHtml(item.notes)}</p>` : ""}
|
||||
${item.adminNote ? `<p class="req-muted">${escapeHtml(item.adminNote)}</p>` : ""}
|
||||
</div>
|
||||
<div class="req-list-actions">${actions}</div>
|
||||
@@ -609,14 +646,22 @@
|
||||
tab.addEventListener("click", () => setView(tab.dataset.view));
|
||||
});
|
||||
|
||||
root.querySelectorAll(".req-type-btn").forEach((button) => {
|
||||
els.searchView.querySelectorAll(".req-type-btn").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
root.querySelectorAll(".req-type-btn").forEach((item) => item.classList.remove("active"));
|
||||
els.searchView.querySelectorAll(".req-type-btn").forEach((item) => item.classList.remove("active"));
|
||||
button.classList.add("active");
|
||||
state.mediaType = button.dataset.type;
|
||||
});
|
||||
});
|
||||
|
||||
root.querySelectorAll('[data-role="custom-type"]').forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
root.querySelectorAll('[data-role="custom-type"]').forEach((item) => item.classList.remove("active"));
|
||||
button.classList.add("active");
|
||||
state.customMediaType = button.dataset.type;
|
||||
});
|
||||
});
|
||||
|
||||
els.searchBtn.addEventListener("click", runSearch);
|
||||
els.searchInput.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
@@ -624,6 +669,54 @@
|
||||
}
|
||||
});
|
||||
|
||||
els.customForm.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const title = els.customTitle.value.trim();
|
||||
if (!title) {
|
||||
showMessage("Enter a title for the custom request.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.status && !(state.status.requestSubmissionEnabled ?? state.status.RequestSubmissionEnabled)) {
|
||||
showMessage("Request submission is disabled. Enable it in Dashboard → Plugins → Request.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
const yearRaw = els.customYear.value.trim();
|
||||
const year = yearRaw ? Number(yearRaw) : null;
|
||||
if (yearRaw && (!Number.isFinite(year) || year < 1870 || year > 2100)) {
|
||||
showMessage("Year must be between 1870 and 2100.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
els.customSubmit.disabled = true;
|
||||
try {
|
||||
await api("", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
isCustom: true,
|
||||
mediaType: state.customMediaType,
|
||||
title,
|
||||
year,
|
||||
notes: els.customNotes.value.trim() || null,
|
||||
allSeasons: true,
|
||||
tmdbId: 0
|
||||
})
|
||||
});
|
||||
els.customForm.reset();
|
||||
state.customMediaType = "movie";
|
||||
root.querySelectorAll('[data-role="custom-type"]').forEach((item) => {
|
||||
item.classList.toggle("active", item.dataset.type === "movie");
|
||||
});
|
||||
showMessage(`Custom request submitted for “${title}”.`);
|
||||
setView("mine");
|
||||
} catch (error) {
|
||||
showMessage(error.message, true);
|
||||
} finally {
|
||||
els.customSubmit.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all([loadStatus(), loadCurrentUser()]).then(() => {
|
||||
applyAdminUi();
|
||||
});
|
||||
@@ -636,8 +729,12 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
if (container.dataset.reqMounted === "1") {
|
||||
return container._jellyfinRequestController || null;
|
||||
const force = !!options.force;
|
||||
const hasUi = !!container.querySelector(".req-root");
|
||||
if (container.dataset.reqMounted === "1" && hasUi && !force) {
|
||||
const existing = container._jellyfinRequestController || null;
|
||||
existing?.reload?.();
|
||||
return existing;
|
||||
}
|
||||
|
||||
container.innerHTML = MARKUP;
|
||||
|
||||
Reference in new issue
Block a user