@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
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Directive, Injector, Attribute, 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, getOrderedDataset, provideAsWidgetRef, WmComponentsModule } from '@wm/components/base';
|
|
3
|
+
import { register, PROP_STRING, PROP_ANY, PROP_NUMBER, PROP_BOOLEAN, StylableComponent, styler, APPLY_STYLES_TYPE, getEvaluatedData, getOrderedDataset, provideAsWidgetRef, WmComponentsModule } from '@wm/components/base';
|
|
4
|
+
import { $parseExpr, getClonedObject, $appDigest, $parseEvent } from '@wm/core';
|
|
4
5
|
|
|
5
6
|
const registerProps = () => {
|
|
6
7
|
register('wm-tree', new Map([
|
|
@@ -22,327 +23,314 @@ const registerProps = () => {
|
|
|
22
23
|
]));
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
|
|
26
26
|
const defaultTreeIconClass = 'plus-minus';
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
const WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
|
|
58
|
+
class TreeDirective extends StylableComponent {
|
|
59
|
+
constructor(inj, binddatavalue, bindnodelabel, bindnodeicon, bindnodechildren, bindnodeid) {
|
|
29
60
|
super(inj, WIDGET_INFO);
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
view: {
|
|
37
|
-
dblClickExpand: false,
|
|
38
|
-
fontCss: {
|
|
39
|
-
'font-awesome': true
|
|
40
|
-
},
|
|
41
|
-
switchIcon: {},
|
|
42
|
-
},
|
|
43
|
-
check: {},
|
|
44
|
-
callback: {}
|
|
45
|
-
};
|
|
61
|
+
this.binddatavalue = binddatavalue;
|
|
62
|
+
this.bindnodelabel = bindnodelabel;
|
|
63
|
+
this.bindnodeicon = bindnodeicon;
|
|
64
|
+
this.bindnodechildren = bindnodechildren;
|
|
65
|
+
this.bindnodeid = bindnodeid;
|
|
46
66
|
styler(this.nativeElement, this, APPLY_STYLES_TYPE.CONTAINER);
|
|
67
|
+
this.bindEvents();
|
|
47
68
|
}
|
|
48
69
|
onPropertyChange(key, nv, ov) {
|
|
49
70
|
switch (key) {
|
|
50
71
|
case 'dataset':
|
|
51
72
|
this.nodes = this.getNodes(nv);
|
|
52
|
-
|
|
53
|
-
this.expandTree(this.level, this.nodes, 0);
|
|
54
|
-
}
|
|
73
|
+
this._selectNode = undefined;
|
|
55
74
|
this.renderTree();
|
|
56
75
|
break;
|
|
57
|
-
case '
|
|
58
|
-
if (nv > 0) {
|
|
59
|
-
this.level = nv;
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
case 'treeicons':
|
|
63
|
-
this.treeicon = nv;
|
|
64
|
-
break;
|
|
76
|
+
case 'nodeicon':
|
|
65
77
|
case 'nodelabel':
|
|
66
|
-
|
|
67
|
-
break;
|
|
68
|
-
case 'icon':
|
|
69
|
-
this.nodeicon = nv;
|
|
78
|
+
case 'nodechildren':
|
|
70
79
|
case 'orderby':
|
|
71
80
|
this.renderTree();
|
|
72
81
|
break;
|
|
73
|
-
case '
|
|
74
|
-
this.
|
|
82
|
+
case 'treeicons':
|
|
83
|
+
this.changeTreeIcons(nv, ov);
|
|
84
|
+
break;
|
|
85
|
+
case 'datavalue':
|
|
86
|
+
this.selectById(nv);
|
|
75
87
|
break;
|
|
76
88
|
default:
|
|
77
89
|
super.onPropertyChange(key, nv, ov);
|
|
78
|
-
break;
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
constructNodes(nodes, parent, levels, deep, _evalDataValue) {
|
|
93
|
+
const $ul = $('<ul></ul>');
|
|
94
|
+
const _iconClses = ICON_CLASSES[this.treeicons || defaultTreeIconClass];
|
|
95
|
+
const _expr = (this.binddatavalue || this.datavalue);
|
|
96
|
+
let _iconCls, _cls;
|
|
97
|
+
_cls = levels > 0 ? ' expanded ' : ' collapsed ';
|
|
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);
|
|
87
147
|
}
|
|
88
148
|
else {
|
|
89
|
-
|
|
90
|
-
|
|
149
|
+
if (!nodeIcon) {
|
|
150
|
+
$iconNode.addClass('leaf-node');
|
|
151
|
+
}
|
|
152
|
+
$li.addClass('leaf-node');
|
|
91
153
|
}
|
|
92
154
|
});
|
|
93
155
|
}
|
|
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
|
|
110
156
|
getNodesFromString(value) {
|
|
111
157
|
return value.split(',').map((item) => {
|
|
112
158
|
return {
|
|
113
|
-
'
|
|
159
|
+
'label': item && item.trim()
|
|
114
160
|
};
|
|
115
161
|
});
|
|
116
162
|
}
|
|
117
|
-
// gets the nodes and orders the nodes if required
|
|
118
163
|
getNodes(newVal) {
|
|
119
164
|
let nodes;
|
|
120
|
-
if (_.
|
|
121
|
-
nodes = getOrderedDataset(newVal, this.orderby);
|
|
122
|
-
}
|
|
123
|
-
else if (_.isObject(newVal)) {
|
|
124
|
-
nodes = [newVal];
|
|
125
|
-
}
|
|
126
|
-
else if (_.isString(newVal) && !_.isEmpty(newVal)) {
|
|
165
|
+
if (_.isString(newVal) && !_.isEmpty(newVal)) {
|
|
127
166
|
newVal = newVal.trim();
|
|
128
167
|
if (newVal) {
|
|
129
168
|
nodes = this.getNodesFromString(newVal);
|
|
130
169
|
}
|
|
131
170
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
setNodeclasses(treeId, treeNode) {
|
|
136
|
-
return treeNode.icon ? { add: [`${treeNode.icon}`] } : '';
|
|
137
|
-
}
|
|
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
|
-
});
|
|
156
|
-
}
|
|
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
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
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;
|
|
171
|
+
else if (_.isArray(newVal)) {
|
|
172
|
+
newVal = getOrderedDataset(newVal, this.orderby);
|
|
173
|
+
nodes = newVal;
|
|
194
174
|
}
|
|
195
|
-
else {
|
|
196
|
-
|
|
175
|
+
else if (_.isObject(newVal)) {
|
|
176
|
+
nodes = [newVal];
|
|
197
177
|
}
|
|
198
|
-
return
|
|
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);
|
|
178
|
+
return nodes;
|
|
210
179
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}) : '';
|
|
180
|
+
changeTreeIcons(nv, ov) {
|
|
181
|
+
const $el = $(this.nativeElement);
|
|
182
|
+
nv = nv || defaultTreeIconClass;
|
|
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);
|
|
232
186
|
}
|
|
233
|
-
|
|
234
|
-
|
|
187
|
+
toggleExpandCollapseNode($event, $i, $li) {
|
|
188
|
+
const treeIcons = ICON_CLASSES[this.treeicons || defaultTreeIconClass];
|
|
189
|
+
const $liPath = this.findSelectedNodeParent($li);
|
|
190
|
+
let path = '';
|
|
191
|
+
// construct the path of the node
|
|
192
|
+
$liPath
|
|
193
|
+
.each((i, el) => {
|
|
194
|
+
const current = $(el).children('.title').text();
|
|
195
|
+
path = `/${current + path}`;
|
|
196
|
+
});
|
|
235
197
|
const eventParams = {
|
|
236
|
-
'$event': event,
|
|
237
|
-
"$item":
|
|
198
|
+
'$event': $event,
|
|
199
|
+
"$item": $li.data('nodedata'),
|
|
238
200
|
"$path": path
|
|
239
201
|
};
|
|
240
|
-
|
|
202
|
+
if ($i.hasClass('collapsed')) {
|
|
203
|
+
$i.removeClass(`collapsed ${treeIcons.collapsed}`).addClass(`expanded ${treeIcons.expanded}`);
|
|
204
|
+
$li.removeClass('collapsed').addClass('expanded');
|
|
205
|
+
this.invokeEventCallback('expand', eventParams);
|
|
206
|
+
}
|
|
207
|
+
else if ($i.hasClass('expanded')) {
|
|
208
|
+
$i.removeClass(`expanded ${treeIcons.expanded}`).addClass(`collapsed ${treeIcons.collapsed}`);
|
|
209
|
+
$li.removeClass('expanded').addClass('collapsed');
|
|
210
|
+
this.invokeEventCallback('collapse', eventParams);
|
|
211
|
+
}
|
|
241
212
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
213
|
+
renderTree(forceRender) {
|
|
214
|
+
let docFrag, $li, $liPath, data, path = '';
|
|
215
|
+
const levels = +this.nativeElement.getAttribute('levels') || 0, $el = $(this.nativeElement);
|
|
216
|
+
$el.empty();
|
|
217
|
+
if (forceRender) {
|
|
218
|
+
this._selectNode = undefined;
|
|
219
|
+
}
|
|
220
|
+
if (this.nodes && this.nodes.length) {
|
|
221
|
+
docFrag = document.createDocumentFragment();
|
|
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;
|
|
251
232
|
}
|
|
252
|
-
|
|
253
|
-
|
|
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}`;
|
|
238
|
+
});
|
|
239
|
+
this.selecteditem = getClonedObject(data) || {};
|
|
240
|
+
this.selecteditem.path = path;
|
|
241
|
+
this.invokeEventCallback('select', { $event: undefined, $item: data, $path: path });
|
|
242
|
+
$appDigest();
|
|
243
|
+
}
|
|
254
244
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
selectNode(evt, value) {
|
|
246
|
+
const target = evt && $(evt.target), $el = $(this.nativeElement), $li = _.isObject(value) ? value : $el.find(`li[id="${value}"]`).first();
|
|
247
|
+
let data, path = '', $liPath, nodeAction;
|
|
248
|
+
$el.find('.selected').removeClass('selected');
|
|
249
|
+
if (!$li.length) {
|
|
250
|
+
return;
|
|
259
251
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
252
|
+
$li.addClass('selected');
|
|
253
|
+
data = $li.data('nodedata');
|
|
254
|
+
nodeAction = data[this.nodeaction || 'action'];
|
|
255
|
+
// if the selectNode is initiated by click event then use the nativeElement target from event
|
|
256
|
+
$liPath = target ? target.parents('.app-tree li') : this.findSelectedNodeParent($li);
|
|
257
|
+
// construct the path of the node
|
|
258
|
+
$liPath
|
|
259
|
+
.each((i, el) => {
|
|
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);
|
|
264
274
|
}
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
}
|
|
275
|
+
else {
|
|
276
|
+
this.datavalue = getClonedObject(data) || {};
|
|
273
277
|
}
|
|
274
278
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
if (matches === null)
|
|
282
|
-
return count;
|
|
283
|
-
for (let match of matches) {
|
|
284
|
-
count++;
|
|
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
285
|
}
|
|
286
|
-
|
|
286
|
+
this.invokeEventCallback('select', { $event: evt, $item: data, $path: path });
|
|
287
|
+
$appDigest();
|
|
287
288
|
}
|
|
288
|
-
//
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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");
|
|
289
|
+
// click event is added on the host nativeElement
|
|
290
|
+
bindEvents() {
|
|
291
|
+
$(this.nativeElement).on('click', (evt) => {
|
|
292
|
+
const target = $(evt.target), li = target.closest('li'), $i = target.is('i') ? target : target.siblings('i.collapsed,i.expanded');
|
|
293
|
+
evt.stopPropagation();
|
|
294
|
+
if (target.is('span.title')) { // select the node only if it is nodelabel
|
|
295
|
+
this.selecteditem = {};
|
|
296
|
+
this.selectNode(evt, li);
|
|
301
297
|
}
|
|
302
|
-
if (this.
|
|
303
|
-
|
|
304
|
-
if (this.nodeicon.includes("children")) {
|
|
305
|
-
depth = this.countDepth(this.nodeicon);
|
|
306
|
-
}
|
|
307
|
-
this.setNodeData(this.nodes, depth, depth, null, "icon");
|
|
308
|
-
}
|
|
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
|
-
}
|
|
298
|
+
if (target.is('i') || (target.is('span.title') && this.nodeclick === 'expand')) {
|
|
299
|
+
this.toggleExpandCollapseNode(evt, $i, li);
|
|
314
300
|
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
findSelectedNodeParent($li) {
|
|
304
|
+
return $li.find('> span.title').parents('.app-tree li');
|
|
322
305
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
306
|
+
selectById(value) {
|
|
307
|
+
this.selectNode(undefined, value);
|
|
308
|
+
}
|
|
309
|
+
deselectById(value) {
|
|
310
|
+
this.selecteditem = {};
|
|
311
|
+
this.selectById();
|
|
327
312
|
}
|
|
328
313
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
{ type:
|
|
332
|
-
selector: '
|
|
333
|
-
template: "<ul #wmTree class=\"ztree\" id=\"ztree\"></ul> ",
|
|
314
|
+
TreeDirective.initializeProps = registerProps();
|
|
315
|
+
TreeDirective.decorators = [
|
|
316
|
+
{ type: Directive, args: [{
|
|
317
|
+
selector: 'div[wmTree]',
|
|
334
318
|
providers: [
|
|
335
|
-
provideAsWidgetRef(
|
|
336
|
-
]
|
|
337
|
-
encapsulation: ViewEncapsulation.None
|
|
319
|
+
provideAsWidgetRef(TreeDirective)
|
|
320
|
+
]
|
|
338
321
|
},] }
|
|
339
322
|
];
|
|
340
|
-
|
|
341
|
-
{ type: Injector }
|
|
323
|
+
TreeDirective.ctorParameters = () => [
|
|
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',] }] }
|
|
342
330
|
];
|
|
343
331
|
|
|
344
332
|
const components = [
|
|
345
|
-
|
|
333
|
+
TreeDirective
|
|
346
334
|
];
|
|
347
335
|
class TreeModule {
|
|
348
336
|
}
|
|
@@ -362,5 +350,5 @@ TreeModule.decorators = [
|
|
|
362
350
|
* Generated bundle index. Do not edit.
|
|
363
351
|
*/
|
|
364
352
|
|
|
365
|
-
export {
|
|
353
|
+
export { TreeDirective, TreeModule, registerProps as ɵa };
|
|
366
354
|
//# sourceMappingURL=index.js.map
|