1- import { Component , OnInit , ViewChild } from '@angular/core' ;
2- import { Ng2TreeSettings , NodeEvent , RenamableNode , TreeModel } from '../../../index' ;
3- import { NodeMenuItemAction } from '../../menu/menu.events' ;
4- import { MenuItemSelectedEvent } from '../../tree.events' ;
1+ import { Component , OnInit , ViewChild } from '@angular/core' ;
2+ import { Ng2TreeSettings , NodeEvent , RenamableNode , TreeModel } from '../../../index' ;
3+ import { NodeMenuItemAction } from '../../menu/menu.events' ;
4+ import { MenuItemSelectedEvent } from '../../tree.events' ;
55
66declare const alertify : any ;
77
@@ -14,6 +14,7 @@ declare const alertify: any;
1414 <div class="tree-content">
1515 <tree #treeFonts
1616 [tree]="fonts"
17+ [settings]="{rootIsVisible: false}"
1718 (menuItemSelected)="onMenuItemSelected($event)"
1819 (nodeRemoved)="onNodeRemoved($event)"
1920 (nodeRenamed)="onNodeRenamed($event)"
@@ -31,7 +32,7 @@ declare const alertify: any;
3132 <div class="tree-content">
3233 <tree
3334 [tree]="pls"
34- [settings]="settings "
35+ [settings]="disabledCheckboxesSettings "
3536 (nodeRemoved)="onNodeRemoved($event)"
3637 (nodeRenamed)="onNodeRenamed($event)"
3738 (nodeSelected)="onNodeSelected($event)"
@@ -54,7 +55,8 @@ declare const alertify: any;
5455 (nodeMoved)="onNodeMoved($event)"
5556 (nodeCreated)="onNodeFFSCreated($event)"
5657 (nodeExpanded)="onNodeExpanded($event)"
57- (nodeCollapsed)="onNodeCollapsed($event)">
58+ (nodeCollapsed)="onNodeCollapsed($event)"
59+ [settings]="settings">
5860 </tree>
5961 </div>
6062
@@ -67,18 +69,13 @@ declare const alertify: any;
6769 <button button (click)="handleActionOnFFS(12, 'remove')">Remove 'nano'</button>
6870 <button button (click)="handleActionOnFFS(52, 'reloadChildren')">Reload Music's children</button>
6971 <button button (click)="setChildrenFFS(36)">Set 'etc' children</button>
70- <button button (click)="addChildFFS(2, { value: 'ping'})">Add a child with name 'ping' to 'bin'</button>
71- <button button (click)="addChildFFS(22, { value: 'lost'})">Add a child with name 'lost' to 'lost+found'
72- </button>
73- <button button (click)="addChildFFS(22, { value: 'found', children: []})">Add a child with name 'found' to
74- 'lost+found'
75- </button>
76- <button button (click)="addChildFFS(36, { value: 'found', children: []})">Add a child with name 'found' to
77- 'etc'
78- </button>
79- <button button (click)="addChildFFS(78, { value: 'Voodo People'})">Add a child with name 'Voodo People' to
80- '2Cellos'
81- </button>
72+ <button button (click)="addChildFFS(2, {value: 'ping'})">Add a child with name 'ping' to 'bin'</button>
73+ <button button (click)="addChildFFS(22, {value: 'lost'})">Add a child with name 'lost' to 'lost+found'</button>
74+ <button button (click)="addChildFFS(22, {value: 'found', children: []})">Add a child with name 'found' to 'lost+found'</button>
75+ <button button (click)="addChildFFS(36, {value: 'found', children: []})">Add a child with name 'found' to 'etc'</button>
76+ <button button (click)="addChildFFS(78, {value: 'Voodo People'})">Add a child with name 'Voodo People' to '2Cellos'</button>
77+ <button button (click)="checkFolder(52)">Check Music folder</button>
78+ <button button (click)="uncheckFolder(52)">Uncheck Music folder</button>
8279 </div>
8380 </div>
8481 <div class="tree-container">
@@ -175,11 +172,22 @@ declare const alertify: any;
175172} )
176173export class AppComponent implements OnInit {
177174 public settings : Ng2TreeSettings = {
178- rootIsVisible : false
175+ rootIsVisible : false ,
176+ showCheckboxes : true ,
177+ } ;
178+
179+ public disabledCheckboxesSettings : Ng2TreeSettings = {
180+ rootIsVisible : false ,
181+ showCheckboxes : true ,
182+ enableCheckboxes : false
179183 } ;
180184
185+
181186 public fonts : TreeModel = {
182187 value : 'Fonts' ,
188+ settings : {
189+ isCollapsedOnInit : true
190+ } ,
183191 children : [
184192 {
185193 value : 'Serif - All my children and I are STATIC ¯\\_(ツ)_/¯' ,
@@ -208,10 +216,10 @@ export class AppComponent implements OnInit {
208216 value : 'Sans-serif (Right click me - I have a custom menu)' ,
209217 id : 11 ,
210218 settings : {
211- menuItems : [
212- { action : NodeMenuItemAction . Custom , name : 'Foo' , cssClass : 'fa fa-arrow-right' } ,
213- { action : NodeMenuItemAction . Custom , name : 'Bar' , cssClass : 'fa fa-arrow-right' } ,
214- { action : NodeMenuItemAction . Custom , name : 'Baz' , cssClass : 'fa fa-arrow-right' }
219+ menuItems : [
220+ { action : NodeMenuItemAction . Custom , name : 'Foo' , cssClass : 'fa fa-arrow-right' } ,
221+ { action : NodeMenuItemAction . Custom , name : 'Bar' , cssClass : 'fa fa-arrow-right' } ,
222+ { action : NodeMenuItemAction . Custom , name : 'Baz' , cssClass : 'fa fa-arrow-right' }
215223 ]
216224 } ,
217225 children : [
@@ -253,6 +261,7 @@ export class AppComponent implements OnInit {
253261 value : '/' ,
254262 id : 1 ,
255263 settings : {
264+
256265 cssClasses : {
257266 expanded : 'fa fa-caret-down' ,
258267 collapsed : 'fa fa-caret-right' ,
@@ -269,6 +278,7 @@ export class AppComponent implements OnInit {
269278 value : 'bin' ,
270279 id : 2 ,
271280 children : [
281+
272282 { value : 'bash' , id : 3 } ,
273283 { value : 'umount' , id : 4 } ,
274284 { value : 'cp' , id : 5 } ,
@@ -304,7 +314,10 @@ export class AppComponent implements OnInit {
304314 {
305315 value : 'lost+found' ,
306316 id : 22 ,
307- children : [ ]
317+ children : [ ] ,
318+ settings : {
319+ checked : true
320+ }
308321 } ,
309322 { value : 'abi-4.4.0-57-generic' , id : 23 } ,
310323 { value : 'config-4.4.0-57-generic' , id : 24 } ,
@@ -475,31 +488,31 @@ export class AppComponent implements OnInit {
475488 {
476489 value : 'Web Application Icons' ,
477490 children : [
478- { value : 'calendar' , icon : 'fa-calendar' } ,
479- { value : 'download' , icon : 'fa-download' } ,
480- { value : 'group' , icon : 'fa-group' } ,
481- { value : 'print' , icon : 'fa-print' }
491+ { value : 'calendar' , icon : 'fa-calendar' } ,
492+ { value : 'download' , icon : 'fa-download' } ,
493+ { value : 'group' , icon : 'fa-group' } ,
494+ { value : 'print' , icon : 'fa-print' }
482495 ]
483496 } ,
484497 {
485498 value : 'Hand Icons' ,
486499 children : [
487- { value : 'pointer' , icon : 'fa-hand-pointer-o' } ,
488- { value : 'grab' , icon : 'fa-hand-rock-o' } ,
489- { value : 'thumbs up' , icon : 'fa-thumbs-o-up ' } ,
490- { value : 'thumbs down' , icon : 'fa-thumbs-o-down' }
500+ { value : 'pointer' , icon : 'fa-hand-pointer-o' } ,
501+ { value : 'grab' , icon : 'fa-hand-rock-o' } ,
502+ { value : 'thumbs up' , icon : 'fa-thumbs-o-up ' } ,
503+ { value : 'thumbs down' , icon : 'fa-thumbs-o-down' }
491504 ]
492505 } ,
493506 {
494507 value : 'File Type Icons' ,
495508 children : [
496- { value : 'file' , icon : 'fa-file-o' } ,
497- { value : 'audio' , icon : 'fa-file-audio-o' } ,
498- { value : 'movie' , icon : 'fa-file-movie-o ' } ,
499- { value : 'archive' , icon : 'fa-file-zip-o' }
509+ { value : 'file' , icon : 'fa-file-o' } ,
510+ { value : 'audio' , icon : 'fa-file-audio-o' } ,
511+ { value : 'movie' , icon : 'fa-file-movie-o ' } ,
512+ { value : 'archive' , icon : 'fa-file-zip-o' }
500513 ]
501514 } ,
502- ]
515+ ]
503516 } ;
504517
505518 private static logEvent ( e : NodeEvent , message : string ) : void {
@@ -631,4 +644,24 @@ export class AppComponent implements OnInit {
631644 console . log ( `Controller is absent for a node with id: ${ id } ` ) ;
632645 }
633646 }
647+
648+ public checkFolder ( id : number ) : void {
649+ const treeController = this . treeFFS . getControllerByNodeId ( id ) ;
650+ if ( treeController ) {
651+ treeController . check ( ) ;
652+ } else {
653+ console . log ( `Controller is absent for a node with id: ${ id } ` ) ;
654+ }
655+
656+ }
657+
658+ public uncheckFolder ( id : number ) : void {
659+ const treeController = this . treeFFS . getControllerByNodeId ( id ) ;
660+ if ( treeController ) {
661+ treeController . uncheck ( ) ;
662+ } else {
663+ console . log ( `Controller is absent for a node with id: ${ id } ` ) ;
664+ }
665+
666+ }
634667}
0 commit comments