use numberValue() to prevent web errors with integers

This commit is contained in:
proddy
2024-09-01 12:29:23 +02:00
parent 1d45a08668
commit 94d1aa56b1
4 changed files with 18 additions and 23 deletions

View File

@@ -203,7 +203,7 @@ const CustomEntitiesDialog = ({
margin="normal"
sx={{ width: '11ch' }}
type="number"
value={editItem.offset}
value={numberValue(editItem.offset)}
onChange={updateFormValue}
/>
</Grid>
@@ -288,21 +288,16 @@ const CustomEntitiesDialog = ({
{editItem.value_type === DeviceValueType.STRING &&
editItem.device_id !== '0' && (
<Grid>
<TextField
<ValidatedTextField
fieldErrors={fieldErrors}
name="factor"
label="Bytes"
value={editItem.factor}
value={numberValue(editItem.factor)}
sx={{ width: '11ch' }}
variant="outlined"
onChange={updateFormValue}
margin="normal"
type="number"
slotProps={{
htmlInput: {
min: '1',
max: String(256 - editItem.offset),
step: '1'
}
}}
/>
</Grid>
)}

View File

@@ -17,7 +17,7 @@ import Grid from '@mui/material/Grid2';
import { dialogStyle } from 'CustomTheme';
import { useI18nContext } from 'i18n/i18n-react';
import { updateValue } from 'utils';
import { numberValue, updateValue } from 'utils';
import EntityMaskToggle from './EntityMaskToggle';
import { DeviceEntityMask } from './types';
@@ -127,8 +127,8 @@ const CustomizationsDialog = ({
<TextField
name="mi"
label={LL.MIN()}
value={editItem.mi}
sx={{ width: '8ch' }}
value={numberValue(editItem.mi)}
sx={{ width: '11ch' }}
type="number"
onChange={updateFormValue}
/>
@@ -137,8 +137,8 @@ const CustomizationsDialog = ({
<TextField
name="ma"
label={LL.MAX()}
value={editItem.ma}
sx={{ width: '8ch' }}
value={numberValue(editItem.ma)}
sx={{ width: '11ch' }}
type="number"
onChange={updateFormValue}
/>

View File

@@ -91,7 +91,7 @@ const SensorsAnalogDialog = ({
fieldErrors={fieldErrors}
name="g"
label="GPIO"
sx={{ width: '15ch' }}
sx={{ width: '11ch' }}
value={numberValue(editItem.g)}
type="number"
variant="outlined"
@@ -157,7 +157,7 @@ const SensorsAnalogDialog = ({
label={LL.OFFSET()}
value={numberValue(editItem.o)}
type="number"
sx={{ width: '15ch' }}
sx={{ width: '11ch' }}
variant="outlined"
onChange={updateFormValue}
slotProps={{
@@ -178,7 +178,7 @@ const SensorsAnalogDialog = ({
label={LL.STARTVALUE()}
value={numberValue(editItem.o)}
type="number"
sx={{ width: '15ch' }}
sx={{ width: '11ch' }}
variant="outlined"
onChange={updateFormValue}
slotProps={{
@@ -193,7 +193,7 @@ const SensorsAnalogDialog = ({
name="f"
label={LL.FACTOR()}
value={numberValue(editItem.f)}
sx={{ width: '15ch' }}
sx={{ width: '11ch' }}
type="number"
variant="outlined"
onChange={updateFormValue}
@@ -210,7 +210,7 @@ const SensorsAnalogDialog = ({
name="o"
label={LL.VALUE(0)}
value={numberValue(editItem.o)}
fullWidth
sx={{ width: '11ch' }}
type="number"
variant="outlined"
onChange={updateFormValue}
@@ -281,7 +281,7 @@ const SensorsAnalogDialog = ({
value={numberValue(editItem.f)}
type="number"
variant="outlined"
sx={{ width: '15ch' }}
sx={{ width: '11ch' }}
onChange={updateFormValue}
slotProps={{
input: {
@@ -299,7 +299,7 @@ const SensorsAnalogDialog = ({
label={LL.DUTY_CYCLE()}
value={numberValue(editItem.o)}
type="number"
sx={{ width: '15ch' }}
sx={{ width: '11ch' }}
variant="outlined"
onChange={updateFormValue}
slotProps={{

View File

@@ -95,7 +95,7 @@ const SensorsTemperatureDialog = ({
name="o"
label={LL.OFFSET()}
value={numberValue(editItem.o)}
sx={{ width: '12ch' }}
sx={{ width: '11ch' }}
type="number"
variant="outlined"
onChange={updateFormValue}