addLabel -> CommonDialogs

This commit is contained in:
Andrew Dolgov 2018-12-01 22:19:20 +03:00
parent 2cd23e344c
commit bc96eac2ac
3 changed files with 26 additions and 28 deletions

View File

@ -651,6 +651,29 @@ const CommonDialogs = {
}); });
dialog.show(); dialog.show();
},
addLabel: function(select, callback) {
const caption = prompt(__("Please enter label caption:"), "");
if (caption != undefined && caption.trim().length > 0) {
const query = {op: "pref-labels", method: "add", caption: caption.trim()};
if (select)
Object.extend(query, {output: "select"});
notify_progress("Loading, please wait...", true);
xhrPost("backend.php", query, (transport) => {
if (callback) {
callback(transport);
} else if (App.isPrefs()) {
updateLabelList();
} else {
Feeds.reload();
}
});
}
} }
}; };
@ -1067,31 +1090,6 @@ function uploadFeedIcon() {
return false; return false;
} }
function addLabel(select, callback) {
const caption = prompt(__("Please enter label caption:"), "");
if (caption != undefined && caption.trim().length > 0) {
const query = { op: "pref-labels", method: "add", caption: caption.trim() };
if (select)
Object.extend(query, {output: "select"});
notify_progress("Loading, please wait...", true);
xhrPost("backend.php", query, (transport) => {
if (callback) {
callback(transport);
} else if (App.isPrefs()) {
updateLabelList();
} else {
Feeds.reload();
}
});
}
}
function createNewRuleElement(parentNode, replaceNode) { function createNewRuleElement(parentNode, replaceNode) {
const form = document.forms["filter_new_rule_form"]; const form = document.forms["filter_new_rule_form"];
const query = { op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form) }; const query = { op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form) };

View File

@ -97,7 +97,7 @@ const App = {
CommonDialogs.quickAddFeed(); CommonDialogs.quickAddFeed();
return false; return false;
case "create_label": case "create_label":
addLabel(); CommonDialogs.addLabel();
return false; return false;
case "create_filter": case "create_filter":
quickAddFilter(); quickAddFilter();

View File

@ -421,7 +421,7 @@ const App = {
} }
}; };
this.hotkey_actions["create_label"] = function () { this.hotkey_actions["create_label"] = function () {
addLabel(); CommonDialogs.addLabel();
}; };
this.hotkey_actions["create_filter"] = function () { this.hotkey_actions["create_filter"] = function () {
quickAddFilter(); quickAddFilter();
@ -480,7 +480,7 @@ const App = {
onActionSelected: function(opid) { onActionSelected: function(opid) {
switch (opid) { switch (opid) {
case "qmcPrefs": case "qmcPrefs":
gotoPreferences(); document.location.href = "prefs.php";
break; break;
case "qmcLogout": case "qmcLogout":
document.location.href = "backend.php?op=logout"; document.location.href = "backend.php?op=logout";