diff options
author | Andrew Dolgov <[email protected]> | 2018-12-02 15:30:07 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-12-02 15:30:07 +0300 |
commit | 58e54282d36d54c2be0e50f78fbc500772a3b762 (patch) | |
tree | 0cae6646245d0ff6404a7f25569f8e75b69cbf2f /js/PrefFeedTree.js | |
parent | 50a4c2d7236841f5bf23ab4c47529fef3b1dda2e (diff) |
prefs: move more global functions into matching classes
Diffstat (limited to 'js/PrefFeedTree.js')
-rw-r--r-- | js/PrefFeedTree.js | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index a23624c08..afb56faa1 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -35,14 +35,14 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio menu.addChild(new dijit.MenuItem({ label: __("Edit category"), onClick: function() { - editCat(this.getParent().row_id, this.getParent().item, null); + dijit.byId("feedTree").editCategory(this.getParent().row_id, this.getParent().item, null); }})); menu.addChild(new dijit.MenuItem({ label: __("Remove category"), onClick: function() { - removeCategory(this.getParent().row_id, this.getParent().item); + dijit.byId("feedTree").removeCategory(this.getParent().row_id, this.getParent().item); }})); menu.bindDomNode(tnode.domNode); @@ -123,6 +123,16 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio updateFeedList(); }); }, + removeCategory: function(id, item) { + if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) { + notify_progress("Removing category..."); + + xhrPost("backend.php", {op: "pref-feeds", method: "removeCat", ids: id}, () => { + notify(''); + updateFeedList(); + }); + } + }, removeSelectedFeeds: function() { const sel_rows = this.getSelectedFeeds(); @@ -284,6 +294,22 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio dialog.show(); }); }, + editCategory: function(id, item) { + // uncategorized + if (String(item.id) == "CAT:0") + return; + + const new_name = prompt(__('Rename category to:'), item.name); + + if (new_name && new_name != item.name) { + + notify_progress("Loading, please wait..."); + + xhrPost("backend.php", { op: 'pref-feeds', method: 'renamecat', id: id, title: new_name }, () => { + updateFeedList(); + }); + } + }, createCategory: function() { const title = prompt(__("Category title:")); @@ -322,6 +348,51 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio }); dialog.show(); + }, + showInactiveFeeds: function() { + const query = "backend.php?op=pref-feeds&method=inactiveFeeds"; + + if (dijit.byId("inactiveFeedsDlg")) + dijit.byId("inactiveFeedsDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "inactiveFeedsDlg", + title: __("Feeds without recent updates"), + style: "width: 600px", + getSelectedFeeds: function () { + return Tables.getSelected("prefInactiveFeedList"); + }, + removeSelected: function () { + const sel_rows = this.getSelectedFeeds(); + + if (sel_rows.length > 0) { + if (confirm(__("Remove selected feeds?"))) { + notify_progress("Removing selected feeds...", true); + + const query = { + op: "pref-feeds", method: "remove", + ids: sel_rows.toString() + }; + + xhrPost("backend.php", query, () => { + notify(''); + dialog.hide(); + updateFeedList(); + }); + } + + } else { + alert(__("No feeds are selected.")); + } + }, + execute: function () { + if (this.validate()) { + } + }, + href: query + }); + + dialog.show(); } }); }); |