replace disabled sensor gpio (99) with code logic

This commit is contained in:
proddy
2025-11-17 17:49:30 +01:00
parent 25ea7d8b0c
commit 090387ef37
7 changed files with 75 additions and 68 deletions

View File

@@ -152,20 +152,6 @@ const SensorsAnalogDialog = ({
[creating, LL]
);
// Ensure the current GPIO is in the list when no creating
// note GPIO 99 means not set
const availableGPIOs = useMemo(() => {
const filteredList = analogGPIOList.filter((gpio) => gpio !== 99);
if (
editItem.g !== undefined &&
editItem.g !== 99 &&
!filteredList.includes(editItem.g)
) {
return [...filteredList, editItem.g].sort((a, b) => a - b);
}
return filteredList;
}, [analogGPIOList, editItem.g]);
return (
<Dialog sx={dialogStyle} open={open} onClose={handleClose}>
<DialogTitle>{dialogTitle}</DialogTitle>
@@ -175,12 +161,12 @@ const SensorsAnalogDialog = ({
name="g"
label="GPIO"
value={editItem.g}
sx={{ width: '8ch' }}
sx={{ width: '9ch' }}
disabled={editItem.s}
select
onChange={updateFormValue}
>
{availableGPIOs?.map((gpio: number) => (
{analogGPIOList?.map((gpio: number) => (
<MenuItem key={gpio} value={gpio}>
{gpio}
</MenuItem>