diff --git a/src/webui/www/private/addtorrent.html b/src/webui/www/private/addtorrent.html index 32e934273..dd5dc514e 100644 --- a/src/webui/www/private/addtorrent.html +++ b/src/webui/www/private/addtorrent.html @@ -7,8 +7,10 @@ + + @@ -109,6 +111,10 @@ } } + #btn-group-tagsSelect button { + background-color: initial; + } + @@ -193,6 +199,17 @@ + + + + + +
+ + +
+ + diff --git a/src/webui/www/private/scripts/addtorrent.js b/src/webui/www/private/scripts/addtorrent.js index d6f1b4cac..3addf2750 100644 --- a/src/webui/www/private/scripts/addtorrent.js +++ b/src/webui/www/private/scripts/addtorrent.js @@ -52,6 +52,26 @@ window.qBittorrent.AddTorrent ??= (() => { } }; + const getTags = () => { + const tagsSelect = document.getElementById("tagsSelect"); + for (const tag of window.parent.qBittorrent.Client.tagMap.keys()) { + const option = document.createElement("option"); + option.value = tag; + option.textContent = tag; + tagsSelect.appendChild(option); + } + + new vanillaSelectBox("#tagsSelect", { + maxHeight: 200, + search: false, + disableSelectAll: true, + translations: { + all: window.parent.qBittorrent.Client.tagMap.length === 0 ? "" : "QBT_TR(All)QBT_TR[CONTEXT=AddNewTorrentDialog]", + }, + keepInlineStyles: false + }); + }; + const getPreferences = () => { const pref = window.parent.qBittorrent.Cache.preferences.get(); @@ -137,6 +157,11 @@ window.qBittorrent.AddTorrent ??= (() => { } }; + const changeTagsSelect = (element) => { + const tags = [...element.options].filter(opt => opt.selected).map(opt => opt.value); + document.getElementById("tags").value = tags.join(","); + }; + const isAutoTMMEnabled = () => { return document.getElementById("autoTMM").selectedIndex === 1; }; @@ -283,10 +308,12 @@ window.qBittorrent.AddTorrent ??= (() => { getPreferences(); getCategories(); + getTags(); }); window.addEventListener("DOMContentLoaded", (event) => { document.getElementById("useDownloadPath").addEventListener("change", (e) => changeUseDownloadPath(e.target.checked)); + document.getElementById("tagsSelect").addEventListener("change", (e) => changeTagsSelect(e.target)); }); return exports();