Commit 1e490cf1 authored by d.arizona's avatar d.arizona

drag drop

parent af7e9aed
...@@ -4,8 +4,6 @@ import { TextField, List, ListSubheader, Typography, Collapse } from '@material- ...@@ -4,8 +4,6 @@ import { TextField, List, ListSubheader, Typography, Collapse } from '@material-
import MinimizeIcon from '@material-ui/icons/Minimize'; import MinimizeIcon from '@material-ui/icons/Minimize';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove'; import RemoveIcon from '@material-ui/icons/Remove';
import TreeView from '@material-ui/lab/TreeView';
import TreeItem from '@material-ui/lab/TreeItem';
import Nestable from 'react-nestable'; import Nestable from 'react-nestable';
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
...@@ -73,7 +71,8 @@ export default class VisualReportItems extends Component { ...@@ -73,7 +71,8 @@ export default class VisualReportItems extends Component {
] ]
}, },
], ],
arrayCollapse: [] arrayCollapse: [],
defaultCollapsed: false
} }
} }
...@@ -94,32 +93,30 @@ export default class VisualReportItems extends Component { ...@@ -94,32 +93,30 @@ export default class VisualReportItems extends Component {
} }
} }
renderItem = ({ item, index }) => { onDefaultCollapsed = () => this.setState({
return(item.text) defaultCollapsed: !this.state.defaultCollapsed
// if (item.children.length > 0) { });
// return (
// <TreeView collapse = (collapseCase) => {
// defaultCollapseIcon={<RemoveIcon />} let arrayCollapse = this.state.arrayCollapse
// defaultExpandIcon={< AddIcon/>} let index = arrayCollapse.findIndex((val) => val.id === collapseCase)
// > if (arrayCollapse.includes(collapseCase)) {
// {item.children.length > 0 && arrayCollapse.splice(index, 1)
// <TreeItem nodeId={item.id} style={{margin: 10}} label={item.text}> } else {
// {item.children.map((items,indexs) => { arrayCollapse.push(collapseCase)
// return ( }
// <TreeItem nodeId={items.id} style={{margin: 10}} label={items.text}/> if (this.refNestable) {
// ) this.refNestable.collapse(arrayCollapse.length > 0? arrayCollapse : 'NONE');
// })} }
// </TreeItem> };
// // :
// // <TreeItem nodeId={item.id} style={{margin: 10}} label={item.text}/> renderItem = ({ item, collapseIcon }) => {
// } return (
// </TreeView> <div>
// ) {collapseIcon ? (this.state.arrayCollapse.includes(item.id)? <AddIcon/> : <RemoveIcon/>) : null}
// } else { <button type="button" onClick={() => this.collapse(item.id)}>{item.text}</button>
// return ( </div>
// <TreeItem nodeId={item.id} style={{margin: 10}} label={item.text}/> )
// )
// }
}; };
render() { render() {
...@@ -141,7 +138,6 @@ export default class VisualReportItems extends Component { ...@@ -141,7 +138,6 @@ export default class VisualReportItems extends Component {
style={{ width: 250 }} style={{ width: 250 }}
select select
label="Item Laporan" label="Item Laporan"
// onChange={handleChange}
helperText="" helperText=""
SelectProps={{ SelectProps={{
native: true, native: true,
...@@ -177,7 +173,6 @@ export default class VisualReportItems extends Component { ...@@ -177,7 +173,6 @@ export default class VisualReportItems extends Component {
style={{ width: 250 }} style={{ width: 250 }}
select select
label="Perusahaan" label="Perusahaan"
// onChange={handleChange}
helperText="" helperText=""
SelectProps={{ SelectProps={{
native: true, native: true,
...@@ -210,7 +205,9 @@ export default class VisualReportItems extends Component { ...@@ -210,7 +205,9 @@ export default class VisualReportItems extends Component {
<div className="margin-top-30px"> <div className="margin-top-30px">
<Nestable <Nestable
items={this.state.items} items={this.state.items}
collapsed={this.state.defaultCollapsed}
renderItem={this.renderItem} renderItem={this.renderItem}
ref={el => this.refNestable = el}
onChange={(e) => this.setState({items: e})} onChange={(e) => this.setState({items: e})}
/> />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment