mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-19 21:01:33 +00:00
embed some pref-feed helper functions into the tree
This commit is contained in:
@@ -109,6 +109,213 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
|
||||
(id.match("root") && position == "over"));
|
||||
}
|
||||
},
|
||||
resetFeedOrder: function() {
|
||||
notify_progress("Loading, please wait...");
|
||||
|
||||
xhrPost("backend.php", {op: "pref-feeds", method: "feedsortreset"}, () => {
|
||||
updateFeedList();
|
||||
});
|
||||
},
|
||||
resetCatOrder: function() {
|
||||
notify_progress("Loading, please wait...");
|
||||
|
||||
xhrPost("backend.php", {op: "pref-feeds", method: "catsortreset"}, () => {
|
||||
updateFeedList();
|
||||
});
|
||||
},
|
||||
removeSelectedFeeds: function() {
|
||||
const sel_rows = this.getSelectedFeeds();
|
||||
|
||||
if (sel_rows.length > 0) {
|
||||
if (confirm(__("Unsubscribe from selected feeds?"))) {
|
||||
|
||||
notify_progress("Unsubscribing from selected feeds...", true);
|
||||
|
||||
const query = {
|
||||
op: "pref-feeds", method: "remove",
|
||||
ids: sel_rows.toString()
|
||||
};
|
||||
|
||||
xhrPost("backend.php", query, () => {
|
||||
updateFeedList();
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
alert(__("No feeds are selected."));
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
getSelectedCategories: function() {
|
||||
const tree = this;
|
||||
const items = tree.model.getCheckedItems();
|
||||
const rv = [];
|
||||
|
||||
items.each(function (item) {
|
||||
if (item.id[0].match("CAT:"))
|
||||
rv.push(tree.model.store.getValue(item, 'bare_id'));
|
||||
});
|
||||
|
||||
return rv;
|
||||
},
|
||||
removeSelectedCategories: function() {
|
||||
const sel_rows = this.getSelectedCategories();
|
||||
|
||||
if (sel_rows.length > 0) {
|
||||
if (confirm(__("Remove selected categories?"))) {
|
||||
notify_progress("Removing selected categories...");
|
||||
|
||||
const query = {
|
||||
op: "pref-feeds", method: "removeCat",
|
||||
ids: sel_rows.toString()
|
||||
};
|
||||
|
||||
xhrPost("backend.php", query, () => {
|
||||
updateFeedList();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
alert(__("No categories are selected."));
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
getSelectedFeeds: function() {
|
||||
const tree = this;
|
||||
const items = tree.model.getCheckedItems();
|
||||
const rv = [];
|
||||
|
||||
items.each(function (item) {
|
||||
if (item.id[0].match("FEED:"))
|
||||
rv.push(tree.model.store.getValue(item, 'bare_id'));
|
||||
});
|
||||
|
||||
return rv;
|
||||
},
|
||||
editSelectedFeed: function() {
|
||||
const rows = this.getSelectedFeeds();
|
||||
|
||||
if (rows.length == 0) {
|
||||
alert(__("No feeds are selected."));
|
||||
return;
|
||||
}
|
||||
|
||||
notify("");
|
||||
|
||||
if (rows.length > 1) {
|
||||
return this.editMultiple();
|
||||
} else {
|
||||
CommonDialogs.editFeed(rows[0], {});
|
||||
}
|
||||
},
|
||||
editMultiple: function() {
|
||||
const rows = this.getSelectedFeeds();
|
||||
|
||||
if (rows.length == 0) {
|
||||
alert(__("No feeds are selected."));
|
||||
return;
|
||||
}
|
||||
|
||||
notify_progress("Loading, please wait...");
|
||||
|
||||
if (dijit.byId("feedEditDlg"))
|
||||
dijit.byId("feedEditDlg").destroyRecursive();
|
||||
|
||||
xhrPost("backend.php", {op: "pref-feeds", method: "editfeeds", ids: rows.toString()}, (transport) => {
|
||||
notify("");
|
||||
|
||||
const dialog = new dijit.Dialog({
|
||||
id: "feedEditDlg",
|
||||
title: __("Edit Multiple Feeds"),
|
||||
style: "width: 600px",
|
||||
getChildByName: function (name) {
|
||||
let rv = null;
|
||||
this.getChildren().each(
|
||||
function (child) {
|
||||
if (child.name == name) {
|
||||
rv = child;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return rv;
|
||||
},
|
||||
toggleField: function (checkbox, elem, label) {
|
||||
this.getChildByName(elem).attr('disabled', !checkbox.checked);
|
||||
|
||||
if ($(label))
|
||||
if (checkbox.checked)
|
||||
$(label).removeClassName('insensitive');
|
||||
else
|
||||
$(label).addClassName('insensitive');
|
||||
|
||||
},
|
||||
execute: function () {
|
||||
if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
|
||||
const query = this.attr('value');
|
||||
|
||||
/* normalize unchecked checkboxes because [] is not serialized */
|
||||
|
||||
Object.keys(query).each((key) => {
|
||||
let val = query[key];
|
||||
|
||||
if (typeof val == "object" && val.length == 0)
|
||||
query[key] = ["off"];
|
||||
});
|
||||
|
||||
notify_progress("Saving data...", true);
|
||||
|
||||
xhrPost("backend.php", query, () => {
|
||||
dialog.hide();
|
||||
updateFeedList();
|
||||
});
|
||||
}
|
||||
},
|
||||
content: transport.responseText
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
});
|
||||
},
|
||||
createCategory: function() {
|
||||
const title = prompt(__("Category title:"));
|
||||
|
||||
if (title) {
|
||||
notify_progress("Creating category...");
|
||||
|
||||
xhrPost("backend.php", {op: "pref-feeds", method: "addCat", cat: title}, () => {
|
||||
notify('');
|
||||
updateFeedList();
|
||||
});
|
||||
}
|
||||
},
|
||||
batchSubscribe: function() {
|
||||
const query = "backend.php?op=pref-feeds&method=batchSubscribe";
|
||||
|
||||
// overlapping widgets
|
||||
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
|
||||
if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
|
||||
|
||||
const dialog = new dijit.Dialog({
|
||||
id: "batchSubDlg",
|
||||
title: __("Batch subscribe"),
|
||||
style: "width: 600px",
|
||||
execute: function () {
|
||||
if (this.validate()) {
|
||||
notify_progress(__("Subscribing to feeds..."), true);
|
||||
|
||||
xhrPost("backend.php", this.attr('value'), () => {
|
||||
notify("");
|
||||
updateFeedList();
|
||||
dialog.hide();
|
||||
});
|
||||
}
|
||||
},
|
||||
href: query
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user