expanded component extensions with secondary components (mainly due to the scd30)
This commit is contained in:
parent
1f733d1d01
commit
98717b7c00
5 changed files with 131 additions and 75 deletions
|
|
@ -49,6 +49,7 @@ export default function DeviceScannedComponents(props: Props){
|
|||
},[scannedComponents])
|
||||
|
||||
useEffect(() => {
|
||||
console.log(components)
|
||||
let steps: CompStep[] = []
|
||||
components.forEach(comp => {
|
||||
steps.push({
|
||||
|
|
@ -117,7 +118,7 @@ export default function DeviceScannedComponents(props: Props){
|
|||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() => {
|
||||
close();
|
||||
setOpenDialog(false)
|
||||
}}>
|
||||
Cancel
|
||||
</Button>
|
||||
|
|
@ -164,20 +165,23 @@ export default function DeviceScannedComponents(props: Props){
|
|||
);
|
||||
};
|
||||
|
||||
const componentSelection = (newComponent: Component, checked: boolean) => {
|
||||
const componentSelection = (newComponents: Component[], checked: boolean) => {
|
||||
let cloneList = cloneDeep(components)
|
||||
if(checked){
|
||||
//add the component to the list
|
||||
cloneList.push(newComponent)
|
||||
cloneList = cloneList.concat(newComponents)
|
||||
}else{
|
||||
//remove any components that match the component location: (type)-(addressType)-(address)
|
||||
components.forEach((comp, i) => {
|
||||
//check the components location against the one in the list
|
||||
if(comp.locationString() === newComponent.locationString()){
|
||||
cloneList.splice(i, 1)
|
||||
}
|
||||
newComponents.forEach(newComponent => {
|
||||
//remove any components that match the component location: (type)-(addressType)-(address)
|
||||
cloneList.forEach((comp, i) => {
|
||||
//check the components location against the one in the list
|
||||
if(comp.locationString() === newComponent.locationString()){
|
||||
cloneList.splice(i, 1)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
console.log(cloneList)
|
||||
setComponents(cloneList)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue