mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 23:25:56 +00:00
* filters: remove duplicate code, overall cleanup
* check if some tres exist before trying to reload them
This commit is contained in:
@@ -134,85 +134,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
|
||||
|
||||
this.editFilter(rows[0]);
|
||||
},
|
||||
editFilter: function(id) {
|
||||
|
||||
const query = "backend.php?op=pref-filters&method=edit&id=" + encodeURIComponent(id);
|
||||
|
||||
if (dijit.byId("feedEditDlg"))
|
||||
dijit.byId("feedEditDlg").destroyRecursive();
|
||||
|
||||
if (dijit.byId("filterEditDlg"))
|
||||
dijit.byId("filterEditDlg").destroyRecursive();
|
||||
|
||||
const dialog = new dijit.Dialog({
|
||||
id: "filterEditDlg",
|
||||
title: __("Edit Filter"),
|
||||
test: function () {
|
||||
Filters.editFilterTest(dojo.formToObject("filter_edit_form"));
|
||||
},
|
||||
selectRules: function (select) {
|
||||
Lists.select("filterDlg_Matches", select);
|
||||
},
|
||||
selectActions: function (select) {
|
||||
Lists.select("filterDlg_Actions", select);
|
||||
},
|
||||
editRule: function (e) {
|
||||
const li = e.parentNode;
|
||||
const rule = li.getElementsByTagName("INPUT")[1].value;
|
||||
Filters.addFilterRule(li, rule);
|
||||
},
|
||||
editAction: function (e) {
|
||||
const li = e.parentNode;
|
||||
const action = li.getElementsByTagName("INPUT")[1].value;
|
||||
Filters.addFilterAction(li, action);
|
||||
},
|
||||
removeFilter: function () {
|
||||
const msg = __("Remove filter?");
|
||||
|
||||
if (confirm(msg)) {
|
||||
this.hide();
|
||||
|
||||
Notify.progress("Removing filter...");
|
||||
|
||||
const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id};
|
||||
|
||||
xhrPost("backend.php", query, () => {
|
||||
dijit.byId("filterTree").reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
addAction: function () {
|
||||
Filters.addFilterAction();
|
||||
},
|
||||
addRule: function () {
|
||||
Filters.addFilterRule();
|
||||
},
|
||||
deleteAction: function () {
|
||||
$$("#filterDlg_Actions li[class*=Selected]").each(function (e) {
|
||||
e.parentNode.removeChild(e)
|
||||
});
|
||||
},
|
||||
deleteRule: function () {
|
||||
$$("#filterDlg_Matches li[class*=Selected]").each(function (e) {
|
||||
e.parentNode.removeChild(e)
|
||||
});
|
||||
},
|
||||
execute: function () {
|
||||
if (this.validate()) {
|
||||
|
||||
Notify.progress("Saving data...", true);
|
||||
|
||||
xhrPost("backend.php", dojo.formToObject("filter_edit_form"), () => {
|
||||
dialog.hide();
|
||||
dijit.byId("filterTree").reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
href: query
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
},
|
||||
removeSelectedFilters: function() {
|
||||
const sel_rows = this.getSelectedFilters();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user