fixed errors VC

This commit is contained in:
Daniel Barbero Martin 2020-01-25 11:57:04 +01:00
parent 06a3318fb6
commit 5ff10ac514
8 changed files with 68 additions and 68 deletions

View File

@ -301,6 +301,15 @@ function createVisualConsole(
type: item.props.type
};
// Trick, to allow the percentile item to reuse the height field to save the max value,
// it is very ugly, change some year.
if (item.props.type === 3) {
data = {
width: e.newSize.width,
type: item.props.type
};
}
if (item.props.processValue != undefined) {
data.processValue = item.props.processValue;
}
@ -329,7 +338,7 @@ function createVisualConsole(
// Resize the element to its initial Size.
item.resize(e.prevSize.width, e.prevSize.height);
item.setMeta({ isUpdating: false });
done();
return; // Stop task execution.
}
@ -347,6 +356,7 @@ function createVisualConsole(
// Resize the element to its initial Size.
item.resize(e.prevSize.width, e.prevSize.height);
item.setMeta({ isUpdating: false });
done();
return; // Stop task execution.
}

View File

@ -1404,12 +1404,6 @@ class Item extends CachedModel
$result['border_color'] = $border_color;
}
// TODO change.
$fill_color = static::getFillColor($data);
if ($fill_color !== null) {
$result['fill_color'] = $fill_color;
}
$linked_layout_node_id = static::parseIntOr(
static::issetInArray(
$data,
@ -1676,29 +1670,6 @@ class Item extends CachedModel
}
/**
* Extract a fill color value.
*
* @param array $data Unknown input data structure.
*
* @return mixed String representing the fill color (not empty) or null.
*/
protected static function getFillColor(array $data)
{
return static::notEmptyStringOr(
static::issetInArray(
$data,
[
'fillColor',
'fill_color',
'labelColor',
]
),
null
);
}
/**
* Insert or update an item in the database
*

View File

@ -31,6 +31,29 @@ final class Box extends Item
}
/**
* Extract a fill color value.
*
* @param array $data Unknown input data structure.
*
* @return mixed String representing the fill color (not empty) or null.
*/
protected static function getFillColor(array $data)
{
return static::notEmptyStringOr(
static::issetInArray(
$data,
[
'fillColor',
'fill_color',
'labelColor',
]
),
null
);
}
/**
* Return a valid representation of a record in database.
*

View File

@ -107,17 +107,7 @@ final class Percentile extends Item
{
$labelColor = null;
if (isset($data['labelColor']) === true) {
switch ($data['labelColor']) {
case 'fillColor':
case 'fill_color':
case 'labelColor':
$labelColor = $data['labelColor'];
break;
default:
$labelColor = '#444444';
break;
}
$labelColor = $data['labelColor'];
}
return $labelColor;
@ -137,19 +127,7 @@ final class Percentile extends Item
{
$color = null;
if (isset($data['color']) === true) {
switch ($data['color']) {
case 'borderColor':
case 'border_color':
case 'gridColor':
case 'color':
case 'legendBackgroundColor':
$color = $data['color'];
break;
default:
$color = '#F0F0F0';
break;
}
$color = $data['color'];
}
return $color;
@ -174,8 +152,15 @@ final class Percentile extends Item
null
);
if ($max_value !== null) {
// TODO: XXX.
// $return['height'] = $max_value;
$return['height'] = $max_value;
}
$min_value = static::parseIntOr(
static::issetInArray($data, ['minValue']),
null
);
if ($min_value !== null) {
$return['border_width'] = $min_value;
}
$percentileType = static::encodePercentileType($data);
@ -217,9 +202,8 @@ final class Percentile extends Item
$return['type'] = (int) $data['type'];
$return['percentileType'] = static::extractPercentileType($data);
$return['valueType'] = static::extractValueType($data);
// TODO: Add min value to the database.
$return['minValue'] = static::parseFloatOr(
static::issetInArray($data, ['minValue']),
static::issetInArray($data, ['minValue', 'border_width']),
null
);
$return['maxValue'] = static::parseFloatOr(
@ -483,7 +467,6 @@ final class Percentile extends Item
],
];
// TODO: ADD bbdd.
// Min Value.
$inputs[] = [
'label' => __('Min. Value'),
@ -496,7 +479,6 @@ final class Percentile extends Item
],
];
// TODO: ADD bbdd.
// Max Value.
$inputs[] = [
'label' => __('Max. Value'),
@ -615,10 +597,6 @@ final class Percentile extends Item
$values['width'] = 100;
}
if (isset($values['height']) === false) {
$values['height'] = 100;
}
return $values;
}

View File

@ -71,6 +71,7 @@ input.vs_button_ghost {
margin-top: 13px;
}
div#editor div#toolbox input.visual_editor_button_toolbox,
div#edit-controls input.visual_editor_button_toolbox {
padding-right: 20px;
padding-top: 12px;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -273,15 +273,32 @@ export default class Percentile extends Item<PercentileProps> {
element.innerHTML = this.createDomElement().innerHTML;
}
/**
* To update the content element.
* @override Item.updateDomElement
*/
protected resizeElement(width: number, height: number): void {
if (this.props.percentileType === "progress-bar") {
super.resizeElement(width, height);
super.resizeElement(width, width / 4);
} else {
console.log("entra por donde ancho y alto es lo mismo");
super.resizeElement(width, width);
}
}
/**
* To update the content element.
* @override Item.updateDomElement
*/
public resize(width: number): void {
this.resizeElement(width, width);
const height = this.props.maxValue || 0;
super.setProps({
...this.props, // Object spread: http://es6-features.org/#SpreadOperator
width,
height
});
}
private getProgress(): number {
const minValue = this.props.minValue || 0;
const maxValue = this.props.maxValue || 100;