UNPKG

5.15 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var core_1 = require("@angular/core");
4var tree_service_1 = require("./tree.service");
5var TreeTypes = require("./tree.types");
6var tree_1 = require("./tree");
7var TreeComponent = (function () {
8 function TreeComponent(treeService) {
9 this.treeService = treeService;
10 this.nodeCreated = new core_1.EventEmitter();
11 this.nodeRemoved = new core_1.EventEmitter();
12 this.nodeRenamed = new core_1.EventEmitter();
13 this.nodeSelected = new core_1.EventEmitter();
14 this.nodeUnselected = new core_1.EventEmitter();
15 this.nodeMoved = new core_1.EventEmitter();
16 this.nodeExpanded = new core_1.EventEmitter();
17 this.nodeCollapsed = new core_1.EventEmitter();
18 this.loadNextLevel = new core_1.EventEmitter();
19 this.nodeChecked = new core_1.EventEmitter();
20 this.nodeUnchecked = new core_1.EventEmitter();
21 this.menuItemSelected = new core_1.EventEmitter();
22 this.subscriptions = [];
23 }
24 TreeComponent.prototype.ngOnChanges = function (changes) {
25 if (!this.treeModel) {
26 this.tree = TreeComponent.EMPTY_TREE;
27 }
28 else {
29 this.tree = new tree_1.Tree(this.treeModel);
30 }
31 };
32 TreeComponent.prototype.ngOnInit = function () {
33 var _this = this;
34 this.subscriptions.push(this.treeService.nodeRemoved$.subscribe(function (e) {
35 _this.nodeRemoved.emit(e);
36 }));
37 this.subscriptions.push(this.treeService.nodeRenamed$.subscribe(function (e) {
38 _this.nodeRenamed.emit(e);
39 }));
40 this.subscriptions.push(this.treeService.nodeCreated$.subscribe(function (e) {
41 _this.nodeCreated.emit(e);
42 }));
43 this.subscriptions.push(this.treeService.nodeSelected$.subscribe(function (e) {
44 _this.nodeSelected.emit(e);
45 }));
46 this.subscriptions.push(this.treeService.nodeUnselected$.subscribe(function (e) {
47 _this.nodeUnselected.emit(e);
48 }));
49 this.subscriptions.push(this.treeService.nodeMoved$.subscribe(function (e) {
50 _this.nodeMoved.emit(e);
51 }));
52 this.subscriptions.push(this.treeService.nodeExpanded$.subscribe(function (e) {
53 _this.nodeExpanded.emit(e);
54 }));
55 this.subscriptions.push(this.treeService.nodeCollapsed$.subscribe(function (e) {
56 _this.nodeCollapsed.emit(e);
57 }));
58 this.subscriptions.push(this.treeService.menuItemSelected$.subscribe(function (e) {
59 _this.menuItemSelected.emit(e);
60 }));
61 this.subscriptions.push(this.treeService.loadNextLevel$.subscribe(function (e) {
62 _this.loadNextLevel.emit(e);
63 }));
64 this.subscriptions.push(this.treeService.nodeChecked$.subscribe(function (e) {
65 _this.nodeChecked.emit(e);
66 }));
67 this.subscriptions.push(this.treeService.nodeUnchecked$.subscribe(function (e) {
68 _this.nodeUnchecked.emit(e);
69 }));
70 };
71 TreeComponent.prototype.getController = function () {
72 return this.rootComponent.controller;
73 };
74 TreeComponent.prototype.getControllerByNodeId = function (id) {
75 return this.treeService.getController(id);
76 };
77 TreeComponent.prototype.ngOnDestroy = function () {
78 this.subscriptions.forEach(function (sub) { return sub && sub.unsubscribe(); });
79 };
80 TreeComponent.EMPTY_TREE = new tree_1.Tree({ value: '' });
81 TreeComponent.decorators = [
82 { type: core_1.Component, args: [{
83 selector: 'tree',
84 template: "<tree-internal #rootComponent [tree]=\"tree\" [settings]=\"settings\" [template]=\"template\"></tree-internal>",
85 providers: [tree_service_1.TreeService]
86 },] },
87 ];
88 /** @nocollapse */
89 TreeComponent.ctorParameters = function () { return [
90 { type: tree_service_1.TreeService, decorators: [{ type: core_1.Inject, args: [tree_service_1.TreeService,] },] },
91 ]; };
92 TreeComponent.propDecorators = {
93 "treeModel": [{ type: core_1.Input, args: ['tree',] },],
94 "settings": [{ type: core_1.Input },],
95 "nodeCreated": [{ type: core_1.Output },],
96 "nodeRemoved": [{ type: core_1.Output },],
97 "nodeRenamed": [{ type: core_1.Output },],
98 "nodeSelected": [{ type: core_1.Output },],
99 "nodeUnselected": [{ type: core_1.Output },],
100 "nodeMoved": [{ type: core_1.Output },],
101 "nodeExpanded": [{ type: core_1.Output },],
102 "nodeCollapsed": [{ type: core_1.Output },],
103 "loadNextLevel": [{ type: core_1.Output },],
104 "nodeChecked": [{ type: core_1.Output },],
105 "nodeUnchecked": [{ type: core_1.Output },],
106 "menuItemSelected": [{ type: core_1.Output },],
107 "rootComponent": [{ type: core_1.ViewChild, args: ['rootComponent',] },],
108 "template": [{ type: core_1.ContentChild, args: [core_1.TemplateRef,] },],
109 };
110 return TreeComponent;
111}());
112exports.TreeComponent = TreeComponent;
113//# sourceMappingURL=tree.component.js.map
\No newline at end of file