This commit is contained in:
proddy
2025-11-17 23:00:45 +01:00
parent 24421a0224
commit 80dd16740d
8 changed files with 75 additions and 38 deletions

View File

@@ -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

View File

@@ -201,7 +201,7 @@ export enum DeviceValueUOM {
export const DeviceValueUOM_s = [
'',
'°C',
'°C',
'°C Rel',
'%',
'l/min',
'kWh',

View File

@@ -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)' }}>