@wavemaker/app-ng-runtime 11.4.0-next.28152 → 11.4.0-rc.5339
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 +1 -2
- app-ng-runtime/build-task/bundles/index.umd.js +8 -10
- app-ng-runtime/build-task/bundles/index.umd.js.map +1 -1
- app-ng-runtime/build-task/esm2015/basic/tree/tree.build.js +3 -4
- app-ng-runtime/build-task/esm2015/data/form/form-field/form-field.build.js +2 -2
- app-ng-runtime/build-task/esm2015/navigation/popover/popover.build.js +3 -3
- app-ng-runtime/build-task/fesm2015/index.js +8 -10
- app-ng-runtime/build-task/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/base/bundles/index.umd.js +29 -4
- app-ng-runtime/components/base/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/base/esm2015/public_api.js +2 -2
- app-ng-runtime/components/base/esm2015/utils/widget-utils.js +22 -4
- app-ng-runtime/components/base/esm2015/widgets/common/base/base-field-validations.js +3 -2
- app-ng-runtime/components/base/esm2015/widgets/common/dialog/dialog.service.js +7 -1
- app-ng-runtime/components/base/fesm2015/index.js +30 -6
- app-ng-runtime/components/base/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/base/index.metadata.json +1 -1
- app-ng-runtime/components/base/public_api.d.ts +1 -1
- app-ng-runtime/components/base/utils/widget-utils.d.ts +8 -1
- app-ng-runtime/components/basic/tree/bundles/index.umd.js +280 -256
- 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.component.js +322 -0
- app-ng-runtime/components/basic/tree/esm2015/tree.module.js +3 -3
- app-ng-runtime/components/basic/tree/fesm2015/index.js +260 -248
- 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.component.d.ts +34 -0
- app-ng-runtime/components/containers/tabs/bundles/index.umd.js +39 -23
- app-ng-runtime/components/containers/tabs/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/containers/tabs/esm2015/tab-pane/tab-pane.component.js +8 -1
- app-ng-runtime/components/containers/tabs/esm2015/tabs.animator.js +33 -13
- app-ng-runtime/components/containers/tabs/fesm2015/index.js +40 -13
- app-ng-runtime/components/containers/tabs/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/containers/tabs/tabs.animator.d.ts +5 -1
- app-ng-runtime/components/data/form/bundles/index.umd.js +37 -13
- app-ng-runtime/components/data/form/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/data/form/esm2015/form-field/form-field.directive.js +26 -7
- app-ng-runtime/components/data/form/esm2015/form.component.js +10 -5
- app-ng-runtime/components/data/form/fesm2015/index.js +34 -10
- app-ng-runtime/components/data/form/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/data/form/index.metadata.json +1 -1
- app-ng-runtime/components/data/list/bundles/index.umd.js +52 -43
- app-ng-runtime/components/data/list/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/data/list/esm2015/list.component.js +52 -43
- app-ng-runtime/components/data/list/fesm2015/index.js +51 -42
- 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/data/list/list.component.d.ts +1 -1
- app-ng-runtime/components/data/pagination/bundles/index.umd.js +22 -5
- app-ng-runtime/components/data/pagination/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/data/pagination/esm2015/pagination.component.js +23 -6
- app-ng-runtime/components/data/pagination/fesm2015/index.js +22 -5
- app-ng-runtime/components/data/pagination/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/data/pagination/index.metadata.json +1 -1
- app-ng-runtime/components/data/pagination/pagination.component.d.ts +1 -0
- app-ng-runtime/components/data/table/bundles/index.umd.js +64 -12
- app-ng-runtime/components/data/table/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/data/table/esm2015/table.component.js +63 -13
- app-ng-runtime/components/data/table/esm2015/table.props.js +3 -1
- app-ng-runtime/components/data/table/fesm2015/index.js +64 -12
- app-ng-runtime/components/data/table/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/data/table/index.metadata.json +1 -1
- app-ng-runtime/components/data/table/table.component.d.ts +9 -0
- app-ng-runtime/components/dialogs/default/base-dialog.d.ts +1 -0
- app-ng-runtime/components/dialogs/default/bundles/index.umd.js +17 -3
- app-ng-runtime/components/dialogs/default/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/dialogs/default/esm2015/base-dialog.js +18 -5
- app-ng-runtime/components/dialogs/default/fesm2015/index.js +17 -4
- 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/base-date-time.component.d.ts +1 -0
- app-ng-runtime/components/input/epoch/bundles/index.umd.js +78 -35
- app-ng-runtime/components/input/epoch/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/input/epoch/date-time/date-time-picker.component.d.ts +1 -0
- app-ng-runtime/components/input/epoch/esm2015/base-date-time.component.js +55 -31
- app-ng-runtime/components/input/epoch/esm2015/date/date.component.js +3 -3
- app-ng-runtime/components/input/epoch/esm2015/date-time/date-time-picker.component.js +31 -11
- app-ng-runtime/components/input/epoch/esm2015/date-time/date-time.component.js +2 -2
- app-ng-runtime/components/input/epoch/fesm2015/index.js +87 -43
- 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/menu/bundles/index.umd.js +25 -19
- app-ng-runtime/components/navigation/menu/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/navigation/menu/esm2015/menu-dropdown-item/menu-dropdown-item.component.js +15 -5
- app-ng-runtime/components/navigation/menu/esm2015/menu.component.js +14 -19
- app-ng-runtime/components/navigation/menu/fesm2015/index.js +25 -20
- app-ng-runtime/components/navigation/menu/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/navigation/menu/index.metadata.json +1 -1
- app-ng-runtime/components/navigation/menu/menu-dropdown-item/menu-dropdown-item.component.d.ts +7 -4
- app-ng-runtime/components/navigation/menu/menu.component.d.ts +3 -7
- app-ng-runtime/components/navigation/popover/bundles/index.umd.js +3 -1
- app-ng-runtime/components/navigation/popover/bundles/index.umd.js.map +1 -1
- app-ng-runtime/components/navigation/popover/esm2015/popover.component.js +5 -3
- app-ng-runtime/components/navigation/popover/fesm2015/index.js +4 -2
- app-ng-runtime/components/navigation/popover/fesm2015/index.js.map +1 -1
- app-ng-runtime/core/bundles/index.umd.js +7 -1
- app-ng-runtime/core/bundles/index.umd.js.map +1 -1
- app-ng-runtime/core/esm2015/services/pagination.service.js +8 -2
- app-ng-runtime/core/fesm2015/index.js +7 -1
- app-ng-runtime/core/fesm2015/index.js.map +1 -1
- app-ng-runtime/mobile/components/page/default/bundles/index.umd.js +24 -6
- app-ng-runtime/mobile/components/page/default/bundles/index.umd.js.map +1 -1
- app-ng-runtime/mobile/components/page/default/esm2015/page.directive.js +20 -3
- app-ng-runtime/mobile/components/page/default/fesm2015/index.js +19 -2
- app-ng-runtime/mobile/components/page/default/fesm2015/index.js.map +1 -1
- app-ng-runtime/mobile/components/page/default/index.metadata.json +1 -1
- app-ng-runtime/mobile/components/page/default/page.directive.d.ts +4 -1
- app-ng-runtime/package.json +1 -1
- app-ng-runtime/scripts/datatable/datatable.js +86 -36
- app-ng-runtime/scripts/tree-keyboard-navigation/keyboard-navigation.js +251 -0
- app-ng-runtime/variables/bundles/index.umd.js +14 -4
- app-ng-runtime/variables/bundles/index.umd.js.map +1 -1
- app-ng-runtime/variables/esm2015/manager/action/notification-action.manager.js +5 -6
- app-ng-runtime/variables/esm2015/service/variables.service.js +8 -1
- app-ng-runtime/variables/fesm2015/index.js +11 -5
- 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 +4 -0
- app-ng-runtime/components/basic/tree/esm2015/tree.directive.js +0 -310
- app-ng-runtime/components/basic/tree/tree.directive.d.ts +0 -35
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component, ViewEncapsulation, Injector, NgModule } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { register, PROP_STRING, PROP_ANY, PROP_NUMBER, PROP_BOOLEAN, StylableComponent, styler, APPLY_STYLES_TYPE,
|
|
4
|
-
import { $parseExpr, getClonedObject, $appDigest, $parseEvent } from '@wm/core';
|
|
3
|
+
import { register, PROP_STRING, PROP_ANY, PROP_NUMBER, PROP_BOOLEAN, StylableComponent, styler, APPLY_STYLES_TYPE, getOrderedDataset, provideAsWidgetRef, WmComponentsModule } from '@wm/components/base';
|
|
5
4
|
|
|
6
5
|
const registerProps = () => {
|
|
7
6
|
register('wm-tree', new Map([
|
|
@@ -23,314 +22,327 @@ const registerProps = () => {
|
|
|
23
22
|
]));
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
const defaultTreeIconClass = 'plus-minus';
|
|
27
|
-
const ICON_CLASSES = {
|
|
28
|
-
'folder': {
|
|
29
|
-
'expanded': 'wi-folder-open',
|
|
30
|
-
'collapsed': 'wi-folder'
|
|
31
|
-
},
|
|
32
|
-
'circle-plus-minus': {
|
|
33
|
-
'expanded': 'wi-remove-circle-outline',
|
|
34
|
-
'collapsed': 'wi-add-circle-outline'
|
|
35
|
-
},
|
|
36
|
-
'chevron': {
|
|
37
|
-
'expanded': 'wi-keyboard-arrow-down',
|
|
38
|
-
'collapsed': 'wi-keyboard-arrow-right'
|
|
39
|
-
},
|
|
40
|
-
'menu': {
|
|
41
|
-
'expanded': 'wi-arrow-down',
|
|
42
|
-
'collapsed': 'wi-arrow-right'
|
|
43
|
-
},
|
|
44
|
-
'triangle': {
|
|
45
|
-
'expanded': 'wi-arrow-drop-down-circle',
|
|
46
|
-
'collapsed': 'wi-play-circle-filled'
|
|
47
|
-
},
|
|
48
|
-
'expand-collapse': {
|
|
49
|
-
'expanded': 'wi-expand-less',
|
|
50
|
-
'collapsed': 'wi-expand-more'
|
|
51
|
-
},
|
|
52
|
-
'plus-minus': {
|
|
53
|
-
'expanded': 'wi-minus',
|
|
54
|
-
'collapsed': 'wi-plus'
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
25
|
const WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
const defaultTreeIconClass = 'plus-minus';
|
|
27
|
+
class TreeComponent extends StylableComponent {
|
|
28
|
+
constructor(inj) {
|
|
60
29
|
super(inj, WIDGET_INFO);
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
30
|
+
this.setting = {
|
|
31
|
+
data: {
|
|
32
|
+
simpleData: {
|
|
33
|
+
enable: true
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
view: {
|
|
37
|
+
dblClickExpand: false,
|
|
38
|
+
fontCss: {
|
|
39
|
+
'font-awesome': true
|
|
40
|
+
},
|
|
41
|
+
switchIcon: {},
|
|
42
|
+
},
|
|
43
|
+
check: {},
|
|
44
|
+
callback: {}
|
|
45
|
+
};
|
|
66
46
|
styler(this.nativeElement, this, APPLY_STYLES_TYPE.CONTAINER);
|
|
67
|
-
this.bindEvents();
|
|
68
47
|
}
|
|
69
48
|
onPropertyChange(key, nv, ov) {
|
|
70
49
|
switch (key) {
|
|
71
50
|
case 'dataset':
|
|
72
51
|
this.nodes = this.getNodes(nv);
|
|
73
|
-
this.
|
|
52
|
+
if (this.level > 0) {
|
|
53
|
+
this.expandTree(this.level, this.nodes, 0);
|
|
54
|
+
}
|
|
74
55
|
this.renderTree();
|
|
75
56
|
break;
|
|
76
|
-
case '
|
|
57
|
+
case 'levels':
|
|
58
|
+
if (nv > 0) {
|
|
59
|
+
this.level = nv;
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case 'treeicons':
|
|
63
|
+
this.treeicon = nv;
|
|
64
|
+
break;
|
|
77
65
|
case 'nodelabel':
|
|
78
|
-
|
|
66
|
+
this.nodelabel = nv;
|
|
67
|
+
break;
|
|
68
|
+
case 'icon':
|
|
69
|
+
this.nodeicon = nv;
|
|
79
70
|
case 'orderby':
|
|
80
71
|
this.renderTree();
|
|
81
72
|
break;
|
|
82
|
-
case '
|
|
83
|
-
this.
|
|
84
|
-
break;
|
|
85
|
-
case 'datavalue':
|
|
86
|
-
this.selectById(nv);
|
|
73
|
+
case 'class':
|
|
74
|
+
this.treeClass = nv;
|
|
87
75
|
break;
|
|
88
76
|
default:
|
|
89
77
|
super.onPropertyChange(key, nv, ov);
|
|
78
|
+
break;
|
|
90
79
|
}
|
|
91
80
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_iconCls = _cls + (levels > 0 ? _iconClses.expanded : _iconClses.collapsed);
|
|
99
|
-
deep = deep || 0;
|
|
100
|
-
parent.append($ul);
|
|
101
|
-
nodes.forEach((node, idx) => {
|
|
102
|
-
const $li = $('<li></li>'), $iconNode = $('<i></i>'), nodeLabel = getEvaluatedData(node, { field: this.nodelabel, bindExpression: this.bindnodelabel }, this.viewParent) || node.label, nodeIcon = getEvaluatedData(node, { field: this.nodeicon, bindExpression: this.bindnodeicon }, this.viewParent) || node.icon, nodeChildren = getEvaluatedData(node, { field: this.nodechildren, bindExpression: this.bindnodechildren }, this.viewParent) || node.children;
|
|
103
|
-
let nodeIdValue = getEvaluatedData(node, { field: this.nodeid, bindExpression: this.bindnodeid }, this.viewParent);
|
|
104
|
-
if (nodeIdValue === undefined) {
|
|
105
|
-
nodeIdValue = node.children;
|
|
106
|
-
}
|
|
107
|
-
let isNodeMatched = false, expandCollapseIcon;
|
|
108
|
-
$li.data('nodedata', node)
|
|
109
|
-
.append($iconNode)
|
|
110
|
-
.append(`<span class="title">${nodeLabel}</span>`)
|
|
111
|
-
.appendTo($ul);
|
|
112
|
-
// if datavalue(ie, expr) is provided select the tree node accordingly
|
|
113
|
-
// if datavalue === 'FirstNode' -- select the FirstNode at level 0
|
|
114
|
-
// if datavalue === 'LastNode' -- select the LastNode at level 0
|
|
115
|
-
// if datavalue is a bind expression evaluate the expression for each node of the tree till the condition is satisfied.
|
|
116
|
-
// if node identifier is present then verify the datavalue is bound expr or static value and compare with the node model
|
|
117
|
-
if (this.bindnodeid || this.nodeid) {
|
|
118
|
-
isNodeMatched = this.binddatavalue ? nodeIdValue === _evalDataValue : nodeIdValue === _expr;
|
|
119
|
-
if (nodeIdValue !== undefined) {
|
|
120
|
-
$li.attr('id', nodeIdValue);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else if (this.binddatavalue) { // evaluate the expression only if it is bound (useExpression)
|
|
124
|
-
isNodeMatched = !!$parseExpr(_expr)(this, node);
|
|
125
|
-
}
|
|
126
|
-
// Perform LastNode check only at level 0.(ie, deep = 0);
|
|
127
|
-
if (!this._selectNode) {
|
|
128
|
-
if ((_expr === 'FirstNode' && idx === 0)
|
|
129
|
-
|| (!deep && _expr === 'LastNode' && idx === nodes.length - 1)
|
|
130
|
-
|| isNodeMatched) {
|
|
131
|
-
// save a reference of the node to be selected in `_selectNode`
|
|
132
|
-
this._selectNode = $li;
|
|
133
|
-
this.datavalue = nodeIdValue;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (nodeIcon) {
|
|
137
|
-
$iconNode.addClass(nodeIcon);
|
|
138
|
-
}
|
|
139
|
-
if (nodeChildren && nodeChildren.length) { // parent node
|
|
140
|
-
$li.addClass(`parent-node ${_cls}`);
|
|
141
|
-
expandCollapseIcon = $(`<i class="wi ${_iconCls}"></i>`);
|
|
142
|
-
if (nodeIcon) {
|
|
143
|
-
$iconNode.addClass(nodeIcon);
|
|
144
|
-
}
|
|
145
|
-
$li.prepend(expandCollapseIcon);
|
|
146
|
-
this.constructNodes(nodeChildren, $li, levels - 1, deep + 1, _evalDataValue);
|
|
81
|
+
// expands the tree nodes if the property is selected.
|
|
82
|
+
expandTree(level, node, childLevel) {
|
|
83
|
+
node.map(childNode => {
|
|
84
|
+
if ("children" in childNode && !("open" in childNode) && childLevel < level) {
|
|
85
|
+
childNode["open"] = true;
|
|
86
|
+
this.expandTree(level, childNode.children, childLevel + 1);
|
|
147
87
|
}
|
|
148
88
|
else {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
$li.addClass('leaf-node');
|
|
89
|
+
childLevel = 0;
|
|
90
|
+
return;
|
|
153
91
|
}
|
|
154
92
|
});
|
|
155
93
|
}
|
|
94
|
+
// sets the template for the tree based on the property selected.
|
|
95
|
+
setTreeTemplate(value) {
|
|
96
|
+
if (value === 'Classic') {
|
|
97
|
+
this.setting.check["enable"] = false;
|
|
98
|
+
}
|
|
99
|
+
else if (value === 'Checkbox') {
|
|
100
|
+
this.setting.check["enable"] = true;
|
|
101
|
+
this.setting.check["chkStyle"] = 'checkbox';
|
|
102
|
+
}
|
|
103
|
+
else if (value === 'Radio') {
|
|
104
|
+
this.setting.check["enable"] = true;
|
|
105
|
+
this.setting.check["chkStyle"] = 'radio';
|
|
106
|
+
this.setting.check["radioType"] = "all";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// extracts nodes from string format
|
|
156
110
|
getNodesFromString(value) {
|
|
157
111
|
return value.split(',').map((item) => {
|
|
158
112
|
return {
|
|
159
|
-
'
|
|
113
|
+
'name': item && item.trim()
|
|
160
114
|
};
|
|
161
115
|
});
|
|
162
116
|
}
|
|
117
|
+
// gets the nodes and orders the nodes if required
|
|
163
118
|
getNodes(newVal) {
|
|
164
119
|
let nodes;
|
|
165
|
-
if (_.
|
|
120
|
+
if (_.isArray(newVal)) {
|
|
121
|
+
nodes = getOrderedDataset(newVal, this.orderby);
|
|
122
|
+
}
|
|
123
|
+
else if (_.isObject(newVal)) {
|
|
124
|
+
nodes = [newVal];
|
|
125
|
+
}
|
|
126
|
+
else if (_.isString(newVal) && !_.isEmpty(newVal)) {
|
|
166
127
|
newVal = newVal.trim();
|
|
167
128
|
if (newVal) {
|
|
168
129
|
nodes = this.getNodesFromString(newVal);
|
|
169
130
|
}
|
|
170
131
|
}
|
|
171
|
-
else if (_.isArray(newVal)) {
|
|
172
|
-
newVal = getOrderedDataset(newVal, this.orderby);
|
|
173
|
-
nodes = newVal;
|
|
174
|
-
}
|
|
175
|
-
else if (_.isObject(newVal)) {
|
|
176
|
-
nodes = [newVal];
|
|
177
|
-
}
|
|
178
132
|
return nodes;
|
|
179
133
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
ov = ov || defaultTreeIconClass;
|
|
184
|
-
$el.find('i.expanded').removeClass(ICON_CLASSES[ov].expanded).addClass(ICON_CLASSES[nv].expanded);
|
|
185
|
-
$el.find('i.collapsed').removeClass(ICON_CLASSES[ov].collapsed).addClass(ICON_CLASSES[nv].collapsed);
|
|
134
|
+
// adds class to the nodes inorder to add icons to respective node.
|
|
135
|
+
setNodeclasses(treeId, treeNode) {
|
|
136
|
+
return treeNode.icon ? { add: [`${treeNode.icon}`] } : '';
|
|
186
137
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.invokeEventCallback('expand', eventParams);
|
|
138
|
+
;
|
|
139
|
+
// Sets the node label with any icon if bound to
|
|
140
|
+
setNodeData(nodes, depth, level, parentNode, type) {
|
|
141
|
+
if (depth === 0) {
|
|
142
|
+
nodes.map(node => {
|
|
143
|
+
if (node.children) {
|
|
144
|
+
this.setNodeData(node.children, depth, level, parentNode, type);
|
|
145
|
+
}
|
|
146
|
+
if (node.icon && this.nodelabel == 'icon') {
|
|
147
|
+
node[type] = node.icon;
|
|
148
|
+
}
|
|
149
|
+
else if (node.name && this.nodelabel == 'name') {
|
|
150
|
+
node[type] = node.name;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
206
156
|
}
|
|
207
|
-
else
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
157
|
+
else {
|
|
158
|
+
nodes.map(node => {
|
|
159
|
+
if (node.children && level > 1) {
|
|
160
|
+
if (depth === level) {
|
|
161
|
+
parentNode = node;
|
|
162
|
+
}
|
|
163
|
+
this.setNodeData(node.children, depth, level - 1, parentNode, type);
|
|
164
|
+
}
|
|
165
|
+
if (level === 1 && (type === "name" ? this.nodelabel.includes("label") || this.nodelabel.includes("name") : this.nodeicon.includes("label") || this.nodeicon.includes("name"))) {
|
|
166
|
+
parentNode[type] = node.name || node.label;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
else if (level === 1 && (node.icon !== undefined) && (type === "name" ? this.nodelabel.includes("icon") : this.nodeicon.includes("icon"))) {
|
|
170
|
+
parentNode[type] = node.icon;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
211
177
|
}
|
|
212
178
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
$
|
|
217
|
-
|
|
218
|
-
|
|
179
|
+
// adds tree icons to the nodes on load of the tree
|
|
180
|
+
changeTreeIcons(nv) {
|
|
181
|
+
let eleClose = $('ul[name="' + this.name + '"] li span.button.switch');
|
|
182
|
+
$(eleClose).map((idx, ele) => {
|
|
183
|
+
$(ele).addClass(nv);
|
|
184
|
+
$(ele).on("click", function (e) {
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
$(ele).addClass(nv);
|
|
187
|
+
}, 0);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
getPath(treeNode, path) {
|
|
192
|
+
if (treeNode.getParentNode() === null) {
|
|
193
|
+
path = "/" + treeNode.name + path;
|
|
219
194
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.constructNodes(this.nodes, $(docFrag), levels, 0, this.datavalue);
|
|
223
|
-
$el.append(docFrag);
|
|
195
|
+
else {
|
|
196
|
+
path = this.getPath(treeNode.getParentNode(), path) + "/" + treeNode.name;
|
|
224
197
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
198
|
+
return path;
|
|
199
|
+
}
|
|
200
|
+
// binds the click event to all nodes to open the child nodes
|
|
201
|
+
onClick(event, treeId, treeNode, clickFlag) {
|
|
202
|
+
var treeObj = $.fn.zTree.getZTreeObj(`${this.name}`);
|
|
203
|
+
let path = this.getPath(treeNode, "");
|
|
204
|
+
const eventParams = {
|
|
205
|
+
'$event': event,
|
|
206
|
+
"$item": treeNode,
|
|
207
|
+
"$path": path
|
|
208
|
+
};
|
|
209
|
+
this.invokeEventCallback('select', eventParams);
|
|
210
|
+
}
|
|
211
|
+
// Adds tree icon classes to child nodes when expanded
|
|
212
|
+
onExpand(event, treeId, treeNode) {
|
|
213
|
+
let self = this;
|
|
214
|
+
let path = this.getPath(treeNode, "");
|
|
215
|
+
const eventParams = {
|
|
216
|
+
'$event': event,
|
|
217
|
+
"$item": treeNode,
|
|
218
|
+
"$path": path
|
|
219
|
+
};
|
|
220
|
+
this.invokeEventCallback('expand', eventParams);
|
|
221
|
+
treeNode.children ? treeNode.children.map((el) => {
|
|
222
|
+
if (el.isParent) {
|
|
223
|
+
let ele = $(`#${el.tId}_switch`);
|
|
224
|
+
$(ele).addClass(self.treeicon || defaultTreeIconClass);
|
|
225
|
+
$(ele).on("click", function (e) {
|
|
226
|
+
setTimeout(() => {
|
|
227
|
+
$(ele).addClass(self.treeicon || defaultTreeIconClass);
|
|
228
|
+
}, 0);
|
|
229
|
+
});
|
|
232
230
|
}
|
|
233
|
-
|
|
234
|
-
.each((i, el) => {
|
|
235
|
-
const $current = $(el), $i = $current.children('i.collapsed'), $title = $current.children('.title');
|
|
236
|
-
this.toggleExpandCollapseNode(undefined, $i, $current);
|
|
237
|
-
path = `/${$title.text() + path}`;
|
|
238
|
-
});
|
|
239
|
-
this.selecteditem = getClonedObject(data) || {};
|
|
240
|
-
this.selecteditem.path = path;
|
|
241
|
-
this.invokeEventCallback('select', { $event: undefined, $item: data, $path: path });
|
|
242
|
-
$appDigest();
|
|
243
|
-
}
|
|
231
|
+
}) : '';
|
|
244
232
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const current = $(el).children('.title').text();
|
|
261
|
-
path = `/${current + path}`;
|
|
262
|
-
});
|
|
263
|
-
// expand the current node till the viewParent level which is collapsed
|
|
264
|
-
$li.parentsUntil($el, 'li.parent-node.collapsed')
|
|
265
|
-
.each((index, el) => {
|
|
266
|
-
const $current = $(el), $i = $current.children('i.collapsed');
|
|
267
|
-
this.toggleExpandCollapseNode(undefined, $i, $current);
|
|
268
|
-
});
|
|
269
|
-
this.selecteditem = getClonedObject(data) || {};
|
|
270
|
-
this.selecteditem.path = path;
|
|
271
|
-
if (target) {
|
|
272
|
-
if (this.nodeid || this.bindnodeid) {
|
|
273
|
-
this.datavalue = getEvaluatedData(data, { field: this.nodeid, bindExpression: this.bindnodeid }, this.viewParent);
|
|
233
|
+
onCollapse(event, treeId, treeNode) {
|
|
234
|
+
let path = this.getPath(treeNode, "");
|
|
235
|
+
const eventParams = {
|
|
236
|
+
'$event': event,
|
|
237
|
+
"$item": treeNode,
|
|
238
|
+
"$path": path
|
|
239
|
+
};
|
|
240
|
+
this.invokeEventCallback('collapse', eventParams);
|
|
241
|
+
}
|
|
242
|
+
// function to support backward compatibility of objects
|
|
243
|
+
modifyObjects(array) {
|
|
244
|
+
array.forEach(obj => {
|
|
245
|
+
if (obj.label !== undefined) {
|
|
246
|
+
obj.name = obj.label;
|
|
247
|
+
delete obj.label;
|
|
274
248
|
}
|
|
275
|
-
|
|
276
|
-
this.
|
|
249
|
+
if (obj.children !== undefined) {
|
|
250
|
+
this.modifyObjects(obj.children);
|
|
277
251
|
}
|
|
252
|
+
});
|
|
253
|
+
return array;
|
|
254
|
+
}
|
|
255
|
+
// sets the node children property to parent nodes
|
|
256
|
+
setNodeChildren(nodes, depth, level, parentNode) {
|
|
257
|
+
if (depth <= 0) {
|
|
258
|
+
return nodes;
|
|
278
259
|
}
|
|
279
|
-
|
|
280
|
-
|
|
260
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
261
|
+
const node = nodes[i];
|
|
262
|
+
if (depth === level) {
|
|
263
|
+
parentNode = nodes[i];
|
|
264
|
+
}
|
|
265
|
+
if (node.children && node.children.length > 0) {
|
|
266
|
+
if (level === 1) {
|
|
267
|
+
parentNode.children = node.children.map(child => ({ name: child.name, children: child === null || child === void 0 ? void 0 : child.children }));
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
this.setNodeChildren(node.children, depth, level - 1, parentNode);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
281
274
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
return nodes;
|
|
276
|
+
}
|
|
277
|
+
countDepth(str) {
|
|
278
|
+
const regex = /\[.*?\]/g;
|
|
279
|
+
let matches = str.match(regex);
|
|
280
|
+
let count = 1;
|
|
281
|
+
if (matches === null)
|
|
282
|
+
return count;
|
|
283
|
+
for (let match of matches) {
|
|
284
|
+
count++;
|
|
285
285
|
}
|
|
286
|
-
|
|
287
|
-
$appDigest();
|
|
286
|
+
return count;
|
|
288
287
|
}
|
|
289
|
-
//
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
288
|
+
// Renders the tree on to the dom
|
|
289
|
+
renderTree() {
|
|
290
|
+
console.log(this.nodes, 'this.nodes');
|
|
291
|
+
if (this.nodes) {
|
|
292
|
+
this.nativeElement.setAttribute('id', this.name);
|
|
293
|
+
this.nodes = this.modifyObjects(this.nodes);
|
|
294
|
+
this.setTreeTemplate(this.treeClass);
|
|
295
|
+
if (this.nodelabel) {
|
|
296
|
+
let depth = 0;
|
|
297
|
+
if (this.nodelabel.includes("children")) {
|
|
298
|
+
depth = this.countDepth(this.nodelabel);
|
|
299
|
+
}
|
|
300
|
+
this.setNodeData(this.nodes, depth, depth, null, "name");
|
|
297
301
|
}
|
|
298
|
-
if (
|
|
299
|
-
|
|
302
|
+
if (this.nodeicon) {
|
|
303
|
+
let depth = 0;
|
|
304
|
+
if (this.nodeicon.includes("children")) {
|
|
305
|
+
depth = this.countDepth(this.nodeicon);
|
|
306
|
+
}
|
|
307
|
+
this.setNodeData(this.nodes, depth, depth, null, "icon");
|
|
300
308
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
if (this.nodechildren) {
|
|
310
|
+
let depth = this.countDepth(this.nodechildren);
|
|
311
|
+
if (depth > 1) {
|
|
312
|
+
this.nodes = this.setNodeChildren(this.nodes, depth, depth, null);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
this.setting.view['nodeClasses'] = this.setNodeclasses;
|
|
317
|
+
this.setting.callback["onClick"] = this.onClick.bind(this);
|
|
318
|
+
this.setting.callback["onExpand"] = this.onExpand.bind(this);
|
|
319
|
+
this.setting.callback["onCollapse"] = this.onCollapse.bind(this);
|
|
320
|
+
let zTree = $.fn.zTree.init($('ul[name="' + this.name + '"]'), this.setting, this.nodes);
|
|
321
|
+
$.fn.zTreeKeyboardNavigation(zTree, $('ul[name="' + this.name + '"]'), null, this.treeicon || defaultTreeIconClass);
|
|
308
322
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
323
|
+
ngAfterViewInit() {
|
|
324
|
+
setTimeout(() => {
|
|
325
|
+
this.changeTreeIcons(this.treeicon || defaultTreeIconClass);
|
|
326
|
+
}, 200);
|
|
312
327
|
}
|
|
313
328
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
{ type:
|
|
317
|
-
selector: '
|
|
329
|
+
TreeComponent.initializeProps = registerProps();
|
|
330
|
+
TreeComponent.decorators = [
|
|
331
|
+
{ type: Component, args: [{
|
|
332
|
+
selector: 'ul[wmTree]',
|
|
333
|
+
template: "<ul #wmTree class=\"ztree\" id=\"ztree\"></ul> ",
|
|
318
334
|
providers: [
|
|
319
|
-
provideAsWidgetRef(
|
|
320
|
-
]
|
|
335
|
+
provideAsWidgetRef(TreeComponent)
|
|
336
|
+
],
|
|
337
|
+
encapsulation: ViewEncapsulation.None
|
|
321
338
|
},] }
|
|
322
339
|
];
|
|
323
|
-
|
|
324
|
-
{ type: Injector }
|
|
325
|
-
{ type: undefined, decorators: [{ type: Attribute, args: ['datavalue.bind',] }] },
|
|
326
|
-
{ type: undefined, decorators: [{ type: Attribute, args: ['nodelabel.bind',] }] },
|
|
327
|
-
{ type: undefined, decorators: [{ type: Attribute, args: ['nodeicon.bind',] }] },
|
|
328
|
-
{ type: undefined, decorators: [{ type: Attribute, args: ['nodechildren.bind',] }] },
|
|
329
|
-
{ type: undefined, decorators: [{ type: Attribute, args: ['nodeid.bind',] }] }
|
|
340
|
+
TreeComponent.ctorParameters = () => [
|
|
341
|
+
{ type: Injector }
|
|
330
342
|
];
|
|
331
343
|
|
|
332
344
|
const components = [
|
|
333
|
-
|
|
345
|
+
TreeComponent
|
|
334
346
|
];
|
|
335
347
|
class TreeModule {
|
|
336
348
|
}
|
|
@@ -350,5 +362,5 @@ TreeModule.decorators = [
|
|
|
350
362
|
* Generated bundle index. Do not edit.
|
|
351
363
|
*/
|
|
352
364
|
|
|
353
|
-
export {
|
|
365
|
+
export { TreeComponent, TreeModule, registerProps as ɵa };
|
|
354
366
|
//# sourceMappingURL=index.js.map
|