@wavemaker/app-ng-runtime 11.4.0-next.24577 → 11.4.0-next.24579
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 +5 -7
- 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/fesm2015/index.js +5 -7
- app-ng-runtime/build-task/fesm2015/index.js.map +1 -1
- app-ng-runtime/components/basic/tree/bundles/index.umd.js +271 -255
- 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 +314 -0
- app-ng-runtime/components/basic/tree/esm2015/tree.module.js +3 -3
- app-ng-runtime/components/basic/tree/fesm2015/index.js +251 -247
- 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 +33 -0
- app-ng-runtime/package.json +1 -1
- app-ng-runtime/scripts/tree-keyboard-navigation/keyboard-navigation.js +251 -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,319 @@ 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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.constructNodes(this.nodes, $(docFrag), levels, 0, this.datavalue);
|
|
223
|
-
$el.append(docFrag);
|
|
224
|
-
}
|
|
225
|
-
if (this._selectNode) {
|
|
226
|
-
$li = this._selectNode;
|
|
227
|
-
$li.addClass('selected');
|
|
228
|
-
data = $li.data('nodedata');
|
|
229
|
-
$liPath = this.findSelectedNodeParent($li);
|
|
230
|
-
if (!$liPath.length) {
|
|
231
|
-
$liPath = $li;
|
|
232
|
-
}
|
|
233
|
-
$liPath
|
|
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}`;
|
|
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);
|
|
238
188
|
});
|
|
239
|
-
|
|
240
|
-
this.selecteditem.path = path;
|
|
241
|
-
this.invokeEventCallback('select', { $event: undefined, $item: data, $path: path });
|
|
242
|
-
$appDigest();
|
|
243
|
-
}
|
|
189
|
+
});
|
|
244
190
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
$el.find('.selected').removeClass('selected');
|
|
249
|
-
if (!$li.length) {
|
|
250
|
-
return;
|
|
191
|
+
getPath(treeNode, path) {
|
|
192
|
+
if (treeNode.getParentNode() === null) {
|
|
193
|
+
path = "/" + treeNode.name + path;
|
|
251
194
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (this.nodeid || this.bindnodeid) {
|
|
273
|
-
this.datavalue = getEvaluatedData(data, { field: this.nodeid, bindExpression: this.bindnodeid }, this.viewParent);
|
|
195
|
+
else {
|
|
196
|
+
path = this.getPath(treeNode.getParentNode(), path) + "/" + treeNode.name;
|
|
197
|
+
}
|
|
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
|
+
if (this.nodeclick === 'expand') {
|
|
204
|
+
treeObj.expandNode(treeNode, treeNode.open ? false : true, false, true);
|
|
205
|
+
this.changeTreeIcons(this.treeicon || defaultTreeIconClass);
|
|
206
|
+
let path = this.getPath(treeNode, "");
|
|
207
|
+
const eventParams = {
|
|
208
|
+
'$event': event,
|
|
209
|
+
"$item": treeNode,
|
|
210
|
+
"$path": path
|
|
211
|
+
};
|
|
212
|
+
this.invokeEventCallback('select', eventParams);
|
|
213
|
+
if (treeNode.open) {
|
|
214
|
+
// this.invokeEventCallback('expand', eventParams);
|
|
274
215
|
}
|
|
275
216
|
else {
|
|
276
|
-
this.
|
|
217
|
+
this.invokeEventCallback('collapse', eventParams);
|
|
277
218
|
}
|
|
278
219
|
}
|
|
279
|
-
else {
|
|
280
|
-
this.datavalue = value;
|
|
281
|
-
}
|
|
282
|
-
//[Todo-CSP]: this data will be dynamic, can not generate function upfront
|
|
283
|
-
if (nodeAction) {
|
|
284
|
-
$parseEvent(nodeAction)(this);
|
|
285
|
-
}
|
|
286
|
-
this.invokeEventCallback('select', { $event: evt, $item: data, $path: path });
|
|
287
|
-
$appDigest();
|
|
288
220
|
}
|
|
289
|
-
//
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
221
|
+
// Adds tree icon classes to child nodes when expanded
|
|
222
|
+
onExpand(event, treeId, treeNode) {
|
|
223
|
+
let self = this;
|
|
224
|
+
treeNode.children ? treeNode.children.map((el) => {
|
|
225
|
+
if (el.isParent) {
|
|
226
|
+
let ele = $(`#${el.tId}_switch`);
|
|
227
|
+
$(ele).addClass(self.treeicon || defaultTreeIconClass);
|
|
228
|
+
$(ele).on("click", function (e) {
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
$(ele).addClass(self.treeicon || defaultTreeIconClass);
|
|
231
|
+
}, 0);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}) : '';
|
|
235
|
+
}
|
|
236
|
+
// function to support backward compatibility of objects
|
|
237
|
+
modifyObjects(array) {
|
|
238
|
+
array.forEach(obj => {
|
|
239
|
+
if (obj.label !== undefined) {
|
|
240
|
+
obj.name = obj.label;
|
|
241
|
+
delete obj.label;
|
|
297
242
|
}
|
|
298
|
-
if (
|
|
299
|
-
this.
|
|
243
|
+
if (obj.children !== undefined) {
|
|
244
|
+
this.modifyObjects(obj.children);
|
|
300
245
|
}
|
|
301
246
|
});
|
|
247
|
+
return array;
|
|
248
|
+
}
|
|
249
|
+
// sets the node children property to parent nodes
|
|
250
|
+
setNodeChildren(nodes, depth, level, parentNode) {
|
|
251
|
+
if (depth <= 0) {
|
|
252
|
+
return nodes;
|
|
253
|
+
}
|
|
254
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
255
|
+
const node = nodes[i];
|
|
256
|
+
if (depth === level) {
|
|
257
|
+
parentNode = nodes[i];
|
|
258
|
+
}
|
|
259
|
+
if (node.children && node.children.length > 0) {
|
|
260
|
+
if (level === 1) {
|
|
261
|
+
parentNode.children = node.children.map(child => ({ name: child.name, children: child === null || child === void 0 ? void 0 : child.children }));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this.setNodeChildren(node.children, depth, level - 1, parentNode);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return nodes;
|
|
302
270
|
}
|
|
303
|
-
|
|
304
|
-
|
|
271
|
+
countDepth(str) {
|
|
272
|
+
const regex = /\[.*?\]/g;
|
|
273
|
+
let matches = str.match(regex);
|
|
274
|
+
let count = 1;
|
|
275
|
+
if (matches === null)
|
|
276
|
+
return count;
|
|
277
|
+
for (let match of matches) {
|
|
278
|
+
count++;
|
|
279
|
+
}
|
|
280
|
+
return count;
|
|
305
281
|
}
|
|
306
|
-
|
|
307
|
-
|
|
282
|
+
// Renders the tree on to the dom
|
|
283
|
+
renderTree() {
|
|
284
|
+
if (this.nodes) {
|
|
285
|
+
this.nativeElement.setAttribute('id', this.name);
|
|
286
|
+
this.nodes = this.modifyObjects(this.nodes);
|
|
287
|
+
this.setTreeTemplate(this.treeClass);
|
|
288
|
+
if (this.nodelabel) {
|
|
289
|
+
let depth = 0;
|
|
290
|
+
if (this.nodelabel.includes("children")) {
|
|
291
|
+
depth = this.countDepth(this.nodelabel);
|
|
292
|
+
}
|
|
293
|
+
this.setNodeData(this.nodes, depth, depth, null, "name");
|
|
294
|
+
}
|
|
295
|
+
if (this.nodeicon) {
|
|
296
|
+
let depth = 0;
|
|
297
|
+
if (this.nodeicon.includes("children")) {
|
|
298
|
+
depth = this.countDepth(this.nodeicon);
|
|
299
|
+
}
|
|
300
|
+
this.setNodeData(this.nodes, depth, depth, null, "icon");
|
|
301
|
+
}
|
|
302
|
+
if (this.nodechildren) {
|
|
303
|
+
let depth = this.countDepth(this.nodechildren);
|
|
304
|
+
if (depth > 1) {
|
|
305
|
+
this.nodes = this.setNodeChildren(this.nodes, depth, depth, null);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
this.setting.view['nodeClasses'] = this.setNodeclasses;
|
|
310
|
+
this.setting.callback["onClick"] = this.onClick.bind(this);
|
|
311
|
+
this.setting.callback["onExpand"] = this.onExpand.bind(this);
|
|
312
|
+
let zTree = $.fn.zTree.init($('ul[name="' + this.name + '"]'), this.setting, this.nodes);
|
|
313
|
+
$.fn.zTreeKeyboardNavigation(zTree, $('ul[name="' + this.name + '"]'), null, this.treeicon || defaultTreeIconClass);
|
|
308
314
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
315
|
+
ngAfterViewInit() {
|
|
316
|
+
setTimeout(() => {
|
|
317
|
+
this.changeTreeIcons(this.treeicon || defaultTreeIconClass);
|
|
318
|
+
}, 200);
|
|
312
319
|
}
|
|
313
320
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
{ type:
|
|
317
|
-
selector: '
|
|
321
|
+
TreeComponent.initializeProps = registerProps();
|
|
322
|
+
TreeComponent.decorators = [
|
|
323
|
+
{ type: Component, args: [{
|
|
324
|
+
selector: 'ul[wmTree]',
|
|
325
|
+
template: "<ul #wmTree class=\"ztree\" id=\"ztree\"></ul> ",
|
|
318
326
|
providers: [
|
|
319
|
-
provideAsWidgetRef(
|
|
320
|
-
]
|
|
327
|
+
provideAsWidgetRef(TreeComponent)
|
|
328
|
+
],
|
|
329
|
+
encapsulation: ViewEncapsulation.None
|
|
321
330
|
},] }
|
|
322
331
|
];
|
|
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',] }] }
|
|
332
|
+
TreeComponent.ctorParameters = () => [
|
|
333
|
+
{ type: Injector }
|
|
330
334
|
];
|
|
331
335
|
|
|
332
336
|
const components = [
|
|
333
|
-
|
|
337
|
+
TreeComponent
|
|
334
338
|
];
|
|
335
339
|
class TreeModule {
|
|
336
340
|
}
|
|
@@ -350,5 +354,5 @@ TreeModule.decorators = [
|
|
|
350
354
|
* Generated bundle index. Do not edit.
|
|
351
355
|
*/
|
|
352
356
|
|
|
353
|
-
export {
|
|
357
|
+
export { TreeComponent, TreeModule, registerProps as ɵa };
|
|
354
358
|
//# sourceMappingURL=index.js.map
|