mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
Fixed errors VC
This commit is contained in:
parent
c3ae3f08a7
commit
d8a09bf359
@ -2140,16 +2140,30 @@ function load_modal(settings) {
|
|||||||
modal: true,
|
modal: true,
|
||||||
title: settings.modal.title,
|
title: settings.modal.title,
|
||||||
width: width,
|
width: width,
|
||||||
|
minHeight:
|
||||||
|
settings.onshow.minHeight != undefined
|
||||||
|
? settings.onshow.minHeight
|
||||||
|
: "auto",
|
||||||
|
maxHeight:
|
||||||
|
settings.onshow.maxHeight != undefined
|
||||||
|
? settings.onshow.maxHeight
|
||||||
|
: "auto",
|
||||||
overlay: settings.modal.overlay,
|
overlay: settings.modal.overlay,
|
||||||
buttons: required_buttons,
|
buttons: required_buttons,
|
||||||
closeOnEscape: false,
|
closeOnEscape: true,
|
||||||
open: function() {
|
open: function() {
|
||||||
$(".ui-dialog-titlebar-close").hide();
|
//$(".ui-dialog-titlebar-close").hide();
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
if (id_modal_target != undefined) {
|
if (id_modal_target != undefined) {
|
||||||
$(id_modal_target).remove();
|
$(id_modal_target).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.cleanup != undefined) {
|
||||||
|
settings.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(this).dialog("destroy");
|
||||||
},
|
},
|
||||||
beforeClose: settings.beforeClose()
|
beforeClose: settings.beforeClose()
|
||||||
});
|
});
|
||||||
|
@ -478,7 +478,7 @@ function createVisualConsole(
|
|||||||
},
|
},
|
||||||
copyItem: function(item) {
|
copyItem: function(item) {
|
||||||
var id = item.props.id;
|
var id = item.props.id;
|
||||||
item.setMeta({ isUpdating: true });
|
item.setMeta({ isSelected: false, isUpdating: true });
|
||||||
|
|
||||||
var taskId = "visual-console-item-update-" + id;
|
var taskId = "visual-console-item-update-" + id;
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ function createVisualConsole(
|
|||||||
itemRetrieved["id"] = data;
|
itemRetrieved["id"] = data;
|
||||||
|
|
||||||
var newItem = visualConsole.addElement(itemRetrieved);
|
var newItem = visualConsole.addElement(itemRetrieved);
|
||||||
newItem.setMeta({ editMode: true });
|
newItem.setMeta({ editMode: true, isSelected: true });
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@ -1428,7 +1428,9 @@ function createOrUpdateVisualConsoleItem(
|
|||||||
],
|
],
|
||||||
onshow: {
|
onshow: {
|
||||||
page: "include/rest-api/index",
|
page: "include/rest-api/index",
|
||||||
method: "loadTabs"
|
method: "loadTabs",
|
||||||
|
maxHeight: 600,
|
||||||
|
minHeight: 400
|
||||||
},
|
},
|
||||||
onsubmit: {
|
onsubmit: {
|
||||||
page: "include/rest-api/index",
|
page: "include/rest-api/index",
|
||||||
|
@ -149,8 +149,10 @@ if ($getVisualConsole === true) {
|
|||||||
return;
|
return;
|
||||||
} else if ($updateVisualConsoleItem === true) {
|
} else if ($updateVisualConsoleItem === true) {
|
||||||
$data = get_parameter('data');
|
$data = get_parameter('data');
|
||||||
if ($data) {
|
|
||||||
|
if (isset($data) === true) {
|
||||||
$data['id'] = $itemId;
|
$data['id'] = $itemId;
|
||||||
|
$data['id_layout'] = $visualConsoleId;
|
||||||
$result = $item->save($data);
|
$result = $item->save($data);
|
||||||
|
|
||||||
echo $item;
|
echo $item;
|
||||||
|
@ -1383,12 +1383,6 @@ class Item extends CachedModel
|
|||||||
$result['id_group'] = $id_group;
|
$result['id_group'] = $id_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO change.
|
|
||||||
$border_width = static::getBorderWidth($data);
|
|
||||||
if ($border_width !== null) {
|
|
||||||
$result['border_width'] = $border_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
$label_position = static::notEmptyStringOr(
|
$label_position = static::notEmptyStringOr(
|
||||||
static::issetInArray($data, ['labelPosition', 'label_position']),
|
static::issetInArray($data, ['labelPosition', 'label_position']),
|
||||||
null
|
null
|
||||||
@ -1506,7 +1500,13 @@ class Item extends CachedModel
|
|||||||
);
|
);
|
||||||
if ($show_last_value === null) {
|
if ($show_last_value === null) {
|
||||||
$show_last_value = static::parseIntOr(
|
$show_last_value = static::parseIntOr(
|
||||||
static::issetInArray($data, ['show_last_value', 'showLastValue']),
|
static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'show_last_value',
|
||||||
|
'showLastValue',
|
||||||
|
]
|
||||||
|
),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1635,7 +1635,7 @@ class Item extends CachedModel
|
|||||||
*
|
*
|
||||||
* @return integer Valid border width.
|
* @return integer Valid border width.
|
||||||
*/
|
*/
|
||||||
private static function getBorderWidth(array $data)
|
protected static function getBorderWidth(array $data)
|
||||||
{
|
{
|
||||||
return static::parseIntOr(
|
return static::parseIntOr(
|
||||||
static::issetInArray($data, ['border_width', 'borderWidth']),
|
static::issetInArray($data, ['border_width', 'borderWidth']),
|
||||||
@ -1651,7 +1651,7 @@ class Item extends CachedModel
|
|||||||
*
|
*
|
||||||
* @return mixed String representing the border color (not empty) or null.
|
* @return mixed String representing the border color (not empty) or null.
|
||||||
*/
|
*/
|
||||||
private static function getBorderColor(array $data)
|
protected static function getBorderColor(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr(
|
return static::notEmptyStringOr(
|
||||||
static::issetInArray(
|
static::issetInArray(
|
||||||
@ -1676,7 +1676,7 @@ class Item extends CachedModel
|
|||||||
*
|
*
|
||||||
* @return mixed String representing the fill color (not empty) or null.
|
* @return mixed String representing the fill color (not empty) or null.
|
||||||
*/
|
*/
|
||||||
private static function getFillColor(array $data)
|
protected static function getFillColor(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr(
|
return static::notEmptyStringOr(
|
||||||
static::issetInArray(
|
static::issetInArray(
|
||||||
@ -1725,6 +1725,7 @@ class Item extends CachedModel
|
|||||||
$save,
|
$save,
|
||||||
['id' => $save['id']]
|
['id' => $save['id']]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Invalidate the item's cache.
|
// Invalidate the item's cache.
|
||||||
if ($result !== false && $result > 0) {
|
if ($result !== false && $result > 0) {
|
||||||
// TODO: Invalidate the cache with the function clearCachedData.
|
// TODO: Invalidate the cache with the function clearCachedData.
|
||||||
|
@ -12,6 +12,43 @@ final class Box extends Item
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid representation of a record in database.
|
||||||
|
*
|
||||||
|
* @param array $data Input data.
|
||||||
|
*
|
||||||
|
* @return array Data structure representing a record in database.
|
||||||
|
*
|
||||||
|
* @overrides Item->encode.
|
||||||
|
*/
|
||||||
|
protected function encode(array $data): array
|
||||||
|
{
|
||||||
|
$return = parent::encode($data);
|
||||||
|
|
||||||
|
$border_width = parent::getBorderWidth($data);
|
||||||
|
if ($border_width !== null) {
|
||||||
|
$return['border_width'] = $border_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
$border_color = static::getBorderColor($data);
|
||||||
|
if ($border_color !== null) {
|
||||||
|
$return['border_color'] = $border_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fill_color = static::getFillColor($data);
|
||||||
|
if ($fill_color !== null) {
|
||||||
|
$return['fill_color'] = $fill_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fill_transparent = static::extractFillTransparent($data);
|
||||||
|
if ($fill_transparent !== null) {
|
||||||
|
$return['show_statistics'] = static::parseBool($fill_transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a valid representation of the model.
|
* Returns a valid representation of the model.
|
||||||
*
|
*
|
||||||
@ -30,10 +67,26 @@ final class Box extends Item
|
|||||||
$boxData['borderWidth'] = $this->extractBorderWidth($data);
|
$boxData['borderWidth'] = $this->extractBorderWidth($data);
|
||||||
$boxData['borderColor'] = $this->extractBorderColor($data);
|
$boxData['borderColor'] = $this->extractBorderColor($data);
|
||||||
$boxData['fillColor'] = $this->extractFillColor($data);
|
$boxData['fillColor'] = $this->extractFillColor($data);
|
||||||
|
$boxData['fillTransparent'] = $this->extractFillTransparent($data);
|
||||||
return $boxData;
|
return $boxData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the "Fill transparent" switch value.
|
||||||
|
*
|
||||||
|
* @param array $data Unknown input data structure.
|
||||||
|
*
|
||||||
|
* @return boolean If the statistics should be shown or not.
|
||||||
|
*/
|
||||||
|
private static function extractFillTransparent(array $data): bool
|
||||||
|
{
|
||||||
|
return static::parseBool(
|
||||||
|
static::issetInArray($data, ['fillTransparent', 'show_statistics'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract a border width value.
|
* Extract a border width value.
|
||||||
*
|
*
|
||||||
@ -225,6 +278,17 @@ final class Box extends Item
|
|||||||
'return' => true,
|
'return' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Fill transparent.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Fill transparent'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'fillTransparent',
|
||||||
|
'id' => 'fillTransparent',
|
||||||
|
'type' => 'switch',
|
||||||
|
'value' => $values['fillTransparent'],
|
||||||
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $inputs;
|
return $inputs;
|
||||||
|
@ -54,7 +54,6 @@ final class ModuleGraph extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
$show_legend = static::extractShowLegend($data);
|
$show_legend = static::extractShowLegend($data);
|
||||||
|
|
||||||
if ($show_legend !== null) {
|
if ($show_legend !== null) {
|
||||||
$return['show_statistics'] = static::parseBool($show_legend);
|
$return['show_statistics'] = static::parseBool($show_legend);
|
||||||
}
|
}
|
||||||
@ -597,11 +596,11 @@ final class ModuleGraph extends Item
|
|||||||
|
|
||||||
// Default values.
|
// Default values.
|
||||||
if (isset($values['width']) === false) {
|
if (isset($values['width']) === false) {
|
||||||
$values['width'] = 100;
|
$values['width'] = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($values['height']) === false) {
|
if (isset($values['height']) === false) {
|
||||||
$values['height'] = 100;
|
$values['height'] = 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
|
@ -408,6 +408,9 @@ class View extends \HTML
|
|||||||
$data['borderColor'] = \get_parameter('borderColor');
|
$data['borderColor'] = \get_parameter('borderColor');
|
||||||
$data['borderWidth'] = \get_parameter('borderWidth');
|
$data['borderWidth'] = \get_parameter('borderWidth');
|
||||||
$data['fillColor'] = \get_parameter('fillColor');
|
$data['fillColor'] = \get_parameter('fillColor');
|
||||||
|
$data['fillTransparent'] = \get_parameter_switch(
|
||||||
|
'fillTransparent'
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LINE_ITEM:
|
case LINE_ITEM:
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -14,6 +14,7 @@ interface BoxProps extends ItemProps {
|
|||||||
borderWidth: number;
|
borderWidth: number;
|
||||||
borderColor: string | null;
|
borderColor: string | null;
|
||||||
fillColor: string | null;
|
fillColor: string | null;
|
||||||
|
fillTransparent: boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,99 +37,11 @@ export function boxPropsDecoder(data: AnyObject): BoxProps | never {
|
|||||||
// Custom properties.
|
// Custom properties.
|
||||||
borderWidth: parseIntOr(data.borderWidth, 0),
|
borderWidth: parseIntOr(data.borderWidth, 0),
|
||||||
borderColor: notEmptyStringOr(data.borderColor, null),
|
borderColor: notEmptyStringOr(data.borderColor, null),
|
||||||
fillColor: notEmptyStringOr(data.fillColor, null)
|
fillColor: notEmptyStringOr(data.fillColor, null),
|
||||||
|
fillTransparent: data.fillTransparent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to add item to the Box item form
|
|
||||||
* This item consists of a label and a color type input color.
|
|
||||||
* Element border color is stored in the borderColor property
|
|
||||||
*/
|
|
||||||
class BorderColorInputGroup extends InputGroup<Partial<BoxProps>> {
|
|
||||||
protected createContent(): HTMLElement | HTMLElement[] {
|
|
||||||
const borderColorLabel = document.createElement("label");
|
|
||||||
borderColorLabel.textContent = t("Border color");
|
|
||||||
|
|
||||||
const borderColorInput = document.createElement("input");
|
|
||||||
borderColorInput.type = "color";
|
|
||||||
borderColorInput.required = true;
|
|
||||||
|
|
||||||
borderColorInput.value = `${this.currentData.borderColor ||
|
|
||||||
this.initialData.borderColor ||
|
|
||||||
"#000000"}`;
|
|
||||||
|
|
||||||
borderColorInput.addEventListener("change", e => {
|
|
||||||
this.updateData({
|
|
||||||
borderColor: (e.target as HTMLInputElement).value
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
borderColorLabel.appendChild(borderColorInput);
|
|
||||||
|
|
||||||
return borderColorLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to add item to the Box item form
|
|
||||||
* This item consists of a label and a color type input number.
|
|
||||||
* Element border width is stored in the borderWidth property
|
|
||||||
*/
|
|
||||||
class BorderWidthInputGroup extends InputGroup<Partial<BoxProps>> {
|
|
||||||
protected createContent(): HTMLElement | HTMLElement[] {
|
|
||||||
const borderWidthLabel = document.createElement("label");
|
|
||||||
borderWidthLabel.textContent = t("Border Width");
|
|
||||||
|
|
||||||
const borderWidthInput = document.createElement("input");
|
|
||||||
borderWidthInput.type = "number";
|
|
||||||
borderWidthInput.min = "0";
|
|
||||||
borderWidthInput.required = true;
|
|
||||||
borderWidthInput.value = `${this.currentData.borderWidth ||
|
|
||||||
this.initialData.borderWidth ||
|
|
||||||
0}`;
|
|
||||||
borderWidthInput.addEventListener("change", e =>
|
|
||||||
this.updateData({
|
|
||||||
borderWidth: parseIntOr((e.target as HTMLInputElement).value, 0)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
borderWidthLabel.appendChild(borderWidthInput);
|
|
||||||
|
|
||||||
return borderWidthLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to add item to the Box item form
|
|
||||||
* This item consists of a label and a color type input color.
|
|
||||||
* Element fill color is stored in the fillcolor property
|
|
||||||
*/
|
|
||||||
class FillColorInputGroup extends InputGroup<Partial<BoxProps>> {
|
|
||||||
protected createContent(): HTMLElement | HTMLElement[] {
|
|
||||||
const fillColorLabel = document.createElement("label");
|
|
||||||
fillColorLabel.textContent = t("Fill color");
|
|
||||||
|
|
||||||
const fillColorInput = document.createElement("input");
|
|
||||||
fillColorInput.type = "color";
|
|
||||||
fillColorInput.required = true;
|
|
||||||
|
|
||||||
fillColorInput.value = `${this.currentData.fillColor ||
|
|
||||||
this.initialData.fillColor ||
|
|
||||||
"#000000"}`;
|
|
||||||
|
|
||||||
fillColorInput.addEventListener("change", e => {
|
|
||||||
this.updateData({
|
|
||||||
fillColor: (e.target as HTMLInputElement).value
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
fillColorLabel.appendChild(fillColorInput);
|
|
||||||
|
|
||||||
return fillColorLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Box extends Item<BoxProps> {
|
export default class Box extends Item<BoxProps> {
|
||||||
protected createDomElement(): HTMLElement {
|
protected createDomElement(): HTMLElement {
|
||||||
const box: HTMLDivElement = document.createElement("div");
|
const box: HTMLDivElement = document.createElement("div");
|
||||||
@ -136,9 +49,13 @@ export default class Box extends Item<BoxProps> {
|
|||||||
// To prevent this item to expand beyond its parent.
|
// To prevent this item to expand beyond its parent.
|
||||||
box.style.boxSizing = "border-box";
|
box.style.boxSizing = "border-box";
|
||||||
|
|
||||||
|
if (this.props.fillTransparent) {
|
||||||
|
box.style.backgroundColor = "transparent";
|
||||||
|
} else {
|
||||||
if (this.props.fillColor) {
|
if (this.props.fillColor) {
|
||||||
box.style.backgroundColor = this.props.fillColor;
|
box.style.backgroundColor = this.props.fillColor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Border.
|
// Border.
|
||||||
if (this.props.borderWidth > 0) {
|
if (this.props.borderWidth > 0) {
|
||||||
@ -161,9 +78,13 @@ export default class Box extends Item<BoxProps> {
|
|||||||
* @override Item.updateDomElement
|
* @override Item.updateDomElement
|
||||||
*/
|
*/
|
||||||
protected updateDomElement(element: HTMLElement): void {
|
protected updateDomElement(element: HTMLElement): void {
|
||||||
|
if (this.props.fillTransparent) {
|
||||||
|
element.style.backgroundColor = "transparent";
|
||||||
|
} else {
|
||||||
if (this.props.fillColor) {
|
if (this.props.fillColor) {
|
||||||
element.style.backgroundColor = this.props.fillColor;
|
element.style.backgroundColor = this.props.fillColor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Border.
|
// Border.
|
||||||
if (this.props.borderWidth > 0) {
|
if (this.props.borderWidth > 0) {
|
||||||
@ -190,13 +111,6 @@ export default class Box extends Item<BoxProps> {
|
|||||||
|
|
||||||
public static getFormContainer(props: Partial<BoxProps>): FormContainer {
|
public static getFormContainer(props: Partial<BoxProps>): FormContainer {
|
||||||
const formContainer = super.getFormContainer(props);
|
const formContainer = super.getFormContainer(props);
|
||||||
formContainer.addInputGroup(
|
|
||||||
new BorderColorInputGroup("border-color", props)
|
|
||||||
);
|
|
||||||
formContainer.addInputGroup(
|
|
||||||
new BorderWidthInputGroup("border-width", props)
|
|
||||||
);
|
|
||||||
formContainer.addInputGroup(new FillColorInputGroup("fill-width", props));
|
|
||||||
|
|
||||||
return formContainer;
|
return formContainer;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user