From 400feb5d0cf2da3ccb35aa615b64008202d5ac51 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Thu, 26 Mar 2015 15:48:27 +0100 Subject: [PATCH] In alert command preview is not array but contain data, create textarea instead of select --- .../godmode/alerts/alert_commands.php | 26 ++++++++++++------- .../godmode/alerts/configure_alert_action.php | 15 ++++++++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 941300975a..c92f5ef9e8 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -93,17 +93,23 @@ if (is_ajax ()) { if (empty($fv)) { $fv = array(); } - - foreach ($fv as $fv_option) { - $fv_option = explode(',', $fv_option); - $fields_value_select[$fv_option[0]] = $fv_option[1]; + if (count($fv) > 1) { + foreach ($fv as $fv_option) { + $fv_option = explode(',', $fv_option); + $fields_value_select[$fv_option[0]] = $fv_option[1]; + } + + $ffield = html_print_select($fields_value_select, + 'field' . $i . '_value', '', '', '', 0, true, false, false, 'fields'); + $rfield = html_print_select($fields_value_select, + 'field' . $i . '_recovery_value', '', '', '', 0, true, false, false, 'fields_recovery'); + } + else { + $ffield = html_print_textarea ('field' . $i . '_value',1, 1, $fv[0], + 'style="min-height:40px" class="fields"', true); + $rfield = html_print_textarea ('field' . $i . '_recovery_value', 1, 1, $fv[0], + 'style="min-height:40px" class="fields_recovery"', true); } - - - $ffield = html_print_select($fields_value_select, - 'field' . $i . '_value', '', '', '', 0, true, false, false, 'fields'); - $rfield = html_print_select($fields_value_select, - 'field' . $i . '_recovery_value', '', '', '', 0, true, false, false, 'fields_recovery'); } else { $ffield = html_print_textarea ('field' . $i . '_value', diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 4631b1bf0e..fd48c695df 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -263,6 +263,8 @@ $(document).ready (function () { var old_recovery_value = ''; var field_row = data["fields_rows"][i]; + old_value = ''; + old_recovery_value = ''; // Only keep the value if is provided from hidden (first time) if (($("[name=field" + i + "_value]").attr('id')) == ("hidden-field" + i + "_value")) { @@ -282,11 +284,16 @@ $(document).ready (function () { $('#table_macros-field' + i).hide(); } else { - $('#table_macros-field' + i).replaceWith(field_row); - $("[name=field" + i + "_value]").val(old_value); - $("[name=field" + i + "_recovery_value]") - .val(old_recovery_value); + $('#table_macros-field' + i).replaceWith(field_row); + if (old_value != '' && old_recovery_value != ''){ + $("[name=field" + i + "_value]").val(old_value); + $("[name=field" + i + "_recovery_value]").val(old_recovery_value); + } + else{ + $("[name=field" + i + "_value]").val($("[name=field" + i + "_value]").val()); + $("[name=field" + i + "_recovery_value]").val($("[name=field" + i + "_recovery_value]").val()); + } // Add help hint only in first field if (i == 1) {