diff --git a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx index 29697f8..2ef7bae 100644 --- a/src/ts/@overflow/meta/react/components/SensorItemTree.tsx +++ b/src/ts/@overflow/meta/react/components/SensorItemTree.tsx @@ -35,6 +35,7 @@ export type SensorItemTreeProps = SensorItemTreeStateProps & SensorItemTreeDispa export interface SensorItemTreeState { categoryState: Map; + categoryCheckState: Map; itemState: Map>; } @@ -56,6 +57,7 @@ export class SensorItemTree extends React.Component { // this.state.itemState[key] = new Array(data.metaSensorItemList.length).fill(false); elems.push( - + { let newCategoryState: Map = _.clone(this.state.categoryState); newCategoryState[key] = !newCategoryState[key]; @@ -94,8 +96,10 @@ export class SensorItemTree extends React.Component - , checkProps: CheckboxProps) => { + + this.state.categoryCheckState[key] = checkProps.checked; let newItemState: Map> = _.clone(this.state.itemState); if (newItemState[key] === undefined) { newItemState[key] = new Array(data.metaSensorItemList.length).fill(false); @@ -140,16 +144,21 @@ export class SensorItemTree extends React.Component , checkProps: CheckboxProps) => { - if(this.selectedItemMap[parentKey] === undefined) { + if (this.selectedItemMap[parentKey] === undefined) { this.selectedItemMap[parentKey] = []; } if (checkProps.checked) { this.selectedItemMap[parentKey].push(item); } else { let index: number = this.selectedItemMap[parentKey].indexOf(item); - if(index >= 0) { + if (index >= 0) { this.selectedItemMap[parentKey].splice(index, 1); } + if (this.selectedItemMap[parentKey].length <= 0) { + let newCheckState: Map = _.clone(this.state.categoryCheckState); + newCheckState[parentKey] = false; + this.setState({ categoryCheckState: newCheckState }); + } } }} /> Sensor Item @@ -175,6 +184,13 @@ export class SensorItemTree extends React.Component): boolean { + if (metaSensorItemList.length <= 0) { + return true; + } + return false; + } + private GetMetaSensorItemType(id: number): MetaSensorItemType { for (let i: number = 0; i < SensorTypeJsonData.length; ++i) {