disable radio and dropdown for the component if it is primed to add
This commit is contained in:
parent
5bebde4bfb
commit
54a826bc2d
1 changed files with 5 additions and 3 deletions
|
|
@ -21,7 +21,7 @@ export default function ScannedI2C(props: Props){
|
||||||
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
|
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
|
||||||
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
|
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
|
||||||
const [selectedPrimarySubtype, setSelectedPrimarySubtype] = useState(0)
|
const [selectedPrimarySubtype, setSelectedPrimarySubtype] = useState(0)
|
||||||
const [added,setAdded] = useState(false)
|
const [added, setAdded] = useState(false)
|
||||||
const [addressInUse, setAddressInUse] = useState(false)
|
const [addressInUse, setAddressInUse] = useState(false)
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
|
|
@ -80,7 +80,7 @@ export default function ScannedI2C(props: Props){
|
||||||
|
|
||||||
const componentSelected = (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => {
|
const componentSelected = (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => {
|
||||||
let toAdd: Component[] = []
|
let toAdd: Component[] = []
|
||||||
setAdded(true)
|
setAdded(checked)
|
||||||
//build a component with given information and defaults for the rest
|
//build a component with given information and defaults for the rest
|
||||||
let primaryComponent = Component.create()
|
let primaryComponent = Component.create()
|
||||||
primaryComponent.settings.type = selectedPrimaryType
|
primaryComponent.settings.type = selectedPrimaryType
|
||||||
|
|
@ -120,6 +120,7 @@ export default function ScannedI2C(props: Props){
|
||||||
{types.map((type, i) => {
|
{types.map((type, i) => {
|
||||||
return (
|
return (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
|
disabled={added}
|
||||||
key={i}
|
key={i}
|
||||||
value={type}
|
value={type}
|
||||||
control={<Radio />}
|
control={<Radio />}
|
||||||
|
|
@ -132,6 +133,7 @@ export default function ScannedI2C(props: Props){
|
||||||
<Grid2 size={8}>
|
<Grid2 size={8}>
|
||||||
{subtypeOptions.length > 0 &&
|
{subtypeOptions.length > 0 &&
|
||||||
<TextField
|
<TextField
|
||||||
|
disabled={added}
|
||||||
value={selectedPrimarySubtype}
|
value={selectedPrimarySubtype}
|
||||||
fullWidth
|
fullWidth
|
||||||
onChange={(event)=>{
|
onChange={(event)=>{
|
||||||
|
|
@ -152,7 +154,7 @@ export default function ScannedI2C(props: Props){
|
||||||
<Checkbox
|
<Checkbox
|
||||||
value={added}
|
value={added}
|
||||||
onChange={componentSelected}
|
onChange={componentSelected}
|
||||||
//disabled={addressInUse}
|
disabled={addressInUse}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue