@wavemaker/app-ng-runtime 11.4.0-next.25701 → 11.4.0-next.25703
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- app-ng-runtime/build-task/basic/tree/tree.build.d.ts +2 -1
- app-ng-runtime/build-task/bundles/index.umd.js +9 -7
- app-ng-runtime/build-task/bundles/index.umd.js.map +1 -1
- app-ng-runtime/build-task/esm2015/basic/tree/tree.build.js +4 -3
- app-ng-runtime/build-task/esm2015/navigation/popover/popover.build.js +3 -3
- app-ng-runtime/build-task/fesm2015/index.js +9 -7
- app-ng-runtime/build-task/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/base/bundles/index.umd.js +3 -6
- app-ng-runtime/components/base/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/base/esm2015/utils/widget-utils.js +4 -7
- app-ng-runtime/components/base/fesm2015/index.js +3 -6
- app-ng-runtime/components/base/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/base/utils/widget-utils.d.ts +1 -1
- app-ng-runtime/components/basic/tree/bundles/index.umd.js +256 -280
- app-ng-runtime/components/basic/tree/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/basic/tree/esm2015/public_api.js +2 -2
- app-ng-runtime/components/basic/tree/esm2015/tree.directive.js +310 -0
- app-ng-runtime/components/basic/tree/esm2015/tree.module.js +3 -3
- app-ng-runtime/components/basic/tree/fesm2015/index.js +248 -260
- app-ng-runtime/components/basic/tree/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/basic/tree/index.metadata.json +1 -1
- app-ng-runtime/components/basic/tree/public_api.d.ts +1 -1
- app-ng-runtime/components/basic/tree/tree.directive.d.ts +35 -0
- app-ng-runtime/components/data/list/bundles/index.umd.js +4 -28
- app-ng-runtime/components/data/list/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/data/list/esm2015/list.component.js +5 -29
- app-ng-runtime/components/data/list/fesm2015/index.js +4 -28
- app-ng-runtime/components/data/list/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/data/list/index.metadata.json +1 -1
- app-ng-runtime/components/dialogs/default/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/dialogs/default/esm2015/base-dialog.js +1 -1
- app-ng-runtime/components/dialogs/default/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/dialogs/default/index.metadata.json +1 -1
- app-ng-runtime/components/input/epoch/bundles/index.umd.js +21 -39
- app-ng-runtime/components/input/epoch/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/input/epoch/esm2015/base-date-time.component.js +25 -43
- app-ng-runtime/components/input/epoch/esm2015/date/date.component.js +3 -3
- app-ng-runtime/components/input/epoch/esm2015/date-time/date-time.component.js +2 -2
- app-ng-runtime/components/input/epoch/fesm2015/index.js +27 -45
- app-ng-runtime/components/input/epoch/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/input/epoch/index.metadata.json +1 -1
- app-ng-runtime/components/navigation/popover/bundles/index.umd.js +4 -3
- app-ng-runtime/components/navigation/popover/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/navigation/popover/esm2015/popover.component.js +6 -5
- app-ng-runtime/components/navigation/popover/fesm2015/index.js +5 -4
- app-ng-runtime/components/navigation/popover/fesm2015/index.js.map +1 -1
- app-ng-runtime/package.json +1 -1
- app-ng-runtime/scripts/datatable/datatable.js +23 -23
- app-ng-runtime/variables/bundles/index.umd.js +4 -14
- app-ng-runtime/variables/bundles/index.umd.js.map +1 -1
- app-ng-runtime/variables/esm2015/manager/action/notification-action.manager.js +6 -5
- app-ng-runtime/variables/esm2015/service/variables.service.js +1 -8
- app-ng-runtime/variables/fesm2015/index.js +5 -11
- app-ng-runtime/variables/fesm2015/index.js.map +1 -1
- app-ng-runtime/variables/index.metadata.json +1 -1
- app-ng-runtime/variables/service/variables.service.d.ts +0 -4
- app-ng-runtime/components/basic/tree/esm2015/tree.component.js +0 -322
- app-ng-runtime/components/basic/tree/tree.component.d.ts +0 -34
- app-ng-runtime/scripts/tree-keyboard-navigation/keyboard-navigation.js +0 -251
|
@@ -116,4 +116,4 @@ export declare const setFocusTrap: (container: any, allowOutsideClick: any, setR
|
|
|
116
116
|
* @param element {HTMLElement}
|
|
117
117
|
* @returns {Array}
|
|
118
118
|
*/
|
|
119
|
-
export declare const getKeyboardFocusableElements: (element: HTMLElement) => Element
|
|
119
|
+
export declare const getKeyboardFocusableElements: (element: HTMLElement) => NodeListOf<Element>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@wm/components/base')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@wm/components/basic/tree', ['exports', '@angular/core', '@angular/common', '@wm/components/base'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wm = global.wm || {}, global.wm.components = global.wm.components || {}, global.wm.components.basic = global.wm.components.basic || {}, global.wm.components.basic.tree = {}), global.ng.core, global.ng.common, global.wm.components.base));
|
|
5
|
-
})(this, (function (exports, core, common, base) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@wm/components/base'), require('@wm/core')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@wm/components/basic/tree', ['exports', '@angular/core', '@angular/common', '@wm/components/base', '@wm/core'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wm = global.wm || {}, global.wm.components = global.wm.components || {}, global.wm.components.basic = global.wm.components.basic || {}, global.wm.components.basic.tree = {}), global.ng.core, global.ng.common, global.wm.components.base, global.wm.core));
|
|
5
|
+
})(this, (function (exports, core$1, common, base, core) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -342,345 +342,321 @@
|
|
|
342
342
|
]));
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
-
var WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
|
|
346
345
|
var defaultTreeIconClass = 'plus-minus';
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
|
|
346
|
+
var ICON_CLASSES = {
|
|
347
|
+
'folder': {
|
|
348
|
+
'expanded': 'wi-folder-open',
|
|
349
|
+
'collapsed': 'wi-folder'
|
|
350
|
+
},
|
|
351
|
+
'circle-plus-minus': {
|
|
352
|
+
'expanded': 'wi-remove-circle-outline',
|
|
353
|
+
'collapsed': 'wi-add-circle-outline'
|
|
354
|
+
},
|
|
355
|
+
'chevron': {
|
|
356
|
+
'expanded': 'wi-keyboard-arrow-down',
|
|
357
|
+
'collapsed': 'wi-keyboard-arrow-right'
|
|
358
|
+
},
|
|
359
|
+
'menu': {
|
|
360
|
+
'expanded': 'wi-arrow-down',
|
|
361
|
+
'collapsed': 'wi-arrow-right'
|
|
362
|
+
},
|
|
363
|
+
'triangle': {
|
|
364
|
+
'expanded': 'wi-arrow-drop-down-circle',
|
|
365
|
+
'collapsed': 'wi-play-circle-filled'
|
|
366
|
+
},
|
|
367
|
+
'expand-collapse': {
|
|
368
|
+
'expanded': 'wi-expand-less',
|
|
369
|
+
'collapsed': 'wi-expand-more'
|
|
370
|
+
},
|
|
371
|
+
'plus-minus': {
|
|
372
|
+
'expanded': 'wi-minus',
|
|
373
|
+
'collapsed': 'wi-plus'
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
|
|
377
|
+
var TreeDirective = /** @class */ (function (_super) {
|
|
378
|
+
__extends(TreeDirective, _super);
|
|
379
|
+
function TreeDirective(inj, binddatavalue, bindnodelabel, bindnodeicon, bindnodechildren, bindnodeid) {
|
|
350
380
|
var _this = _super.call(this, inj, WIDGET_INFO) || this;
|
|
351
|
-
_this.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
},
|
|
357
|
-
view: {
|
|
358
|
-
dblClickExpand: false,
|
|
359
|
-
fontCss: {
|
|
360
|
-
'font-awesome': true
|
|
361
|
-
},
|
|
362
|
-
switchIcon: {},
|
|
363
|
-
},
|
|
364
|
-
check: {},
|
|
365
|
-
callback: {}
|
|
366
|
-
};
|
|
381
|
+
_this.binddatavalue = binddatavalue;
|
|
382
|
+
_this.bindnodelabel = bindnodelabel;
|
|
383
|
+
_this.bindnodeicon = bindnodeicon;
|
|
384
|
+
_this.bindnodechildren = bindnodechildren;
|
|
385
|
+
_this.bindnodeid = bindnodeid;
|
|
367
386
|
base.styler(_this.nativeElement, _this, base.APPLY_STYLES_TYPE.CONTAINER);
|
|
387
|
+
_this.bindEvents();
|
|
368
388
|
return _this;
|
|
369
389
|
}
|
|
370
|
-
|
|
390
|
+
TreeDirective.prototype.onPropertyChange = function (key, nv, ov) {
|
|
371
391
|
switch (key) {
|
|
372
392
|
case 'dataset':
|
|
373
393
|
this.nodes = this.getNodes(nv);
|
|
374
|
-
|
|
375
|
-
this.expandTree(this.level, this.nodes, 0);
|
|
376
|
-
}
|
|
394
|
+
this._selectNode = undefined;
|
|
377
395
|
this.renderTree();
|
|
378
396
|
break;
|
|
379
|
-
case '
|
|
380
|
-
if (nv > 0) {
|
|
381
|
-
this.level = nv;
|
|
382
|
-
}
|
|
383
|
-
break;
|
|
384
|
-
case 'treeicons':
|
|
385
|
-
this.treeicon = nv;
|
|
386
|
-
break;
|
|
397
|
+
case 'nodeicon':
|
|
387
398
|
case 'nodelabel':
|
|
388
|
-
|
|
389
|
-
break;
|
|
390
|
-
case 'icon':
|
|
391
|
-
this.nodeicon = nv;
|
|
399
|
+
case 'nodechildren':
|
|
392
400
|
case 'orderby':
|
|
393
401
|
this.renderTree();
|
|
394
402
|
break;
|
|
395
|
-
case '
|
|
396
|
-
this.
|
|
403
|
+
case 'treeicons':
|
|
404
|
+
this.changeTreeIcons(nv, ov);
|
|
405
|
+
break;
|
|
406
|
+
case 'datavalue':
|
|
407
|
+
this.selectById(nv);
|
|
397
408
|
break;
|
|
398
409
|
default:
|
|
399
410
|
_super.prototype.onPropertyChange.call(this, key, nv, ov);
|
|
400
|
-
break;
|
|
401
411
|
}
|
|
402
412
|
};
|
|
403
|
-
|
|
404
|
-
TreeComponent.prototype.expandTree = function (level, node, childLevel) {
|
|
413
|
+
TreeDirective.prototype.constructNodes = function (nodes, parent, levels, deep, _evalDataValue) {
|
|
405
414
|
var _this = this;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
var $ul = $('<ul></ul>');
|
|
416
|
+
var _iconClses = ICON_CLASSES[this.treeicons || defaultTreeIconClass];
|
|
417
|
+
var _expr = (this.binddatavalue || this.datavalue);
|
|
418
|
+
var _iconCls, _cls;
|
|
419
|
+
_cls = levels > 0 ? ' expanded ' : ' collapsed ';
|
|
420
|
+
_iconCls = _cls + (levels > 0 ? _iconClses.expanded : _iconClses.collapsed);
|
|
421
|
+
deep = deep || 0;
|
|
422
|
+
parent.append($ul);
|
|
423
|
+
nodes.forEach(function (node, idx) {
|
|
424
|
+
var $li = $('<li></li>'), $iconNode = $('<i></i>'), nodeLabel = base.getEvaluatedData(node, { field: _this.nodelabel, bindExpression: _this.bindnodelabel }, _this.viewParent) || node.label, nodeIcon = base.getEvaluatedData(node, { field: _this.nodeicon, bindExpression: _this.bindnodeicon }, _this.viewParent) || node.icon, nodeChildren = base.getEvaluatedData(node, { field: _this.nodechildren, bindExpression: _this.bindnodechildren }, _this.viewParent) || node.children;
|
|
425
|
+
var nodeIdValue = base.getEvaluatedData(node, { field: _this.nodeid, bindExpression: _this.bindnodeid }, _this.viewParent);
|
|
426
|
+
if (nodeIdValue === undefined) {
|
|
427
|
+
nodeIdValue = node.children;
|
|
428
|
+
}
|
|
429
|
+
var isNodeMatched = false, expandCollapseIcon;
|
|
430
|
+
$li.data('nodedata', node)
|
|
431
|
+
.append($iconNode)
|
|
432
|
+
.append("<span class=\"title\">" + nodeLabel + "</span>")
|
|
433
|
+
.appendTo($ul);
|
|
434
|
+
// if datavalue(ie, expr) is provided select the tree node accordingly
|
|
435
|
+
// if datavalue === 'FirstNode' -- select the FirstNode at level 0
|
|
436
|
+
// if datavalue === 'LastNode' -- select the LastNode at level 0
|
|
437
|
+
// if datavalue is a bind expression evaluate the expression for each node of the tree till the condition is satisfied.
|
|
438
|
+
// if node identifier is present then verify the datavalue is bound expr or static value and compare with the node model
|
|
439
|
+
if (_this.bindnodeid || _this.nodeid) {
|
|
440
|
+
isNodeMatched = _this.binddatavalue ? nodeIdValue === _evalDataValue : nodeIdValue === _expr;
|
|
441
|
+
if (nodeIdValue !== undefined) {
|
|
442
|
+
$li.attr('id', nodeIdValue);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
else if (_this.binddatavalue) { // evaluate the expression only if it is bound (useExpression)
|
|
446
|
+
isNodeMatched = !!core.$parseExpr(_expr)(_this, node);
|
|
447
|
+
}
|
|
448
|
+
// Perform LastNode check only at level 0.(ie, deep = 0);
|
|
449
|
+
if (!_this._selectNode) {
|
|
450
|
+
if ((_expr === 'FirstNode' && idx === 0)
|
|
451
|
+
|| (!deep && _expr === 'LastNode' && idx === nodes.length - 1)
|
|
452
|
+
|| isNodeMatched) {
|
|
453
|
+
// save a reference of the node to be selected in `_selectNode`
|
|
454
|
+
_this._selectNode = $li;
|
|
455
|
+
_this.datavalue = nodeIdValue;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (nodeIcon) {
|
|
459
|
+
$iconNode.addClass(nodeIcon);
|
|
460
|
+
}
|
|
461
|
+
if (nodeChildren && nodeChildren.length) { // parent node
|
|
462
|
+
$li.addClass("parent-node " + _cls);
|
|
463
|
+
expandCollapseIcon = $("<i class=\"wi " + _iconCls + "\"></i>");
|
|
464
|
+
if (nodeIcon) {
|
|
465
|
+
$iconNode.addClass(nodeIcon);
|
|
466
|
+
}
|
|
467
|
+
$li.prepend(expandCollapseIcon);
|
|
468
|
+
_this.constructNodes(nodeChildren, $li, levels - 1, deep + 1, _evalDataValue);
|
|
410
469
|
}
|
|
411
470
|
else {
|
|
412
|
-
|
|
413
|
-
|
|
471
|
+
if (!nodeIcon) {
|
|
472
|
+
$iconNode.addClass('leaf-node');
|
|
473
|
+
}
|
|
474
|
+
$li.addClass('leaf-node');
|
|
414
475
|
}
|
|
415
476
|
});
|
|
416
477
|
};
|
|
417
|
-
|
|
418
|
-
TreeComponent.prototype.setTreeTemplate = function (value) {
|
|
419
|
-
if (value === 'Classic') {
|
|
420
|
-
this.setting.check["enable"] = false;
|
|
421
|
-
}
|
|
422
|
-
else if (value === 'Checkbox') {
|
|
423
|
-
this.setting.check["enable"] = true;
|
|
424
|
-
this.setting.check["chkStyle"] = 'checkbox';
|
|
425
|
-
}
|
|
426
|
-
else if (value === 'Radio') {
|
|
427
|
-
this.setting.check["enable"] = true;
|
|
428
|
-
this.setting.check["chkStyle"] = 'radio';
|
|
429
|
-
this.setting.check["radioType"] = "all";
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
// extracts nodes from string format
|
|
433
|
-
TreeComponent.prototype.getNodesFromString = function (value) {
|
|
478
|
+
TreeDirective.prototype.getNodesFromString = function (value) {
|
|
434
479
|
return value.split(',').map(function (item) {
|
|
435
480
|
return {
|
|
436
|
-
'
|
|
481
|
+
'label': item && item.trim()
|
|
437
482
|
};
|
|
438
483
|
});
|
|
439
484
|
};
|
|
440
|
-
|
|
441
|
-
TreeComponent.prototype.getNodes = function (newVal) {
|
|
485
|
+
TreeDirective.prototype.getNodes = function (newVal) {
|
|
442
486
|
var nodes;
|
|
443
|
-
if (_.
|
|
444
|
-
nodes = base.getOrderedDataset(newVal, this.orderby);
|
|
445
|
-
}
|
|
446
|
-
else if (_.isObject(newVal)) {
|
|
447
|
-
nodes = [newVal];
|
|
448
|
-
}
|
|
449
|
-
else if (_.isString(newVal) && !_.isEmpty(newVal)) {
|
|
487
|
+
if (_.isString(newVal) && !_.isEmpty(newVal)) {
|
|
450
488
|
newVal = newVal.trim();
|
|
451
489
|
if (newVal) {
|
|
452
490
|
nodes = this.getNodesFromString(newVal);
|
|
453
491
|
}
|
|
454
492
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
TreeComponent.prototype.setNodeclasses = function (treeId, treeNode) {
|
|
459
|
-
return treeNode.icon ? { add: ["" + treeNode.icon] } : '';
|
|
460
|
-
};
|
|
461
|
-
;
|
|
462
|
-
// Sets the node label with any icon if bound to
|
|
463
|
-
TreeComponent.prototype.setNodeData = function (nodes, depth, level, parentNode, type) {
|
|
464
|
-
var _this = this;
|
|
465
|
-
if (depth === 0) {
|
|
466
|
-
nodes.map(function (node) {
|
|
467
|
-
if (node.children) {
|
|
468
|
-
_this.setNodeData(node.children, depth, level, parentNode, type);
|
|
469
|
-
}
|
|
470
|
-
if (node.icon && _this.nodelabel == 'icon') {
|
|
471
|
-
node[type] = node.icon;
|
|
472
|
-
}
|
|
473
|
-
else if (node.name && _this.nodelabel == 'name') {
|
|
474
|
-
node[type] = node.name;
|
|
475
|
-
}
|
|
476
|
-
else {
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
nodes.map(function (node) {
|
|
483
|
-
if (node.children && level > 1) {
|
|
484
|
-
if (depth === level) {
|
|
485
|
-
parentNode = node;
|
|
486
|
-
}
|
|
487
|
-
_this.setNodeData(node.children, depth, level - 1, parentNode, type);
|
|
488
|
-
}
|
|
489
|
-
if (level === 1 && (type === "name" ? _this.nodelabel.includes("label") || _this.nodelabel.includes("name") : _this.nodeicon.includes("label") || _this.nodeicon.includes("name"))) {
|
|
490
|
-
parentNode[type] = node.name || node.label;
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
else if (level === 1 && (node.icon !== undefined) && (type === "name" ? _this.nodelabel.includes("icon") : _this.nodeicon.includes("icon"))) {
|
|
494
|
-
parentNode[type] = node.icon;
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
else {
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
// adds tree icons to the nodes on load of the tree
|
|
504
|
-
TreeComponent.prototype.changeTreeIcons = function (nv) {
|
|
505
|
-
var eleClose = $('ul[name="' + this.name + '"] li span.button.switch');
|
|
506
|
-
$(eleClose).map(function (idx, ele) {
|
|
507
|
-
$(ele).addClass(nv);
|
|
508
|
-
$(ele).on("click", function (e) {
|
|
509
|
-
setTimeout(function () {
|
|
510
|
-
$(ele).addClass(nv);
|
|
511
|
-
}, 0);
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
};
|
|
515
|
-
TreeComponent.prototype.getPath = function (treeNode, path) {
|
|
516
|
-
if (treeNode.getParentNode() === null) {
|
|
517
|
-
path = "/" + treeNode.name + path;
|
|
493
|
+
else if (_.isArray(newVal)) {
|
|
494
|
+
newVal = base.getOrderedDataset(newVal, this.orderby);
|
|
495
|
+
nodes = newVal;
|
|
518
496
|
}
|
|
519
|
-
else {
|
|
520
|
-
|
|
497
|
+
else if (_.isObject(newVal)) {
|
|
498
|
+
nodes = [newVal];
|
|
521
499
|
}
|
|
522
|
-
return
|
|
500
|
+
return nodes;
|
|
523
501
|
};
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
"$item": treeNode,
|
|
531
|
-
"$path": path
|
|
532
|
-
};
|
|
533
|
-
this.invokeEventCallback('select', eventParams);
|
|
502
|
+
TreeDirective.prototype.changeTreeIcons = function (nv, ov) {
|
|
503
|
+
var $el = $(this.nativeElement);
|
|
504
|
+
nv = nv || defaultTreeIconClass;
|
|
505
|
+
ov = ov || defaultTreeIconClass;
|
|
506
|
+
$el.find('i.expanded').removeClass(ICON_CLASSES[ov].expanded).addClass(ICON_CLASSES[nv].expanded);
|
|
507
|
+
$el.find('i.collapsed').removeClass(ICON_CLASSES[ov].collapsed).addClass(ICON_CLASSES[nv].collapsed);
|
|
534
508
|
};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
var
|
|
538
|
-
var path =
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
treeNode.children ? treeNode.children.map(function (el) {
|
|
546
|
-
if (el.isParent) {
|
|
547
|
-
var ele_1 = $("#" + el.tId + "_switch");
|
|
548
|
-
$(ele_1).addClass(self.treeicon || defaultTreeIconClass);
|
|
549
|
-
$(ele_1).on("click", function (e) {
|
|
550
|
-
setTimeout(function () {
|
|
551
|
-
$(ele_1).addClass(self.treeicon || defaultTreeIconClass);
|
|
552
|
-
}, 0);
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
}) : '';
|
|
556
|
-
};
|
|
557
|
-
TreeComponent.prototype.onCollapse = function (event, treeId, treeNode) {
|
|
558
|
-
var path = this.getPath(treeNode, "");
|
|
509
|
+
TreeDirective.prototype.toggleExpandCollapseNode = function ($event, $i, $li) {
|
|
510
|
+
var treeIcons = ICON_CLASSES[this.treeicons || defaultTreeIconClass];
|
|
511
|
+
var $liPath = this.findSelectedNodeParent($li);
|
|
512
|
+
var path = '';
|
|
513
|
+
// construct the path of the node
|
|
514
|
+
$liPath
|
|
515
|
+
.each(function (i, el) {
|
|
516
|
+
var current = $(el).children('.title').text();
|
|
517
|
+
path = "/" + (current + path);
|
|
518
|
+
});
|
|
559
519
|
var eventParams = {
|
|
560
|
-
'$event': event,
|
|
561
|
-
"$item":
|
|
520
|
+
'$event': $event,
|
|
521
|
+
"$item": $li.data('nodedata'),
|
|
562
522
|
"$path": path
|
|
563
523
|
};
|
|
564
|
-
|
|
524
|
+
if ($i.hasClass('collapsed')) {
|
|
525
|
+
$i.removeClass("collapsed " + treeIcons.collapsed).addClass("expanded " + treeIcons.expanded);
|
|
526
|
+
$li.removeClass('collapsed').addClass('expanded');
|
|
527
|
+
this.invokeEventCallback('expand', eventParams);
|
|
528
|
+
}
|
|
529
|
+
else if ($i.hasClass('expanded')) {
|
|
530
|
+
$i.removeClass("expanded " + treeIcons.expanded).addClass("collapsed " + treeIcons.collapsed);
|
|
531
|
+
$li.removeClass('expanded').addClass('collapsed');
|
|
532
|
+
this.invokeEventCallback('collapse', eventParams);
|
|
533
|
+
}
|
|
565
534
|
};
|
|
566
|
-
|
|
567
|
-
TreeComponent.prototype.modifyObjects = function (array) {
|
|
535
|
+
TreeDirective.prototype.renderTree = function (forceRender) {
|
|
568
536
|
var _this = this;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
537
|
+
var docFrag, $li, $liPath, data, path = '';
|
|
538
|
+
var levels = +this.nativeElement.getAttribute('levels') || 0, $el = $(this.nativeElement);
|
|
539
|
+
$el.empty();
|
|
540
|
+
if (forceRender) {
|
|
541
|
+
this._selectNode = undefined;
|
|
542
|
+
}
|
|
543
|
+
if (this.nodes && this.nodes.length) {
|
|
544
|
+
docFrag = document.createDocumentFragment();
|
|
545
|
+
this.constructNodes(this.nodes, $(docFrag), levels, 0, this.datavalue);
|
|
546
|
+
$el.append(docFrag);
|
|
547
|
+
}
|
|
548
|
+
if (this._selectNode) {
|
|
549
|
+
$li = this._selectNode;
|
|
550
|
+
$li.addClass('selected');
|
|
551
|
+
data = $li.data('nodedata');
|
|
552
|
+
$liPath = this.findSelectedNodeParent($li);
|
|
553
|
+
if (!$liPath.length) {
|
|
554
|
+
$liPath = $li;
|
|
576
555
|
}
|
|
577
|
-
|
|
578
|
-
|
|
556
|
+
$liPath
|
|
557
|
+
.each(function (i, el) {
|
|
558
|
+
var $current = $(el), $i = $current.children('i.collapsed'), $title = $current.children('.title');
|
|
559
|
+
_this.toggleExpandCollapseNode(undefined, $i, $current);
|
|
560
|
+
path = "/" + ($title.text() + path);
|
|
561
|
+
});
|
|
562
|
+
this.selecteditem = core.getClonedObject(data) || {};
|
|
563
|
+
this.selecteditem.path = path;
|
|
564
|
+
this.invokeEventCallback('select', { $event: undefined, $item: data, $path: path });
|
|
565
|
+
core.$appDigest();
|
|
566
|
+
}
|
|
579
567
|
};
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
568
|
+
TreeDirective.prototype.selectNode = function (evt, value) {
|
|
569
|
+
var _this = this;
|
|
570
|
+
var target = evt && $(evt.target), $el = $(this.nativeElement), $li = _.isObject(value) ? value : $el.find("li[id=\"" + value + "\"]").first();
|
|
571
|
+
var data, path = '', $liPath, nodeAction;
|
|
572
|
+
$el.find('.selected').removeClass('selected');
|
|
573
|
+
if (!$li.length) {
|
|
574
|
+
return;
|
|
584
575
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
576
|
+
$li.addClass('selected');
|
|
577
|
+
data = $li.data('nodedata');
|
|
578
|
+
nodeAction = data[this.nodeaction || 'action'];
|
|
579
|
+
// if the selectNode is initiated by click event then use the nativeElement target from event
|
|
580
|
+
$liPath = target ? target.parents('.app-tree li') : this.findSelectedNodeParent($li);
|
|
581
|
+
// construct the path of the node
|
|
582
|
+
$liPath
|
|
583
|
+
.each(function (i, el) {
|
|
584
|
+
var current = $(el).children('.title').text();
|
|
585
|
+
path = "/" + (current + path);
|
|
586
|
+
});
|
|
587
|
+
// expand the current node till the viewParent level which is collapsed
|
|
588
|
+
$li.parentsUntil($el, 'li.parent-node.collapsed')
|
|
589
|
+
.each(function (index, el) {
|
|
590
|
+
var $current = $(el), $i = $current.children('i.collapsed');
|
|
591
|
+
_this.toggleExpandCollapseNode(undefined, $i, $current);
|
|
592
|
+
});
|
|
593
|
+
this.selecteditem = core.getClonedObject(data) || {};
|
|
594
|
+
this.selecteditem.path = path;
|
|
595
|
+
if (target) {
|
|
596
|
+
if (this.nodeid || this.bindnodeid) {
|
|
597
|
+
this.datavalue = base.getEvaluatedData(data, { field: this.nodeid, bindExpression: this.bindnodeid }, this.viewParent);
|
|
589
598
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
parentNode.children = node.children.map(function (child) { return ({ name: child.name, children: child === null || child === void 0 ? void 0 : child.children }); });
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
else {
|
|
596
|
-
this.setNodeChildren(node.children, depth, level - 1, parentNode);
|
|
597
|
-
}
|
|
599
|
+
else {
|
|
600
|
+
this.datavalue = core.getClonedObject(data) || {};
|
|
598
601
|
}
|
|
599
602
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
TreeComponent.prototype.countDepth = function (str) {
|
|
603
|
-
var e_1, _a;
|
|
604
|
-
var regex = /\[.*?\]/g;
|
|
605
|
-
var matches = str.match(regex);
|
|
606
|
-
var count = 1;
|
|
607
|
-
if (matches === null)
|
|
608
|
-
return count;
|
|
609
|
-
try {
|
|
610
|
-
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
|
611
|
-
var match = matches_1_1.value;
|
|
612
|
-
count++;
|
|
613
|
-
}
|
|
603
|
+
else {
|
|
604
|
+
this.datavalue = value;
|
|
614
605
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
|
619
|
-
}
|
|
620
|
-
finally { if (e_1) throw e_1.error; }
|
|
606
|
+
//[Todo-CSP]: this data will be dynamic, can not generate function upfront
|
|
607
|
+
if (nodeAction) {
|
|
608
|
+
core.$parseEvent(nodeAction)(this);
|
|
621
609
|
}
|
|
622
|
-
|
|
610
|
+
this.invokeEventCallback('select', { $event: evt, $item: data, $path: path });
|
|
611
|
+
core.$appDigest();
|
|
623
612
|
};
|
|
624
|
-
//
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (this.nodelabel.includes("children")) {
|
|
634
|
-
depth = this.countDepth(this.nodelabel);
|
|
635
|
-
}
|
|
636
|
-
this.setNodeData(this.nodes, depth, depth, null, "name");
|
|
637
|
-
}
|
|
638
|
-
if (this.nodeicon) {
|
|
639
|
-
var depth = 0;
|
|
640
|
-
if (this.nodeicon.includes("children")) {
|
|
641
|
-
depth = this.countDepth(this.nodeicon);
|
|
642
|
-
}
|
|
643
|
-
this.setNodeData(this.nodes, depth, depth, null, "icon");
|
|
613
|
+
// click event is added on the host nativeElement
|
|
614
|
+
TreeDirective.prototype.bindEvents = function () {
|
|
615
|
+
var _this = this;
|
|
616
|
+
$(this.nativeElement).on('click', function (evt) {
|
|
617
|
+
var target = $(evt.target), li = target.closest('li'), $i = target.is('i') ? target : target.siblings('i.collapsed,i.expanded');
|
|
618
|
+
evt.stopPropagation();
|
|
619
|
+
if (target.is('span.title')) { // select the node only if it is nodelabel
|
|
620
|
+
_this.selecteditem = {};
|
|
621
|
+
_this.selectNode(evt, li);
|
|
644
622
|
}
|
|
645
|
-
if (
|
|
646
|
-
|
|
647
|
-
if (depth > 1) {
|
|
648
|
-
this.nodes = this.setNodeChildren(this.nodes, depth, depth, null);
|
|
649
|
-
}
|
|
623
|
+
if (target.is('i') || (target.is('span.title') && _this.nodeclick === 'expand')) {
|
|
624
|
+
_this.toggleExpandCollapseNode(evt, $i, li);
|
|
650
625
|
}
|
|
651
|
-
}
|
|
652
|
-
this.setting.view['nodeClasses'] = this.setNodeclasses;
|
|
653
|
-
this.setting.callback["onClick"] = this.onClick.bind(this);
|
|
654
|
-
this.setting.callback["onExpand"] = this.onExpand.bind(this);
|
|
655
|
-
this.setting.callback["onCollapse"] = this.onCollapse.bind(this);
|
|
656
|
-
var zTree = $.fn.zTree.init($('ul[name="' + this.name + '"]'), this.setting, this.nodes);
|
|
657
|
-
$.fn.zTreeKeyboardNavigation(zTree, $('ul[name="' + this.name + '"]'), null, this.treeicon || defaultTreeIconClass);
|
|
626
|
+
});
|
|
658
627
|
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
setTimeout(function () {
|
|
662
|
-
_this.changeTreeIcons(_this.treeicon || defaultTreeIconClass);
|
|
663
|
-
}, 200);
|
|
628
|
+
TreeDirective.prototype.findSelectedNodeParent = function ($li) {
|
|
629
|
+
return $li.find('> span.title').parents('.app-tree li');
|
|
664
630
|
};
|
|
665
|
-
|
|
631
|
+
TreeDirective.prototype.selectById = function (value) {
|
|
632
|
+
this.selectNode(undefined, value);
|
|
633
|
+
};
|
|
634
|
+
TreeDirective.prototype.deselectById = function (value) {
|
|
635
|
+
this.selecteditem = {};
|
|
636
|
+
this.selectById();
|
|
637
|
+
};
|
|
638
|
+
return TreeDirective;
|
|
666
639
|
}(base.StylableComponent));
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
{ type: core.
|
|
670
|
-
selector: '
|
|
671
|
-
template: "<ul #wmTree class=\"ztree\" id=\"ztree\"></ul> ",
|
|
640
|
+
TreeDirective.initializeProps = registerProps();
|
|
641
|
+
TreeDirective.decorators = [
|
|
642
|
+
{ type: core$1.Directive, args: [{
|
|
643
|
+
selector: 'div[wmTree]',
|
|
672
644
|
providers: [
|
|
673
|
-
base.provideAsWidgetRef(
|
|
674
|
-
]
|
|
675
|
-
encapsulation: core.ViewEncapsulation.None
|
|
645
|
+
base.provideAsWidgetRef(TreeDirective)
|
|
646
|
+
]
|
|
676
647
|
},] }
|
|
677
648
|
];
|
|
678
|
-
|
|
679
|
-
{ type: core.Injector }
|
|
649
|
+
TreeDirective.ctorParameters = function () { return [
|
|
650
|
+
{ type: core$1.Injector },
|
|
651
|
+
{ type: undefined, decorators: [{ type: core$1.Attribute, args: ['datavalue.bind',] }] },
|
|
652
|
+
{ type: undefined, decorators: [{ type: core$1.Attribute, args: ['nodelabel.bind',] }] },
|
|
653
|
+
{ type: undefined, decorators: [{ type: core$1.Attribute, args: ['nodeicon.bind',] }] },
|
|
654
|
+
{ type: undefined, decorators: [{ type: core$1.Attribute, args: ['nodechildren.bind',] }] },
|
|
655
|
+
{ type: undefined, decorators: [{ type: core$1.Attribute, args: ['nodeid.bind',] }] }
|
|
680
656
|
]; };
|
|
681
657
|
|
|
682
658
|
var components = [
|
|
683
|
-
|
|
659
|
+
TreeDirective
|
|
684
660
|
];
|
|
685
661
|
var TreeModule = /** @class */ (function () {
|
|
686
662
|
function TreeModule() {
|
|
@@ -688,7 +664,7 @@
|
|
|
688
664
|
return TreeModule;
|
|
689
665
|
}());
|
|
690
666
|
TreeModule.decorators = [
|
|
691
|
-
{ type: core.NgModule, args: [{
|
|
667
|
+
{ type: core$1.NgModule, args: [{
|
|
692
668
|
imports: [
|
|
693
669
|
common.CommonModule,
|
|
694
670
|
base.WmComponentsModule
|
|
@@ -703,7 +679,7 @@
|
|
|
703
679
|
* Generated bundle index. Do not edit.
|
|
704
680
|
*/
|
|
705
681
|
|
|
706
|
-
exports.
|
|
682
|
+
exports.TreeDirective = TreeDirective;
|
|
707
683
|
exports.TreeModule = TreeModule;
|
|
708
684
|
exports["ɵa"] = registerProps;
|
|
709
685
|
|