Skip to content

Commit ee023c7

Browse files
author
Georgii Rychko
authored
Merge pull request #213 from valor-software/develop
2 parents b8ecec1 + 72cfcb6 commit ee023c7

29 files changed

+570
-237
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"webdriver-update": "node ./node_modules/protractor/bin/webdriver-manager update"
5050
},
5151
"devDependencies": {
52-
"@angular/cli": "1.5.4",
52+
"@angular/cli": "1.6.8",
5353
"@angular/common": "5.0.2",
5454
"@angular/compiler": "5.0.2",
5555
"@angular/compiler-cli": "5.0.2",

src/demo/app/app.component.ts

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

66
declare 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
})
176173
export 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
}

src/demo/app/app.module.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { NgModule } from '@angular/core';
2-
import { AppComponent } from './app.component';
3-
import { BrowserModule } from '@angular/platform-browser';
4-
import { TreeModule } from '../../../index';
5-
import { ButtonDirective } from './button';
6-
import { CommonModule } from '@angular/common';
1+
import {NgModule} from '@angular/core';
2+
import {AppComponent} from './app.component';
3+
import {BrowserModule} from '@angular/platform-browser';
4+
import {TreeModule} from '../../../index';
5+
import {ButtonDirective} from './button';
6+
import {CommonModule} from '@angular/common';
77

88
@NgModule({
99
declarations: [AppComponent, ButtonDirective],

src/demo/app/button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, ElementRef } from '@angular/core';
1+
import {Directive, ElementRef} from '@angular/core';
22

33
@Directive({
44
selector: '[button]'

src/demo/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { enableProdMode } from '@angular/core';
2-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1+
import {enableProdMode} from '@angular/core';
2+
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
33

4-
import { AppModule } from './app/app.module';
5-
import { environment } from './environments/environment';
4+
import {AppModule} from './app/app.module';
5+
import {environment} from './environments/environment';
66

77
if (environment.production) {
88
enableProdMode();

src/demo/polyfills.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ import 'core-js/es6/object';
2929
import 'core-js/es6/string';
3030
// import 'core-js/es6/date';
3131
import 'core-js/es6/array';
32+
/** Evergreen browsers require these. **/
33+
import 'core-js/es6/reflect';
34+
import 'core-js/es7/reflect';
35+
/***************************************************************************************************
36+
* Zone JS is required by Angular itself.
37+
*/
38+
import 'zone.js/dist/zone'; // Included with Angular CLI.
3239
// import 'core-js/es6/regexp';
3340
// import 'core-js/es6/map';
3441
// import 'core-js/es6/set';
@@ -40,23 +47,11 @@ import 'core-js/es6/array';
4047
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
4148

4249

43-
/** Evergreen browsers require these. **/
44-
import 'core-js/es6/reflect';
45-
import 'core-js/es7/reflect';
46-
47-
4850
/** ALL Firefox browsers require the following to support `@angular/animation`. **/
4951
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
5052

5153

5254

53-
/***************************************************************************************************
54-
* Zone JS is required by Angular itself.
55-
*/
56-
import 'zone.js/dist/zone'; // Included with Angular CLI.
57-
58-
59-
6055
/***************************************************************************************************
6156
* APPLICATION IMPORTS
6257
*/

src/draggable/captured-node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Tree } from '../tree';
2-
import { ElementRef } from '@angular/core';
1+
import {Tree} from '../tree';
2+
import {ElementRef} from '@angular/core';
33

44
export class CapturedNode {
55
public constructor(private anElement: ElementRef,

src/draggable/draggable.events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ElementRef } from '@angular/core';
2-
import { CapturedNode } from './captured-node';
1+
import {ElementRef} from '@angular/core';
2+
import {CapturedNode} from './captured-node';
33

44
export class NodeDraggableEvent {
55
public constructor(public captured: CapturedNode, public target: ElementRef) {

src/draggable/node-draggable.directive.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Directive, ElementRef, Input, Inject, OnDestroy, OnInit, Renderer2 } from '@angular/core';
2-
import { NodeDraggableService } from './node-draggable.service';
3-
import { CapturedNode } from './captured-node';
4-
import { Tree } from '../tree';
1+
import {Directive, ElementRef, Inject, Input, OnDestroy, OnInit, Renderer2} from '@angular/core';
2+
import {NodeDraggableService} from './node-draggable.service';
3+
import {CapturedNode} from './captured-node';
4+
import {Tree} from '../tree';
55

66
@Directive({
77
selector: '[nodeDraggable]'
@@ -43,7 +43,9 @@ export class NodeDraggableDirective implements OnDestroy, OnInit {
4343
}
4444

4545
private handleDragStart(e: DragEvent): any {
46-
e.stopPropagation();
46+
if (e.stopPropagation) {
47+
e.stopPropagation();
48+
}
4749

4850
this.nodeDraggableService.captureNode(new CapturedNode(this.nodeDraggable, this.tree));
4951

@@ -71,7 +73,9 @@ export class NodeDraggableDirective implements OnDestroy, OnInit {
7173

7274
private handleDrop(e: DragEvent): any {
7375
e.preventDefault();
74-
e.stopPropagation();
76+
if (e.stopPropagation) {
77+
e.stopPropagation();
78+
}
7579

7680
this.removeClass('over-drop-target');
7781

src/draggable/node-draggable.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Injectable, ElementRef } from '@angular/core';
2-
import { Subject } from 'rxjs/Subject';
3-
import { CapturedNode } from './captured-node';
4-
import { NodeDraggableEvent } from './draggable.events';
1+
import {ElementRef, Injectable} from '@angular/core';
2+
import {Subject} from 'rxjs/Subject';
3+
import {CapturedNode} from './captured-node';
4+
import {NodeDraggableEvent} from './draggable.events';
55

66
@Injectable()
77
export class NodeDraggableService {

0 commit comments

Comments
 (0)