diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a3e1d05..4e242d9 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -80,7 +80,31 @@ export class AppComponent implements OnInit { this.menuTarget = node; this.lastClickEvent = [tree, node, $event]; - } + }, + contextMenu: (tree, node, event) => { + event.preventDefault(); + event.stopPropagation(); + + TREE_ACTIONS.FOCUS(tree, node, event); + TREE_ACTIONS.EXPAND(tree, node, event); + + this.addChildTarget = false; + this.deleteTarget = false; + this.menuTarget = false; + + if ( !node.data.noChildren && (!node.data.level || node.data.level === 'manage') ) { + this.addChildTarget = node; + } + + if ( !node.data.noDelete && (!node.data.level || node.data.level === 'manage') ) { + this.deleteTarget = node; + } + + this.menuTarget = node; + this.lastClickEvent = [tree, node, event]; + + this.onNodeMenuClick(event); + }, } } };