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 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) { if (item.props.processValue != undefined) {
data.processValue = item.props.processValue; data.processValue = item.props.processValue;
} }
@ -329,7 +338,7 @@ function createVisualConsole(
// Resize the element to its initial Size. // Resize the element to its initial Size.
item.resize(e.prevSize.width, e.prevSize.height); item.resize(e.prevSize.width, e.prevSize.height);
item.setMeta({ isUpdating: false });
done(); done();
return; // Stop task execution. return; // Stop task execution.
} }
@ -347,6 +356,7 @@ function createVisualConsole(
// Resize the element to its initial Size. // Resize the element to its initial Size.
item.resize(e.prevSize.width, e.prevSize.height); item.resize(e.prevSize.width, e.prevSize.height);
item.setMeta({ isUpdating: false });
done(); done();
return; // Stop task execution. return; // Stop task execution.
} }

View File

@ -1404,12 +1404,6 @@ class Item extends CachedModel
$result['border_color'] = $border_color; $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( $linked_layout_node_id = static::parseIntOr(
static::issetInArray( static::issetInArray(
$data, $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 * 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. * Return a valid representation of a record in database.
* *

View File

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

View File

@ -71,6 +71,7 @@ input.vs_button_ghost {
margin-top: 13px; margin-top: 13px;
} }
div#editor div#toolbox input.visual_editor_button_toolbox,
div#edit-controls input.visual_editor_button_toolbox { div#edit-controls input.visual_editor_button_toolbox {
padding-right: 20px; padding-right: 20px;
padding-top: 12px; 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; element.innerHTML = this.createDomElement().innerHTML;
} }
/**
* To update the content element.
* @override Item.updateDomElement
*/
protected resizeElement(width: number, height: number): void { protected resizeElement(width: number, height: number): void {
if (this.props.percentileType === "progress-bar") { if (this.props.percentileType === "progress-bar") {
super.resizeElement(width, height); super.resizeElement(width, width / 4);
} else { } else {
console.log("entra por donde ancho y alto es lo mismo");
super.resizeElement(width, width); 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 { private getProgress(): number {
const minValue = this.props.minValue || 0; const minValue = this.props.minValue || 0;
const maxValue = this.props.maxValue || 100; const maxValue = this.props.maxValue || 100;