diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index c8911c0f44..74c5a9c389 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -229,15 +229,31 @@ $(document).ready (function () { }); $("#left").click (function () { + var current_fields_size = ($('#fields_selected option').size()); + var selected_fields = []; + var selected_fields_total = ''; + jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) { - field_name = $(value).html(); - if (field_name != ) { - id_field = $(value).attr('value'); - $("select[name='fields_available[]']").append($("").val(id_field).html('' + field_name + '')); - $("#fields_selected").find("option[value='" + id_field + "']").remove(); - $("#fields_available").find("option[value='0']").remove(); - } + field_name = $(value).html(); + selected_fields.push(field_name); + selected_fields_total = selected_fields.length; }); + + if(selected_fields_total === current_fields_size){ + display_confirm_dialog( + "'.__('There must be at least one custom field. Timestamp will be set by default').''; ?>", + "", + "", + function () { + move_left(); + $("#fields_available").find("option[value='timestamp']").remove(); + $("select[name='fields_selected[]']").append($("").val('timestamp').html('' + 'Timestamp' + '')); + } + ); + } + else{ + move_left(); + } }); $("#submit-upd_button").click(function () { @@ -247,4 +263,16 @@ $(document).ready (function () { }); }); }); + +function move_left(){ + jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) { + field_name = $(value).html(); + if (field_name != ) { + id_field = $(value).attr('value'); + $("select[name='fields_available[]']").append($("").val(id_field).html('' + field_name + '')); + $("#fields_selected").find("option[value='" + id_field + "']").remove(); + $("#fields_available").find("option[value='0']").remove(); + } + }); +}