for the most part, deal with filter rules UI

This commit is contained in:
Andrew Dolgov 2021-02-21 09:35:07 +03:00
parent b4e96374bc
commit 94560132dd
12 changed files with 510 additions and 189 deletions

View File

@ -37,7 +37,18 @@ class Labels
} }
} }
static function get_all_labels($owner_uid) { static function get_as_hash($owner_uid) {
$rv = [];
$labels = Labels::get_all($owner_uid);
foreach ($labels as $i => $label) {
$rv[$label["id"]] = $labels[$i];
}
return $rv;
}
static function get_all($owner_uid) {
$rv = array(); $rv = array();
$pdo = Db::pdo(); $pdo = Db::pdo();
@ -46,7 +57,7 @@ class Labels
WHERE owner_uid = ? ORDER BY caption"); WHERE owner_uid = ? ORDER BY caption");
$sth->execute([$owner_uid]); $sth->execute([$owner_uid]);
while ($line = $sth->fetch()) { while ($line = $sth->fetch(PDO::FETCH_ASSOC)) {
array_push($rv, $line); array_push($rv, $line);
} }

View File

@ -318,6 +318,84 @@ class Pref_Filters extends Handler_Protected {
WHERE id = ? AND owner_uid = ?"); WHERE id = ? AND owner_uid = ?");
$sth->execute([$filter_id, $_SESSION['uid']]); $sth->execute([$filter_id, $_SESSION['uid']]);
if (empty($filter_id) || $row = $sth->fetch()) {
$rv = [
"id" => $filter_id,
"enabled" => $row["enabled"] ?? true,
"match_any_rule" => $row["match_any_rule"] ?? false,
"inverse" => $row["inverse"] ?? false,
"title" => $row["title"] ?? "",
"rules" => [],
"actions" => [],
"filter_types" => [],
"filter_actions" => [],
"labels" => Labels::get_all($_SESSION["uid"])
];
$res = $this->pdo->query("SELECT id,description
FROM ttrss_filter_types WHERE id != 5 ORDER BY description");
while ($line = $res->fetch()) {
$rv["filter_types"][$line["id"]] = __($line["description"]);
}
$res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions
ORDER BY name");
while ($line = $res->fetch()) {
$rv["filter_actions"][$line["id"]] = __($line["description"]);
}
if ($filter_id) {
$rules_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
WHERE filter_id = ? ORDER BY reg_exp, id");
$rules_sth->execute([$filter_id]);
while ($rrow = $rules_sth->fetch(PDO::FETCH_ASSOC)) {
if ($rrow["match_on"]) {
$rrow["feed_id"] = json_decode($rrow["match_on"], true);
} else {
if ($rrow["cat_filter"]) {
$feed_id = "CAT:" . (int)$rrow["cat_id"];
} else {
$feed_id = (int)$rrow["feed_id"];
}
$rrow["feed_id"] = ["" . $feed_id]; // set item type to string for in_array()
}
unset($rrow["cat_filter"]);
unset($rrow["cat_id"]);
unset($rrow["filter_id"]);
unset($rrow["id"]);
if (!$rrow["inverse"]) unset($rrow["inverse"]);
unset($rrow["match_on"]);
$rrow["name"] = $this->_get_rule_name($rrow);
array_push($rv["rules"], $rrow);
}
$actions_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
WHERE filter_id = ? ORDER BY id");
$actions_sth->execute([$filter_id]);
while ($arow = $actions_sth->fetch(PDO::FETCH_ASSOC)) {
$arow["action_param_label"] = $arow["action_param"];
unset($arow["filter_id"]);
unset($arow["id"]);
$arow["name"] = $this->_get_action_name($arow);
array_push($rv["actions"], $arow);
}
}
print json_encode($rv);
}
/*return;
if (empty($filter_id) || $row = $sth->fetch()) { if (empty($filter_id) || $row = $sth->fetch()) {
$enabled = $row["enabled"] ?? true; $enabled = $row["enabled"] ?? true;
@ -475,7 +553,7 @@ class Pref_Filters extends Handler_Protected {
} }
print "</footer></form>"; print "</footer></form>";
} } */
} }
private function _get_rule_name($rule) { private function _get_rule_name($rule) {
@ -592,8 +670,7 @@ class Pref_Filters extends Handler_Protected {
$sth->execute(array_merge($ids, [$_SESSION['uid']])); $sth->execute(array_merge($ids, [$_SESSION['uid']]));
} }
private function _save_rules_and_actions($filter_id) private function _save_rules_and_actions($filter_id) {
{
$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?"); $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?");
$sth->execute([$filter_id]); $sth->execute([$filter_id]);
@ -764,7 +841,15 @@ class Pref_Filters extends Handler_Protected {
<?php <?php
} }
function newrule() { function editrule() {
$feed_ids = explode(",", clean($_REQUEST["ids"]));
print json_encode([
"multiselect" => $this->feed_multi_select("feed_id", $feed_ids, 'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"')
]);
/*return;
$rule = json_decode(clean($_REQUEST["rule"]), true); $rule = json_decode(clean($_REQUEST["rule"]), true);
if ($rule) { if ($rule) {
@ -818,7 +903,7 @@ class Pref_Filters extends Handler_Protected {
print "<fieldset>"; print "<fieldset>";
print "<span id='filterDlg_feeds'>"; print "<span id='filterDlg_feeds'>";
$this->feed_multi_select("feed_id", print $this->feed_multi_select("feed_id",
$feed_id, $feed_id,
'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"'); 'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"');
print "</span>"; print "</span>";
@ -840,7 +925,7 @@ class Pref_Filters extends Handler_Protected {
print "</footer>"; print "</footer>";
print "</form>"; print "</form>";*/
} }
function newaction() { function newaction() {
@ -1073,13 +1158,15 @@ class Pref_Filters extends Handler_Protected {
$pdo = Db::pdo(); $pdo = Db::pdo();
$rv = "";
// print_r(in_array("CAT:6",$default_ids)); // print_r(in_array("CAT:6",$default_ids));
if (!$root_id) { if (!$root_id) {
print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>"; $rv .= "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>";
if ($include_all_feeds) { if ($include_all_feeds) {
$is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : ""; $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : "";
print "<option $is_selected value=\"0\">".__('All feeds')."</option>"; $rv .= "<option $is_selected value=\"0\">".__('All feeds')."</option>";
} }
} }
@ -1103,11 +1190,11 @@ class Pref_Filters extends Handler_Protected {
$is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : "";
printf("<option $is_selected value='CAT:%d'>%s</option>", $rv .= sprintf("<option $is_selected value='CAT:%d'>%s</option>",
$line["id"], htmlspecialchars($line["title"])); $line["id"], htmlspecialchars($line["title"]));
if ($line["num_children"] > 0) if ($line["num_children"] > 0)
$this->feed_multi_select($id, $default_ids, $attributes, $rv .= $this->feed_multi_select($id, $default_ids, $attributes,
$include_all_feeds, $line["id"], $nest_level+1); $include_all_feeds, $line["id"], $nest_level+1);
$f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
@ -1123,7 +1210,7 @@ class Pref_Filters extends Handler_Protected {
for ($i = 0; $i < $nest_level; $i++) for ($i = 0; $i < $nest_level; $i++)
$fline["title"] = "" . $fline["title"]; $fline["title"] = "" . $fline["title"];
printf("<option $is_selected value='%d'>%s</option>", $rv .= sprintf("<option $is_selected value='%d'>%s</option>",
$fline["id"], htmlspecialchars($fline["title"])); $fline["id"], htmlspecialchars($fline["title"]));
} }
} }
@ -1131,7 +1218,7 @@ class Pref_Filters extends Handler_Protected {
if (!$root_id) { if (!$root_id) {
$is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : ""; $is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : "";
printf("<option $is_selected value='CAT:0'>%s</option>", $rv .= sprintf("<option $is_selected value='CAT:0'>%s</option>",
__("Uncategorized")); __("Uncategorized"));
$f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
@ -1146,7 +1233,7 @@ class Pref_Filters extends Handler_Protected {
for ($i = 0; $i < $nest_level; $i++) for ($i = 0; $i < $nest_level; $i++)
$fline["title"] = "" . $fline["title"]; $fline["title"] = "" . $fline["title"];
printf("<option $is_selected value='%d'>%s</option>", $rv .= sprintf("<option $is_selected value='%d'>%s</option>",
$fline["id"], htmlspecialchars($fline["title"])); $fline["id"], htmlspecialchars($fline["title"]));
} }
} }
@ -1160,13 +1247,15 @@ class Pref_Filters extends Handler_Protected {
$is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : ""; $is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : "";
printf("<option $is_selected value='%d'>%s</option>", $rv .= sprintf("<option $is_selected value='%d'>%s</option>",
$line["id"], htmlspecialchars($line["title"])); $line["id"], htmlspecialchars($line["title"]));
} }
} }
if (!$root_id) { if (!$root_id) {
print "</select>"; $rv .= "</select>";
} }
return $rv;
} }
} }

