Merge branch '836-bad-parents-line-position-in-visual-console-dev' into 'develop'

836 bad parents line position in visual console dev

See merge request !448
This commit is contained in:
vgilc 2017-05-17 17:48:53 +02:00
commit 4cee2eaea8
4 changed files with 53 additions and 18 deletions

View File

@ -1497,13 +1497,11 @@ function set_static_graph_status(idElement, image, status) {
set_static_graph_status(idElement, image, data); set_static_graph_status(idElement, image, data);
if($('#'+idElement+' table').css('float') == 'right' || $('#'+idElement+ ' table').css('float') == 'left'){ if($('#'+idElement+' table').css('float') == 'right' || $('#'+idElement+ ' table').css('float') == 'left'){
$('#'+idElement+ ' img').css('margin-top', parseInt($('#'+idElement).css('height'))/2 - parseInt($('#'+idElement+ ' img').css('height'))/2); $('#'+idElement+ ' img').css('margin-top', parseInt($('#'+idElement).css('height'))/2 - parseInt($('#'+idElement+ ' img').css('height'))/2);
} }
else{ else{
$('#'+idElement+ ' img').css('margin-left',parseInt($('#'+idElement).css('width'))/2 - parseInt($('#'+idElement+ ' img').css('width'))/2); $('#'+idElement+ ' img').css('margin-left', parseInt($('#'+idElement).css('width'))/2 - parseInt($('#'+idElement+ ' img').css('width'))/2);
} }
} }
}); });
@ -1849,11 +1847,9 @@ function get_image_url(img_src) {
}); });
} }
function set_color_line_status(lines, line, id_data, values) { function set_color_line_status(lines, id_data, values) {
metaconsole = $("input[name='metaconsole']").val(); metaconsole = $("input[name='metaconsole']").val();
var parameter = Array(); var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_color_line"}); parameter.push ({name: "action", value: "get_color_line"});
@ -1875,7 +1871,6 @@ function set_color_line_status(lines, line, id_data, values) {
"node_end": id_data, "node_end": id_data,
"color": color }; "color": color };
lines.push(line); lines.push(line);
refresh_lines(lines, 'background', true); refresh_lines(lines, 'background', true);
@ -2250,7 +2245,7 @@ function createItem(type, values, id_data) {
lines.push(line); lines.push(line);
set_color_line_status(lines, line, id_data, values); set_color_line_status(lines, id_data, values);
refresh_lines(lines, 'background', true); refresh_lines(lines, 'background', true);
} }
@ -2446,7 +2441,7 @@ function updateDB_visual(type, idElement , values, event, top, left) {
if (typeof(values['parent']) != 'undefined' && values['parent'] > 0 ) { if (typeof(values['parent']) != 'undefined' && values['parent'] > 0 ) {
if (!found) { if (!found) {
set_color_line_status(lines, line, idElement, values); set_color_line_status(lines, idElement, values);
} }
} }
@ -2465,6 +2460,7 @@ function updateDB_visual(type, idElement , values, event, top, left) {
refresh_lines(lines, 'background', true); refresh_lines(lines, 'background', true);
break; break;
} }
refresh_lines(lines, 'background', true); refresh_lines(lines, 'background', true);
draw_user_lines("", 0, 0, 0 , 0, 0, true); draw_user_lines("", 0, 0, 0 , 0, 0, true);
} }
@ -2601,9 +2597,19 @@ function updateDB(type, idElement , values, event) {
url: get_url_ajax(), url: get_url_ajax(),
data: parameter, data: parameter,
type: "POST", type: "POST",
dataType: 'text', dataType: 'json',
success: function (data) { success: function (data) {
updateDB_visual(type, idElement , values, event, top, left); if (data['correct']) {
if (data['new_line']) {
var line = {"id": idElement,
"node_begin": values['parent'],
"node_end": idElement,
"color": '#cccccc' };
lines.push(line);
}
updateDB_visual(type, idElement , values, event, top, left);
}
} }
}); });
} }

View File

@ -616,10 +616,20 @@ switch ($action) {
} }
} }
$item_in_db = db_get_row_filter ('tlayout_data', array ('id' => $id_element));
if (($item_in_db['parent_item'] == 0) && ($values['parent_item'] != 0)) {
$new_line = 1;
}
$result = db_process_sql_update('tlayout_data', $values, $result = db_process_sql_update('tlayout_data', $values,
array('id' => $id_element)); array('id' => $id_element));
echo (int)$result; $return_val = array();
$return_val['correct'] = (int)$result;
$return_val['new_line'] = $new_line;
echo json_encode($return_val);
break; break;
} }
break; break;

View File

