more filter stuff

This commit is contained in:
Andrew Dolgov 2021-02-20 21:48:05 +03:00
parent da97b29dbe
commit b4e96374bc
2 changed files with 32 additions and 35 deletions

View File

@ -860,7 +860,7 @@ class Pref_Filters extends Handler_Protected {
print "<section>"; print "<section>";
print "<select name='action_id' dojoType='fox.form.Select' print "<select id=\"filterDlg_actionSelect\" name='action_id' dojoType='fox.form.Select'
onchange='App.dialogOf(this).hideOrShowActionParam(this)'>"; onchange='App.dialogOf(this).hideOrShowActionParam(this)'>";
$res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions $res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions
@ -873,17 +873,17 @@ class Pref_Filters extends Handler_Protected {
print "</select>"; print "</select>";
$param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ? #$param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ?
"" : "display : none"; # "" : "display : none";
$param_hidden = ($action_id == 4 || $action_id == 6) ? #$param_hidden = ($action_id == 4 || $action_id == 6) ?
"" : "display : none"; # "" : "display : none";
$label_param_hidden = ($action_id == 7) ? "" : "display : none"; #$label_param_hidden = ($action_id == 7) ? "" : "display : none";
$plugin_param_hidden = ($action_id == 9) ? "" : "display : none"; #$plugin_param_hidden = ($action_id == 9) ? "" : "display : none";
print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">"; #print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">";
print " "; #print " ";
//print " " . __("with parameters:") . " "; //print " " . __("with parameters:") . " ";
print "<input dojoType='dijit.form.TextBox' print "<input dojoType='dijit.form.TextBox'
id='filterDlg_actionParam' style=\"$param_hidden\" id='filterDlg_actionParam' style=\"$param_hidden\"
@ -917,7 +917,7 @@ class Pref_Filters extends Handler_Protected {
array_merge(["style" => $plugin_param_hidden], $filter_plugin_disabled), array_merge(["style" => $plugin_param_hidden], $filter_plugin_disabled),
"filterDlg_actionParamPlugin"); "filterDlg_actionParamPlugin");
print "</span>"; #print "</span>";
print "&nbsp;"; // tiny layout hack print "&nbsp;"; // tiny layout hack

View File

@ -22,6 +22,11 @@ const Filters = {
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
id: "filterEditDlg", id: "filterEditDlg",
title: id ? __("Edit Filter") : __("Create Filter"), title: id ? __("Edit Filter") : __("Create Filter"),
ACTION_TAG: 4,
ACTION_SCORE: 6,
ACTION_LABEL: 7,
ACTION_PLUGIN: 9,
PARAM_ACTIONS: [4, 6, 7, 9],
test: function() { test: function() {
const test_dialog = new fox.SingleUseDialog({ const test_dialog = new fox.SingleUseDialog({
title: "Test Filter", title: "Test Filter",
@ -193,36 +198,21 @@ const Filters = {
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) {
const action = sender.value; const action = parseInt(sender.value);
const action_param = App.byId("filterDlg_paramBox"); dijit.byId("filterDlg_actionParam").domNode.hide();
dijit.byId("filterDlg_actionParamLabel").domNode.hide();
if (!action_param) { dijit.byId("filterDlg_actionParamPlugin").domNode.hide();
console.log("hideOrShowActionParam: can't find action param box!");
return;
}
// if selected action supports parameters, enable params field // if selected action supports parameters, enable params field
if (action == 4 || action == 6 || action == 7 || action == 9) { if (action == dialog.ACTION_LABEL) {
Element.show(action_param); dijit.byId("filterDlg_actionParamLabel").domNode.show();
} else if (action == dialog.ACTION_PLUGIN) {
Element.hide(dijit.byId("filterDlg_actionParam").domNode); dijit.byId("filterDlg_actionParamPlugin").domNode.show();
Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode); } else if (dialog.PARAM_ACTIONS.indexOf(action) != -1) {
Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode); dijit.byId("filterDlg_actionParam").domNode.show();
if (action == 7) {
Element.show(dijit.byId("filterDlg_actionParamLabel").domNode);
} else if (action == 9) {
Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode);
} else {
Element.show(dijit.byId("filterDlg_actionParam").domNode);
}
} else {
Element.hide(action_param);
} }
}, },
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
dialog.createNewActionElement(App.byId("filterDlg_Actions"), replaceNode); dialog.createNewActionElement(App.byId("filterDlg_Actions"), replaceNode);
@ -236,6 +226,10 @@ const Filters = {
xhr.post("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (reply) => { xhr.post("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (reply) => {
edit_action_dialog.attr('content', reply); edit_action_dialog.attr('content', reply);
setTimeout(() => {
edit_action_dialog.hideOrShowActionParam(dijit.byId("filterDlg_actionSelect").attr('value'));
}, 250);
}); });
}); });
@ -308,6 +302,8 @@ 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);
@ -345,6 +341,7 @@ const Filters = {
} }
}); });
}); });
dialog.show(); dialog.show();
}, },
}; };