Fixed error Color cloud VC
This commit is contained in:
parent
8bcacf546c
commit
69e750da13
pandora_console/include
|
@ -1904,10 +1904,15 @@ function html_print_input_hidden_extended(
|
|||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
function html_print_input_color($name, $value, $class=false, $return=false)
|
||||
function html_print_input_color($name, $value, $id='', $class=false, $return=false)
|
||||
{
|
||||
$attr_type = 'type="color"';
|
||||
$attr_id = 'id="color-'.htmlspecialchars($name, ENT_QUOTES).'"';
|
||||
if (empty($id) === true) {
|
||||
$attr_id = 'id="color-'.htmlspecialchars($name, ENT_QUOTES).'"';
|
||||
} else {
|
||||
$attr_id = 'id="'.$id.'"';
|
||||
}
|
||||
|
||||
$attr_name = 'name="'.htmlspecialchars($name, ENT_QUOTES).'"';
|
||||
$attr_value = 'value="'.htmlspecialchars($value, ENT_QUOTES).'"';
|
||||
$attr_class = 'class="'.($class !== false ? htmlspecialchars($class, ENT_QUOTES) : '').'"';
|
||||
|
@ -3495,6 +3500,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
$output .= html_print_input_color(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
((isset($data['class']) === true) ? $data['class'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
);
|
||||
|
|
|
@ -738,13 +738,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background)
|
|||
$form_items['color_cloud_def_color_row'] = [];
|
||||
$form_items['color_cloud_def_color_row']['items'] = ['color_cloud'];
|
||||
$form_items['color_cloud_def_color_row']['html'] = '<td align="left">'.__('Default color').'</td>
|
||||
<td align="left">'.html_print_input_color('default_color', $default_color, false, true).'</td>';
|
||||
<td align="left">'.html_print_input_color('default_color', $default_color, '', false, true).'</td>';
|
||||
|
||||
// Color ranges
|
||||
$color_range_tip = __('The color of the element will be the one selected in the first range created in which the value of the module is found (with the initial and final values of the range included)').'.';
|
||||
$form_items['color_cloud_color_ranges_row'] = [];
|
||||
$form_items['color_cloud_color_ranges_row']['items'] = ['color_cloud'];
|
||||
$form_items['color_cloud_color_ranges_row']['html'] = '<td align="left">'.__('Ranges').ui_print_help_tip($color_range_tip, true).'</td>'.'<td align="left">'.'<table id="new-color-range" class="databox color-range color-range-creation">'.'<tr>'.'<td>'.__('From value').'</td>'.'<td>'.html_print_input_text('from_value_new', '', '', 5, 255, true).'</td>'.'<td rowspan="4">'.'<a class="color-range-add" href="#">'.html_print_image('images/add.png', true).'</a>'.'</td>'.'</tr>'.'<td>'.__('To value').'</td>'.'<td>'.html_print_input_text('to_value_new', '', '', 5, 255, true).'</td>'.'<td></td>'.'<tr>'.'</tr>'.'<tr>'.'<td>'.__('Color').'</td>'.'<td>'.html_print_input_color('color_new', $default_color, false, true).'</td>'.'<td></td>'.'</tr>'.'</table>'.'</td>';
|
||||
$form_items['color_cloud_color_ranges_row']['html'] = '<td align="left">'.__('Ranges').ui_print_help_tip($color_range_tip, true).'</td>'.'<td align="left">'.'<table id="new-color-range" class="databox color-range color-range-creation">'.'<tr>'.'<td>'.__('From value').'</td>'.'<td>'.html_print_input_text('from_value_new', '', '', 5, 255, true).'</td>'.'<td rowspan="4">'.'<a class="color-range-add" href="#">'.html_print_image('images/add.png', true).'</a>'.'</td>'.'</tr>'.'<td>'.__('To value').'</td>'.'<td>'.html_print_input_text('to_value_new', '', '', 5, 255, true).'</td>'.'<td></td>'.'<tr>'.'</tr>'.'<tr>'.'<td>'.__('Color').'</td>'.'<td>'.html_print_input_color('color_new', $default_color, '', false, true).'</td>'.'<td></td>'.'</tr>'.'</table>'.'</td>';
|
||||
|
||||
// End of Color Cloud rows
|
||||
$form_items['show_on_top_row'] = [];
|
||||
|
|
|
@ -1678,6 +1678,11 @@ function createColorRange(baseUrl, vcId) {
|
|||
}
|
||||
|
||||
$("#itemForm-specific ul.wizard:first").append(data);
|
||||
|
||||
// Default values.
|
||||
document.getElementById("rangeDefaultFrom").value = 0;
|
||||
document.getElementById("rangeDefaultTo").value = 0;
|
||||
document.getElementById("color-rangeDefaultColor").value = "#000000";
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -1760,6 +1765,16 @@ function createColorRangeVisualConsole(
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete color ranges.
|
||||
* @param {string} id UniqId for row range.
|
||||
* @return {Void}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function removeColorRange(id) {
|
||||
$("#li-" + id).remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Onchange time-zone.
|
||||
* @return {void}
|
||||
|
|
|
@ -248,6 +248,7 @@ if ($getVisualConsole === true) {
|
|||
echo json_encode($count);
|
||||
return;
|
||||
} else if ($createColorRangeVisualConsole) {
|
||||
$uniqId = \uniqid();
|
||||
$baseUrl = ui_get_full_url('/', false, false, false);
|
||||
$from = get_parameter('from', 0);
|
||||
$to = get_parameter('to', 0);
|
||||
|
@ -281,10 +282,11 @@ if ($getVisualConsole === true) {
|
|||
'type' => 'button',
|
||||
'attributes' => 'class="remove-item-img"',
|
||||
'return' => true,
|
||||
'script' => 'removeColorRange(\''.$baseUrl.'\',\''.$visualConsoleId.'\')',
|
||||
'script' => 'removeColorRange(\''.$uniqId.'\')',
|
||||
];
|
||||
|
||||
$liRangeColor = '<li class="interval-color-ranges flex-row flex-start w100p">';
|
||||
$classRangeColor = 'interval-color-ranges flex-row flex-start w100p';
|
||||
$liRangeColor = '<li id="li-'.$uniqId.'" class="'.$classRangeColor.'">';
|
||||
$liRangeColor .= '<label>'.__('From').'</label>';
|
||||
$liRangeColor .= html_print_input($rangeFrom);
|
||||
$liRangeColor .= '<label>'.__('To').'</label>';
|
||||
|
|
|
@ -39,21 +39,27 @@ final class ColorCloud extends Item
|
|||
{
|
||||
$colorRangeArray = [];
|
||||
|
||||
if (isset($data['colorRanges']) === true) {
|
||||
foreach ($data['colorRanges'] as $colorRange) {
|
||||
if (\is_numeric($colorRange['fromValue']) === true
|
||||
&& \is_numeric($colorRange['toValue']) === true
|
||||
&& static::notEmptyStringOr(
|
||||
$colorRange['color'],
|
||||
null
|
||||
) !== null
|
||||
) {
|
||||
$colorRangeArray[] = [
|
||||
'color' => $colorRange['color'],
|
||||
'from_value' => (float) $colorRange['fromValue'],
|
||||
'to_value' => (float) $colorRange['toValue'],
|
||||
];
|
||||
if (isset($data['colorRanges']) === true
|
||||
&& is_array($data['colorRanges']) === true
|
||||
) {
|
||||
if (empty($data['colorRanges']) === false) {
|
||||
foreach ($data['colorRanges'] as $colorRange) {
|
||||
if (\is_numeric($colorRange['fromValue']) === true
|
||||
&& \is_numeric($colorRange['toValue']) === true
|
||||
&& static::notEmptyStringOr(
|
||||
$colorRange['color'],
|
||||
null
|
||||
) !== null
|
||||
) {
|
||||
$colorRangeArray[] = [
|
||||
'color' => $colorRange['color'],
|
||||
'from_value' => (float) $colorRange['fromValue'],
|
||||
'to_value' => (float) $colorRange['toValue'],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$colorRangeArray = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +111,7 @@ final class ColorCloud extends Item
|
|||
$return['label'] = json_encode(
|
||||
[
|
||||
'default_color' => ($defaultColor !== null) ? $defaultColor : $prevDataDefaultColor,
|
||||
'color_ranges' => ($colorRanges !== null && (count($colorRanges) > 0)) ? $colorRanges : $prevDataColorRanges,
|
||||
'color_ranges' => ($colorRanges !== null) ? $colorRanges : $prevDataColorRanges,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -426,7 +432,7 @@ final class ColorCloud extends Item
|
|||
|
||||
// Label.
|
||||
$inputs[] = [
|
||||
'label' => __('Default').':',
|
||||
'label' => __('Add new range').':',
|
||||
];
|
||||
|
||||
$baseUrl = ui_get_full_url('/', false, false, false);
|
||||
|
@ -481,7 +487,7 @@ final class ColorCloud extends Item
|
|||
|
||||
// Label.
|
||||
$inputs[] = [
|
||||
'label' => __('Ranges').':',
|
||||
'label' => __('Current ranges').':',
|
||||
];
|
||||
|
||||
if (isset($values['colorRanges']) === true
|
||||
|
@ -489,7 +495,9 @@ final class ColorCloud extends Item
|
|||
&& empty($values['colorRanges']) === false
|
||||
) {
|
||||
foreach ($values['colorRanges'] as $k => $v) {
|
||||
$uniqId = \uniqid();
|
||||
$inputs[] = [
|
||||
'block_id' => $uniqId,
|
||||
'class' => 'interval-color-ranges flex-row flex-start w100p',
|
||||
'direct' => 1,
|
||||
'block_content' => [
|
||||
|
@ -515,6 +523,7 @@ final class ColorCloud extends Item
|
|||
'label' => __('Color'),
|
||||
'arguments' => [
|
||||
'wrapper' => 'div',
|
||||
'id' => 'rangeColor'.$uniqId,
|
||||
'name' => 'rangeColor[]',
|
||||
'type' => 'color',
|
||||
'value' => $v['color'],
|
||||
|
@ -523,12 +532,14 @@ final class ColorCloud extends Item
|
|||
],
|
||||
[
|
||||
'arguments' => [
|
||||
'name' => 'Remove',
|
||||
'name' => 'remove-'.$uniqId,
|
||||
'label' => '',
|
||||
'type' => 'button',
|
||||
'attributes' => 'class="remove-item-img"',
|
||||
'return' => true,
|
||||
'script' => 'removeColorRange(\''.$baseUrl.'\',\''.$values['vCId'].'\')',
|
||||
'script' => 'removeColorRange(
|
||||
\''.$uniqId.'\'
|
||||
)',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -104,7 +104,7 @@ class View extends \HTML
|
|||
'img' => 'event_responses_col.png',
|
||||
],
|
||||
];
|
||||
} else if ($type === BOX_ITEM) {
|
||||
} else if ($type === BOX_ITEM || $type === COLOR_CLOUD) {
|
||||
$activetabs = 1;
|
||||
$tabs = [
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue