webui: add an "Uncategorized" option to category selectors

Add-torrent and set-category dropdowns default to Uncategorized so a
category is no longer forced; set-category preselects the current one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ookami125 2026-06-21 23:34:50 -04:00
parent 9a1d67acd4
commit a35b93caca

View file

@ -494,7 +494,8 @@ async function confirmDelete(hashes) {
/* ---------- add torrent modal ---------- */ /* ---------- add torrent modal ---------- */
function openAddModal() { function openAddModal() {
const cats = state.meta.categories.map((c) => `<option value="${f.esc(c.name)}">${f.esc(c.name || 'Uncategorized')}</option>`).join(''); const cats = '<option value="" selected>Uncategorized</option>' +
state.meta.categories.map((c) => `<option value="${f.esc(c.name)}">${f.esc(c.name || 'Uncategorized')}</option>`).join('');
openModal('Add torrent', ` openModal('Add torrent', `
<div class="field"><label>Magnet link / URL</label> <div class="field"><label>Magnet link / URL</label>
<input type="text" id="addMagnet" placeholder="magnet:?xt=urn:btih:…" /></div> <input type="text" id="addMagnet" placeholder="magnet:?xt=urn:btih:…" /></div>
@ -689,7 +690,10 @@ function onRowContext(e, hash) {
} }
function promptCategory() { function promptCategory() {
const opts = state.meta.categories.map((c) => `<option value="${f.esc(c.name)}">${f.esc(c.name || 'Uncategorized')}</option>`).join(''); const cur = state.snapshot?.torrents?.find((t) => t.hash === [...state.selected][0])?.category || '';
const sel = (v) => (v === cur ? ' selected' : '');
const opts = `<option value=""${sel('')}>Uncategorized</option>` +
state.meta.categories.map((c) => `<option value="${f.esc(c.name)}"${sel(c.name)}>${f.esc(c.name || 'Uncategorized')}</option>`).join('');
openModal('Set category', ` openModal('Set category', `
<div class="field"><label>Category</label><select id="catSel">${opts}</select></div> <div class="field"><label>Category</label><select id="catSel">${opts}</select></div>
<p class="dim" style="font-size:12px">Need a new one? Use <b>+</b> next to Categories in the sidebar.</p>`, <p class="dim" style="font-size:12px">Need a new one? Use <b>+</b> next to Categories in the sidebar.</p>`,