diff --git a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx index 1dcc339..74c593e 100644 --- a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx +++ b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx @@ -2,7 +2,16 @@ import * as React from 'react'; import * as _ from 'lodash'; // import update from 'immutability-helper'; -import { Checkbox, Container, Label, Accordion, Icon, List, ListItemProps } from 'semantic-ui-react'; +import { + Checkbox, + Container, + Label, + Accordion, + Icon, + List, + ListItemProps, + CheckboxProps, +} from 'semantic-ui-react'; import MetaSensorItemType from '../../api/model/MetaSensorItemType'; @@ -26,7 +35,7 @@ export type SensorItemTreeProps = SensorItemTreeStateProps & SensorItemTreeDispa export interface SensorItemTreeState { categoryState: Map; - itemState: Map; + itemState: Map>; } interface TreeItem { @@ -71,20 +80,29 @@ export class SensorItemTree extends React.Component { - // this.state.portState[key] = false; + // this.state.itemState[key] = new Array(data.metaSensorItemList.length).fill(false); elems.push( - + { {/*let newPortState: Map = new Map(this.state.portState);*/ } - let newCategoryState: Map = _.cloneDeep(this.state.categoryState); + let newCategoryState: Map = _.clone(this.state.categoryState); + newCategoryState[key] = !newCategoryState[key]; + this.setState({ categoryState: newCategoryState }); }} /> - + , checkProps: CheckboxProps) => { + let newItemState: Map> = _.clone(this.state.itemState); + newItemState[key] = _.cloneDeep(this.state.itemState[key]); + newItemState[key].fill(checkProps.checked); + this.setState({ itemState: newItemState }); + }} /> Category {this.state.categoryState[key] ? this.ViewSensorItem(data.metaSensorItemList, key) : ''} @@ -97,21 +115,25 @@ export class SensorItemTree extends React.Component { - let checkList: boolean[] = this.state.itemState[parentKey]; elems.push( { {/*let newPortState: Map = new Map(this.state.portState);*/ } - let newItemState: Map = _.cloneDeep(this.state.itemState[parentKey]); - newItemState[idx] = !newItemState[idx]; + let newItemState: Map> = _.clone(this.state.itemState); + newItemState[parentKey][idx] = !newItemState[parentKey][idx]; this.setState({ itemState: newItemState }); }}> - + Sensor Item