View File

@ -399,7 +399,7 @@ class RPC extends Handler_Protected {
$params["icon_indicator_white"] = $this->image_to_base64("images/indicator_white.gif"); $params["icon_indicator_white"] = $this->image_to_base64("images/indicator_white.gif");
$params["labels"] = Labels::get_all_labels($_SESSION["uid"]); $params["labels"] = Labels::get_all($_SESSION["uid"]);
return $params; return $params;
} }
@ -430,7 +430,7 @@ class RPC extends Handler_Protected {
$data["max_feed_id"] = (int) $max_feed_id; $data["max_feed_id"] = (int) $max_feed_id;
$data["num_feeds"] = (int) $num_feeds; $data["num_feeds"] = (int) $num_feeds;
$data['cdm_expanded'] = get_pref('CDM_EXPANDED'); $data['cdm_expanded'] = get_pref('CDM_EXPANDED');
$data["labels"] = Labels::get_all_labels($_SESSION["uid"]); $data["labels"] = Labels::get_all($_SESSION["uid"]);
if (LOG_DESTINATION == 'sql' && $_SESSION['access_level'] >= 10) { if (LOG_DESTINATION == 'sql' && $_SESSION['access_level'] >= 10) {
if (DB_TYPE == 'pgsql') { if (DB_TYPE == 'pgsql') {

View File

@ -60,21 +60,11 @@
return $rv; return $rv;
} }
function select_labels(string $name, string $value, array $attributes = [], string $id = "") { /*function select_labels(string $name, string $value, array $attributes = [], string $id = "") {
$pdo = \Db::pdo(); $values = \Labels::get_as_hash($_SESSION["uid"]);
$sth = $pdo->prepare("SELECT caption FROM ttrss_labels2
WHERE owner_uid = ? ORDER BY caption");
$sth->execute([$_SESSION['uid']]);
$values = [];
while ($row = $sth->fetch()) {
array_push($values, $row["caption"]);
}
return select_tag($name, $value, $values, $attributes, $id); return select_tag($name, $value, $values, $attributes, $id);
} }*/
function select_hash(string $name, $value, array $values, array $attributes = [], string $id = "") { function select_hash(string $name, $value, array $values, array $attributes = [], string $id = "") {
$attributes_str = attributes_to_string($attributes); $attributes_str = attributes_to_string($attributes);

View File

@ -7,26 +7,17 @@
/* exported Filters */ /* exported Filters */
const Filters = { const Filters = {
edit: function(id) { // if no id, new filter dialog edit: function(filter_id = null) { // if no id, new filter dialog
let query;
if (!App.isPrefs()) {
query = {
op: "pref-filters", method: "edit",
feed: Feeds.getActive(), is_cat: Feeds.activeIsCat()
};
} else {
query = {op: "pref-filters", method: "edit", id: id};
}
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
id: "filterEditDlg", id: "filterEditDlg",
title: id ? __("Edit Filter") : __("Create Filter"), title: filter_id ? __("Edit Filter") : __("Create Filter"),
ACTION_TAG: 4, ACTION_TAG: 4,
ACTION_SCORE: 6, ACTION_SCORE: 6,
ACTION_LABEL: 7, ACTION_LABEL: 7,
ACTION_PLUGIN: 9, ACTION_PLUGIN: 9,
PARAM_ACTIONS: [4, 6, 7, 9], PARAM_ACTIONS: [4, 6, 7, 9],
filter_info: {},
test: function() { test: function() {
const test_dialog = new fox.SingleUseDialog({ const test_dialog = new fox.SingleUseDialog({
title: "Test Filter", title: "Test Filter",
@ -116,16 +107,17 @@ const Filters = {
test_dialog.show(); test_dialog.show();
}, },
createNewRuleElement: function(parentNode, replaceNode) { insertRule: function(parentNode, replaceNode) {
const rule = dojo.formToJson("filter_new_rule_form"); const rule = dojo.formToJson("filter_new_rule_form");
xhr.post("backend.php", {op: "pref-filters", method: "printrulename", rule: rule}, (reply) => { xhr.post("backend.php", {op: "pref-filters", method: "printrulename", rule: rule}, (reply) => {
try { try {
const li = document.createElement('li'); const li = document.createElement('li');
li.addClassName("rule");
li.innerHTML = `<input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'> li.innerHTML = `${App.FormFields.checkbox_tag("", false, {onclick: 'Lists.onRowChecked(this)'})}
<span onclick='App.dialogOf(this).onRuleClicked(this)'>${reply}</span> <span class="name" onclick='App.dialogOf(this).onRuleClicked(this)'>${reply}</span>
${App.FormFields.hidden_tag("rule[]", rule)}`; <span class="payload" >${App.FormFields.hidden_tag("rule[]", rule)}</span>`;
dojo.parser.parse(li); dojo.parser.parse(li);
@ -139,7 +131,7 @@ const Filters = {
} }
}); });
}, },
createNewActionElement: function(parentNode, replaceNode) { insertAction: function(parentNode, replaceNode) {
const form = document.forms["filter_new_action_form"]; const form = document.forms["filter_new_action_form"];
if (form.action_id.value == 7) { if (form.action_id.value == 7) {
@ -153,10 +145,11 @@ const Filters = {
xhr.post("backend.php", { op: "pref-filters", method: "printactionname", action: action }, (reply) => { xhr.post("backend.php", { op: "pref-filters", method: "printactionname", action: action }, (reply) => {
try { try {
const li = document.createElement('li'); const li = document.createElement('li');
li.addClassName("action");
li.innerHTML = `<input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'> li.innerHTML = `${App.FormFields.checkbox_tag("", false, {onclick: 'Lists.onRowChecked(this)'})}
<span onclick='App.dialogOf(this).onActionClicked(this)'>${reply}</span> <span class="name" onclick='App.dialogOf(this).onActionClicked(this)'>${reply}</span>
${App.FormFields.hidden_tag("action[]", action)}`; <span class="payload">${App.FormFields.hidden_tag("action[]", action)}</span>`;
dojo.parser.parse(li); dojo.parser.parse(li);
@ -171,30 +164,84 @@ const Filters = {
} }
}); });
}, },
editRule: function(replaceNode, ruleStr) { editRule: function(replaceNode, ruleStr = null) {
const edit_rule_dialog = new fox.SingleUseDialog({ const edit_rule_dialog = new fox.SingleUseDialog({
id: "filterNewRuleDlg", id: "filterNewRuleDlg",
title: ruleStr ? __("Edit rule") : __("Add rule"), title: ruleStr ? __("Edit rule") : __("Add rule"),
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
dialog.createNewRuleElement(App.byId("filterDlg_Matches"), replaceNode); dialog.insertRule(App.byId("filterDlg_Matches"), replaceNode);
this.hide(); this.hide();
} }
}, },
content: __('Loading, please wait...'), content: __('Loading, please wait...'),
}); });
const tmph = dojo.connect(edit_rule_dialog, "onShow", null, function (/* e */) { const tmph = dojo.connect(edit_rule_dialog, "onShow", null, function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhr.post("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (reply) => { let rule;
edit_rule_dialog.attr('content', reply);
if (ruleStr) {
rule = JSON.parse(ruleStr);
} else {
rule = {
reg_exp: "",
filter_type: 1,
feed_id: ["0"],
inverse: false,
};
}
console.log(rule, dialog.filter_info);
xhr.json("backend.php", {op: "pref-filters", method: "editrule", ids: rule.feed_id.join(",")}, function (editrule) {
edit_rule_dialog.attr('content',
`
<form name="filter_new_rule_form" id="filter_new_rule_form" onsubmit="return false">
<section>
<textarea dojoType="fox.form.ValidationTextArea"
required="true" id="filterDlg_regExp" ValidRegExp="true"
rows="4" style="font-size : 14px; width : 530px; word-break: break-all"
name="reg_exp">${rule.reg_exp}</textarea>
<div dojoType="dijit.Tooltip" id="filterDlg_regExp_tip" connectId="filterDlg_regExp" position="below"></div>
<fieldset>
<label class="checkbox">".
${App.FormFields.checkbox_tag("inverse", rule.inverse)}
${__("Inverse regular expression matching")}
</label>
</fieldset>
<fieldset>
<label style="display : inline">${__("on field")}</label>
${App.FormFields.select_hash("filter_type", rule.filter_type, dialog.filter_info.filter_types)}
<label style="padding-left : 10px; display : inline">${__("in")}</label>
</fieldset>
<fieldset>
<span id="filterDlg_feeds">
${editrule.multiselect}
</span>
</fieldset>
</section>
<footer>
${App.FormFields.button_tag(App.FormFields.icon("help") + " " + __("More info"), "", {class: 'pull-left alt-info',
onclick: "window.open('https://tt-rss.org/wiki/ContentFilters')"})}
${App.FormFields.submit_tag(__("Save rule"), {onclick: "App.dialogOf(this).execute()"})}
${App.FormFields.cancel_dialog_tag(__("Cancel"))}
</footer>
</form>
`);
}); });
}); });
edit_rule_dialog.show(); edit_rule_dialog.show();
}, },
editAction: function(replaceNode, actionStr) { /*editAction: function(replaceNode, actionStr) {
const edit_action_dialog = new fox.SingleUseDialog({ const edit_action_dialog = new fox.SingleUseDialog({
title: actionStr ? __("Edit action") : __("Add action"), title: actionStr ? __("Edit action") : __("Add action"),
hideOrShowActionParam: function(sender) { hideOrShowActionParam: function(sender) {
@ -221,7 +268,7 @@ const Filters = {
} }
}); });
const tmph = dojo.connect(edit_action_dialog, "onShow", null, function (/* e */) { const tmph = dojo.connect(edit_action_dialog, "onShow", null, function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhr.post("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (reply) => { xhr.post("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (reply) => {
@ -234,22 +281,65 @@ const Filters = {
}); });
edit_action_dialog.show(); edit_action_dialog.show();
}, */
/*editAction: function(replaceNode, actionStr) {
const edit_action_dialog = new fox.SingleUseDialog({
title: actionStr ? __("Edit action") : __("Add action"),
hideOrShowActionParam: function(sender) {
const action = parseInt(sender.value);
dijit.byId("filterDlg_actionParam").domNode.hide();
dijit.byId("filterDlg_actionParamLabel").domNode.hide();
dijit.byId("filterDlg_actionParamPlugin").domNode.hide();
// if selected action supports parameters, enable params field
if (action == dialog.ACTION_LABEL) {
dijit.byId("filterDlg_actionParamLabel").domNode.show();
} else if (action == dialog.ACTION_PLUGIN) {
dijit.byId("filterDlg_actionParamPlugin").domNode.show();
} else if (dialog.PARAM_ACTIONS.indexOf(action) != -1) {
dijit.byId("filterDlg_actionParam").domNode.show();
}
}, },
execute: function () {
if (this.validate()) {
dialog.createNewActionElement(App.byId("filterDlg_Actions"), replaceNode);
this.hide();
}
}
});
const tmph = dojo.connect(edit_action_dialog, "onShow", null, function () {
dojo.disconnect(tmph);
xhr.post("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (reply) => {
edit_action_dialog.attr('content', reply);
setTimeout(() => {
edit_action_dialog.hideOrShowActionParam(dijit.byId("filterDlg_actionSelect").attr('value'));
}, 250);
});
});
edit_action_dialog.show();
},*/
selectRules: function (select) { selectRules: function (select) {
Lists.select("filterDlg_Matches", select); Lists.select("filterDlg_Matches", select);
}, },
selectActions: function (select) { selectActions: function (select) {
Lists.select("filterDlg_Actions", select); Lists.select("filterDlg_Actions", select);
}, },
onRuleClicked: function (e) { onRuleClicked: function (elem) {
const li = e.closest('li');
const rule = li.querySelector('input[name="rule[]"]').value const li = elem.closest('li');
const rule = li.querySelector('input[name="rule[]"]').value;
this.editRule(li, rule); this.editRule(li, rule);
}, },
onActionClicked: function (e) { onActionClicked: function (elem) {
const li = e.closest('li');
const action = li.querySelector('input[name="action[]"]').value const li = elem.closest('li');
const action = li.querySelector('input[name="action[]"]').value;
this.editAction(li, action); this.editAction(li, action);
}, },
@ -302,13 +392,141 @@ const Filters = {
content: __("Loading, please wait...") content: __("Loading, please wait...")
}); });
const tmph = dojo.connect(dialog, 'onShow', function () { const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhr.post("backend.php", query, function (reply) { const query = {op: "pref-filters", method: "edit", id: filter_id};
dialog.attr('content', reply);
/*if (!App.isPrefs()) {
query = {
op: "pref-filters", method: "edit",
feed: Feeds.getActive(), is_cat: Feeds.activeIsCat()
};
} else {
query = {op: "pref-filters", method: "edit", id: id};
}*/
xhr.json("backend.php", query, function (filter) {
dialog.filter_info = filter;
const options = {
enabled: [ filter.enabled, __('Enabled') ],
match_any_rule: [ filter.match_any_rule, __('Match any rule') ],
inverse: [ filter.inverse, __('Inverse matching') ],
};
dialog.attr('content',
`
<form onsubmit='return false'>
${App.FormFields.hidden_tag("op", "pref-filters")}
${App.FormFields.hidden_tag("id", filter_id)}
${App.FormFields.hidden_tag("method", filter_id ? "editSave" : "add")}
${App.FormFields.hidden_tag("csrf_token", App.getInitParam('csrf_token'))}
<section>
<input required="true" dojoType="dijit.form.ValidationTextBox" style="width : 530px"
placeholder="${__("Title")}" name="title" value="${App.escapeHtml(filter.title)}">
</section>
<div dojoType="dijit.layout.TabContainer" style="height : 300px">
<div dojoType="dijit.layout.ContentPane" title="${__('Match')}">
<div style="padding : 0" dojoType="dijit.layout.BorderContainer" gutters="false">
<div dojoType="fox.Toolbar" region="top">
<div dojoType="fox.form.DropDownButton">
<span>${__("Select")}</span>
<div dojoType="dijit.Menu" style="display: none;">
<!-- can"t use App.dialogOf() here because DropDownButton is not a child of the Dialog -->
<div onclick="dijit.byId('filterEditDlg').selectRules(true)"
dojoType="dijit.MenuItem">${__("All")}</div>
<div onclick="dijit.byId('filterEditDlg').selectRules(false)"
dojoType="dijit.MenuItem">${__("None")}</div>
</div>
</div>
<button dojoType="dijit.form.Button" onclick="App.dialogOf(this).addRule()">
${__("Add")}
</button>
<button dojoType="dijit.form.Button" onclick="App.dialogOf(this).deleteRule()">
${__("Delete")}
</button>
</div>
<div dojoType="dijit.layout.ContentPane" region="center">
<ul id="filterDlg_Matches">
${filter.rules.map((rule) => `
<li class='rule'>
${App.FormFields.checkbox_tag("", false, "", {onclick: 'Lists.onRowChecked(this)'})}
<span class='name' onclick='App.dialogOf(this).onRuleClicked(this)'>${rule.name}</span>
<span class='payload'>${App.FormFields.hidden_tag("rule[]", JSON.stringify(rule))}</span>
</li>
`).join("")}
</ul>
</div>
</div>
</div>
<div dojoType="dijit.layout.ContentPane" title="${__('Apply actions')}">
<div style="padding : 0" dojoType="dijit.layout.BorderContainer" gutters="false">
<div dojoType="fox.Toolbar" region="top">
<div dojoType="fox.form.DropDownButton">
<span>${__("Select")}</span>
<div dojoType="dijit.Menu" style="display: none">
<div onclick="dijit.byId('filterEditDlg').selectActions(true)"
dojoType="dijit.MenuItem">${__("All")}</div>
<div onclick="dijit.byId('filterEditDlg').selectActions(false)"
dojoType="dijit.MenuItem">${__("None")}</div>
</div>
</div>
<button dojoType="dijit.form.Button" onclick="App.dialogOf(this).addAction()">".
${__("Add")}
</button>
<button dojoType="dijit.form.Button" onclick="App.dialogOf(this).deleteAction()">".
${__("Delete")}
</button>
</div>
<div dojoType="dijit.layout.ContentPane" region="center">
<ul id="filterDlg_Actions">
${filter.actions.map((action) => `
<li class='rule'>
${App.FormFields.checkbox_tag("", false, "", {onclick: 'Lists.onRowChecked(this)'})}
<span class='name' onclick='App.dialogOf(this).onRuleClicked(this)'>${App.escapeHtml(action.name)}</span>
<span class='payload'>${App.FormFields.hidden_tag("action[]", JSON.stringify(action))}</span>
</li>
`).join("")}
</ul>
</div>
</div>
</div>
</div>
<br/>
<section class="narrow">
${Object.keys(options).map((name) =>
`
<fieldset class='narrow'>
<label class="checkbox">
${App.FormFields.checkbox_tag(name, options[name][0])}
${options[name][1]}
</label>
</fieldset>
`).join("")}
</section>
<footer>
${filter_id ?
`
${App.FormFields.button_tag(__("Remove"), "", {class: "pull-left alt-danger", onclick: "App.dialogOf(this).removeFilter()"})}
${App.FormFields.button_tag(__("Test"), "", {class: "alt-info", onclick: "App.dialogOf(this).test()"})}
${App.FormFields.submit_tag(__("Save"), {onclick: "App.dialogOf(this).execute()"})}
${App.FormFields.cancel_dialog_tag(__("Cancel"))}
` : `
${App.FormFields.button_tag(__("Test"), "", {class: "alt-info", onclick: "App.dialogOf(this).test()"})}
${App.FormFields.submit_tag(__("Create"), {onclick: "App.dialogOf(this).execute()"})}
${App.FormFields.cancel_dialog_tag(__("Cancel"))}
`}
</footer>
</form>
`);
if (!App.isPrefs()) { if (!App.isPrefs()) {
const selectedText = App.getSelectedText(); const selectedText = App.getSelectedText();

View File

@ -19,6 +19,7 @@ class Auto_Assign_Labels extends Plugin {
function get_all_labels_filter_format($owner_uid) { function get_all_labels_filter_format($owner_uid) {
$rv = array(); $rv = array();
// TODO: use Labels::get_all()
$sth = $this->pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = ?"); $sth = $this->pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = ?");
$sth->execute([$owner_uid]); $sth->execute([$owner_uid]);

View File

@ -822,16 +822,18 @@ body.ttrss_main #headlines-spacer a:hover {
} }
body.ttrss_main ul#filterDlg_Matches, body.ttrss_main ul#filterDlg_Matches,
body.ttrss_main ul#filterDlg_Actions { body.ttrss_main ul#filterDlg_Actions {
max-height: 100px;
overflow: auto;
list-style-type: none; list-style-type: none;
margin: 0;
padding: 0;
/*max-height : 100px;
overflow : auto;
border-style : solid; border-style : solid;
border-color: #ddd; border-color : @border-default;
border-width : 1px 1px 1px 1px; border-width : 1px 1px 1px 1px;
background-color: white; background-color : @default-bg;
margin : 0px 0px 5px 0px; margin : 0px 0px 5px 0px;
padding : 4px; padding : 4px;
min-height: 16px; min-height : 16px;*/
} }
body.ttrss_main ul#filterDlg_Matches li, body.ttrss_main ul#filterDlg_Matches li,
body.ttrss_main ul#filterDlg_Actions li { body.ttrss_main ul#filterDlg_Actions li {

View File

@ -822,16 +822,18 @@ body.ttrss_main #headlines-spacer a:hover {
} }
body.ttrss_main ul#filterDlg_Matches, body.ttrss_main ul#filterDlg_Matches,
body.ttrss_main ul#filterDlg_Actions { body.ttrss_main ul#filterDlg_Actions {
max-height: 100px;
overflow: auto;
list-style-type: none; list-style-type: none;
margin: 0;
padding: 0;
/*max-height : 100px;
overflow : auto;
border-style : solid; border-style : solid;
border-color: #222; border-color : @border-default;
border-width : 1px 1px 1px 1px; border-width : 1px 1px 1px 1px;
background-color: #333; background-color : @default-bg;
margin : 0px 0px 5px 0px; margin : 0px 0px 5px 0px;
padding : 4px; padding : 4px;
min-height: 16px; min-height : 16px;*/
} }
body.ttrss_main ul#filterDlg_Matches li, body.ttrss_main ul#filterDlg_Matches li,
body.ttrss_main ul#filterDlg_Actions li { body.ttrss_main ul#filterDlg_Actions li {

View File

@ -822,16 +822,18 @@ body.ttrss_main #headlines-spacer a:hover {
} }
body.ttrss_main ul#filterDlg_Matches, body.ttrss_main ul#filterDlg_Matches,
body.ttrss_main ul#filterDlg_Actions { body.ttrss_main ul#filterDlg_Actions {
max-height: 100px;
overflow: auto;
list-style-type: none; list-style-type: none;
margin: 0;
padding: 0;
/*max-height : 100px;
overflow : auto;
border-style : solid; border-style : solid;
border-color: #ddd; border-color : @border-default;
border-width : 1px 1px 1px 1px; border-width : 1px 1px 1px 1px;
background-color: white; background-color : @default-bg;
margin : 0px 0px 5px 0px; margin : 0px 0px 5px 0px;
padding : 4px; padding : 4px;
min-height: 16px; min-height : 16px;*/
} }
body.ttrss_main ul#filterDlg_Matches li, body.ttrss_main ul#filterDlg_Matches li,
body.ttrss_main ul#filterDlg_Actions li { body.ttrss_main ul#filterDlg_Actions li {

View File

@ -955,16 +955,18 @@ body.ttrss_main {
} }
ul#filterDlg_Matches, ul#filterDlg_Actions { ul#filterDlg_Matches, ul#filterDlg_Actions {
max-height : 100px;
overflow : auto;
list-style-type : none; list-style-type : none;
margin : 0;
padding: 0;
/*max-height : 100px;
overflow : auto;
border-style : solid; border-style : solid;
border-color : @border-default; border-color : @border-default;
border-width : 1px 1px 1px 1px; border-width : 1px 1px 1px 1px;
background-color : @default-bg; background-color : @default-bg;
margin : 0px 0px 5px 0px; margin : 0px 0px 5px 0px;
padding : 4px; padding : 4px;
min-height : 16px; min-height : 16px;*/
} }
ul#filterDlg_Matches li, ul#filterDlg_Actions li { ul#filterDlg_Matches li, ul#filterDlg_Actions li {

View File

@ -823,16 +823,18 @@ body.ttrss_main #headlines-spacer a:hover {
} }
body.ttrss_main ul#filterDlg_Matches, body.ttrss_main ul#filterDlg_Matches,
body.ttrss_main ul#filterDlg_Actions { body.ttrss_main ul#filterDlg_Actions {
max-height: 100px;
overflow: auto;
list-style-type: none; list-style-type: none;
margin: 0;
padding: 0;
/*max-height : 100px;
overflow : auto;
border-style : solid; border-style : solid;
border-color: #222; border-color : @border-default;
border-width : 1px 1px 1px 1px; border-width : 1px 1px 1px 1px;
background-color: #333; background-color : @default-bg;
margin : 0px 0px 5px 0px; margin : 0px 0px 5px 0px;
padding : 4px; padding : 4px;
min-height: 16px; min-height : 16px;*/
} }
body.ttrss_main ul#filterDlg_Matches li, body.ttrss_main ul#filterDlg_Matches li,
body.ttrss_main ul#filterDlg_Actions li { body.ttrss_main ul#filterDlg_Actions li {

View File

@ -823,16 +823,18 @@ body.ttrss_main #headlines-spacer a:hover {
} }
body.ttrss_main ul#filterDlg_Matches, body.ttrss_main ul#filterDlg_Matches,
body.ttrss_main ul#filterDlg_Actions { body.ttrss_main ul#filterDlg_Actions {
max-height: 100px;
overflow: auto;
list-style-type: none; list-style-type: none;
margin: 0;
padding: 0;
/*max-height : 100px;
overflow : auto;
border-style : solid; border-style : solid;
border-color: #222; border-color : @border-default;
border-width : 1px 1px 1px 1px; border-width : 1px 1px 1px 1px;
background-color: #333; background-color : @default-bg;
margin : 0px 0px 5px 0px; margin : 0px 0px 5px 0px;
padding : 4px; padding : 4px;
min-height: 16px; min-height : 16px;*/
} }
body.ttrss_main ul#filterDlg_Matches li, body.ttrss_main ul#filterDlg_Matches li,
body.ttrss_main ul#filterDlg_Actions li { body.ttrss_main ul#filterDlg_Actions li {