mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Merge pull request #201 from proddy:dev
fixes #199 - change value validation fails
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
|||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
|
|
||||||
import { FormButton } from '../components';
|
import { FormButton } from '../components';
|
||||||
import { DeviceValue, DeviceValueUOM, DeviceValueUOM_s } from './EMSESPtypes';
|
import { DeviceValue, DeviceValueUOM_s } from './EMSESPtypes';
|
||||||
|
|
||||||
interface ValueFormProps {
|
interface ValueFormProps {
|
||||||
devicevalue: DeviceValue;
|
devicevalue: DeviceValue;
|
||||||
@@ -25,17 +25,6 @@ interface ValueFormProps {
|
|||||||
data: keyof DeviceValue
|
data: keyof DeviceValue
|
||||||
) => (event: React.ChangeEvent<HTMLInputElement>) => void;
|
) => (event: React.ChangeEvent<HTMLInputElement>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatValue(value: any, uom: number) {
|
|
||||||
if (uom === DeviceValueUOM.DEGREES) {
|
|
||||||
return new Intl.NumberFormat(undefined, {
|
|
||||||
minimumFractionDigits: 1
|
|
||||||
}).format(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ValueForm extends React.Component<ValueFormProps> {
|
class ValueForm extends React.Component<ValueFormProps> {
|
||||||
formRef: RefObject<any> = React.createRef();
|
formRef: RefObject<any> = React.createRef();
|
||||||
|
|
||||||
@@ -79,7 +68,7 @@ class ValueForm extends React.Component<ValueFormProps> {
|
|||||||
{!devicevalue.l && (
|
{!devicevalue.l && (
|
||||||
<OutlinedInput
|
<OutlinedInput
|
||||||
id="value"
|
id="value"
|
||||||
value={formatValue(devicevalue.v, devicevalue.u)}
|
value={devicevalue.v}
|
||||||
autoFocus
|
autoFocus
|
||||||
fullWidth
|
fullWidth
|
||||||
onChange={handleValueChange('v')}
|
onChange={handleValueChange('v')}
|
||||||
|
|||||||
Reference in New Issue
Block a user