Last active
June 1, 2016 01:14
-
-
Save matthieu-D/2df797bc5a24c037d69ead95b40540da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input } from '@angular/core'; | |
import {Draggable,Droppable} from 'primeng/primeng'; | |
import {TreeManager} from './tree-manager'; | |
@Component({ | |
selector: 'tree-node', | |
directives: [Draggable,Droppable, TreeNode], | |
template: require('./tree-node.html') | |
}) | |
export class TreeNode{ | |
@Input() children; | |
treeManager:TreeManager; | |
constructor(treeManager:TreeManager) { | |
this.treeManager = treeManager; | |
} | |
onDragStart(event,child){ | |
this.treeManager.setSelectedNode(child); | |
} | |
onDragEnd(event,child){ | |
this.children.splice(this.children.indexOf(child), 1); | |
} | |
onDrop(event,node){ | |
node.subNodes = [...node.subNodes, this.treeManager.getSelectedNode()] | |
} | |
toggle(child) { | |
child.expanded = !child.expanded; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment