From 899dc9a49bae23ea58edc8cc3084662d209fae36 Mon Sep 17 00:00:00 2001 From: jsatoh Date: Wed, 14 Dec 2011 04:11:34 +0000 Subject: [PATCH] 2011-12-14 Junichi Satoh * godmode/alerts/configure_alert_compound.php: Improved that actions can be removed in step 2. (Added delete button.) git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5256 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++++ .../alerts/configure_alert_compound.php | 28 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a0ee8910c4..d4a9ba8224 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2011-12-14 Junichi Satoh + + * godmode/alerts/configure_alert_compound.php: Improved that actions + can be removed in step 2. (Added delete button.) + 2011-12-13 Ramon Novoa * pandoradb_data.sql, diff --git a/pandora_console/godmode/alerts/configure_alert_compound.php b/pandora_console/godmode/alerts/configure_alert_compound.php index 8f38b63df9..d05e3a7b03 100644 --- a/pandora_console/godmode/alerts/configure_alert_compound.php +++ b/pandora_console/godmode/alerts/configure_alert_compound.php @@ -178,9 +178,16 @@ function update_compound ($step) { $result = alerts_update_alert_compound ($id, $values); /* Update actions */ - $actions = (array) get_parameter ('actions'); - - foreach ($actions as $id_action) { + $remove_actions = alerts_get_alert_compound_actions ($id); + $add_actions = (array) get_parameter ('actions'); + + if (!empty ($remove_actions)) { + foreach ($remove_actions as $key => $action) { + alerts_delete_alert_compound_action ($key); + } + } + + foreach ($add_actions as $id_action) { /* TODO: fires_min and fires_max missing */ alerts_add_alert_compound_action ($id, (int) $id_action); } @@ -425,7 +432,12 @@ if ($step == 2) { $table->data['actions'][1] .= __('From').' '.$action['fires_min']. ' '.__('to').' '.$action['fires_max']; } - $table->data['actions'][1] .= ')'; + $table->data['actions'][1] .= ')'; + $table->data['actions'][1] .= ''; + $table->data['actions'][1] .= html_print_image('images/cross.png', true, array("title" => __('Delete'))); + $table->data['actions'][1] .= ''; + $table->data['actions'][1] .= html_print_input_hidden ('actions[]', $action['id'], true); + $table->data['actions'][1] .= ''; } } $table->data['actions'][1] .= ''; @@ -726,6 +738,10 @@ function add_alert () { return false; } +function remove_action () { + $(this).parent ().remove (); +} + $(document).ready (function () { $("a.add_alert").click (add_alert); @@ -885,13 +901,15 @@ $(document).ready (function () { $("#button-add_action").click (function () { value = $("#action option[selected]").html (); id = $("#action").fieldValue (); + a = $("").append ("\">").click (remove_action); input = input = $("") .attr ("name", "actions[]") .attr ("value", id); - li = $("
  • ").append (value).append (input); + li = $("
  • ").append (value).append (a).append (input); $("ul#alert_actions").append (li); $("#compound-actions").show (); }); + $("a.remove_action").click (remove_action); $("#recovery_notify").change (function () { if (this.value == 1) {