@ -1182,7 +1182,9 @@ function visual_map_print_item($mode = "read", $layoutData,
else if($layoutData['label_position']=='right'){ else if($layoutData['label_position']=='right'){
$imgpos = 'float:left'; $imgpos = 'float:left';
} }
$varsize = getimagesize($img); $varsize = getimagesize($img);
if ($width == 0 || $height == 0) { if ($width == 0 || $height == 0) {
if($varsize[0] > 150 || $varsize[1] > 150){ if($varsize[0] > 150 || $varsize[1] > 150){
echo html_print_image($img, true, echo html_print_image($img, true,

View File

@ -17,7 +17,6 @@
* @param editor Boolean variable to set other css selector in editor (when true). * @param editor Boolean variable to set other css selector in editor (when true).
*/ */
function draw_line (line, id_div) { function draw_line (line, id_div) {
selector = ''; selector = '';
//Check if the global var resize_map is defined //Check if the global var resize_map is defined
@ -38,17 +37,32 @@ function draw_line (line, id_div) {
have_node_begin_img = $('#' + line['node_begin'] + " img").length; have_node_begin_img = $('#' + line['node_begin'] + " img").length;
have_node_end_img = $('#' + line['node_end'] + " img").length; have_node_end_img = $('#' + line['node_end'] + " img").length;
if (have_node_begin_img) {
var img_pos_begin = $('#' + line['node_begin'] + " img").position();
var img_margin_left_begin = $('#' + line['node_begin'] + " img").css("margin-left");
var img_margin_left_begin_aux = img_margin_left_begin.split("px");
img_margin_left_begin = parseFloat(img_margin_left_begin_aux[0]);
}
if (have_node_end_img) {
var img_pos_end = $('#' + line['node_end'] + " img").position();
var img_margin_left_end = $('#' + line['node_end'] + " img").css("margin-left");
var img_margin_left_end_aux = img_margin_left_end.split("px");
img_margin_left_end = parseFloat(img_margin_left_end_aux[0]);
}
if (line['x1']) { if (line['x1']) {
x1 = line['x']; x1 = line['x'];
} }
else { else {
if (have_node_begin_img) { if (have_node_begin_img) {
width = $('#' + line['node_begin'] + " img").width(); width = $('#' + line['node_begin'] + " img").width();
x1 = parseInt($('#' + line['node_begin']).css (selector + 'left')) + (width / 2) + img_pos_begin.left + img_margin_left_begin;
} }
else { else {
width = $('#' + line['node_begin']).width(); width = $('#' + line['node_begin']).width();
x1 = parseInt($('#' + line['node_begin']).css (selector + 'left')) + (width / 2);
} }
x1 = parseInt($('#' + line['node_begin']).css (selector + 'left')) + (width / 2);
} }
if (line['y1']) { if (line['y1']) {
@ -57,11 +71,12 @@ function draw_line (line, id_div) {
else { else {
if (have_node_begin_img) { if (have_node_begin_img) {
height = parseInt($('#' + line['node_begin'] + " img").css('height')); height = parseInt($('#' + line['node_begin'] + " img").css('height'));
y1 = parseInt($('#' + line['node_begin']).css (selector + 'top')) + (height / 2) + img_pos_begin.top;
} }
else { else {
height = $('#' + line['node_begin']).height(); height = $('#' + line['node_begin']).height();
y1 = parseInt($('#' + line['node_begin']).css (selector + 'top')) + (height / 2);
} }
y1 = parseInt($('#' + line['node_begin']).css (selector + 'top')) + (height / 2);
} }
if (line['x2']) { if (line['x2']) {
@ -70,11 +85,12 @@ function draw_line (line, id_div) {
else { else {
if (have_node_end_img) { if (have_node_end_img) {
width = $('#' + line['node_end'] + " img").width(); width = $('#' + line['node_end'] + " img").width();
x2 = parseInt($('#' + line['node_end']).css (selector + 'left')) + (width / 2) + img_pos_end.left + img_margin_left_end;
} }
else { else {
width = $('#' + line['node_end']).width(); width = $('#' + line['node_end']).width();
x2 = parseInt($('#' + line['node_end']).css (selector + 'left')) + (width / 2);
} }
x2 = parseInt($('#' + line['node_end']).css (selector + 'left')) + (width / 2);
} }
if (line['y2']) { if (line['y2']) {
@ -83,11 +99,12 @@ function draw_line (line, id_div) {
else { else {
if (have_node_end_img) { if (have_node_end_img) {
height = parseInt($('#' + line['node_end'] + " img").css('height')); height = parseInt($('#' + line['node_end'] + " img").css('height'));
y2 = parseInt($('#' + line['node_end']).css (selector + 'top')) + (height / 2) + img_pos_end.top;
} }
else { else {
height = $('#' + line['node_end']).height(); height = $('#' + line['node_end']).height();
y2 = parseInt($('#' + line['node_end']).css (selector + 'top')) + (height / 2);
} }
y2 = parseInt($('#' + line['node_end']).css (selector + 'top')) + (height / 2);
} }