remove old category editor

allow creating/removing categories in main feed editor
This commit is contained in:
Andrew Dolgov
2012-08-15 09:38:57 +04:00
parent e07f89815b
commit 5ef071e00b
3 changed files with 85 additions and 219 deletions
+45
View File
@@ -35,6 +35,51 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
dojo.place(param, tnode.labelNode, 'after');
}
var id = args.item.id[0];
var bare_id = parseInt(id.substr(id.indexOf(':')+1));
if (id.match("CAT:") && bare_id > 0) {
var menu = new dijit.Menu();
menu.row_id = bare_id;
menu.item = args.item;
menu.addChild(new dijit.MenuItem({
label: __("Edit category"),
onClick: function() {
editCat(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);
}}));
menu.bindDomNode(tnode.domNode);
tnode._menu = menu;
} else if (id.match("FEED:")) {
var menu = new dijit.Menu();
menu.row_id = bare_id;
menu.item = args.item;
menu.addChild(new dijit.MenuItem({
label: __("Edit feed"),
onClick: function() {
editFeed(this.getParent().row_id);
}}));
menu.addChild(new dijit.MenuItem({
label: __("Unsubscribe"),
onClick: function() {
unsubscribeFeed(this.getParent().row_id, this.getParent().item.name);
}}));
menu.bindDomNode(tnode.domNode);
tnode._menu = menu;
}
return tnode;
},
onDndDrop: function() {
+38 -59
View File
@@ -1169,72 +1169,51 @@ function pref_hotkey_handler(e) {
}
}
function editFeedCats() {
function removeCategory(id, item) {
try {
var query = "backend.php?op=pref-feeds&method=editCats";
if (dijit.byId("feedCatEditDlg"))
dijit.byId("feedCatEditDlg").destroyRecursive();
var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
dialog = new dijit.Dialog({
id: "feedCatEditDlg",
title: __("Feed Categories"),
style: "width: 600px",
getSelectedCategories: function() {
return getSelectedTableRowIds("prefFeedCatList");
},
removeSelected: function() {
var sel_rows = this.getSelectedCategories();
if (ok) {
var query = "?op=pref-feeds&method=editCats&action=remove&ids="+
param_escape(id);
if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected categories?"));
notify_progress("Removing category...");
if (ok) {
notify_progress("Removing selected categories...", true);
var query = "?op=pref-feeds&method=editCats&action=remove&ids="+
param_escape(sel_rows.toString());
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
notify('');
dialog.attr('content', transport.responseText);
updateFeedList();
} });
}
} else {
alert(__("No categories are selected."));
}
},
addCategory: function() {
if (this.validate()) {
notify_progress("Creating category...");
var query = "?op=pref-feeds&method=editCats&action=add&cat=" +
param_escape(this.attr('value').newcat);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
notify('');
dialog.attr('content', transport.responseText);
updateFeedList();
} });
}
},
execute: function() {
if (this.validate()) {
}
},
href: query});
dialog.show();
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
notify('');
updateFeedList();
} });
}
} catch (e) {
exception_error("editFeedCats", e);
exception_error("removeCategory", e);
}
}
function createCategory() {
try {
var title = prompt(__("Category title:"));
if (title) {
notify_progress("Creating category...");
var query = "?op=pref-feeds&method=editCats&action=add&cat=" +
param_escape(title);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
notify('');
updateFeedList();
} });
}
} catch (e) {
exception_error("createCategory", e);
}
}