filter edit dialog: add remove button

This commit is contained in:
Andrew Dolgov 2008-08-06 09:08:26 +01:00
parent ecace165c1
commit a44db887de
2 changed files with 34 additions and 68 deletions

View File

@ -38,74 +38,6 @@
$filter_types[$line["id"]] = __($line["description"]);
}
/* print "<table width='100%'>";
print "<tr><td>".__('Match:')."</td>
<td><input onkeypress=\"return filterCR(event, filterEditSave)\"
onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
name=\"reg_exp\" class=\"iedit\" value=\"$reg_exp\">";
print "</td></tr><tr><td>".__('On field:')."</td><td>";
print_select_hash("filter_type", $filter_type, $filter_types, "class=\"_iedit\"");
print "</td></tr>";
print "<tr><td>".__('Feed:')."</td><td colspan='2'>";
print_feed_select($link, "feed_id", $feed_id);
print "</td></tr>";
print "<tr><td>".__('Action:')."</td>";
print "<td colspan='2'><select name=\"action_id\"
onchange=\"filterDlgCheckAction(this)\">";
$result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
ORDER BY name");
while ($line = db_fetch_assoc($result)) {
$is_sel = ($line["id"] == $action_id) ? "selected" : "";
printf("<option value='%d' $is_sel>%s</option>", $line["id"], __($line["description"]));
}
print "</select>";
print "</td></tr>";
print "<tr><td>".__('Params:')."</td>";
$param_disabled = ($action_id == 4 || $action_id == 6) ? "" : "disabled";
print "<td><input $param_disabled class='iedit'
name=\"action_param\" value=\"$action_param\"></td></tr>";
if ($enabled) {
$checked = "checked";
} else {
$checked = "";
}
print "<tr><td valign='top'>Options:</td><td>
<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
<label for=\"enabled\">".__('Enabled')."</label><br/>";
if ($inverse) {
$checked = "checked";
} else {
$checked = "";
}
print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
<label for=\"inverse\">".__('Inverse match')."</label>";
print "</td></tr></table>";
print "</form>";
print "<hr>"; */
print "<div class=\"dlgSec\">".__("Match")."</div>";
print "<div class=\"dlgSecCont\">";
@ -188,6 +120,14 @@
type=\"submit\" onclick=\"return filterEditCancel()\"
value=\"".__('Cancel')."\">";
$reg_exp = htmlspecialchars($reg_exp); // second escaping seems to be needed for javascript
print "<div style=\"float : left\">";
print "<input type=\"submit\"
class=\"button\" onclick='return removeFilter($filter_id, \"$reg_exp\")'
value=\"".__('Remove')."\"> ";
print "</div>";
print "</div>";
return;

View File

@ -2156,3 +2156,29 @@ function rescore_all_feeds() {
xmlhttp.send(null);
}
}
function removeFilter(id, title) {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
var msg = __("Remove filter %s?").replace("%s", title);
var ok = confirm(msg);
if (ok) {
closeInfoBox();
notify_progress("Removing filter...");
xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
param_escape(id), true);
xmlhttp.onreadystatechange=filterlist_callback;
xmlhttp.send(null);
}
return false;
}