From da1f74c9c4e94a7093281daad268aa44ebe5f6c7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 Nov 2010 21:29:19 +0300 Subject: [PATCH] refactor category editor --- modules/pref-feeds.php | 30 ++++-------- prefs.js | 103 +++++++++++++++++++++++++---------------- 2 files changed, 71 insertions(+), 62 deletions(-) diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index d0bc194a..1b3e451f 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -1021,11 +1021,6 @@ } - header("Content-Type: text/xml"); - print ""; - print "".__('Category editor').""; - print " - - "; + + "; $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]." @@ -1059,13 +1052,9 @@ if (db_num_rows($result) != 0) { -# print __('Select:')." -# ".__('All').", -# ".__('None').""; -# print "
"; - print "
"; +# print ""; print ""; @@ -1105,6 +1094,7 @@ cid: this.srcNodeRef.getAttribute('cat-id')}, load: function(response) { elem.attr('value', response); + updateFeedList(); } }); @@ -1117,7 +1107,7 @@ print "
"; - print "
"; +# print ""; print "
"; @@ -1127,15 +1117,13 @@ print "
- +
"; - print "
"; - print "]]>
"; - return; } diff --git a/prefs.js b/prefs.js index fdedbd86..b613aec3 100644 --- a/prefs.js +++ b/prefs.js @@ -356,10 +356,9 @@ function getSelectedFilters() { } -function getSelectedFeedCats() { +/* function getSelectedFeedCats() { return getSelectedTableRowIds("prefFeedCatList"); -} - +} */ function removeSelectedLabels() { @@ -583,37 +582,6 @@ function removeSelectedPrefProfiles() { return false; } -function removeSelectedFeedCats() { - - var sel_rows = getSelectedFeedCats(); - - if (sel_rows.length > 0) { - - var ok = confirm(__("Remove selected categories?")); - - if (ok) { - notify_progress("Removing selected categories..."); - - var query = "?op=pref-feeds&subop=editCats&action=remove&ids="+ - param_escape(sel_rows.toString()); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - infobox_callback2(transport); - } }); - - } - - } else { - - alert(__("No categories are selected.")); - - } - - return false; -} - function userEditCancel() { closeInfoBox(); return false; @@ -1245,15 +1213,68 @@ function pref_hotkey_handler(e) { function editFeedCats() { try { - var query = "?op=pref-feeds&subop=editCats"; + var query = "backend.php?op=pref-feeds&subop=editCats"; - notify_progress("Loading, please wait..."); + if (dijit.byId("feedCatEditDlg")) + dijit.byId("feedCatEditDlg").destroyRecursive(); + + 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 (sel_rows.length > 0) { + var ok = confirm(__("Remove selected categories?")); + + if (ok) { + notify_progress("Removing selected categories...", true); + + var query = "?op=pref-feeds&subop=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&subop=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) { - infobox_callback2(transport); - } }); } catch (e) { exception_error("editFeedCats", e); } -- 2.39.5