1 | !function(e){function t(e){Object.defineProperty(this,e,{enumerable:!0,get:function(){return this[v][e]}})}function r(e){if("undefined"!=typeof System&&System.isModule?System.isModule(e):"[object Module]"===Object.prototype.toString.call(e))return e;var t={default:e,__useDefault:e};if(e&&e.__esModule)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new o(t)}function o(e){Object.defineProperty(this,v,{value:e}),Object.keys(e).forEach(t,this)}function n(e){return"@node/"===e.substr(0,6)?c(e,r(m(e.substr(6))),{}):p[e]}function u(e){var t=n(e);if(!t)throw new Error('Module "'+e+'" expected, but not contained in build.');if(t.module)return t.module;var r=t.linkRecord;return i(t,r),a(t,r,[]),t.module}function i(e,t){if(!t.depLoads){t.declare&&d(e,t),t.depLoads=[];for(var r=0;r<t.deps.length;r++){var o=n(t.deps[r]);t.depLoads.push(o),o.linkRecord&&i(o,o.linkRecord);var u=t.setters&&t.setters[r];u&&(u(o.module||o.linkRecord.moduleObj),o.importerSetters.push(u))}return e}}function d(t,r){var o=r.moduleObj,n=t.importerSetters,u=!1,i=r.declare.call(e,function(e,t){if(!u){if("object"==typeof e)for(var r in e)"__useDefault"!==r&&(o[r]=e[r]);else o[e]=t;u=!0;for(var i=0;i<n.length;i++)n[i](o);return u=!1,t}},{id:t.key});"function"!=typeof i?(r.setters=i.setters,r.execute=i.execute):(r.setters=[],r.execute=i)}function l(e,t,r){return p[e]={key:e,module:void 0,importerSetters:[],linkRecord:{deps:t,depLoads:void 0,declare:r,setters:void 0,execute:void 0,moduleObj:{}}}}function f(e,t,r,o){var n={};return p[e]={key:e,module:void 0,importerSetters:[],linkRecord:{deps:t,depLoads:void 0,declare:void 0,execute:o,executingRequire:r,moduleObj:{default:n,__useDefault:n},setters:void 0}}}function s(e,t,r){return function(o){for(var n=0;n<e.length;n++)if(e[n]===o){var u,i=t[n],d=i.linkRecord;return u=d?-1===r.indexOf(i)?a(i,d,r):d.moduleObj:i.module,"__useDefault"in u?u.__useDefault:u}}}function a(t,r,n){if(n.push(t),t.module)return t.module;var u;if(r.setters){for(var i=0;i<r.deps.length;i++){var d=r.depLoads[i],l=d.linkRecord;l&&-1===n.indexOf(d)&&(u=a(d,l,l.setters?n:[]))}r.execute.call(y)}else{var f={id:t.key},c=r.moduleObj;Object.defineProperty(f,"exports",{configurable:!0,set:function(e){c.default=c.__useDefault=e},get:function(){return c.__useDefault}});var p=s(r.deps,r.depLoads,n);if(!r.executingRequire)for(var i=0;i<r.deps.length;i++)p(r.deps[i]);var v=r.execute.call(e,p,c.__useDefault,f);void 0!==v?c.default=c.__useDefault=v:f.exports!==c.__useDefault&&(c.default=c.__useDefault=f.exports);var m=c.__useDefault;if(m&&m.__esModule)for(var b in m)Object.hasOwnProperty.call(m,b)&&(c[b]=m[b])}var f=t.module=new o(r.moduleObj);if(!r.setters)for(var i=0;i<t.importerSetters.length;i++)t.importerSetters[i](f);return f}function c(e,t){return p[e]={key:e,module:t,importerSetters:[],linkRecord:void 0}}var p={},v="undefined"!=typeof Symbol?Symbol():"@@baseObject";o.prototype=Object.create(null),"undefined"!=typeof Symbol&&Symbol.toStringTag&&(o.prototype[Symbol.toStringTag]="Module");var m="undefined"!=typeof System&&System._nodeRequire||"undefined"!=typeof require&&"undefined"!=typeof require.resolve&&"undefined"!=typeof process&&process.platform&&require,y={};return Object.freeze&&Object.freeze(y),function(e,t,n,i){return function(d){d(function(d){var s={_nodeRequire:m,register:l,registerDynamic:f,registry:{get:function(e){return p[e].module},set:c},newModule:function(e){return new o(e)}};c("@empty",new o({}));for(var a=0;a<t.length;a++)c(t[a],r(arguments[a],{}));i(s);var v=u(e[0]);if(e.length>1)for(var a=1;a<e.length;a++)u(e[a]);return n?v.__useDefault:(v instanceof o&&Object.defineProperty(v,"__esModule",{value:!0}),v)})}}}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this)
|
2 |
|
3 | (["a"], ["2a","10","28","1f","24","d","c","e"], true, function($__System) {
|
4 | var require = this.require, exports = this.exports, module = this.module;
|
5 | $__System.registerDynamic("b", ["c", "d", "e"], true, function ($__require, exports, module) {
|
6 | "use strict";
|
7 |
|
8 | var global = this || self,
|
9 | GLOBAL = global;
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | $__require("c");
|
12 | $__require("d");
|
13 | $__require("e");
|
14 |
|
15 |
|
16 | exports.noop = function () {};
|
17 |
|
18 | });
|
19 | $__System.registerDynamic("f", ["10", "11", "12", "13"], true, function ($__require, exports, module) {
|
20 | "use strict";
|
21 |
|
22 | var global = this || self,
|
23 | GLOBAL = global;
|
24 | Object.defineProperty(exports, "__esModule", { value: true });
|
25 | var core_1 = $__require("10");
|
26 | var tree_service_1 = $__require("11");
|
27 | var TreeTypes = $__require("12");
|
28 | var tree_1 = $__require("13");
|
29 | var TreeComponent = function () {
|
30 | function TreeComponent(treeService) {
|
31 | this.treeService = treeService;
|
32 | this.nodeCreated = new core_1.EventEmitter();
|
33 | this.nodeRemoved = new core_1.EventEmitter();
|
34 | this.nodeRenamed = new core_1.EventEmitter();
|
35 | this.nodeSelected = new core_1.EventEmitter();
|
36 | this.nodeUnselected = new core_1.EventEmitter();
|
37 | this.nodeMoved = new core_1.EventEmitter();
|
38 | this.nodeExpanded = new core_1.EventEmitter();
|
39 | this.nodeCollapsed = new core_1.EventEmitter();
|
40 | this.loadNextLevel = new core_1.EventEmitter();
|
41 | this.nodeChecked = new core_1.EventEmitter();
|
42 | this.nodeUnchecked = new core_1.EventEmitter();
|
43 | this.menuItemSelected = new core_1.EventEmitter();
|
44 | this.subscriptions = [];
|
45 | }
|
46 | TreeComponent.prototype.ngOnChanges = function (changes) {
|
47 | if (!this.treeModel) {
|
48 | this.tree = TreeComponent.EMPTY_TREE;
|
49 | } else {
|
50 | this.tree = new tree_1.Tree(this.treeModel);
|
51 | }
|
52 | };
|
53 | TreeComponent.prototype.ngOnInit = function () {
|
54 | var _this = this;
|
55 | this.subscriptions.push(this.treeService.nodeRemoved$.subscribe(function (e) {
|
56 | _this.nodeRemoved.emit(e);
|
57 | }));
|
58 | this.subscriptions.push(this.treeService.nodeRenamed$.subscribe(function (e) {
|
59 | _this.nodeRenamed.emit(e);
|
60 | }));
|
61 | this.subscriptions.push(this.treeService.nodeCreated$.subscribe(function (e) {
|
62 | _this.nodeCreated.emit(e);
|
63 | }));
|
64 | this.subscriptions.push(this.treeService.nodeSelected$.subscribe(function (e) {
|
65 | _this.nodeSelected.emit(e);
|
66 | }));
|
67 | this.subscriptions.push(this.treeService.nodeUnselected$.subscribe(function (e) {
|
68 | _this.nodeUnselected.emit(e);
|
69 | }));
|
70 | this.subscriptions.push(this.treeService.nodeMoved$.subscribe(function (e) {
|
71 | _this.nodeMoved.emit(e);
|
72 | }));
|
73 | this.subscriptions.push(this.treeService.nodeExpanded$.subscribe(function (e) {
|
74 | _this.nodeExpanded.emit(e);
|
75 | }));
|
76 | this.subscriptions.push(this.treeService.nodeCollapsed$.subscribe(function (e) {
|
77 | _this.nodeCollapsed.emit(e);
|
78 | }));
|
79 | this.subscriptions.push(this.treeService.menuItemSelected$.subscribe(function (e) {
|
80 | _this.menuItemSelected.emit(e);
|
81 | }));
|
82 | this.subscriptions.push(this.treeService.loadNextLevel$.subscribe(function (e) {
|
83 | _this.loadNextLevel.emit(e);
|
84 | }));
|
85 | this.subscriptions.push(this.treeService.nodeChecked$.subscribe(function (e) {
|
86 | _this.nodeChecked.emit(e);
|
87 | }));
|
88 | this.subscriptions.push(this.treeService.nodeUnchecked$.subscribe(function (e) {
|
89 | _this.nodeUnchecked.emit(e);
|
90 | }));
|
91 | };
|
92 | TreeComponent.prototype.getController = function () {
|
93 | return this.rootComponent.controller;
|
94 | };
|
95 | TreeComponent.prototype.getControllerByNodeId = function (id) {
|
96 | return this.treeService.getController(id);
|
97 | };
|
98 | TreeComponent.prototype.ngOnDestroy = function () {
|
99 | this.subscriptions.forEach(function (sub) {
|
100 | return sub && sub.unsubscribe();
|
101 | });
|
102 | };
|
103 | TreeComponent.EMPTY_TREE = new tree_1.Tree({ value: '' });
|
104 | TreeComponent.decorators = [{ type: core_1.Component, args: [{
|
105 | selector: 'tree',
|
106 | template: "<tree-internal #rootComponent [tree]=\"tree\" [settings]=\"settings\" [template]=\"template\"></tree-internal>",
|
107 | providers: [tree_service_1.TreeService]
|
108 | }] }];
|
109 |
|
110 | TreeComponent.ctorParameters = function () {
|
111 | return [{ type: tree_service_1.TreeService, decorators: [{ type: core_1.Inject, args: [tree_service_1.TreeService] }] }];
|
112 | };
|
113 | TreeComponent.propDecorators = {
|
114 | "treeModel": [{ type: core_1.Input, args: ['tree'] }],
|
115 | "settings": [{ type: core_1.Input }],
|
116 | "nodeCreated": [{ type: core_1.Output }],
|
117 | "nodeRemoved": [{ type: core_1.Output }],
|
118 | "nodeRenamed": [{ type: core_1.Output }],
|
119 | "nodeSelected": [{ type: core_1.Output }],
|
120 | "nodeUnselected": [{ type: core_1.Output }],
|
121 | "nodeMoved": [{ type: core_1.Output }],
|
122 | "nodeExpanded": [{ type: core_1.Output }],
|
123 | "nodeCollapsed": [{ type: core_1.Output }],
|
124 | "loadNextLevel": [{ type: core_1.Output }],
|
125 | "nodeChecked": [{ type: core_1.Output }],
|
126 | "nodeUnchecked": [{ type: core_1.Output }],
|
127 | "menuItemSelected": [{ type: core_1.Output }],
|
128 | "rootComponent": [{ type: core_1.ViewChild, args: ['rootComponent'] }],
|
129 | "template": [{ type: core_1.ContentChild, args: [core_1.TemplateRef] }]
|
130 | };
|
131 | return TreeComponent;
|
132 | }();
|
133 | exports.TreeComponent = TreeComponent;
|
134 |
|
135 | });
|
136 | $__System.registerDynamic("14", ["15", "16", "17"], true, function ($__require, exports, module) {
|
137 | "use strict";
|
138 |
|
139 | var global = this || self,
|
140 | GLOBAL = global;
|
141 | Object.defineProperty(exports, "__esModule", { value: true });
|
142 | var menu_events_1 = $__require("15");
|
143 | var event_utils_1 = $__require("16");
|
144 | var fn_utils_1 = $__require("17");
|
145 | var TreeController = function () {
|
146 | function TreeController(component) {
|
147 | this.component = component;
|
148 | this.tree = this.component.tree;
|
149 | this.treeService = this.component.treeService;
|
150 | }
|
151 | TreeController.prototype.select = function () {
|
152 | if (!this.isSelected()) {
|
153 | this.component.onNodeSelected({ button: event_utils_1.MouseButtons.Left });
|
154 | }
|
155 | };
|
156 | TreeController.prototype.unselect = function () {
|
157 | if (this.isSelected()) {
|
158 | this.component.onNodeUnselected({ button: event_utils_1.MouseButtons.Left });
|
159 | }
|
160 | };
|
161 | TreeController.prototype.isSelected = function () {
|
162 | return this.component.isSelected;
|
163 | };
|
164 | TreeController.prototype.expand = function () {
|
165 | if (this.isCollapsed()) {
|
166 | this.component.onSwitchFoldingType();
|
167 | }
|
168 | };
|
169 | TreeController.prototype.expandToParent = function (tree) {
|
170 | if (tree === void 0) {
|
171 | tree = this.tree;
|
172 | }
|
173 | if (tree) {
|
174 | var controller = this.treeService.getController(tree.id);
|
175 | if (controller) {
|
176 | controller.expand();
|
177 | this.expandToParent(tree.parent);
|
178 | }
|
179 | }
|
180 | };
|
181 | TreeController.prototype.isExpanded = function () {
|
182 | return this.tree.isNodeExpanded();
|
183 | };
|
184 | TreeController.prototype.collapse = function () {
|
185 | if (this.isExpanded()) {
|
186 | this.component.onSwitchFoldingType();
|
187 | }
|
188 | };
|
189 | TreeController.prototype.isCollapsed = function () {
|
190 | return this.tree.isNodeCollapsed();
|
191 | };
|
192 | TreeController.prototype.toTreeModel = function () {
|
193 | return this.tree.toTreeModel();
|
194 | };
|
195 | TreeController.prototype.rename = function (newValue) {
|
196 | this.tree.markAsBeingRenamed();
|
197 | this.component.applyNewValue({ type: 'keyup', value: newValue });
|
198 | };
|
199 | TreeController.prototype.remove = function () {
|
200 | this.component.onMenuItemSelected({ nodeMenuItemAction: menu_events_1.NodeMenuItemAction.Remove });
|
201 | };
|
202 | TreeController.prototype.addChild = function (newNode) {
|
203 | if (this.tree.hasDeferredChildren() && !this.tree.childrenWereLoaded()) {
|
204 | return;
|
205 | }
|
206 | var newTree = this.tree.createNode(Array.isArray(newNode.children), newNode);
|
207 | this.treeService.fireNodeCreated(newTree);
|
208 | };
|
209 | TreeController.prototype.addChildAsync = function (newNode) {
|
210 | if (this.tree.hasDeferredChildren() && !this.tree.childrenWereLoaded()) {
|
211 | return Promise.reject(new Error('This node loads its children asynchronously, hence child cannot be added this way'));
|
212 | }
|
213 | var newTree = this.tree.createNode(Array.isArray(newNode.children), newNode);
|
214 | this.treeService.fireNodeCreated(newTree);
|
215 |
|
216 | return new Promise(function (resolve) {
|
217 | setTimeout(function () {
|
218 | resolve(newTree);
|
219 | });
|
220 | });
|
221 | };
|
222 | TreeController.prototype.changeNodeId = function (id) {
|
223 | if (!id) {
|
224 | throw Error('You should supply an id!');
|
225 | }
|
226 | if (this.treeService.hasController(id)) {
|
227 | throw Error("Controller already exists for the given id: " + id);
|
228 | }
|
229 | this.treeService.deleteController(this.tree.id);
|
230 | this.tree.id = id;
|
231 | this.treeService.setController(this.tree.id, this);
|
232 | };
|
233 | TreeController.prototype.reloadChildren = function () {
|
234 | this.tree.reloadChildren();
|
235 | };
|
236 | TreeController.prototype.setChildren = function (children) {
|
237 | if (!this.tree.isLeaf()) {
|
238 | this.tree.setChildren(children);
|
239 | }
|
240 | };
|
241 | TreeController.prototype.startRenaming = function () {
|
242 | this.tree.markAsBeingRenamed();
|
243 | };
|
244 | TreeController.prototype.check = function () {
|
245 | this.component.onNodeChecked();
|
246 | };
|
247 | TreeController.prototype.uncheck = function () {
|
248 | this.component.onNodeUnchecked();
|
249 | };
|
250 | TreeController.prototype.isChecked = function () {
|
251 | return this.tree.checked;
|
252 | };
|
253 | TreeController.prototype.isIndetermined = function () {
|
254 | return fn_utils_1.get(this.component, 'checkboxElementRef.nativeElement.indeterminate');
|
255 | };
|
256 | TreeController.prototype.allowSelection = function () {
|
257 | this.tree.selectionAllowed = true;
|
258 | };
|
259 | TreeController.prototype.forbidSelection = function () {
|
260 | this.tree.selectionAllowed = false;
|
261 | };
|
262 | TreeController.prototype.isSelectionAllowed = function () {
|
263 | return this.tree.selectionAllowed;
|
264 | };
|
265 | return TreeController;
|
266 | }();
|
267 | exports.TreeController = TreeController;
|
268 |
|
269 | });
|
270 | $__System.registerDynamic("18", ["10", "12", "13", "14", "19", "15", "1a", "11", "16", "17"], true, function ($__require, exports, module) {
|
271 | "use strict";
|
272 |
|
273 | var global = this || self,
|
274 | GLOBAL = global;
|
275 | Object.defineProperty(exports, "__esModule", { value: true });
|
276 | var core_1 = $__require("10");
|
277 | var TreeTypes = $__require("12");
|
278 | var tree_types_1 = $__require("12");
|
279 | var tree_1 = $__require("13");
|
280 | var tree_controller_1 = $__require("14");
|
281 | var node_menu_service_1 = $__require("19");
|
282 | var menu_events_1 = $__require("15");
|
283 | var editable_events_1 = $__require("1a");
|
284 | var tree_service_1 = $__require("11");
|
285 | var EventUtils = $__require("16");
|
286 | var fn_utils_1 = $__require("17");
|
287 | var TreeInternalComponent = function () {
|
288 | function TreeInternalComponent(nodeMenuService, treeService, nodeElementRef) {
|
289 | this.nodeMenuService = nodeMenuService;
|
290 | this.treeService = treeService;
|
291 | this.nodeElementRef = nodeElementRef;
|
292 | this.isSelected = false;
|
293 | this.isRightMenuVisible = false;
|
294 | this.isLeftMenuVisible = false;
|
295 | this.isReadOnly = false;
|
296 | this.subscriptions = [];
|
297 | }
|
298 | TreeInternalComponent.prototype.ngAfterViewInit = function () {
|
299 | if (this.tree.checked && !this.tree.firstCheckedFired) {
|
300 | this.tree.firstCheckedFired = true;
|
301 | this.treeService.fireNodeChecked(this.tree);
|
302 | }
|
303 | };
|
304 | TreeInternalComponent.prototype.ngOnInit = function () {
|
305 | var _this = this;
|
306 | var nodeId = fn_utils_1.get(this.tree, 'node.id', '');
|
307 | if (nodeId) {
|
308 | this.controller = new tree_controller_1.TreeController(this);
|
309 | this.treeService.setController(nodeId, this.controller);
|
310 | }
|
311 | this.settings = this.settings || new tree_types_1.Ng2TreeSettings();
|
312 | this.isReadOnly = !fn_utils_1.get(this.settings, 'enableCheckboxes', true);
|
313 | if (this.tree.isRoot() && this.settings.rootIsVisible === false) {
|
314 | this.tree.disableCollapseOnInit();
|
315 | }
|
316 | this.subscriptions.push(this.nodeMenuService.hideMenuStream(this.nodeElementRef).subscribe(function () {
|
317 | _this.isRightMenuVisible = false;
|
318 | _this.isLeftMenuVisible = false;
|
319 | }));
|
320 | this.subscriptions.push(this.treeService.unselectStream(this.tree).subscribe(function () {
|
321 | return _this.isSelected = false;
|
322 | }));
|
323 | this.subscriptions.push(this.treeService.draggedStream(this.tree, this.nodeElementRef).subscribe(function (e) {
|
324 | if (_this.tree.hasSibling(e.captured.tree)) {
|
325 | _this.swapWithSibling(e.captured.tree, _this.tree);
|
326 | } else if (_this.tree.isBranch()) {
|
327 | _this.moveNodeToThisTreeAndRemoveFromPreviousOne(e, _this.tree);
|
328 | } else {
|
329 | _this.moveNodeToParentTreeAndRemoveFromPreviousOne(e, _this.tree);
|
330 | }
|
331 | }));
|
332 | this.subscriptions.push(this.treeService.nodeChecked$.merge(this.treeService.nodeUnchecked$).filter(function (e) {
|
333 | return _this.eventContainsId(e) && _this.tree.hasChild(e.node);
|
334 | }).subscribe(function (e) {
|
335 | return _this.updateCheckboxState();
|
336 | }));
|
337 | };
|
338 | TreeInternalComponent.prototype.ngOnChanges = function (changes) {
|
339 | this.controller = new tree_controller_1.TreeController(this);
|
340 | };
|
341 | TreeInternalComponent.prototype.ngOnDestroy = function () {
|
342 | if (fn_utils_1.get(this.tree, 'node.id', '')) {
|
343 | this.treeService.deleteController(this.tree.node.id);
|
344 | }
|
345 | this.subscriptions.forEach(function (sub) {
|
346 | return sub && sub.unsubscribe();
|
347 | });
|
348 | };
|
349 | TreeInternalComponent.prototype.swapWithSibling = function (sibling, tree) {
|
350 | tree.swapWithSibling(sibling);
|
351 | this.treeService.fireNodeMoved(sibling, sibling.parent);
|
352 | };
|
353 | TreeInternalComponent.prototype.moveNodeToThisTreeAndRemoveFromPreviousOne = function (e, tree) {
|
354 | this.treeService.fireNodeRemoved(e.captured.tree);
|
355 | var addedChild = tree.addChild(e.captured.tree);
|
356 | this.treeService.fireNodeMoved(addedChild, e.captured.tree.parent);
|
357 | };
|
358 | TreeInternalComponent.prototype.moveNodeToParentTreeAndRemoveFromPreviousOne = function (e, tree) {
|
359 | this.treeService.fireNodeRemoved(e.captured.tree);
|
360 | var addedSibling = tree.addSibling(e.captured.tree, tree.positionInParent);
|
361 | this.treeService.fireNodeMoved(addedSibling, e.captured.tree.parent);
|
362 | };
|
363 | TreeInternalComponent.prototype.onNodeSelected = function (e) {
|
364 | if (!this.tree.selectionAllowed) {
|
365 | return;
|
366 | }
|
367 | if (EventUtils.isLeftButtonClicked(e)) {
|
368 | this.isSelected = true;
|
369 | this.treeService.fireNodeSelected(this.tree);
|
370 | }
|
371 | };
|
372 | TreeInternalComponent.prototype.onNodeUnselected = function (e) {
|
373 | if (!this.tree.selectionAllowed) {
|
374 | return;
|
375 | }
|
376 | if (EventUtils.isLeftButtonClicked(e)) {
|
377 | this.isSelected = false;
|
378 | this.treeService.fireNodeUnselected(this.tree);
|
379 | }
|
380 | };
|
381 | TreeInternalComponent.prototype.showRightMenu = function (e) {
|
382 | if (!this.tree.hasRightMenu()) {
|
383 | return;
|
384 | }
|
385 | if (EventUtils.isRightButtonClicked(e)) {
|
386 | this.isRightMenuVisible = !this.isRightMenuVisible;
|
387 | this.nodeMenuService.hideMenuForAllNodesExcept(this.nodeElementRef);
|
388 | }
|
389 | e.preventDefault();
|
390 | };
|
391 | TreeInternalComponent.prototype.showLeftMenu = function (e) {
|
392 | if (!this.tree.hasLeftMenu()) {
|
393 | return;
|
394 | }
|
395 | if (EventUtils.isLeftButtonClicked(e)) {
|
396 | this.isLeftMenuVisible = !this.isLeftMenuVisible;
|
397 | this.nodeMenuService.hideMenuForAllNodesExcept(this.nodeElementRef);
|
398 | if (this.isLeftMenuVisible) {
|
399 | e.preventDefault();
|
400 | }
|
401 | }
|
402 | };
|
403 | TreeInternalComponent.prototype.onMenuItemSelected = function (e) {
|
404 | switch (e.nodeMenuItemAction) {
|
405 | case menu_events_1.NodeMenuItemAction.NewTag:
|
406 | this.onNewSelected(e);
|
407 | break;
|
408 | case menu_events_1.NodeMenuItemAction.NewFolder:
|
409 | this.onNewSelected(e);
|
410 | break;
|
411 | case menu_events_1.NodeMenuItemAction.Rename:
|
412 | this.onRenameSelected();
|
413 | break;
|
414 | case menu_events_1.NodeMenuItemAction.Remove:
|
415 | this.onRemoveSelected();
|
416 | break;
|
417 | case menu_events_1.NodeMenuItemAction.Custom:
|
418 | this.onCustomSelected();
|
419 | this.treeService.fireMenuItemSelected(this.tree, e.nodeMenuItemSelected);
|
420 | break;
|
421 | default:
|
422 | throw new Error("Chosen menu item doesn't exist");
|
423 | }
|
424 | };
|
425 | TreeInternalComponent.prototype.onNewSelected = function (e) {
|
426 | this.tree.createNode(e.nodeMenuItemAction === menu_events_1.NodeMenuItemAction.NewFolder);
|
427 | this.isRightMenuVisible = false;
|
428 | this.isLeftMenuVisible = false;
|
429 | };
|
430 | TreeInternalComponent.prototype.onRenameSelected = function () {
|
431 | this.tree.markAsBeingRenamed();
|
432 | this.isRightMenuVisible = false;
|
433 | this.isLeftMenuVisible = false;
|
434 | };
|
435 | TreeInternalComponent.prototype.onRemoveSelected = function () {
|
436 | this.treeService.deleteController(fn_utils_1.get(this.tree, 'node.id', ''));
|
437 | this.treeService.fireNodeRemoved(this.tree);
|
438 | };
|
439 | TreeInternalComponent.prototype.onCustomSelected = function () {
|
440 | this.isRightMenuVisible = false;
|
441 | this.isLeftMenuVisible = false;
|
442 | };
|
443 | TreeInternalComponent.prototype.onSwitchFoldingType = function () {
|
444 | this.tree.switchFoldingType();
|
445 | this.treeService.fireNodeSwitchFoldingType(this.tree);
|
446 | };
|
447 | TreeInternalComponent.prototype.applyNewValue = function (e) {
|
448 | if ((e.action === editable_events_1.NodeEditableEventAction.Cancel || this.tree.isNew()) && tree_1.Tree.isValueEmpty(e.value)) {
|
449 | return this.treeService.fireNodeRemoved(this.tree);
|
450 | }
|
451 | if (this.tree.isNew()) {
|
452 | this.tree.value = e.value;
|
453 | this.treeService.fireNodeCreated(this.tree);
|
454 | }
|
455 | if (this.tree.isBeingRenamed()) {
|
456 | var oldValue = this.tree.value;
|
457 | this.tree.value = e.value;
|
458 | this.treeService.fireNodeRenamed(oldValue, this.tree);
|
459 | }
|
460 | this.tree.markAsModified();
|
461 | };
|
462 | TreeInternalComponent.prototype.shouldShowInputForTreeValue = function () {
|
463 | return this.tree.isNew() || this.tree.isBeingRenamed();
|
464 | };
|
465 | TreeInternalComponent.prototype.isRootHidden = function () {
|
466 | return this.tree.isRoot() && !this.settings.rootIsVisible;
|
467 | };
|
468 | TreeInternalComponent.prototype.hasCustomMenu = function () {
|
469 | return this.tree.hasCustomMenu();
|
470 | };
|
471 | TreeInternalComponent.prototype.switchNodeCheckStatus = function () {
|
472 | if (!this.tree.checked) {
|
473 | this.onNodeChecked();
|
474 | } else {
|
475 | this.onNodeUnchecked();
|
476 | }
|
477 | };
|
478 | TreeInternalComponent.prototype.onNodeChecked = function () {
|
479 | if (!this.checkboxElementRef) {
|
480 | return;
|
481 | }
|
482 | this.checkboxElementRef.nativeElement.indeterminate = false;
|
483 | this.treeService.fireNodeChecked(this.tree);
|
484 | this.executeOnChildController(function (controller) {
|
485 | return controller.check();
|
486 | });
|
487 | this.tree.checked = true;
|
488 | };
|
489 | TreeInternalComponent.prototype.onNodeUnchecked = function () {
|
490 | if (!this.checkboxElementRef) {
|
491 | return;
|
492 | }
|
493 | this.checkboxElementRef.nativeElement.indeterminate = false;
|
494 | this.treeService.fireNodeUnchecked(this.tree);
|
495 | this.executeOnChildController(function (controller) {
|
496 | return controller.uncheck();
|
497 | });
|
498 | this.tree.checked = false;
|
499 | };
|
500 | TreeInternalComponent.prototype.executeOnChildController = function (executor) {
|
501 | var _this = this;
|
502 | if (this.tree.hasLoadedChildern()) {
|
503 | this.tree.children.forEach(function (child) {
|
504 | var controller = _this.treeService.getController(child.id);
|
505 | if (!fn_utils_1.isNil(controller)) {
|
506 | executor(controller);
|
507 | }
|
508 | });
|
509 | }
|
510 | };
|
511 | TreeInternalComponent.prototype.updateCheckboxState = function () {
|
512 | var _this = this;
|
513 |
|
514 | setTimeout(function () {
|
515 | var checkedChildrenAmount = _this.tree.checkedChildrenAmount();
|
516 | if (checkedChildrenAmount === 0) {
|
517 | _this.checkboxElementRef.nativeElement.indeterminate = false;
|
518 | _this.tree.checked = false;
|
519 | _this.treeService.fireNodeUnchecked(_this.tree);
|
520 | } else if (checkedChildrenAmount === _this.tree.loadedChildrenAmount()) {
|
521 | _this.checkboxElementRef.nativeElement.indeterminate = false;
|
522 | _this.tree.checked = true;
|
523 | _this.treeService.fireNodeChecked(_this.tree);
|
524 | } else {
|
525 | _this.tree.checked = false;
|
526 | _this.checkboxElementRef.nativeElement.indeterminate = true;
|
527 | _this.treeService.fireNodeIndetermined(_this.tree);
|
528 | }
|
529 | });
|
530 | };
|
531 | TreeInternalComponent.prototype.eventContainsId = function (event) {
|
532 | if (!event.node.id) {
|
533 | console.warn('"Node with checkbox" feature requires a unique id assigned to every node, please consider to add it.');
|
534 | return false;
|
535 | }
|
536 | return true;
|
537 | };
|
538 | TreeInternalComponent.decorators = [{ type: core_1.Component, args: [{
|
539 | selector: 'tree-internal',
|
540 | template: "\n <ul class=\"tree\" *ngIf=\"tree\" [ngClass]=\"{rootless: isRootHidden()}\">\n <li>\n <div class=\"value-container\"\n [ngClass]=\"{rootless: isRootHidden()}\"\n [class.selected]=\"isSelected\"\n (contextmenu)=\"showRightMenu($event)\"\n [nodeDraggable]=\"nodeElementRef\"\n [tree]=\"tree\">\n\n <div class=\"folding\" (click)=\"onSwitchFoldingType()\" [ngClass]=\"tree.foldingCssClass\"></div>\n\n <div class=\"node-checkbox\" *ngIf=\"settings.showCheckboxes\">\n <input checkbox type=\"checkbox\" [disabled]=\"isReadOnly\" [checked]=\"this.tree.checked\" (change)=\"switchNodeCheckStatus()\" #checkbox />\n </div>\n\n <div class=\"node-value\"\n *ngIf=\"!shouldShowInputForTreeValue()\"\n [class.node-selected]=\"isSelected\"\n (click)=\"onNodeSelected($event)\">\n <div *ngIf=\"tree.nodeTemplate\" class=\"node-template\" [innerHTML]=\"tree.nodeTemplate | safeHtml\"></div>\n <span *ngIf=\"!template\" class=\"node-name\" [innerHTML]=\"tree.value | safeHtml\"></span>\n <span class=\"loading-children\" *ngIf=\"tree.childrenAreBeingLoaded()\"></span>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ $implicit: tree.node }\"></ng-template>\n </div>\n\n <input type=\"text\" class=\"node-value\"\n *ngIf=\"shouldShowInputForTreeValue()\"\n [nodeEditable]=\"tree.value\"\n (valueChanged)=\"applyNewValue($event)\"/>\n\n <div class=\"node-left-menu\" *ngIf=\"tree.hasLeftMenu()\" (click)=\"showLeftMenu($event)\" [innerHTML]=\"tree.leftMenuTemplate\">\n </div>\n <node-menu *ngIf=\"tree.hasLeftMenu() && isLeftMenuVisible && !hasCustomMenu()\"\n (menuItemSelected)=\"onMenuItemSelected($event)\">\n </node-menu>\n </div>\n\n <node-menu *ngIf=\"isRightMenuVisible && !hasCustomMenu()\"\n (menuItemSelected)=\"onMenuItemSelected($event)\">\n </node-menu>\n\n <node-menu *ngIf=\"hasCustomMenu() && (isRightMenuVisible || isLeftMenuVisible)\"\n [menuItems]=\"tree.menuItems\"\n (menuItemSelected)=\"onMenuItemSelected($event)\">\n </node-menu>\n\n <div *ngIf=\"tree.keepNodesInDOM()\" [ngStyle]=\"{'display': tree.isNodeExpanded() ? 'block' : 'none'}\">\n <tree-internal *ngFor=\"let child of tree.childrenAsync | async\" [tree]=\"child\" [template]=\"template\" [settings]=\"settings\"></tree-internal>\n </div>\n <ng-template [ngIf]=\"tree.isNodeExpanded() && !tree.keepNodesInDOM()\">\n <tree-internal *ngFor=\"let child of tree.childrenAsync | async\" [tree]=\"child\" [template]=\"template\" [settings]=\"settings\"></tree-internal>\n </ng-template>\n </li>\n </ul>\n "
|
541 | }] }];
|
542 |
|
543 | TreeInternalComponent.ctorParameters = function () {
|
544 | return [{ type: node_menu_service_1.NodeMenuService }, { type: tree_service_1.TreeService }, { type: core_1.ElementRef }];
|
545 | };
|
546 | TreeInternalComponent.propDecorators = {
|
547 | "tree": [{ type: core_1.Input }],
|
548 | "settings": [{ type: core_1.Input }],
|
549 | "template": [{ type: core_1.Input }],
|
550 | "checkboxElementRef": [{ type: core_1.ViewChild, args: ['checkbox'] }]
|
551 | };
|
552 | return TreeInternalComponent;
|
553 | }();
|
554 | exports.TreeInternalComponent = TreeInternalComponent;
|
555 |
|
556 | });
|
557 | $__System.registerDynamic("1b", [], true, function ($__require, exports, module) {
|
558 | "use strict";
|
559 |
|
560 | var global = this || self,
|
561 | GLOBAL = global;
|
562 | Object.defineProperty(exports, "__esModule", { value: true });
|
563 | var CapturedNode = function () {
|
564 | function CapturedNode(anElement, aTree) {
|
565 | this.anElement = anElement;
|
566 | this.aTree = aTree;
|
567 | }
|
568 | CapturedNode.prototype.canBeDroppedAt = function (element) {
|
569 | return !this.sameAs(element) && !this.contains(element);
|
570 | };
|
571 | CapturedNode.prototype.contains = function (other) {
|
572 | return this.element.nativeElement.contains(other.nativeElement);
|
573 | };
|
574 | CapturedNode.prototype.sameAs = function (other) {
|
575 | return this.element === other;
|
576 | };
|
577 | Object.defineProperty(CapturedNode.prototype, "element", {
|
578 | get: function () {
|
579 | return this.anElement;
|
580 | },
|
581 | enumerable: true,
|
582 | configurable: true
|
583 | });
|
584 | Object.defineProperty(CapturedNode.prototype, "tree", {
|
585 | get: function () {
|
586 | return this.aTree;
|
587 | },
|
588 | enumerable: true,
|
589 | configurable: true
|
590 | });
|
591 | return CapturedNode;
|
592 | }();
|
593 | exports.CapturedNode = CapturedNode;
|
594 |
|
595 | });
|
596 | $__System.registerDynamic("12", ["17"], true, function ($__require, exports, module) {
|
597 | "use strict";
|
598 |
|
599 | var global = this || self,
|
600 | GLOBAL = global;
|
601 | Object.defineProperty(exports, "__esModule", { value: true });
|
602 | var fn_utils_1 = $__require("17");
|
603 | var FoldingType = function () {
|
604 | function FoldingType(_cssClass) {
|
605 | this._cssClass = _cssClass;
|
606 | }
|
607 | Object.defineProperty(FoldingType.prototype, "cssClass", {
|
608 | get: function () {
|
609 | return this._cssClass;
|
610 | },
|
611 | enumerable: true,
|
612 | configurable: true
|
613 | });
|
614 | FoldingType.Expanded = new FoldingType('node-expanded');
|
615 | FoldingType.Collapsed = new FoldingType('node-collapsed');
|
616 | FoldingType.Empty = new FoldingType('node-empty');
|
617 | FoldingType.Leaf = new FoldingType('node-leaf');
|
618 | return FoldingType;
|
619 | }();
|
620 | exports.FoldingType = FoldingType;
|
621 | var TreeModelSettings = function () {
|
622 | function TreeModelSettings() {}
|
623 | TreeModelSettings.merge = function (child, parent) {
|
624 | var parentCascadingSettings = fn_utils_1.omit(fn_utils_1.get(parent, 'settings'), TreeModelSettings.NOT_CASCADING_SETTINGS);
|
625 | return fn_utils_1.defaultsDeep({}, fn_utils_1.get(child, 'settings'), parentCascadingSettings, {
|
626 | static: false,
|
627 | leftMenu: false,
|
628 | rightMenu: true,
|
629 | isCollapsedOnInit: false,
|
630 | checked: false,
|
631 | keepNodesInDOM: false,
|
632 | selectionAllowed: true
|
633 | });
|
634 | };
|
635 | TreeModelSettings.NOT_CASCADING_SETTINGS = ['selectionAllowed'];
|
636 | return TreeModelSettings;
|
637 | }();
|
638 | exports.TreeModelSettings = TreeModelSettings;
|
639 | var Ng2TreeSettings = function () {
|
640 | function Ng2TreeSettings() {
|
641 | |
642 |
|
643 |
|
644 |
|
645 |
|
646 | this.rootIsVisible = true;
|
647 | this.showCheckboxes = false;
|
648 | this.enableCheckboxes = true;
|
649 | }
|
650 | return Ng2TreeSettings;
|
651 | }();
|
652 | exports.Ng2TreeSettings = Ng2TreeSettings;
|
653 | var TreeStatus;
|
654 | (function (TreeStatus) {
|
655 | TreeStatus[TreeStatus["New"] = 0] = "New";
|
656 | TreeStatus[TreeStatus["Modified"] = 1] = "Modified";
|
657 | TreeStatus[TreeStatus["IsBeingRenamed"] = 2] = "IsBeingRenamed";
|
658 | })(TreeStatus = exports.TreeStatus || (exports.TreeStatus = {}));
|
659 |
|
660 | });
|
661 | $__System.registerDynamic('1c', ['@empty'], true, function ($__require, exports, module) {
|
662 | var global = this || self,
|
663 | GLOBAL = global;
|
664 |
|
665 |
|
666 |
|
667 | var rb = $__require('@empty').randomBytes;
|
668 |
|
669 | function rng() {
|
670 | return rb(16);
|
671 | }
|
672 |
|
673 | module.exports = rng;
|
674 | });
|
675 | $__System.registerDynamic('1d', [], true, function ($__require, exports, module) {
|
676 | var global = this || self,
|
677 | GLOBAL = global;
|
678 | |
679 |
|
680 |
|
681 |
|
682 | var byteToHex = [];
|
683 | for (var i = 0; i < 256; ++i) {
|
684 | byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
685 | }
|
686 |
|
687 | function bytesToUuid(buf, offset) {
|
688 | var i = offset || 0;
|
689 | var bth = byteToHex;
|
690 | return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + '-' + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]];
|
691 | }
|
692 |
|
693 | module.exports = bytesToUuid;
|
694 | });
|
695 | $__System.registerDynamic('1e', ['1c', '1d'], true, function ($__require, exports, module) {
|
696 | var global = this || self,
|
697 | GLOBAL = global;
|
698 | var rng = $__require('1c');
|
699 | var bytesToUuid = $__require('1d');
|
700 |
|
701 | function v4(options, buf, offset) {
|
702 | var i = buf && offset || 0;
|
703 |
|
704 | if (typeof options == 'string') {
|
705 | buf = options == 'binary' ? new Array(16) : null;
|
706 | options = null;
|
707 | }
|
708 | options = options || {};
|
709 |
|
710 | var rnds = options.random || (options.rng || rng)();
|
711 |
|
712 |
|
713 | rnds[6] = rnds[6] & 0x0f | 0x40;
|
714 | rnds[8] = rnds[8] & 0x3f | 0x80;
|
715 |
|
716 |
|
717 | if (buf) {
|
718 | for (var ii = 0; ii < 16; ++ii) {
|
719 | buf[i + ii] = rnds[ii];
|
720 | }
|
721 | }
|
722 |
|
723 | return buf || bytesToUuid(rnds);
|
724 | }
|
725 |
|
726 | module.exports = v4;
|
727 | });
|
728 | $__System.registerDynamic("13", ["17", "1f", "12", "1e"], true, function ($__require, exports, module) {
|
729 | "use strict";
|
730 |
|
731 | var global = this || self,
|
732 | GLOBAL = global;
|
733 | Object.defineProperty(exports, "__esModule", { value: true });
|
734 | var fn_utils_1 = $__require("17");
|
735 | var Observable_1 = $__require("1f");
|
736 | var tree_types_1 = $__require("12");
|
737 | var uuidv4 = $__require("1e");
|
738 | var ChildrenLoadingState;
|
739 | (function (ChildrenLoadingState) {
|
740 | ChildrenLoadingState[ChildrenLoadingState["NotStarted"] = 0] = "NotStarted";
|
741 | ChildrenLoadingState[ChildrenLoadingState["Loading"] = 1] = "Loading";
|
742 | ChildrenLoadingState[ChildrenLoadingState["Completed"] = 2] = "Completed";
|
743 | })(ChildrenLoadingState || (ChildrenLoadingState = {}));
|
744 | var Tree = function () {
|
745 | |
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 | function Tree(node, parent, isBranch) {
|
752 | if (parent === void 0) {
|
753 | parent = null;
|
754 | }
|
755 | if (isBranch === void 0) {
|
756 | isBranch = false;
|
757 | }
|
758 | var _this = this;
|
759 | this._childrenLoadingState = ChildrenLoadingState.NotStarted;
|
760 | this._childrenAsyncOnce = fn_utils_1.once(function () {
|
761 | return new Observable_1.Observable(function (observer) {
|
762 | setTimeout(function () {
|
763 | _this._childrenLoadingState = ChildrenLoadingState.Loading;
|
764 | _this._loadChildren(function (children) {
|
765 | _this._children = (children || []).map(function (child) {
|
766 | return new Tree(child, _this);
|
767 | });
|
768 | _this._childrenLoadingState = ChildrenLoadingState.Completed;
|
769 | observer.next(_this.children);
|
770 | observer.complete();
|
771 | });
|
772 | });
|
773 | });
|
774 | });
|
775 | this.buildTreeFromModel(node, parent, isBranch || Array.isArray(node.children));
|
776 | }
|
777 |
|
778 | |
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 | |
786 |
|
787 |
|
788 |
|
789 |
|
790 |
|
791 | Tree.isValueEmpty =
|
792 |
|
793 | |
794 |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 | function (value) {
|
800 | return fn_utils_1.isEmpty(fn_utils_1.trim(value));
|
801 | };
|
802 | |
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 | |
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 | Tree.isRenamable = |
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 | function (value) {
|
821 | return fn_utils_1.has(value, 'setName') && fn_utils_1.isFunction(value.setName) && fn_utils_1.has(value, 'toString') && fn_utils_1.isFunction(value.toString) && value.toString !== Object.toString;
|
822 | };
|
823 | Tree.cloneTreeShallow = function (origin) {
|
824 | var tree = new Tree(Object.assign({}, origin.node));
|
825 | tree._children = origin._children;
|
826 | return tree;
|
827 | };
|
828 | Tree.applyNewValueToRenamable = function (value, newValue) {
|
829 | var renamableValue = Object.assign({}, value);
|
830 | renamableValue.setName(newValue);
|
831 | return renamableValue;
|
832 | };
|
833 | Tree.prototype.buildTreeFromModel = function (model, parent, isBranch) {
|
834 | var _this = this;
|
835 | this.parent = parent;
|
836 | this.node = Object.assign(fn_utils_1.omit(model, 'children'), { settings: tree_types_1.TreeModelSettings.merge(model, fn_utils_1.get(parent, 'node')) }, { emitLoadNextLevel: model.emitLoadNextLevel === true });
|
837 | if (fn_utils_1.isFunction(this.node.loadChildren)) {
|
838 | this._loadChildren = this.node.loadChildren;
|
839 | } else {
|
840 | fn_utils_1.get(model, 'children', []).forEach(function (child, index) {
|
841 | _this._addChild(new Tree(child, _this), index);
|
842 | });
|
843 | }
|
844 | if (!Array.isArray(this._children)) {
|
845 | this._children = this.node.loadChildren || isBranch ? [] : null;
|
846 | }
|
847 | };
|
848 | Tree.prototype.hasDeferredChildren = function () {
|
849 | return typeof this._loadChildren === 'function';
|
850 | };
|
851 |
|
852 |
|
853 | Tree.prototype.loadingChildrenRequested =
|
854 | function () {
|
855 | this._childrenLoadingState = ChildrenLoadingState.Loading;
|
856 | };
|
857 | |
858 |
|
859 |
|
860 |
|
861 |
|
862 | |
863 |
|
864 |
|
865 |
|
866 |
|
867 | Tree.prototype.childrenAreBeingLoaded = |
868 |
|
869 |
|
870 |
|
871 |
|
872 | function () {
|
873 | return this._childrenLoadingState === ChildrenLoadingState.Loading;
|
874 | };
|
875 | |
876 |
|
877 |
|
878 |
|
879 |
|
880 | |
881 |
|
882 |
|
883 |
|
884 |
|
885 | Tree.prototype.childrenWereLoaded = |
886 |
|
887 |
|
888 |
|
889 |
|
890 | function () {
|
891 | return this._childrenLoadingState === ChildrenLoadingState.Completed;
|
892 | };
|
893 | Tree.prototype.canLoadChildren = function () {
|
894 | return this._childrenLoadingState === ChildrenLoadingState.NotStarted && this.foldingType === tree_types_1.FoldingType.Expanded && !!this._loadChildren;
|
895 | };
|
896 | |
897 |
|
898 |
|
899 |
|
900 |
|
901 | |
902 |
|
903 |
|
904 |
|
905 |
|
906 | Tree.prototype.childrenShouldBeLoaded = |
907 |
|
908 |
|
909 |
|
910 |
|
911 | function () {
|
912 | return !this.childrenWereLoaded() && (!!this._loadChildren || this.node.emitLoadNextLevel === true);
|
913 | };
|
914 | Object.defineProperty(Tree.prototype, "children", {
|
915 | |
916 |
|
917 |
|
918 |
|
919 | get: /**
|
920 | * Get children of the current tree.
|
921 | * @returns {Tree[]} The children of the current tree.
|
922 | */
|
923 | function () {
|
924 | return this._children;
|
925 | },
|
926 | enumerable: true,
|
927 | configurable: true
|
928 | });
|
929 | Object.defineProperty(Tree.prototype, "childrenAsync", {
|
930 | |
931 |
|
932 |
|
933 |
|
934 |
|
935 | get: /**
|
936 | * By getting value from this property you start process of loading node's children using `loadChildren` function.
|
937 | * Once children are loaded `loadChildren` function won't be called anymore and loaded for the first time children are emitted in case of subsequent calls.
|
938 | * @returns {Observable<Tree[]>} An observable which emits children once they are loaded.
|
939 | */
|
940 | function () {
|
941 | if (this.canLoadChildren()) {
|
942 | return this._childrenAsyncOnce();
|
943 | }
|
944 | return Observable_1.Observable.of(this.children);
|
945 | },
|
946 | enumerable: true,
|
947 | configurable: true
|
948 | });
|
949 | |
950 |
|
951 |
|
952 | |
953 |
|
954 |
|
955 | Tree.prototype.reloadChildren = |
956 |
|
957 |
|
958 | function () {
|
959 | var _this = this;
|
960 | if (this.childrenShouldBeLoaded()) {
|
961 | this._childrenLoadingState = ChildrenLoadingState.Loading;
|
962 | this._loadChildren(function (children) {
|
963 | _this._children = children && children.map(function (child) {
|
964 | return new Tree(child, _this);
|
965 | });
|
966 | _this._childrenLoadingState = ChildrenLoadingState.Completed;
|
967 | });
|
968 | }
|
969 | };
|
970 | |
971 |
|
972 |
|
973 | |
974 |
|
975 |
|
976 | Tree.prototype.setChildren = |
977 |
|
978 |
|
979 | function (children) {
|
980 | var _this = this;
|
981 | this._children = children && children.map(function (child) {
|
982 | return new Tree(child, _this);
|
983 | });
|
984 | if (this.childrenShouldBeLoaded()) {
|
985 | this._childrenLoadingState = ChildrenLoadingState.Completed;
|
986 | }
|
987 | };
|
988 | |
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 | |
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 | Tree.prototype.createNode = |
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 | function (isBranch, model) {
|
1007 | if (model === void 0) {
|
1008 | model = { value: '' };
|
1009 | }
|
1010 | var tree = new Tree(model, this, isBranch);
|
1011 | if (!model.id) {
|
1012 | tree.markAsNew();
|
1013 | }
|
1014 | tree.id = tree.id || uuidv4();
|
1015 | if (this.childrenShouldBeLoaded() && !(this.childrenAreBeingLoaded() || this.childrenWereLoaded())) {
|
1016 | return null;
|
1017 | }
|
1018 | if (this.isLeaf()) {
|
1019 | return this.addSibling(tree);
|
1020 | } else {
|
1021 | return this.addChild(tree);
|
1022 | }
|
1023 | };
|
1024 | Object.defineProperty(Tree.prototype, "value", {
|
1025 | |
1026 |
|
1027 |
|
1028 |
|
1029 | get: /**
|
1030 | * Get the value of the current node
|
1031 | * @returns {(string|RenamableNode)} The value of the node.
|
1032 | */
|
1033 | function () {
|
1034 | return this.node.value;
|
1035 | },
|
1036 | |
1037 |
|
1038 |
|
1039 |
|
1040 | set: /**
|
1041 | * Set the value of the current node
|
1042 | * @param {(string|RenamableNode)} value - The new value of the node.
|
1043 | */
|
1044 | function (value) {
|
1045 | if (typeof value !== 'string' && !Tree.isRenamable(value)) {
|
1046 | return;
|
1047 | }
|
1048 | var stringifiedValue = '' + value;
|
1049 | if (Tree.isRenamable(this.value)) {
|
1050 | this.node.value = Tree.applyNewValueToRenamable(this.value, stringifiedValue);
|
1051 | } else {
|
1052 | this.node.value = Tree.isValueEmpty(stringifiedValue) ? this.node.value : stringifiedValue;
|
1053 | }
|
1054 | },
|
1055 | enumerable: true,
|
1056 | configurable: true
|
1057 | });
|
1058 | Object.defineProperty(Tree.prototype, "checked", {
|
1059 | get: function () {
|
1060 | return !!fn_utils_1.get(this.node.settings, 'checked');
|
1061 | },
|
1062 | set: function (checked) {
|
1063 | this.node.settings = Object.assign({}, this.node.settings, { checked: checked });
|
1064 | },
|
1065 | enumerable: true,
|
1066 | configurable: true
|
1067 | });
|
1068 | Object.defineProperty(Tree.prototype, "checkedChildren", {
|
1069 | get: function () {
|
1070 | return this.hasLoadedChildern() ? this.children.filter(function (child) {
|
1071 | return child.checked;
|
1072 | }) : [];
|
1073 | },
|
1074 | enumerable: true,
|
1075 | configurable: true
|
1076 | });
|
1077 | Object.defineProperty(Tree.prototype, "selectionAllowed", {
|
1078 | get: function () {
|
1079 | var value = fn_utils_1.get(this.node.settings, 'selectionAllowed');
|
1080 | return fn_utils_1.isNil(value) ? true : !!value;
|
1081 | },
|
1082 | set: function (selectionAllowed) {
|
1083 | this.node.settings = Object.assign({}, this.node.settings, { selectionAllowed: selectionAllowed });
|
1084 | },
|
1085 | enumerable: true,
|
1086 | configurable: true
|
1087 | });
|
1088 | Tree.prototype.hasLoadedChildern = function () {
|
1089 | return !fn_utils_1.isEmpty(this.children);
|
1090 | };
|
1091 | Tree.prototype.loadedChildrenAmount = function () {
|
1092 | return fn_utils_1.size(this.children);
|
1093 | };
|
1094 | Tree.prototype.checkedChildrenAmount = function () {
|
1095 | return fn_utils_1.size(this.checkedChildren);
|
1096 | };
|
1097 | |
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 | |
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 | Tree.prototype.addSibling = |
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 | function (sibling, position) {
|
1116 | if (Array.isArray(fn_utils_1.get(this.parent, 'children'))) {
|
1117 | return this.parent.addChild(sibling, position);
|
1118 | }
|
1119 | return null;
|
1120 | };
|
1121 | |
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 | |
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | Tree.prototype.addChild = |
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 | function (child, position) {
|
1140 | var newborn = this._addChild(Tree.cloneTreeShallow(child), position);
|
1141 | this._setFoldingType();
|
1142 | if (this.isNodeCollapsed()) {
|
1143 | this.switchFoldingType();
|
1144 | }
|
1145 | return newborn;
|
1146 | };
|
1147 | Tree.prototype._addChild = function (child, position) {
|
1148 | if (position === void 0) {
|
1149 | position = fn_utils_1.size(this._children) || 0;
|
1150 | }
|
1151 | child.parent = this;
|
1152 | if (Array.isArray(this._children)) {
|
1153 | this._children.splice(position, 0, child);
|
1154 | } else {
|
1155 | this._children = [child];
|
1156 | }
|
1157 | return child;
|
1158 | };
|
1159 | |
1160 |
|
1161 |
|
1162 |
|
1163 | |
1164 |
|
1165 |
|
1166 |
|
1167 | Tree.prototype.swapWithSibling = |
1168 |
|
1169 |
|
1170 |
|
1171 | function (sibling) {
|
1172 | if (!this.hasSibling(sibling)) {
|
1173 | return;
|
1174 | }
|
1175 | var siblingIndex = sibling.positionInParent;
|
1176 | var thisTreeIndex = this.positionInParent;
|
1177 | this.parent._children[siblingIndex] = this;
|
1178 | this.parent._children[thisTreeIndex] = sibling;
|
1179 | };
|
1180 | Object.defineProperty(Tree.prototype, "positionInParent", {
|
1181 | |
1182 |
|
1183 |
|
1184 |
|
1185 | get: /**
|
1186 | * Get a node's position in its parent.
|
1187 | * @returns {number} The position inside a parent.
|
1188 | */
|
1189 | function () {
|
1190 | if (this.isRoot()) {
|
1191 | return -1;
|
1192 | }
|
1193 | return this.parent.children ? this.parent.children.indexOf(this) : -1;
|
1194 | },
|
1195 | enumerable: true,
|
1196 | configurable: true
|
1197 | });
|
1198 | |
1199 |
|
1200 |
|
1201 |
|
1202 | |
1203 |
|
1204 |
|
1205 |
|
1206 | Tree.prototype.isStatic = |
1207 |
|
1208 |
|
1209 |
|
1210 | function () {
|
1211 | return fn_utils_1.get(this.node.settings, 'static', false);
|
1212 | };
|
1213 | |
1214 |
|
1215 |
|
1216 |
|
1217 | |
1218 |
|
1219 |
|
1220 |
|
1221 | Tree.prototype.hasLeftMenu = |
1222 |
|
1223 |
|
1224 |
|
1225 | function () {
|
1226 | return !fn_utils_1.get(this.node.settings, 'static', false) && fn_utils_1.get(this.node.settings, 'leftMenu', false);
|
1227 | };
|
1228 | |
1229 |
|
1230 |
|
1231 |
|
1232 | |
1233 |
|
1234 |
|
1235 |
|
1236 | Tree.prototype.hasRightMenu = |
1237 |
|
1238 |
|
1239 |
|
1240 | function () {
|
1241 | return !fn_utils_1.get(this.node.settings, 'static', false) && fn_utils_1.get(this.node.settings, 'rightMenu', false);
|
1242 | };
|
1243 | |
1244 |
|
1245 |
|
1246 |
|
1247 | |
1248 |
|
1249 |
|
1250 |
|
1251 | Tree.prototype.isLeaf = |
1252 |
|
1253 |
|
1254 |
|
1255 | function () {
|
1256 | return !this.isBranch();
|
1257 | };
|
1258 | Object.defineProperty(Tree.prototype, "menuItems", {
|
1259 | |
1260 |
|
1261 |
|
1262 |
|
1263 | get: /**
|
1264 | * Get menu items of the current tree.
|
1265 | * @returns {NodeMenuItem[]} The menu items of the current tree.
|
1266 | */
|
1267 | function () {
|
1268 | return fn_utils_1.get(this.node.settings, 'menuItems');
|
1269 | },
|
1270 | enumerable: true,
|
1271 | configurable: true
|
1272 | });
|
1273 | |
1274 |
|
1275 |
|
1276 |
|
1277 | |
1278 |
|
1279 |
|
1280 |
|
1281 | Tree.prototype.hasCustomMenu = |
1282 |
|
1283 |
|
1284 |
|
1285 | function () {
|
1286 | return !this.isStatic() && !!fn_utils_1.get(this.node.settings, 'menuItems', false);
|
1287 | };
|
1288 | |
1289 |
|
1290 |
|
1291 |
|
1292 | |
1293 |
|
1294 |
|
1295 |
|
1296 | Tree.prototype.isBranch = |
1297 |
|
1298 |
|
1299 |
|
1300 | function () {
|
1301 | return this.node.emitLoadNextLevel === true || Array.isArray(this._children);
|
1302 | };
|
1303 | |
1304 |
|
1305 |
|
1306 |
|
1307 | |
1308 |
|
1309 |
|
1310 |
|
1311 | Tree.prototype.hasChildren = |
1312 |
|
1313 |
|
1314 |
|
1315 | function () {
|
1316 | return !fn_utils_1.isEmpty(this._children) || this.childrenShouldBeLoaded();
|
1317 | };
|
1318 | |
1319 |
|
1320 |
|
1321 |
|
1322 | |
1323 |
|
1324 |
|
1325 |
|
1326 | Tree.prototype.isRoot = |
1327 |
|
1328 |
|
1329 |
|
1330 | function () {
|
1331 | return fn_utils_1.isNil(this.parent);
|
1332 | };
|
1333 | |
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 | |
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 | Tree.prototype.hasSibling = |
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 | function (tree) {
|
1349 | return !this.isRoot() && fn_utils_1.includes(this.parent.children, tree);
|
1350 | };
|
1351 | |
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 | |
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 | Tree.prototype.hasChild = |
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 | function (tree) {
|
1370 | return fn_utils_1.includes(this._children, tree);
|
1371 | };
|
1372 | |
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 | |
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 | Tree.prototype.removeChild = |
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 | function (tree) {
|
1388 | if (!this.hasChildren()) {
|
1389 | return;
|
1390 | }
|
1391 | var childIndex = this._children.findIndex(function (child) {
|
1392 | return child === tree;
|
1393 | });
|
1394 | if (childIndex >= 0) {
|
1395 | this._children.splice(childIndex, 1);
|
1396 | }
|
1397 | this._setFoldingType();
|
1398 | };
|
1399 | |
1400 |
|
1401 |
|
1402 | |
1403 |
|
1404 |
|
1405 | Tree.prototype.removeItselfFromParent = |
1406 |
|
1407 |
|
1408 | function () {
|
1409 | if (!this.parent) {
|
1410 | return;
|
1411 | }
|
1412 | this.parent.removeChild(this);
|
1413 | };
|
1414 | |
1415 |
|
1416 |
|
1417 |
|
1418 | |
1419 |
|
1420 |
|
1421 |
|
1422 | Tree.prototype.switchFoldingType = |
1423 |
|
1424 |
|
1425 |
|
1426 | function () {
|
1427 | if (this.isLeaf() || !this.hasChildren()) {
|
1428 | return;
|
1429 | }
|
1430 | this.disableCollapseOnInit();
|
1431 | this.node._foldingType = this.isNodeExpanded() ? tree_types_1.FoldingType.Collapsed : tree_types_1.FoldingType.Expanded;
|
1432 | };
|
1433 | |
1434 |
|
1435 |
|
1436 |
|
1437 | |
1438 |
|
1439 |
|
1440 |
|
1441 | Tree.prototype.isNodeExpanded = |
1442 |
|
1443 |
|
1444 |
|
1445 | function () {
|
1446 | return this.foldingType === tree_types_1.FoldingType.Expanded;
|
1447 | };
|
1448 | |
1449 |
|
1450 |
|
1451 |
|
1452 | |
1453 |
|
1454 |
|
1455 |
|
1456 | Tree.prototype.isNodeCollapsed = |
1457 |
|
1458 |
|
1459 |
|
1460 | function () {
|
1461 | return this.foldingType === tree_types_1.FoldingType.Collapsed;
|
1462 | };
|
1463 | |
1464 |
|
1465 |
|
1466 | |
1467 |
|
1468 |
|
1469 | Tree.prototype._setFoldingType = |
1470 |
|
1471 |
|
1472 | function () {
|
1473 | if (this.childrenShouldBeLoaded()) {
|
1474 | this.node._foldingType = tree_types_1.FoldingType.Collapsed;
|
1475 | } else if (this._children && !fn_utils_1.isEmpty(this._children)) {
|
1476 | this.node._foldingType = this.isCollapsedOnInit() ? tree_types_1.FoldingType.Collapsed : tree_types_1.FoldingType.Expanded;
|
1477 | } else if (Array.isArray(this._children)) {
|
1478 | this.node._foldingType = tree_types_1.FoldingType.Empty;
|
1479 | } else {
|
1480 | this.node._foldingType = tree_types_1.FoldingType.Leaf;
|
1481 | }
|
1482 | };
|
1483 | Object.defineProperty(Tree.prototype, "foldingType", {
|
1484 | |
1485 |
|
1486 |
|
1487 |
|
1488 | get: /**
|
1489 | * Get a current folding type: expanded, collapsed or leaf.
|
1490 | * @returns {FoldingType} A folding type of the current tree.
|
1491 | */
|
1492 | function () {
|
1493 | if (!this.node._foldingType) {
|
1494 | this._setFoldingType();
|
1495 | }
|
1496 | return this.node._foldingType;
|
1497 | },
|
1498 | enumerable: true,
|
1499 | configurable: true
|
1500 | });
|
1501 | Object.defineProperty(Tree.prototype, "foldingCssClass", {
|
1502 | |
1503 |
|
1504 |
|
1505 |
|
1506 | get: /**
|
1507 | * Get a css class for element which displayes folding state - expanded, collapsed or leaf
|
1508 | * @returns {string} A string icontaining css class (classes)
|
1509 | */
|
1510 | function () {
|
1511 | return this.getCssClassesFromSettings() || this.foldingType.cssClass;
|
1512 | },
|
1513 | enumerable: true,
|
1514 | configurable: true
|
1515 | });
|
1516 | Tree.prototype.getCssClassesFromSettings = function () {
|
1517 | if (!this.node._foldingType) {
|
1518 | this._setFoldingType();
|
1519 | }
|
1520 | if (this.node._foldingType === tree_types_1.FoldingType.Collapsed) {
|
1521 | return fn_utils_1.get(this.node.settings, 'cssClasses.collapsed', null);
|
1522 | } else if (this.node._foldingType === tree_types_1.FoldingType.Expanded) {
|
1523 | return fn_utils_1.get(this.node.settings, 'cssClasses.expanded', null);
|
1524 | } else if (this.node._foldingType === tree_types_1.FoldingType.Empty) {
|
1525 | return fn_utils_1.get(this.node.settings, 'cssClasses.empty', null);
|
1526 | }
|
1527 | return fn_utils_1.get(this.node.settings, 'cssClasses.leaf', null);
|
1528 | };
|
1529 | Object.defineProperty(Tree.prototype, "nodeTemplate", {
|
1530 | |
1531 |
|
1532 |
|
1533 |
|
1534 | get: /**
|
1535 | * Get a html template to render before every node's name.
|
1536 | * @returns {string} A string representing a html template.
|
1537 | */
|
1538 | function () {
|
1539 | return this.getTemplateFromSettings();
|
1540 | },
|
1541 | enumerable: true,
|
1542 | configurable: true
|
1543 | });
|
1544 | Tree.prototype.getTemplateFromSettings = function () {
|
1545 | if (this.isLeaf()) {
|
1546 | return fn_utils_1.get(this.node.settings, 'templates.leaf', '');
|
1547 | } else {
|
1548 | return fn_utils_1.get(this.node.settings, 'templates.node', '');
|
1549 | }
|
1550 | };
|
1551 | Object.defineProperty(Tree.prototype, "leftMenuTemplate", {
|
1552 | |
1553 |
|
1554 |
|
1555 |
|
1556 | get: /**
|
1557 | * Get a html template to render for an element activatin left menu of a node.
|
1558 | * @returns {string} A string representing a html template.
|
1559 | */
|
1560 | function () {
|
1561 | if (this.hasLeftMenu()) {
|
1562 | return fn_utils_1.get(this.node.settings, 'templates.leftMenu', '<span></span>');
|
1563 | }
|
1564 | return '';
|
1565 | },
|
1566 | enumerable: true,
|
1567 | configurable: true
|
1568 | });
|
1569 | Tree.prototype.disableCollapseOnInit = function () {
|
1570 | if (this.node.settings) {
|
1571 | this.node.settings.isCollapsedOnInit = false;
|
1572 | }
|
1573 | };
|
1574 | Tree.prototype.isCollapsedOnInit = function () {
|
1575 | return !!fn_utils_1.get(this.node.settings, 'isCollapsedOnInit');
|
1576 | };
|
1577 | Tree.prototype.keepNodesInDOM = function () {
|
1578 | return fn_utils_1.get(this.node.settings, 'keepNodesInDOM');
|
1579 | };
|
1580 | |
1581 |
|
1582 |
|
1583 |
|
1584 | |
1585 |
|
1586 |
|
1587 |
|
1588 | Tree.prototype.isNew = |
1589 |
|
1590 |
|
1591 |
|
1592 | function () {
|
1593 | return this.node._status === tree_types_1.TreeStatus.New;
|
1594 | };
|
1595 | Object.defineProperty(Tree.prototype, "id", {
|
1596 | get: function () {
|
1597 | return fn_utils_1.get(this.node, 'id');
|
1598 | },
|
1599 | set: function (id) {
|
1600 | this.node.id = id;
|
1601 | },
|
1602 | enumerable: true,
|
1603 | configurable: true
|
1604 | });
|
1605 | |
1606 |
|
1607 |
|
1608 | |
1609 |
|
1610 |
|
1611 | Tree.prototype.markAsNew = |
1612 |
|
1613 |
|
1614 | function () {
|
1615 | this.node._status = tree_types_1.TreeStatus.New;
|
1616 | };
|
1617 | |
1618 |
|
1619 |
|
1620 |
|
1621 | |
1622 |
|
1623 |
|
1624 |
|
1625 | Tree.prototype.isBeingRenamed = |
1626 |
|
1627 |
|
1628 |
|
1629 | function () {
|
1630 | return this.node._status === tree_types_1.TreeStatus.IsBeingRenamed;
|
1631 | };
|
1632 | |
1633 |
|
1634 |
|
1635 | |
1636 |
|
1637 |
|
1638 | Tree.prototype.markAsBeingRenamed = |
1639 |
|
1640 |
|
1641 | function () {
|
1642 | this.node._status = tree_types_1.TreeStatus.IsBeingRenamed;
|
1643 | };
|
1644 | |
1645 |
|
1646 |
|
1647 |
|
1648 | |
1649 |
|
1650 |
|
1651 |
|
1652 | Tree.prototype.isModified = |
1653 |
|
1654 |
|
1655 |
|
1656 | function () {
|
1657 | return this.node._status === tree_types_1.TreeStatus.Modified;
|
1658 | };
|
1659 | |
1660 |
|
1661 |
|
1662 | |
1663 |
|
1664 |
|
1665 | Tree.prototype.markAsModified = |
1666 |
|
1667 |
|
1668 | function () {
|
1669 | this.node._status = tree_types_1.TreeStatus.Modified;
|
1670 | };
|
1671 | |
1672 |
|
1673 |
|
1674 |
|
1675 | |
1676 |
|
1677 |
|
1678 |
|
1679 | Tree.prototype.toTreeModel = |
1680 |
|
1681 |
|
1682 |
|
1683 | function () {
|
1684 | var model = fn_utils_1.defaultsDeep(this.isLeaf() ? {} : { children: [] }, this.node);
|
1685 | if (this.children) {
|
1686 | this.children.forEach(function (child) {
|
1687 | model.children.push(child.toTreeModel());
|
1688 | });
|
1689 | }
|
1690 | return model;
|
1691 | };
|
1692 | return Tree;
|
1693 | }();
|
1694 | exports.Tree = Tree;
|
1695 |
|
1696 | });
|
1697 | $__System.registerDynamic("20", ["10", "21", "1b", "13"], true, function ($__require, exports, module) {
|
1698 | "use strict";
|
1699 |
|
1700 | var global = this || self,
|
1701 | GLOBAL = global;
|
1702 | Object.defineProperty(exports, "__esModule", { value: true });
|
1703 | var core_1 = $__require("10");
|
1704 | var node_draggable_service_1 = $__require("21");
|
1705 | var captured_node_1 = $__require("1b");
|
1706 | var tree_1 = $__require("13");
|
1707 | var NodeDraggableDirective = function () {
|
1708 | function NodeDraggableDirective(element, nodeDraggableService, renderer) {
|
1709 | this.element = element;
|
1710 | this.nodeDraggableService = nodeDraggableService;
|
1711 | this.renderer = renderer;
|
1712 | this.disposersForDragListeners = [];
|
1713 | this.nodeNativeElement = element.nativeElement;
|
1714 | }
|
1715 | NodeDraggableDirective.prototype.ngOnInit = function () {
|
1716 | if (!this.tree.isStatic()) {
|
1717 | this.renderer.setAttribute(this.nodeNativeElement, 'draggable', 'true');
|
1718 | this.disposersForDragListeners.push(this.renderer.listen(this.nodeNativeElement, 'dragenter', this.handleDragEnter.bind(this)));
|
1719 | this.disposersForDragListeners.push(this.renderer.listen(this.nodeNativeElement, 'dragover', this.handleDragOver.bind(this)));
|
1720 | this.disposersForDragListeners.push(this.renderer.listen(this.nodeNativeElement, 'dragstart', this.handleDragStart.bind(this)));
|
1721 | this.disposersForDragListeners.push(this.renderer.listen(this.nodeNativeElement, 'dragleave', this.handleDragLeave.bind(this)));
|
1722 | this.disposersForDragListeners.push(this.renderer.listen(this.nodeNativeElement, 'drop', this.handleDrop.bind(this)));
|
1723 | this.disposersForDragListeners.push(this.renderer.listen(this.nodeNativeElement, 'dragend', this.handleDragEnd.bind(this)));
|
1724 | }
|
1725 | };
|
1726 | NodeDraggableDirective.prototype.ngOnDestroy = function () {
|
1727 |
|
1728 | this.disposersForDragListeners.forEach(function (dispose) {
|
1729 | return dispose();
|
1730 | });
|
1731 |
|
1732 | };
|
1733 | NodeDraggableDirective.prototype.handleDragStart = function (e) {
|
1734 | if (e.stopPropagation) {
|
1735 | e.stopPropagation();
|
1736 | }
|
1737 | this.nodeDraggableService.captureNode(new captured_node_1.CapturedNode(this.nodeDraggable, this.tree));
|
1738 | e.dataTransfer.setData('text', NodeDraggableDirective.DATA_TRANSFER_STUB_DATA);
|
1739 | e.dataTransfer.effectAllowed = 'move';
|
1740 | };
|
1741 | NodeDraggableDirective.prototype.handleDragOver = function (e) {
|
1742 | e.preventDefault();
|
1743 | e.dataTransfer.dropEffect = 'move';
|
1744 | };
|
1745 | NodeDraggableDirective.prototype.handleDragEnter = function (e) {
|
1746 | e.preventDefault();
|
1747 | if (this.containsElementAt(e)) {
|
1748 | this.addClass('over-drop-target');
|
1749 | }
|
1750 | };
|
1751 | NodeDraggableDirective.prototype.handleDragLeave = function (e) {
|
1752 | if (!this.containsElementAt(e)) {
|
1753 | this.removeClass('over-drop-target');
|
1754 | }
|
1755 | };
|
1756 | NodeDraggableDirective.prototype.handleDrop = function (e) {
|
1757 | e.preventDefault();
|
1758 | if (e.stopPropagation) {
|
1759 | e.stopPropagation();
|
1760 | }
|
1761 | this.removeClass('over-drop-target');
|
1762 | if (!this.isDropPossible(e)) {
|
1763 | return false;
|
1764 | }
|
1765 | if (this.nodeDraggableService.getCapturedNode()) {
|
1766 | return this.notifyThatNodeWasDropped();
|
1767 | }
|
1768 | };
|
1769 | NodeDraggableDirective.prototype.isDropPossible = function (e) {
|
1770 | var capturedNode = this.nodeDraggableService.getCapturedNode();
|
1771 | return capturedNode && capturedNode.canBeDroppedAt(this.nodeDraggable) && this.containsElementAt(e);
|
1772 | };
|
1773 | NodeDraggableDirective.prototype.handleDragEnd = function (e) {
|
1774 | this.removeClass('over-drop-target');
|
1775 | this.nodeDraggableService.releaseCapturedNode();
|
1776 | };
|
1777 | NodeDraggableDirective.prototype.containsElementAt = function (e) {
|
1778 | var _a = e.x,
|
1779 | x = _a === void 0 ? e.clientX : _a,
|
1780 | _b = e.y,
|
1781 | y = _b === void 0 ? e.clientY : _b;
|
1782 | return this.nodeNativeElement.contains(document.elementFromPoint(x, y));
|
1783 | };
|
1784 | NodeDraggableDirective.prototype.addClass = function (className) {
|
1785 | var classList = this.nodeNativeElement.classList;
|
1786 | classList.add(className);
|
1787 | };
|
1788 | NodeDraggableDirective.prototype.removeClass = function (className) {
|
1789 | var classList = this.nodeNativeElement.classList;
|
1790 | classList.remove(className);
|
1791 | };
|
1792 | NodeDraggableDirective.prototype.notifyThatNodeWasDropped = function () {
|
1793 | this.nodeDraggableService.fireNodeDragged(this.nodeDraggableService.getCapturedNode(), this.nodeDraggable);
|
1794 | };
|
1795 | NodeDraggableDirective.DATA_TRANSFER_STUB_DATA = 'some browsers enable drag-n-drop only when dataTransfer has data';
|
1796 | NodeDraggableDirective.decorators = [{ type: core_1.Directive, args: [{
|
1797 | selector: '[nodeDraggable]'
|
1798 | }] }];
|
1799 |
|
1800 | NodeDraggableDirective.ctorParameters = function () {
|
1801 | return [{ type: core_1.ElementRef, decorators: [{ type: core_1.Inject, args: [core_1.ElementRef] }] }, { type: node_draggable_service_1.NodeDraggableService, decorators: [{ type: core_1.Inject, args: [node_draggable_service_1.NodeDraggableService] }] }, { type: core_1.Renderer2, decorators: [{ type: core_1.Inject, args: [core_1.Renderer2] }] }];
|
1802 | };
|
1803 | NodeDraggableDirective.propDecorators = {
|
1804 | "nodeDraggable": [{ type: core_1.Input }],
|
1805 | "tree": [{ type: core_1.Input }]
|
1806 | };
|
1807 | return NodeDraggableDirective;
|
1808 | }();
|
1809 | exports.NodeDraggableDirective = NodeDraggableDirective;
|
1810 |
|
1811 | });
|
1812 | $__System.registerDynamic("1a", [], true, function ($__require, exports, module) {
|
1813 | "use strict";
|
1814 |
|
1815 | var global = this || self,
|
1816 | GLOBAL = global;
|
1817 | Object.defineProperty(exports, "__esModule", { value: true });
|
1818 | var NodeEditableEventAction;
|
1819 | (function (NodeEditableEventAction) {
|
1820 | NodeEditableEventAction[NodeEditableEventAction["Cancel"] = 0] = "Cancel";
|
1821 | })(NodeEditableEventAction = exports.NodeEditableEventAction || (exports.NodeEditableEventAction = {}));
|
1822 |
|
1823 | });
|
1824 | $__System.registerDynamic("22", ["10", "1a"], true, function ($__require, exports, module) {
|
1825 | "use strict";
|
1826 |
|
1827 | var global = this || self,
|
1828 | GLOBAL = global;
|
1829 | Object.defineProperty(exports, "__esModule", { value: true });
|
1830 | var core_1 = $__require("10");
|
1831 | var editable_events_1 = $__require("1a");
|
1832 | var NodeEditableDirective = function () {
|
1833 | function NodeEditableDirective(renderer, elementRef) {
|
1834 | this.renderer = renderer;
|
1835 | this.elementRef = elementRef;
|
1836 |
|
1837 | this.valueChanged = new core_1.EventEmitter(false);
|
1838 | }
|
1839 | NodeEditableDirective.prototype.ngOnInit = function () {
|
1840 | var nativeElement = this.elementRef.nativeElement;
|
1841 | if (nativeElement) {
|
1842 | nativeElement.focus();
|
1843 | }
|
1844 | this.renderer.setProperty(nativeElement, 'value', this.nodeValue);
|
1845 | };
|
1846 | NodeEditableDirective.prototype.applyNewValue = function (newNodeValue) {
|
1847 | this.valueChanged.emit({ type: 'keyup', value: newNodeValue });
|
1848 | };
|
1849 | NodeEditableDirective.prototype.applyNewValueByLoosingFocus = function (newNodeValue) {
|
1850 | this.valueChanged.emit({ type: 'blur', value: newNodeValue });
|
1851 | };
|
1852 | NodeEditableDirective.prototype.cancelEditing = function () {
|
1853 | this.valueChanged.emit({
|
1854 | type: 'keyup',
|
1855 | value: this.nodeValue,
|
1856 | action: editable_events_1.NodeEditableEventAction.Cancel
|
1857 | });
|
1858 | };
|
1859 | NodeEditableDirective.decorators = [{ type: core_1.Directive, args: [{
|
1860 | selector: '[nodeEditable]'
|
1861 | }] }];
|
1862 |
|
1863 | NodeEditableDirective.ctorParameters = function () {
|
1864 | return [{ type: core_1.Renderer2, decorators: [{ type: core_1.Inject, args: [core_1.Renderer2] }] }, { type: core_1.ElementRef, decorators: [{ type: core_1.Inject, args: [core_1.ElementRef] }] }];
|
1865 | };
|
1866 | NodeEditableDirective.propDecorators = {
|
1867 | "nodeValue": [{ type: core_1.Input, args: ['nodeEditable'] }],
|
1868 | "valueChanged": [{ type: core_1.Output }],
|
1869 | "applyNewValue": [{ type: core_1.HostListener, args: ['keyup.enter', ['$event.target.value']] }],
|
1870 | "applyNewValueByLoosingFocus": [{ type: core_1.HostListener, args: ['blur', ['$event.target.value']] }],
|
1871 | "cancelEditing": [{ type: core_1.HostListener, args: ['keyup.esc'] }]
|
1872 | };
|
1873 | return NodeEditableDirective;
|
1874 | }();
|
1875 | exports.NodeEditableDirective = NodeEditableDirective;
|
1876 |
|
1877 | });
|
1878 | $__System.registerDynamic("16", [], true, function ($__require, exports, module) {
|
1879 | "use strict";
|
1880 |
|
1881 | var global = this || self,
|
1882 | GLOBAL = global;
|
1883 | Object.defineProperty(exports, "__esModule", { value: true });
|
1884 | var Keys;
|
1885 | (function (Keys) {
|
1886 | Keys[Keys["Escape"] = 27] = "Escape";
|
1887 | })(Keys = exports.Keys || (exports.Keys = {}));
|
1888 | var MouseButtons;
|
1889 | (function (MouseButtons) {
|
1890 | MouseButtons[MouseButtons["Left"] = 0] = "Left";
|
1891 | MouseButtons[MouseButtons["Right"] = 2] = "Right";
|
1892 | })(MouseButtons = exports.MouseButtons || (exports.MouseButtons = {}));
|
1893 | function isLeftButtonClicked(e) {
|
1894 | return e.button === MouseButtons.Left;
|
1895 | }
|
1896 | exports.isLeftButtonClicked = isLeftButtonClicked;
|
1897 | function isRightButtonClicked(e) {
|
1898 | return e.button === MouseButtons.Right;
|
1899 | }
|
1900 | exports.isRightButtonClicked = isRightButtonClicked;
|
1901 | function isEscapePressed(e) {
|
1902 | return e.keyCode === Keys.Escape;
|
1903 | }
|
1904 | exports.isEscapePressed = isEscapePressed;
|
1905 |
|
1906 | });
|
1907 | $__System.registerDynamic("23", ["10", "19", "15", "16"], true, function ($__require, exports, module) {
|
1908 | "use strict";
|
1909 |
|
1910 | var global = this || self,
|
1911 | GLOBAL = global;
|
1912 | Object.defineProperty(exports, "__esModule", { value: true });
|
1913 | var core_1 = $__require("10");
|
1914 | var node_menu_service_1 = $__require("19");
|
1915 | var menu_events_1 = $__require("15");
|
1916 | var event_utils_1 = $__require("16");
|
1917 | var NodeMenuComponent = function () {
|
1918 | function NodeMenuComponent(renderer, nodeMenuService) {
|
1919 | this.renderer = renderer;
|
1920 | this.nodeMenuService = nodeMenuService;
|
1921 | this.menuItemSelected = new core_1.EventEmitter();
|
1922 | this.availableMenuItems = [{
|
1923 | name: 'New tag',
|
1924 | action: menu_events_1.NodeMenuItemAction.NewTag,
|
1925 | cssClass: 'new-tag'
|
1926 | }, {
|
1927 | name: 'New folder',
|
1928 | action: menu_events_1.NodeMenuItemAction.NewFolder,
|
1929 | cssClass: 'new-folder'
|
1930 | }, {
|
1931 | name: 'Rename',
|
1932 | action: menu_events_1.NodeMenuItemAction.Rename,
|
1933 | cssClass: 'rename'
|
1934 | }, {
|
1935 | name: 'Remove',
|
1936 | action: menu_events_1.NodeMenuItemAction.Remove,
|
1937 | cssClass: 'remove'
|
1938 | }];
|
1939 | this.disposersForGlobalListeners = [];
|
1940 | }
|
1941 | NodeMenuComponent.prototype.ngOnInit = function () {
|
1942 | this.availableMenuItems = this.menuItems || this.availableMenuItems;
|
1943 | this.disposersForGlobalListeners.push(this.renderer.listen('document', 'keyup', this.closeMenu.bind(this)));
|
1944 | this.disposersForGlobalListeners.push(this.renderer.listen('document', 'mousedown', this.closeMenu.bind(this)));
|
1945 | };
|
1946 | NodeMenuComponent.prototype.ngOnDestroy = function () {
|
1947 | this.disposersForGlobalListeners.forEach(function (dispose) {
|
1948 | return dispose();
|
1949 | });
|
1950 | };
|
1951 | NodeMenuComponent.prototype.onMenuItemSelected = function (e, selectedMenuItem) {
|
1952 | if (event_utils_1.isLeftButtonClicked(e)) {
|
1953 | this.menuItemSelected.emit({
|
1954 | nodeMenuItemAction: selectedMenuItem.action,
|
1955 | nodeMenuItemSelected: selectedMenuItem.name
|
1956 | });
|
1957 | this.nodeMenuService.fireMenuEvent(e.target, menu_events_1.NodeMenuAction.Close);
|
1958 | }
|
1959 | };
|
1960 | NodeMenuComponent.prototype.closeMenu = function (e) {
|
1961 | var mouseClicked = e instanceof MouseEvent;
|
1962 |
|
1963 | var containingTarget = this.menuContainer.nativeElement !== e.target && this.menuContainer.nativeElement.contains(e.target);
|
1964 | if (mouseClicked && !containingTarget || event_utils_1.isEscapePressed(e)) {
|
1965 | this.nodeMenuService.fireMenuEvent(e.target, menu_events_1.NodeMenuAction.Close);
|
1966 | }
|
1967 | };
|
1968 | NodeMenuComponent.decorators = [{ type: core_1.Component, args: [{
|
1969 | selector: 'node-menu',
|
1970 | template: "\n <div class=\"node-menu\">\n <ul class=\"node-menu-content\" #menuContainer>\n <li class=\"node-menu-item\" *ngFor=\"let menuItem of availableMenuItems\"\n (click)=\"onMenuItemSelected($event, menuItem)\">\n <div class=\"node-menu-item-icon {{menuItem.cssClass}}\"></div>\n <span class=\"node-menu-item-value\">{{menuItem.name}}</span>\n </li>\n </ul>\n </div>\n "
|
1971 | }] }];
|
1972 |
|
1973 | NodeMenuComponent.ctorParameters = function () {
|
1974 | return [{ type: core_1.Renderer2, decorators: [{ type: core_1.Inject, args: [core_1.Renderer2] }] }, { type: node_menu_service_1.NodeMenuService, decorators: [{ type: core_1.Inject, args: [node_menu_service_1.NodeMenuService] }] }];
|
1975 | };
|
1976 | NodeMenuComponent.propDecorators = {
|
1977 | "menuItemSelected": [{ type: core_1.Output }],
|
1978 | "menuItems": [{ type: core_1.Input }],
|
1979 | "menuContainer": [{ type: core_1.ViewChild, args: ['menuContainer'] }]
|
1980 | };
|
1981 | return NodeMenuComponent;
|
1982 | }();
|
1983 | exports.NodeMenuComponent = NodeMenuComponent;
|
1984 |
|
1985 | });
|
1986 | $__System.registerDynamic("15", [], true, function ($__require, exports, module) {
|
1987 | "use strict";
|
1988 |
|
1989 | var global = this || self,
|
1990 | GLOBAL = global;
|
1991 | Object.defineProperty(exports, "__esModule", { value: true });
|
1992 | var NodeMenuItemAction;
|
1993 | (function (NodeMenuItemAction) {
|
1994 | NodeMenuItemAction[NodeMenuItemAction["NewFolder"] = 0] = "NewFolder";
|
1995 | NodeMenuItemAction[NodeMenuItemAction["NewTag"] = 1] = "NewTag";
|
1996 | NodeMenuItemAction[NodeMenuItemAction["Rename"] = 2] = "Rename";
|
1997 | NodeMenuItemAction[NodeMenuItemAction["Remove"] = 3] = "Remove";
|
1998 | NodeMenuItemAction[NodeMenuItemAction["Custom"] = 4] = "Custom";
|
1999 | })(NodeMenuItemAction = exports.NodeMenuItemAction || (exports.NodeMenuItemAction = {}));
|
2000 | var NodeMenuAction;
|
2001 | (function (NodeMenuAction) {
|
2002 | NodeMenuAction[NodeMenuAction["Close"] = 0] = "Close";
|
2003 | })(NodeMenuAction = exports.NodeMenuAction || (exports.NodeMenuAction = {}));
|
2004 |
|
2005 | });
|
2006 | $__System.registerDynamic("19", ["10", "24", "15"], true, function ($__require, exports, module) {
|
2007 | "use strict";
|
2008 |
|
2009 | var global = this || self,
|
2010 | GLOBAL = global;
|
2011 | Object.defineProperty(exports, "__esModule", { value: true });
|
2012 | var core_1 = $__require("10");
|
2013 | var Subject_1 = $__require("24");
|
2014 | var menu_events_1 = $__require("15");
|
2015 | var NodeMenuService = function () {
|
2016 | function NodeMenuService() {
|
2017 | this.nodeMenuEvents$ = new Subject_1.Subject();
|
2018 | }
|
2019 | NodeMenuService.prototype.fireMenuEvent = function (sender, action) {
|
2020 | var nodeMenuEvent = { sender: sender, action: action };
|
2021 | this.nodeMenuEvents$.next(nodeMenuEvent);
|
2022 | };
|
2023 | NodeMenuService.prototype.hideMenuStream = function (treeElementRef) {
|
2024 | return this.nodeMenuEvents$.filter(function (e) {
|
2025 | return treeElementRef.nativeElement !== e.sender;
|
2026 | }).filter(function (e) {
|
2027 | return e.action === menu_events_1.NodeMenuAction.Close;
|
2028 | });
|
2029 | };
|
2030 | NodeMenuService.prototype.hideMenuForAllNodesExcept = function (treeElementRef) {
|
2031 | this.nodeMenuEvents$.next({
|
2032 | sender: treeElementRef.nativeElement,
|
2033 | action: menu_events_1.NodeMenuAction.Close
|
2034 | });
|
2035 | };
|
2036 | NodeMenuService.decorators = [{ type: core_1.Injectable }];
|
2037 |
|
2038 | NodeMenuService.ctorParameters = function () {
|
2039 | return [];
|
2040 | };
|
2041 | return NodeMenuService;
|
2042 | }();
|
2043 | exports.NodeMenuService = NodeMenuService;
|
2044 |
|
2045 | });
|
2046 | $__System.registerDynamic("25", [], true, function ($__require, exports, module) {
|
2047 | "use strict";
|
2048 |
|
2049 | var global = this || self,
|
2050 | GLOBAL = global;
|
2051 | var __extends = exports && exports.__extends || function () {
|
2052 | var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
|
2053 | d.__proto__ = b;
|
2054 | } || function (d, b) {
|
2055 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
2056 | };
|
2057 | return function (d, b) {
|
2058 | extendStatics(d, b);
|
2059 | function __() {
|
2060 | this.constructor = d;
|
2061 | }
|
2062 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2063 | };
|
2064 | }();
|
2065 | Object.defineProperty(exports, "__esModule", { value: true });
|
2066 | var NodeEvent = function () {
|
2067 | function NodeEvent(node) {
|
2068 | this.node = node;
|
2069 | }
|
2070 | return NodeEvent;
|
2071 | }();
|
2072 | exports.NodeEvent = NodeEvent;
|
2073 | var NodeSelectedEvent = function (_super) {
|
2074 | __extends(NodeSelectedEvent, _super);
|
2075 | function NodeSelectedEvent(node) {
|
2076 | return _super.call(this, node) || this;
|
2077 | }
|
2078 | return NodeSelectedEvent;
|
2079 | }(NodeEvent);
|
2080 | exports.NodeSelectedEvent = NodeSelectedEvent;
|
2081 | var NodeUnselectedEvent = function (_super) {
|
2082 | __extends(NodeUnselectedEvent, _super);
|
2083 | function NodeUnselectedEvent(node) {
|
2084 | return _super.call(this, node) || this;
|
2085 | }
|
2086 | return NodeUnselectedEvent;
|
2087 | }(NodeEvent);
|
2088 | exports.NodeUnselectedEvent = NodeUnselectedEvent;
|
2089 | var NodeDestructiveEvent = function (_super) {
|
2090 | __extends(NodeDestructiveEvent, _super);
|
2091 | function NodeDestructiveEvent(node) {
|
2092 | return _super.call(this, node) || this;
|
2093 | }
|
2094 | return NodeDestructiveEvent;
|
2095 | }(NodeEvent);
|
2096 | exports.NodeDestructiveEvent = NodeDestructiveEvent;
|
2097 | var NodeMovedEvent = function (_super) {
|
2098 | __extends(NodeMovedEvent, _super);
|
2099 | function NodeMovedEvent(node, previousParent) {
|
2100 | var _this = _super.call(this, node) || this;
|
2101 | _this.previousParent = previousParent;
|
2102 | return _this;
|
2103 | }
|
2104 | return NodeMovedEvent;
|
2105 | }(NodeDestructiveEvent);
|
2106 | exports.NodeMovedEvent = NodeMovedEvent;
|
2107 | var NodeRemovedEvent = function (_super) {
|
2108 | __extends(NodeRemovedEvent, _super);
|
2109 | function NodeRemovedEvent(node, lastIndex) {
|
2110 | var _this = _super.call(this, node) || this;
|
2111 | _this.lastIndex = lastIndex;
|
2112 | return _this;
|
2113 | }
|
2114 | return NodeRemovedEvent;
|
2115 | }(NodeDestructiveEvent);
|
2116 | exports.NodeRemovedEvent = NodeRemovedEvent;
|
2117 | var NodeCreatedEvent = function (_super) {
|
2118 | __extends(NodeCreatedEvent, _super);
|
2119 | function NodeCreatedEvent(node) {
|
2120 | return _super.call(this, node) || this;
|
2121 | }
|
2122 | return NodeCreatedEvent;
|
2123 | }(NodeDestructiveEvent);
|
2124 | exports.NodeCreatedEvent = NodeCreatedEvent;
|
2125 | var NodeRenamedEvent = function (_super) {
|
2126 | __extends(NodeRenamedEvent, _super);
|
2127 | function NodeRenamedEvent(node, oldValue, newValue) {
|
2128 | var _this = _super.call(this, node) || this;
|
2129 | _this.oldValue = oldValue;
|
2130 | _this.newValue = newValue;
|
2131 | return _this;
|
2132 | }
|
2133 | return NodeRenamedEvent;
|
2134 | }(NodeDestructiveEvent);
|
2135 | exports.NodeRenamedEvent = NodeRenamedEvent;
|
2136 | var NodeExpandedEvent = function (_super) {
|
2137 | __extends(NodeExpandedEvent, _super);
|
2138 | function NodeExpandedEvent(node) {
|
2139 | return _super.call(this, node) || this;
|
2140 | }
|
2141 | return NodeExpandedEvent;
|
2142 | }(NodeEvent);
|
2143 | exports.NodeExpandedEvent = NodeExpandedEvent;
|
2144 | var NodeCollapsedEvent = function (_super) {
|
2145 | __extends(NodeCollapsedEvent, _super);
|
2146 | function NodeCollapsedEvent(node) {
|
2147 | return _super.call(this, node) || this;
|
2148 | }
|
2149 | return NodeCollapsedEvent;
|
2150 | }(NodeEvent);
|
2151 | exports.NodeCollapsedEvent = NodeCollapsedEvent;
|
2152 | var MenuItemSelectedEvent = function (_super) {
|
2153 | __extends(MenuItemSelectedEvent, _super);
|
2154 | function MenuItemSelectedEvent(node, selectedItem) {
|
2155 | var _this = _super.call(this, node) || this;
|
2156 | _this.selectedItem = selectedItem;
|
2157 | return _this;
|
2158 | }
|
2159 | return MenuItemSelectedEvent;
|
2160 | }(NodeEvent);
|
2161 | exports.MenuItemSelectedEvent = MenuItemSelectedEvent;
|
2162 | var LoadNextLevelEvent = function (_super) {
|
2163 | __extends(LoadNextLevelEvent, _super);
|
2164 | function LoadNextLevelEvent(node) {
|
2165 | return _super.call(this, node) || this;
|
2166 | }
|
2167 | return LoadNextLevelEvent;
|
2168 | }(NodeEvent);
|
2169 | exports.LoadNextLevelEvent = LoadNextLevelEvent;
|
2170 | var NodeCheckedEvent = function (_super) {
|
2171 | __extends(NodeCheckedEvent, _super);
|
2172 | function NodeCheckedEvent(node) {
|
2173 | return _super.call(this, node) || this;
|
2174 | }
|
2175 | return NodeCheckedEvent;
|
2176 | }(NodeEvent);
|
2177 | exports.NodeCheckedEvent = NodeCheckedEvent;
|
2178 | var NodeUncheckedEvent = function (_super) {
|
2179 | __extends(NodeUncheckedEvent, _super);
|
2180 | function NodeUncheckedEvent(node) {
|
2181 | return _super.call(this, node) || this;
|
2182 | }
|
2183 | return NodeUncheckedEvent;
|
2184 | }(NodeEvent);
|
2185 | exports.NodeUncheckedEvent = NodeUncheckedEvent;
|
2186 | var NodeIndeterminedEvent = function (_super) {
|
2187 | __extends(NodeIndeterminedEvent, _super);
|
2188 | function NodeIndeterminedEvent(node) {
|
2189 | return _super.call(this, node) || this;
|
2190 | }
|
2191 | return NodeIndeterminedEvent;
|
2192 | }(NodeEvent);
|
2193 | exports.NodeIndeterminedEvent = NodeIndeterminedEvent;
|
2194 |
|
2195 | });
|
2196 | $__System.registerDynamic("26", [], true, function ($__require, exports, module) {
|
2197 | "use strict";
|
2198 |
|
2199 | var global = this || self,
|
2200 | GLOBAL = global;
|
2201 | Object.defineProperty(exports, "__esModule", { value: true });
|
2202 | var NodeDraggableEvent = function () {
|
2203 | function NodeDraggableEvent(captured, target) {
|
2204 | this.captured = captured;
|
2205 | this.target = target;
|
2206 | }
|
2207 | return NodeDraggableEvent;
|
2208 | }();
|
2209 | exports.NodeDraggableEvent = NodeDraggableEvent;
|
2210 |
|
2211 | });
|
2212 | $__System.registerDynamic("21", ["10", "24", "26"], true, function ($__require, exports, module) {
|
2213 | "use strict";
|
2214 |
|
2215 | var global = this || self,
|
2216 | GLOBAL = global;
|
2217 | Object.defineProperty(exports, "__esModule", { value: true });
|
2218 | var core_1 = $__require("10");
|
2219 | var Subject_1 = $__require("24");
|
2220 | var draggable_events_1 = $__require("26");
|
2221 | var NodeDraggableService = function () {
|
2222 | function NodeDraggableService() {
|
2223 | this.draggableNodeEvents$ = new Subject_1.Subject();
|
2224 | }
|
2225 | NodeDraggableService.prototype.fireNodeDragged = function (captured, target) {
|
2226 | if (!captured.tree || captured.tree.isStatic()) {
|
2227 | return;
|
2228 | }
|
2229 | this.draggableNodeEvents$.next(new draggable_events_1.NodeDraggableEvent(captured, target));
|
2230 | };
|
2231 | NodeDraggableService.prototype.captureNode = function (node) {
|
2232 | this.capturedNode = node;
|
2233 | };
|
2234 | NodeDraggableService.prototype.getCapturedNode = function () {
|
2235 | return this.capturedNode;
|
2236 | };
|
2237 | NodeDraggableService.prototype.releaseCapturedNode = function () {
|
2238 | this.capturedNode = null;
|
2239 | };
|
2240 | NodeDraggableService.decorators = [{ type: core_1.Injectable }];
|
2241 |
|
2242 | NodeDraggableService.ctorParameters = function () {
|
2243 | return [];
|
2244 | };
|
2245 | return NodeDraggableService;
|
2246 | }();
|
2247 | exports.NodeDraggableService = NodeDraggableService;
|
2248 |
|
2249 | });
|
2250 | $__System.registerDynamic("17", [], true, function ($__require, exports, module) {
|
2251 | "use strict";
|
2252 |
|
2253 | var global = this || self,
|
2254 | GLOBAL = global;
|
2255 | Object.defineProperty(exports, "__esModule", { value: true });
|
2256 | function isEmpty(value) {
|
2257 | if (typeof value === 'string') {
|
2258 | return !/\S/.test(value);
|
2259 | }
|
2260 | if (Array.isArray(value)) {
|
2261 | return value.length === 0;
|
2262 | }
|
2263 | return isNil(value);
|
2264 | }
|
2265 | exports.isEmpty = isEmpty;
|
2266 | function trim(value) {
|
2267 | return isNil(value) ? '' : value.trim();
|
2268 | }
|
2269 | exports.trim = trim;
|
2270 | function has(value, prop) {
|
2271 | return value && typeof value === 'object' && value.hasOwnProperty(prop);
|
2272 | }
|
2273 | exports.has = has;
|
2274 | function isFunction(value) {
|
2275 | return typeof value === 'function';
|
2276 | }
|
2277 | exports.isFunction = isFunction;
|
2278 | function get(value, path, defaultValue) {
|
2279 | var result = value;
|
2280 | for (var _i = 0, _a = path.split('.'); _i < _a.length; _i++) {
|
2281 | var prop = _a[_i];
|
2282 | if (!result || !Reflect.has(result, prop)) {
|
2283 | return defaultValue;
|
2284 | }
|
2285 | result = result[prop];
|
2286 | }
|
2287 | return isNil(result) || result === value ? defaultValue : result;
|
2288 | }
|
2289 | exports.get = get;
|
2290 | function omit(value, propsToSkip) {
|
2291 | if (!value) {
|
2292 | return value;
|
2293 | }
|
2294 | var normalizedPropsToSkip = typeof propsToSkip === 'string' ? [propsToSkip] : propsToSkip;
|
2295 | return Object.keys(value).reduce(function (result, prop) {
|
2296 | if (includes(normalizedPropsToSkip, prop)) {
|
2297 | return result;
|
2298 | }
|
2299 | return Object.assign(result, (_a = {}, _a[prop] = value[prop], _a));
|
2300 | var _a;
|
2301 | }, {});
|
2302 | }
|
2303 | exports.omit = omit;
|
2304 | function size(value) {
|
2305 | return isEmpty(value) ? 0 : value.length;
|
2306 | }
|
2307 | exports.size = size;
|
2308 | function once(fn) {
|
2309 | var result;
|
2310 | return function () {
|
2311 | var args = [];
|
2312 | for (var _i = 0; _i < arguments.length; _i++) {
|
2313 | args[_i] = arguments[_i];
|
2314 | }
|
2315 | if (fn) {
|
2316 | result = fn.apply(null, args);
|
2317 | fn = null;
|
2318 | }
|
2319 | return result;
|
2320 | };
|
2321 | }
|
2322 | exports.once = once;
|
2323 | function defaultsDeep(target) {
|
2324 | var sources = [];
|
2325 | for (var _i = 1; _i < arguments.length; _i++) {
|
2326 | sources[_i - 1] = arguments[_i];
|
2327 | }
|
2328 | return [target].concat(sources).reduce(function (result, source) {
|
2329 | if (!source) {
|
2330 | return result;
|
2331 | }
|
2332 | Object.keys(source).forEach(function (prop) {
|
2333 | if (isNil(result[prop])) {
|
2334 | result[prop] = source[prop];
|
2335 | return;
|
2336 | }
|
2337 | if (typeof result[prop] === 'object' && !Array.isArray(result[prop])) {
|
2338 | result[prop] = defaultsDeep(result[prop], source[prop]);
|
2339 | return;
|
2340 | }
|
2341 | });
|
2342 | return result;
|
2343 | }, {});
|
2344 | }
|
2345 | exports.defaultsDeep = defaultsDeep;
|
2346 | function includes(target, value) {
|
2347 | if (isNil(target)) {
|
2348 | return false;
|
2349 | }
|
2350 | var index = typeof target === 'string' ? target.indexOf(value) : target.indexOf(value);
|
2351 | return index > -1;
|
2352 | }
|
2353 | exports.includes = includes;
|
2354 | function isNil(value) {
|
2355 | return value === undefined || value === null;
|
2356 | }
|
2357 | exports.isNil = isNil;
|
2358 |
|
2359 | });
|
2360 | $__System.registerDynamic("11", ["25", "24", "10", "21", "17"], true, function ($__require, exports, module) {
|
2361 | "use strict";
|
2362 |
|
2363 | var global = this || self,
|
2364 | GLOBAL = global;
|
2365 | Object.defineProperty(exports, "__esModule", { value: true });
|
2366 | var tree_events_1 = $__require("25");
|
2367 | var Subject_1 = $__require("24");
|
2368 | var core_1 = $__require("10");
|
2369 | var node_draggable_service_1 = $__require("21");
|
2370 | var fn_utils_1 = $__require("17");
|
2371 | var TreeService = function () {
|
2372 | function TreeService(nodeDraggableService) {
|
2373 | this.nodeDraggableService = nodeDraggableService;
|
2374 | this.nodeMoved$ = new Subject_1.Subject();
|
2375 | this.nodeRemoved$ = new Subject_1.Subject();
|
2376 | this.nodeRenamed$ = new Subject_1.Subject();
|
2377 | this.nodeCreated$ = new Subject_1.Subject();
|
2378 | this.nodeSelected$ = new Subject_1.Subject();
|
2379 | this.nodeUnselected$ = new Subject_1.Subject();
|
2380 | this.nodeExpanded$ = new Subject_1.Subject();
|
2381 | this.nodeCollapsed$ = new Subject_1.Subject();
|
2382 | this.menuItemSelected$ = new Subject_1.Subject();
|
2383 | this.loadNextLevel$ = new Subject_1.Subject();
|
2384 | this.nodeChecked$ = new Subject_1.Subject();
|
2385 | this.nodeUnchecked$ = new Subject_1.Subject();
|
2386 | this.nodeIndetermined$ = new Subject_1.Subject();
|
2387 | this.controllers = new Map();
|
2388 | this.nodeRemoved$.subscribe(function (e) {
|
2389 | return e.node.removeItselfFromParent();
|
2390 | });
|
2391 | }
|
2392 | TreeService.prototype.unselectStream = function (tree) {
|
2393 | return this.nodeSelected$.filter(function (e) {
|
2394 | return tree !== e.node;
|
2395 | });
|
2396 | };
|
2397 | TreeService.prototype.fireNodeRemoved = function (tree) {
|
2398 | this.nodeRemoved$.next(new tree_events_1.NodeRemovedEvent(tree, tree.positionInParent));
|
2399 | };
|
2400 | TreeService.prototype.fireNodeCreated = function (tree) {
|
2401 | this.nodeCreated$.next(new tree_events_1.NodeCreatedEvent(tree));
|
2402 | };
|
2403 | TreeService.prototype.fireNodeSelected = function (tree) {
|
2404 | this.nodeSelected$.next(new tree_events_1.NodeSelectedEvent(tree));
|
2405 | };
|
2406 | TreeService.prototype.fireNodeUnselected = function (tree) {
|
2407 | this.nodeUnselected$.next(new tree_events_1.NodeUnselectedEvent(tree));
|
2408 | };
|
2409 | TreeService.prototype.fireNodeRenamed = function (oldValue, tree) {
|
2410 | this.nodeRenamed$.next(new tree_events_1.NodeRenamedEvent(tree, oldValue, tree.value));
|
2411 | };
|
2412 | TreeService.prototype.fireNodeMoved = function (tree, parent) {
|
2413 | this.nodeMoved$.next(new tree_events_1.NodeMovedEvent(tree, parent));
|
2414 | };
|
2415 | TreeService.prototype.fireMenuItemSelected = function (tree, selectedItem) {
|
2416 | this.menuItemSelected$.next(new tree_events_1.MenuItemSelectedEvent(tree, selectedItem));
|
2417 | };
|
2418 | TreeService.prototype.fireNodeSwitchFoldingType = function (tree) {
|
2419 | if (tree.isNodeExpanded()) {
|
2420 | this.fireNodeExpanded(tree);
|
2421 | if (this.shouldFireLoadNextLevel(tree)) {
|
2422 | this.fireLoadNextLevel(tree);
|
2423 | }
|
2424 | } else if (tree.isNodeCollapsed()) {
|
2425 | this.fireNodeCollapsed(tree);
|
2426 | }
|
2427 | };
|
2428 | TreeService.prototype.fireNodeExpanded = function (tree) {
|
2429 | this.nodeExpanded$.next(new tree_events_1.NodeExpandedEvent(tree));
|
2430 | };
|
2431 | TreeService.prototype.fireNodeCollapsed = function (tree) {
|
2432 | this.nodeCollapsed$.next(new tree_events_1.NodeCollapsedEvent(tree));
|
2433 | };
|
2434 | TreeService.prototype.fireLoadNextLevel = function (tree) {
|
2435 | this.loadNextLevel$.next(new tree_events_1.LoadNextLevelEvent(tree));
|
2436 | };
|
2437 | TreeService.prototype.fireNodeChecked = function (tree) {
|
2438 | this.nodeChecked$.next(new tree_events_1.NodeCheckedEvent(tree));
|
2439 | };
|
2440 | TreeService.prototype.fireNodeUnchecked = function (tree) {
|
2441 | this.nodeUnchecked$.next(new tree_events_1.NodeUncheckedEvent(tree));
|
2442 | };
|
2443 | TreeService.prototype.draggedStream = function (tree, element) {
|
2444 | return this.nodeDraggableService.draggableNodeEvents$.filter(function (e) {
|
2445 | return e.target === element;
|
2446 | }).filter(function (e) {
|
2447 | return !e.captured.tree.hasChild(tree);
|
2448 | });
|
2449 | };
|
2450 | TreeService.prototype.setController = function (id, controller) {
|
2451 | this.controllers.set(id, controller);
|
2452 | };
|
2453 | TreeService.prototype.deleteController = function (id) {
|
2454 | if (this.controllers.has(id)) {
|
2455 | this.controllers.delete(id);
|
2456 | }
|
2457 | };
|
2458 | TreeService.prototype.getController = function (id) {
|
2459 | if (this.controllers.has(id)) {
|
2460 | return this.controllers.get(id);
|
2461 | }
|
2462 | return null;
|
2463 | };
|
2464 | TreeService.prototype.hasController = function (id) {
|
2465 | return this.controllers.has(id);
|
2466 | };
|
2467 | TreeService.prototype.shouldFireLoadNextLevel = function (tree) {
|
2468 | var shouldLoadNextLevel = tree.node.emitLoadNextLevel && !tree.node.loadChildren && !tree.childrenAreBeingLoaded() && fn_utils_1.isEmpty(tree.children);
|
2469 | if (shouldLoadNextLevel) {
|
2470 | tree.loadingChildrenRequested();
|
2471 | }
|
2472 | return shouldLoadNextLevel;
|
2473 | };
|
2474 | TreeService.prototype.fireNodeIndetermined = function (tree) {
|
2475 | this.nodeIndetermined$.next(new tree_events_1.NodeIndeterminedEvent(tree));
|
2476 | };
|
2477 | TreeService.decorators = [{ type: core_1.Injectable }];
|
2478 |
|
2479 | TreeService.ctorParameters = function () {
|
2480 | return [{ type: node_draggable_service_1.NodeDraggableService, decorators: [{ type: core_1.Inject, args: [node_draggable_service_1.NodeDraggableService] }] }];
|
2481 | };
|
2482 | return TreeService;
|
2483 | }();
|
2484 | exports.TreeService = TreeService;
|
2485 |
|
2486 | });
|
2487 | $__System.registerDynamic("27", ["10", "28"], true, function ($__require, exports, module) {
|
2488 | "use strict";
|
2489 |
|
2490 | var global = this || self,
|
2491 | GLOBAL = global;
|
2492 | Object.defineProperty(exports, "__esModule", { value: true });
|
2493 | var core_1 = $__require("10");
|
2494 | var platform_browser_1 = $__require("28");
|
2495 | var SafeHtmlPipe = function () {
|
2496 | function SafeHtmlPipe(sanitizer) {
|
2497 | this.sanitizer = sanitizer;
|
2498 | }
|
2499 | SafeHtmlPipe.prototype.transform = function (value) {
|
2500 |
|
2501 | return this.sanitizer.bypassSecurityTrustHtml(value);
|
2502 | };
|
2503 | SafeHtmlPipe.decorators = [{ type: core_1.Pipe, args: [{ name: 'safeHtml' }] }];
|
2504 |
|
2505 | SafeHtmlPipe.ctorParameters = function () {
|
2506 | return [{ type: platform_browser_1.DomSanitizer }];
|
2507 | };
|
2508 | return SafeHtmlPipe;
|
2509 | }();
|
2510 | exports.SafeHtmlPipe = SafeHtmlPipe;
|
2511 |
|
2512 | });
|
2513 | $__System.registerDynamic("29", ["b", "10", "f", "18", "2a", "20", "21", "22", "23", "19", "11", "27"], true, function ($__require, exports, module) {
|
2514 | "use strict";
|
2515 |
|
2516 | var global = this || self,
|
2517 | GLOBAL = global;
|
2518 | Object.defineProperty(exports, "__esModule", { value: true });
|
2519 | $__require("b");
|
2520 | var core_1 = $__require("10");
|
2521 | var tree_component_1 = $__require("f");
|
2522 | var tree_internal_component_1 = $__require("18");
|
2523 | var common_1 = $__require("2a");
|
2524 | var node_draggable_directive_1 = $__require("20");
|
2525 | var node_draggable_service_1 = $__require("21");
|
2526 | var node_editable_directive_1 = $__require("22");
|
2527 | var node_menu_component_1 = $__require("23");
|
2528 | var node_menu_service_1 = $__require("19");
|
2529 | var tree_service_1 = $__require("11");
|
2530 | var safe_html_pipe_1 = $__require("27");
|
2531 | var TreeModule = function () {
|
2532 | function TreeModule() {}
|
2533 | TreeModule.decorators = [{ type: core_1.NgModule, args: [{
|
2534 | imports: [common_1.CommonModule],
|
2535 | declarations: [node_draggable_directive_1.NodeDraggableDirective, tree_component_1.TreeComponent, node_editable_directive_1.NodeEditableDirective, node_menu_component_1.NodeMenuComponent, tree_internal_component_1.TreeInternalComponent, safe_html_pipe_1.SafeHtmlPipe],
|
2536 | exports: [tree_component_1.TreeComponent],
|
2537 | providers: [node_draggable_service_1.NodeDraggableService, node_menu_service_1.NodeMenuService, tree_service_1.TreeService]
|
2538 | }] }];
|
2539 |
|
2540 | TreeModule.ctorParameters = function () {
|
2541 | return [];
|
2542 | };
|
2543 | return TreeModule;
|
2544 | }();
|
2545 | exports.TreeModule = TreeModule;
|
2546 |
|
2547 | });
|
2548 | $__System.registerDynamic("a", ["12", "13", "15", "25", "f", "14", "29"], true, function ($__require, exports, module) {
|
2549 | "use strict";
|
2550 |
|
2551 | var global = this || self,
|
2552 | GLOBAL = global;
|
2553 | Object.defineProperty(exports, "__esModule", { value: true });
|
2554 | var tree_types_1 = $__require("12");
|
2555 | exports.TreeModelSettings = tree_types_1.TreeModelSettings;
|
2556 | exports.Ng2TreeSettings = tree_types_1.Ng2TreeSettings;
|
2557 | exports.FoldingType = tree_types_1.FoldingType;
|
2558 | var tree_1 = $__require("13");
|
2559 | exports.Tree = tree_1.Tree;
|
2560 | var menu_events_1 = $__require("15");
|
2561 | exports.NodeMenuItemAction = menu_events_1.NodeMenuItemAction;
|
2562 | var tree_events_1 = $__require("25");
|
2563 | exports.NodeEvent = tree_events_1.NodeEvent;
|
2564 | exports.NodeCreatedEvent = tree_events_1.NodeCreatedEvent;
|
2565 | exports.NodeRemovedEvent = tree_events_1.NodeRemovedEvent;
|
2566 | exports.NodeRenamedEvent = tree_events_1.NodeRenamedEvent;
|
2567 | exports.NodeMovedEvent = tree_events_1.NodeMovedEvent;
|
2568 | exports.NodeSelectedEvent = tree_events_1.NodeSelectedEvent;
|
2569 | exports.NodeExpandedEvent = tree_events_1.NodeExpandedEvent;
|
2570 | exports.NodeCollapsedEvent = tree_events_1.NodeCollapsedEvent;
|
2571 | exports.MenuItemSelectedEvent = tree_events_1.MenuItemSelectedEvent;
|
2572 | exports.NodeDestructiveEvent = tree_events_1.NodeDestructiveEvent;
|
2573 | exports.NodeUncheckedEvent = tree_events_1.NodeUncheckedEvent;
|
2574 | exports.NodeCheckedEvent = tree_events_1.NodeCheckedEvent;
|
2575 | exports.NodeIndeterminedEvent = tree_events_1.NodeIndeterminedEvent;
|
2576 | exports.NodeUnselectedEvent = tree_events_1.NodeUnselectedEvent;
|
2577 | var tree_component_1 = $__require("f");
|
2578 | exports.TreeComponent = tree_component_1.TreeComponent;
|
2579 | var tree_controller_1 = $__require("14");
|
2580 | exports.TreeController = tree_controller_1.TreeController;
|
2581 | var tree_module_1 = $__require("29");
|
2582 | exports.TreeModule = tree_module_1.TreeModule;
|
2583 |
|
2584 | });
|
2585 | })
|
2586 | (function(factory) {
|
2587 | if (typeof define == 'function' && define.amd)
|
2588 | define(["@angular/common","@angular/core","@angular/platform-browser","rxjs/Observable","rxjs/Subject","rxjs/add/observable/of","rxjs/add/operator/filter","rxjs/add/operator/merge"], factory);
|
2589 | else if (typeof module == 'object' && module.exports && typeof require == 'function')
|
2590 | module.exports = factory(require("@angular/common"), require("@angular/core"), require("@angular/platform-browser"), require("rxjs/Observable"), require("rxjs/Subject"), require("rxjs/add/observable/of"), require("rxjs/add/operator/filter"), require("rxjs/add/operator/merge"));
|
2591 | else
|
2592 | throw new Error("Module must be loaded as AMD or CommonJS");
|
2593 | });
|
2594 |
|
\ | No newline at end of file |