Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
callback: (rowInfoIter) => {
var isActive = (rowInfoIter.treeIndex == rowInfo.treeIndex);
// If toggleMode just toggle to activate/inactivate selected node
// If non toggle mode inactive all nodes but selected
if (isActive && toggleMode) {
rowInfoIter.node.active = !rowInfoIter.node.active;
currentTreeData = changeNodeAtPath({ treeData: currentTreeData, path: rowInfoIter.path, newNode: rowInfoIter.node, getNodeKey: ({ treeIndex }) => treeIndex, ignoreCollapsed: false });
}
else if (isActive != rowInfoIter.node.active && !toggleMode) {
rowInfoIter.node.active = isActive;
currentTreeData = changeNodeAtPath({ treeData: currentTreeData, path: rowInfoIter.path, newNode: rowInfoIter.node, getNodeKey: ({ treeIndex }) => treeIndex, ignoreCollapsed: false });
}
}
});
handleClick(event, rowInfo) {
var toggleMode = this.props.toggleMode;
var currentTreeData = this.state.treeData;
// If node has children, we expand/collapse the node
if (rowInfo.node.children != undefined && rowInfo.node.children.length > 0) {
rowInfo.node.expanded = !rowInfo.node.expanded;
currentTreeData = changeNodeAtPath({ treeData: currentTreeData, path: rowInfo.path, newNode: rowInfo.node, getNodeKey: ({ treeIndex }) => treeIndex, ignoreCollapsed: false });
}
// If node has no children, we select the node
else if (rowInfo.node.children == undefined) {
walk({
treeData: currentTreeData,
getNodeKey: ({ treeIndex }) => treeIndex,
ignoreCollapsed: false,
callback: (rowInfoIter) => {
var isActive = (rowInfoIter.treeIndex == rowInfo.treeIndex);
// If toggleMode just toggle to activate/inactivate selected node
// If non toggle mode inactive all nodes but selected
if (isActive && toggleMode) {
rowInfoIter.node.active = !rowInfoIter.node.active;
currentTreeData = changeNodeAtPath({ treeData: currentTreeData, path: rowInfoIter.path, newNode: rowInfoIter.node, getNodeKey: ({ treeIndex }) => treeIndex, ignoreCollapsed: false });
}
else if (isActive != rowInfoIter.node.active && !toggleMode) {
this.setState(state => ({
treeData: changeNodeAtPath({
treeData: state.treeData,
path,
getNodeKey,
newNode: { ...node, isStateful:true }
})
}))
}
onChange={event => {
mutations.dataChange({
data: changeNodeAtPath({
treeData: state.data,
path,
getNodeKey,
newNode: {
...node,
element: event.target.value,
},
}),
})
}}
>
const updateNode = ({ node, path }) => {
var data = changeNodeAtPath({
treeData: treeData,
path,
getNodeKey,
newNode: TreeNodeFormatter(instrumentId, node)
})
setTreeData(data)
reorderConstructs(data)
}
this.setState(state => ({
treeData: changeNodeAtPath({
treeData: state.treeData,
path,
getNodeKey,
newNode: { ...node, name },
}),
}));
}}
const disableNode = ({ node, path, treeIndex }) => {
const newTree = changeNodeAtPath({ treeData: this.state.tree, path, getNodeKey, newNode: { ...node, disabled: !node.disabled }});
QueryTreeActions.update(newTree);
};
return (
this.setState(state => ({
treeData: changeNodeAtPath({
treeData: state.treeData,
path,
getNodeKey,
newNode: { ...node, name},
}),
}));
}}
.then(dirList => {
if (treeData != [] && treeData.length > 0) {
rowInfo.node.children = dirList;
rowInfo.node.expanded = true;
rowInfo.node.load = true;
var newTreeData = changeNodeAtPath({
treeData: treeData,
path: rowInfo.path,
newNode: rowInfo.node,
getNodeKey: ({ treeIndex }) => treeIndex
});
} else {
var newTreeData = dirList;
}
if (!this.props.exploreOnlyDirs || rowInfo == undefined){
this.setState({ selection: undefined })
} else {
this.setState({ selection: rowInfo.node })
}
this.refs.tree.updateTreeData(newTreeData);
});
}