From fd26d5bfdf1c79c340e81b52cf6b45814bdf2884 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 3 Sep 2012 16:06:24 +0400 Subject: [PATCH] implement removing selected categories --- classes/pref/feeds.php | 2 ++ js/prefs.js | 45 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index b81f8265f..74ad97387 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1406,6 +1406,8 @@ class Pref_Feeds extends Handler_Protected { dojoType=\"dijit.MenuItem\">".__('(Un)hide empty categories').""; print "
".__('Reset sort order')."
"; + print "
".__('Remove selected')."
"; print ""; } diff --git a/js/prefs.js b/js/prefs.js index d23d4a68b..91d1e2783 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -264,6 +264,19 @@ function getSelectedFeeds() { return rv; } +function getSelectedCategories() { + var tree = dijit.byId("feedTree"); + var items = tree.model.getCheckedItems(); + var rv = []; + + items.each(function(item) { + if (item.id[0].match("CAT:")) + rv.push(tree.model.store.getValue(item, 'bare_id')); + }); + + return rv; +} + function getSelectedFilters() { var tree = dijit.byId("filterTree"); var items = tree.model.getCheckedItems(); @@ -277,10 +290,6 @@ function getSelectedFilters() { } -/* function getSelectedFeedCats() { - return getSelectedTableRowIds("prefFeedCatList"); -} */ - function removeSelectedLabels() { var sel_rows = getSelectedLabels(); @@ -1233,6 +1242,34 @@ function removeCategory(id, item) { } } +function removeSelectedCategories() { + + var sel_rows = getSelectedCategories(); + + if (sel_rows.length > 0) { + + var ok = confirm(__("Remove selected categories?")); + + if (ok) { + notify_progress("Removing selected categories..."); + + var query = "?op=pref-feeds&method=removeCat&ids="+ + param_escape(sel_rows.toString()); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + updateFeedList(); + } }); + + } + } else { + alert(__("No categories are selected.")); + } + + return false; +} + function createCategory() { try { var title = prompt(__("Category title:"));