This commit is contained in:
fbsanchez 2019-06-17 19:12:45 +02:00
parent 457c1c9edf
commit a8a206fa10
3 changed files with 43 additions and 20 deletions

View File

@ -4275,7 +4275,7 @@ function events_page_comments($event)
// If comments are not stored in json, the format is old.
$comments_array = json_decode(io_safe_output($comments), true);
if (json_last_error() != JSON_ERROR_NONE) {
if (!empty($comments) && json_last_error() != JSON_ERROR_NONE) {
$comments_array = [
[
'comment' => 'Error retrieving comments',
@ -4383,9 +4383,26 @@ function events_page_comments($event)
$childrens_ids
))) && $config['show_events_in_local'] == false || $config['event_replication'] == false
) {
$comments_form = '<br><div id="comments_form" style="width:98%;">'.html_print_textarea('comment', 3, 10, '', 'style="min-height: 15px; padding:0; width: 100%; disabled"', true);
$comments_form = '<br><div id="comments_form" style="width:98%;">';
$comments_form .= html_print_textarea(
'comment',
3,
10,
'',
'style="min-height: 15px; padding:0; width: 100%; disabled"',
true
);
$comments_form .= '<br><div style="text-align:right; margin-top:10px;">'.html_print_button(__('Add comment'), 'comment_button', false, 'event_comment();', 'class="sub next"', true).'</div><br></div>';
$comments_form .= '<br><div style="text-align:right; margin-top:10px;">';
$comments_form .= html_print_button(
__('Add comment'),
'comment_button',
false,
'event_comment();',
'class="sub next"',
true
);
$comments_form .= '</div><br></div>';
} else {
$comments_form = ui_print_message(
__('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.')

View File

@ -1,6 +1,7 @@
/*global jQuery,$,forced_title_callback,Base64, dt_events*/
// Show the modal window of an event
var current_event;
function show_event_dialog(event, dialog_page, result) {
var ajax_file = $("#hidden-ajax_file").val();
@ -8,6 +9,8 @@ function show_event_dialog(event, dialog_page, result) {
dialog_page = "general";
}
current_event = event;
try {
event = JSON.parse(atob(event));
} catch (e) {
@ -56,8 +59,8 @@ function show_event_dialog(event, dialog_page, result) {
opacity: 0.5,
background: "black"
},
width: 850,
height: 750
width: 710,
height: 600
})
.show();
@ -515,19 +518,22 @@ function event_change_owner() {
}
// Save a comment into an event
function event_comment(e) {
var event_id = $("#hidden-id_event").val();
function event_comment() {
var event;
try {
event = JSON.parse(atob(current_event));
} catch (e) {
console.error(e);
return;
}
var event_id = event.id_evento;
var comment = $("#textarea_comment").val();
var meta = $("#hidden-meta").val();
var history = $("#hidden-history").val();
if (comment == "") {
show_event_dialog(
event_id,
$("#hidden-group_rep").val(),
"comments",
"comment_error"
);
show_event_dialog(current_event, "comments", "comment_error");
return false;
}
@ -552,13 +558,8 @@ function event_comment(e) {
success: function(data) {
$("#button-comment_button").removeAttr("disabled");
$("#response_loading").show();
show_event_dialog(
event_id,
$("#hidden-group_rep").val(),
"comments",
data
);
dt_events.draw(false);
show_event_dialog(current_event, "comments", data);
}
});

View File

@ -1616,6 +1616,11 @@ function process_datatables_item(item) {
/* Event ID dash */
item.id_evento = "#"+item.id_evento;
/* Owner */
if (item.owner_user == "0") {
item.owner_user = '<?php echo __('System'); ?>';
}
}
/* Datatables auxiliary functions ends */