diff --git a/src/ts/@overflow/sensor/react/components/item_tree.tsx b/src/ts/@overflow/sensor/react/components/item_tree.tsx index 5f716e2..e0a4494 100644 --- a/src/ts/@overflow/sensor/react/components/item_tree.tsx +++ b/src/ts/@overflow/sensor/react/components/item_tree.tsx @@ -17,7 +17,7 @@ export type Props = StateProps & DispatchProps; export interface State { dropState: Map; - checkBoxState: Map; + // checkBoxState: Map; checkBoxChildrenState: Map>; } @@ -35,7 +35,7 @@ export class ItemTree extends React.Component { this.state = { dropState: new Map(), - checkBoxState: new Map(), + // checkBoxState: new Map(), checkBoxChildrenState: new Map(), }; @@ -70,10 +70,14 @@ export class ItemTree extends React.Component { }); } - private onCheckBox = (key: string, checkProps: CheckboxProps, data: ItemTreeObj) => { - this.state.checkBoxState[key] = checkProps.checked; + private onCheckBox = (pKey: string, key: string, checkProps: CheckboxProps, data: ItemTreeObj) => { + // this.state.checkBoxState[key] = checkProps.checked; let newCheckBoxChildrenState: Map> = _.clone(this.state.checkBoxChildrenState); + if(newCheckBoxChildrenState.get(pKey) === undefined) { + newCheckBoxChildrenState.set(pKey, new Map()); + } + newCheckBoxChildrenState.get(pKey).set(key, checkProps.checked); this.reverseChildrenCheck(data.children, key, checkProps, newCheckBoxChildrenState); @@ -97,20 +101,20 @@ export class ItemTree extends React.Component { let resBool: boolean = false; - if (this.state.checkBoxState[key]) { - resBool = true; + // if (this.state.checkBoxState[key]) { + // resBool = true; + // } + + // if (pKey !== '') { + + let childrenState: Map = this.state.checkBoxChildrenState.get(pKey); + + if (childrenState !== undefined) { + let b: boolean = childrenState.get(key); + resBool = b; } - if (pKey !== '') { - - let childrenState: Map = this.state.checkBoxChildrenState.get(pKey); - - if (childrenState !== undefined) { - let b: boolean = childrenState.get(key); - resBool = b; - } - - } + // } return resBool; } @@ -123,7 +127,7 @@ export class ItemTree extends React.Component { let elems: JSX.Element[]; - elems = this.itemRender(this.props.ItemTreeList, ''); + elems = this.itemRender(this.props.ItemTreeList, 'r'); return elems; } @@ -158,7 +162,7 @@ export class ItemTree extends React.Component { {item.isCheckBox === false ? item.label : , checkProps: CheckboxProps) => { - this.onCheckBox(nkeyStr, checkProps, item); + this.onCheckBox(pKeyStr, nkeyStr, checkProps, item); }} />}