From e9741ea4f8bdab062f4c6d70b419e4163fe61bfb Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 7 Jun 2021 21:18:29 +0200 Subject: [PATCH] improve layout, booleans show as a menu --- interface/src/project/ValueForm.tsx | 77 ++++++++++++++++++----------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/interface/src/project/ValueForm.tsx b/interface/src/project/ValueForm.tsx index bddc32ac2..3200a543b 100644 --- a/interface/src/project/ValueForm.tsx +++ b/interface/src/project/ValueForm.tsx @@ -1,15 +1,21 @@ import React, { RefObject } from 'react'; -import { TextValidator, ValidatorForm } from 'react-material-ui-form-validator'; +import { ValidatorForm } from 'react-material-ui-form-validator'; import { Dialog, DialogTitle, DialogContent, DialogActions, Box, - Typography + Typography, + FormHelperText, + OutlinedInput, + InputAdornment, + TextField, + MenuItem } from '@material-ui/core'; + import { FormButton } from '../components'; -import { DeviceValue } from './EMSESPtypes'; +import { DeviceValue, DeviceValueUOM, DeviceValueUOM_s } from './EMSESPtypes'; interface ValueFormProps { devicevalue: DeviceValue; @@ -27,13 +33,6 @@ class ValueForm extends React.Component { this.formRef.current.submit(); }; - buildLabel = (devicevalue: DeviceValue) => { - if (devicevalue.uom === '' || !devicevalue.uom) { - return 'New value'; - } - return 'New value (' + devicevalue.uom + ')'; - }; - render() { const { devicevalue, @@ -41,6 +40,7 @@ class ValueForm extends React.Component { onDoneEditing, onCancelEditing } = this.props; + return ( { aria-labelledby="user-form-dialog-title" open > - - Change the {devicevalue.name} - + Change Value - - + {devicevalue.u !== DeviceValueUOM.BOOLEAN && ( + + {DeviceValueUOM_s[devicevalue.u]} + + } + aria-describedby="outlined-value-helper-text" + inputProps={{ + 'aria-label': 'value' + }} + /> + )} + {devicevalue.u === DeviceValueUOM.BOOLEAN && ( + + on + off + + )} + + {devicevalue.n} + + - Note: it may take a few seconds before the change is visible. - If nothing happens check the logs. + Note: it may take a few seconds before the change is + registered with the EMS device. -