diff --git a/src/demo/app/app.component.ts b/src/demo/app/app.component.ts index cb332629..ac7b8c55 100644 --- a/src/demo/app/app.component.ts +++ b/src/demo/app/app.component.ts @@ -9,165 +9,183 @@ declare const alertify: any; selector: 'app', template: `
-
-

Fonts tree

-
- - +
+
+

Fonts tree

+
+
+ + +
-
-
-

Programming languages tree

-

this tree is loaded asynchronously

-
- - +
+
+

Programming languages tree

+

this tree is loaded asynchronously

+
+
+ + +
-
-
-
-

Directory/File structure

-

this tree has advanced configurations

+
+
+

Directory/File structure

+

this tree has advanced configurations

+
+
+ + +
+ +
+

Tree API exposed via TreeController

+ + + + + + + + + + + + + + +
-
- - +
+
+

Programming languages tree

+

this tree is using a custom template

+
+
+ + + + + + +
- -
-

Tree API exposed via TreeController

- - - - - - - - - - - - - - -
-
-
-

Programming languages tree

-

this tree is using a custom template

-
- - - - - +
+
+

Custom right click GUI tree

+

this tree is using a custom right click menu

+
+
+ + +
-
`, styles: [` .tree-info { - flex: 1 0 100%; - display: flex; - flex-direction: column; - align-items: flex-start; - } + flex: 1 0 100%; + display: flex; + flex-direction: column; + align-items: flex-start; + } - .tree-controlls { - display: flex; - flex-direction: column; - } + .tree-controlls { + display: flex; + flex-direction: column; + } - .tree-content { - display: flex; - flex-direction: column; - } + .tree-content { + display: flex; + flex-direction: column; + } - .tree-container { - margin-bottom: 20px; + .tree-container { + margin-bottom: 20px; - } + } - .tree-container--with-controls { - display: flex; - flex-wrap: wrap; - } + .tree-container--with-controls { + display: flex; + flex-wrap: wrap; + } - .tree-demo-app { - display: flex; - flex-direction: column; - } + .tree-demo-app { + display: flex; + flex-direction: column; + margin-bottom:50px; + } - .tree-title { - margin: 0; - color: #40a070; - font-size: 2em; - } + .tree-title { + margin: 0; + color: #40a070; + font-size: 2em; + } - .notice { - color: #e91e63; - font-size: 1.2em; - font-style: italic; - } + .notice { + color: #e91e63; + font-size: 1.2em; + font-style: italic; + } - :host /deep/ .fa { - cursor: pointer; - } + :host /deep/ .fa { + cursor: pointer; + } - :host /deep/ .fa.disabled { - cursor: inherit; - color: #757575; - } + :host /deep/ .fa.disabled { + cursor: inherit; + color: #757575; + } - .button { - border-radius: 4px; - box-shadow: 0 2px 4px 0 #888; - background-color: #fff; - -webkit-appearance: none; - border: 1px solid #000; - height: 35px; - outline: none; - } + .button { + border-radius: 4px; + box-shadow: 0 2px 4px 0 #888; + background-color: #fff; + -webkit-appearance: none; + border: 1px solid #000; + height: 35px; + outline: none; + } - .button-pressed { - box-shadow: 0 0 1px 0 #888; - } + .button-pressed { + box-shadow: 0 0 1px 0 #888; + } - .tree-controlls button { - margin: 5px; - } + .tree-controlls button { + margin: 5px; + } `] }) export class AppComponent implements OnInit { @@ -515,6 +533,22 @@ export class AppComponent implements OnInit { ] }; + public custom: TreeModel = { + settings: { + menuItems: [ + { action: NodeMenuItemAction.NewFolder, name: 'Add parent node', cssClass: '' }, + { action: NodeMenuItemAction.NewTag, name: 'Add child node', cssClass: '' }, + { action: NodeMenuItemAction.Remove, name: 'Remove node', cssClass: '' }, + { action: NodeMenuItemAction.Rename, name: 'Rename node', cssClass: '' }, + { action: NodeMenuItemAction.Custom, name: 'Custom Action', cssClass: '' } + ] + }, + value: 'TestParent', + children: [ + {value: 'TestChild', icon: ''} + ] + } + private static logEvent(e: NodeEvent, message: string): void { console.log(e); alertify.message(`${message}: ${e.node.value}`); diff --git a/src/tree-internal.component.ts b/src/tree-internal.component.ts index c1d29732..620adc5a 100644 --- a/src/tree-internal.component.ts +++ b/src/tree-internal.component.ts @@ -229,6 +229,7 @@ export class TreeInternalComponent implements OnInit, OnChanges, OnDestroy, Afte this.onRemoveSelected(); break; case NodeMenuItemAction.Custom: + this.onCustomSelected(); this.treeService.fireMenuItemSelected(this.tree, e.nodeMenuItemSelected); break; default: @@ -253,6 +254,11 @@ export class TreeInternalComponent implements OnInit, OnChanges, OnDestroy, Afte this.treeService.fireNodeRemoved(this.tree); } + private onCustomSelected(): void { + this.isRightMenuVisible = false; + this.isLeftMenuVisible = false; + } + public onSwitchFoldingType(): void { this.tree.switchFoldingType(); this.treeService.fireNodeSwitchFoldingType(this.tree);