mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
WebUI: Improve filter lists
This PR adds following improvements: * Remove unused tracker entries while processing sync data * Take into account filter selection & terms when performing 'Start/stop/delete' context actions in filter lists Now, only filtered torrents will be affected by them, just like in the GUI. * Provide better feedback when performing 'Start/stop/delete' context actions in filter lists Small improvement over GUI - now these actions will be disabled if it's not possible to use them. * Add context menu to status filter list * Fix error when toggling filter title Fixup for small bug introduced in https://github.com/qbittorrent/qBittorrent/pull/21269 PR #21438.
This commit is contained in:
@@ -34,6 +34,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||
return {
|
||||
ContextMenu: ContextMenu,
|
||||
TorrentsTableContextMenu: TorrentsTableContextMenu,
|
||||
StatusesFilterContextMenu: StatusesFilterContextMenu,
|
||||
CategoriesFilterContextMenu: CategoriesFilterContextMenu,
|
||||
TagsFilterContextMenu: TagsFilterContextMenu,
|
||||
TrackersFilterContextMenu: TrackersFilterContextMenu,
|
||||
@@ -300,6 +301,31 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||
}
|
||||
});
|
||||
|
||||
const FilterListContextMenu = new Class({
|
||||
Extends: ContextMenu,
|
||||
initialize: function(options) {
|
||||
this.parent(options);
|
||||
this.torrentObserver = new MutationObserver((records, observer) => {
|
||||
this.updateTorrentActions();
|
||||
});
|
||||
},
|
||||
|
||||
startTorrentObserver: function() {
|
||||
this.torrentObserver.observe(torrentsTable.tableBody, { childList: true });
|
||||
},
|
||||
|
||||
stopTorrentObserver: function() {
|
||||
this.torrentObserver.disconnect();
|
||||
},
|
||||
|
||||
updateTorrentActions: function() {
|
||||
const torrentsVisible = torrentsTable.tableBody.children.length > 0;
|
||||
this.setEnabled("startTorrents", torrentsVisible)
|
||||
.setEnabled("stopTorrents", torrentsVisible)
|
||||
.setEnabled("deleteTorrents", torrentsVisible);
|
||||
}
|
||||
});
|
||||
|
||||
const TorrentsTableContextMenu = new Class({
|
||||
Extends: ContextMenu,
|
||||
|
||||
@@ -574,8 +600,15 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||
}
|
||||
});
|
||||
|
||||
const StatusesFilterContextMenu = new Class({
|
||||
Extends: FilterListContextMenu,
|
||||
updateMenuItems: function() {
|
||||
this.updateTorrentActions();
|
||||
}
|
||||
});
|
||||
|
||||
const CategoriesFilterContextMenu = new Class({
|
||||
Extends: ContextMenu,
|
||||
Extends: FilterListContextMenu,
|
||||
updateMenuItems: function() {
|
||||
const id = Number(this.options.element.id);
|
||||
if ((id !== CATEGORIES_ALL) && (id !== CATEGORIES_UNCATEGORIZED)) {
|
||||
@@ -591,28 +624,34 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||
this.hideItem("deleteCategory");
|
||||
this.hideItem("createSubcategory");
|
||||
}
|
||||
|
||||
this.updateTorrentActions();
|
||||
}
|
||||
});
|
||||
|
||||
const TagsFilterContextMenu = new Class({
|
||||
Extends: ContextMenu,
|
||||
Extends: FilterListContextMenu,
|
||||
updateMenuItems: function() {
|
||||
const id = Number(this.options.element.id);
|
||||
if ((id !== TAGS_ALL) && (id !== TAGS_UNTAGGED))
|
||||
this.showItem("deleteTag");
|
||||
else
|
||||
this.hideItem("deleteTag");
|
||||
|
||||
this.updateTorrentActions();
|
||||
}
|
||||
});
|
||||
|
||||
const TrackersFilterContextMenu = new Class({
|
||||
Extends: ContextMenu,
|
||||
Extends: FilterListContextMenu,
|
||||
updateMenuItems: function() {
|
||||
const id = Number(this.options.element.id);
|
||||
if ((id !== TRACKERS_ALL) && (id !== TRACKERS_TRACKERLESS))
|
||||
this.showItem("deleteTracker");
|
||||
else
|
||||
this.hideItem("deleteTracker");
|
||||
|
||||
this.updateTorrentActions();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user