mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
some fixes on https://github.com/emsesp/EMS-ESP32/pull/2750
This commit is contained in:
@@ -115,6 +115,23 @@ const SensorsAnalogDialog = ({
|
||||
[]
|
||||
);
|
||||
|
||||
const analogGPIOMenuItems = () =>
|
||||
// add selectedItem.g to the list
|
||||
[
|
||||
...(analogGPIOList?.includes(selectedItem.g) || selectedItem.g === undefined
|
||||
? analogGPIOList
|
||||
: [selectedItem.g, ...analogGPIOList])
|
||||
]
|
||||
.filter((gpio, idx, arr) => arr.indexOf(gpio) === idx)
|
||||
.sort((a, b) => a - b)
|
||||
.map((gpio: number) => {
|
||||
return (
|
||||
<MenuItem key={gpio} value={gpio}>
|
||||
{gpio}
|
||||
</MenuItem>
|
||||
);
|
||||
});
|
||||
|
||||
// Reset form when dialog opens or selectedItem changes
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
@@ -162,15 +179,11 @@ const SensorsAnalogDialog = ({
|
||||
label="GPIO"
|
||||
value={editItem.g}
|
||||
sx={{ width: '9ch' }}
|
||||
disabled={editItem.s}
|
||||
disabled={editItem.s || !creating}
|
||||
select
|
||||
onChange={updateFormValue}
|
||||
>
|
||||
{analogGPIOList?.map((gpio: number) => (
|
||||
<MenuItem key={gpio} value={gpio}>
|
||||
{gpio}
|
||||
</MenuItem>
|
||||
))}
|
||||
{analogGPIOMenuItems()}
|
||||
</ValidatedTextField>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
|
||||
@@ -201,7 +201,7 @@ export enum DeviceValueUOM {
|
||||
export const DeviceValueUOM_s = [
|
||||
'',
|
||||
'°C',
|
||||
'°C',
|
||||
'°C Rel',
|
||||
'%',
|
||||
'l/min',
|
||||
'kWh',
|
||||
|
||||
@@ -25,11 +25,22 @@ const ValidatedTextField: FC<ValidatedTextFieldProps> = ({
|
||||
error={!!errors}
|
||||
{...rest}
|
||||
aria-label="Error"
|
||||
slotProps={{
|
||||
inputLabel: {
|
||||
style: rest.disabled ? { color: 'grey' } : undefined
|
||||
sx={{
|
||||
'& .MuiInputBase-input.Mui-disabled': {
|
||||
WebkitTextFillColor: 'grey'
|
||||
}
|
||||
}}
|
||||
{...(rest.disabled && {
|
||||
slotProps: {
|
||||
select: {
|
||||
IconComponent: () => null
|
||||
},
|
||||
inputLabel: {
|
||||
style: { color: 'grey' }
|
||||
}
|
||||
}
|
||||
})}
|
||||
color={rest.disabled ? 'secondary' : 'primary'}
|
||||
/>
|
||||
{errors?.map((e) => (
|
||||
<FormHelperText key={e.message} sx={{ color: 'rgb(250, 95, 84)' }}>
|
||||
|
||||
Reference in New Issue
Block a user