Fixed last value
This commit is contained in:
parent
46fdfc4445
commit
f3fe8099bb
|
@ -1586,12 +1586,35 @@ class Item extends CachedModel
|
|||
$result['timezone'] = $timezone;
|
||||
}
|
||||
|
||||
$show_last_value = static::parseIntOr(
|
||||
static::issetInArray($data, ['show_last_value', 'showLastValue']),
|
||||
$show_last_value = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['showLastValueTooltip']),
|
||||
null
|
||||
);
|
||||
if ($show_last_value === null) {
|
||||
$show_last_value = static::parseIntOr(
|
||||
static::issetInArray($data, ['show_last_value', 'showLastValue']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
if ($show_last_value !== null) {
|
||||
$result['show_last_value'] = $show_last_value;
|
||||
if (\is_numeric($show_last_value) === true) {
|
||||
$result['show_last_value'] = $show_last_value;
|
||||
} else {
|
||||
switch ($show_last_value) {
|
||||
case 'enabled':
|
||||
$result['show_last_value'] = 1;
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
$result['show_last_value'] = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
$result['show_last_value'] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cacheExpiration = static::extractCacheExpiration($data);
|
||||
|
|
|
@ -94,7 +94,8 @@ class ShowLastValueInputGroup extends InputGroup<Partial<StaticGraphProps>> {
|
|||
|
||||
const showLastValueSelect = document.createElement("select");
|
||||
showLastValueSelect.required = true;
|
||||
showLastValueSelect.value =
|
||||
|
||||
const currentValue =
|
||||
this.currentData.showLastValueTooltip ||
|
||||
this.initialData.showLastValueTooltip ||
|
||||
"default";
|
||||
|
@ -103,6 +104,9 @@ class ShowLastValueInputGroup extends InputGroup<Partial<StaticGraphProps>> {
|
|||
const optionElement = document.createElement("option");
|
||||
optionElement.value = option.value;
|
||||
optionElement.textContent = option.text;
|
||||
if (currentValue == optionElement.value) {
|
||||
optionElement.selected = true;
|
||||
}
|
||||
showLastValueSelect.appendChild(optionElement);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue