@ng-nest/ui 15.0.15 → 15.0.16
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.
|
@@ -781,7 +781,7 @@ class XTreeComponent extends XTreeProperty {
|
|
|
781
781
|
insertNode(dragNode, hoverNode, dragPosition) {
|
|
782
782
|
let parent = this.nodes.find((x) => x.id === dragNode.pid);
|
|
783
783
|
this.treeService.moveNode(this.treeData, dragNode, hoverNode, dragPosition);
|
|
784
|
-
this.setDataChange(this.treeData, true, false, parent);
|
|
784
|
+
this.setDataChange(this.treeData, true, false, true, parent);
|
|
785
785
|
}
|
|
786
786
|
cdkDragMoved(event) {
|
|
787
787
|
if (!this.dragging || !this.hoverTreeNode)
|
|
@@ -823,14 +823,14 @@ class XTreeComponent extends XTreeProperty {
|
|
|
823
823
|
this.setDataChange(x);
|
|
824
824
|
});
|
|
825
825
|
}
|
|
826
|
-
setDataChange(value, regetChildren = false, init = true, lazyParant) {
|
|
826
|
+
setDataChange(value, regetChildren = false, init = true, parentOpen = true, lazyParant) {
|
|
827
827
|
if (XIsEmpty(this.checked))
|
|
828
828
|
this.checked = [];
|
|
829
829
|
const getChildren = (node, level) => {
|
|
830
830
|
var _a, _b;
|
|
831
831
|
if (init) {
|
|
832
832
|
node.level = level;
|
|
833
|
-
node.open = Boolean(this.expandedAll) || level <= this.expandedLevel || this.expanded.indexOf(node.id) >= 0 || node.open;
|
|
833
|
+
node.open = Boolean(this.expandedAll) || level <= Number(this.expandedLevel) || this.expanded.indexOf(node.id) >= 0 || node.open;
|
|
834
834
|
node.checked = this.checked.indexOf(node.id) >= 0;
|
|
835
835
|
node.childrenLoaded = node.open;
|
|
836
836
|
}
|
|
@@ -852,9 +852,11 @@ class XTreeComponent extends XTreeProperty {
|
|
|
852
852
|
};
|
|
853
853
|
this.treeData = value;
|
|
854
854
|
this.nodes = value.filter((x) => XIsEmpty(x.pid)).map((x) => getChildren(x, 0));
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
855
|
+
if (parentOpen) {
|
|
856
|
+
for (let item of value) {
|
|
857
|
+
if (!item.leaf && item.open) {
|
|
858
|
+
this.setParentOpen(value, item);
|
|
859
|
+
}
|
|
858
860
|
}
|
|
859
861
|
}
|
|
860
862
|
this.setExpanded();
|
|
@@ -1038,7 +1040,7 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1038
1040
|
}
|
|
1039
1041
|
}
|
|
1040
1042
|
}
|
|
1041
|
-
setActivatedNode(nodes) {
|
|
1043
|
+
setActivatedNode(nodes, parentOpen = true, dataChange = true) {
|
|
1042
1044
|
if (XIsEmpty(this.activatedId) && this.multiple) {
|
|
1043
1045
|
this.activatedId = [];
|
|
1044
1046
|
}
|
|
@@ -1049,7 +1051,7 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1049
1051
|
for (let i = 0; i < ids.length; i++) {
|
|
1050
1052
|
let node = nodes.find((x) => x.id === ids[i]);
|
|
1051
1053
|
if (node) {
|
|
1052
|
-
this.setParentOpen(nodes, node);
|
|
1054
|
+
parentOpen && this.setParentOpen(nodes, node);
|
|
1053
1055
|
if (i === ids.length - 1) {
|
|
1054
1056
|
this.activatedNode = node;
|
|
1055
1057
|
this.activatedChange.emit(this.activatedNode);
|
|
@@ -1062,15 +1064,15 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1062
1064
|
let activatedId = this.activatedId;
|
|
1063
1065
|
this.activatedNode = nodes.find((x) => x.id == activatedId);
|
|
1064
1066
|
if (this.activatedNode) {
|
|
1065
|
-
this.setParentOpen(nodes, this.activatedNode);
|
|
1067
|
+
parentOpen && this.setParentOpen(nodes, this.activatedNode);
|
|
1066
1068
|
this.activatedChange.emit(this.activatedNode);
|
|
1067
1069
|
}
|
|
1068
1070
|
}
|
|
1069
1071
|
if (before) {
|
|
1070
1072
|
before.change && before.change();
|
|
1071
1073
|
}
|
|
1072
|
-
if (!XIsEmpty(nodes)) {
|
|
1073
|
-
this.setDataChange(nodes);
|
|
1074
|
+
if (!XIsEmpty(nodes) && dataChange) {
|
|
1075
|
+
this.setDataChange(nodes, false, true, parentOpen);
|
|
1074
1076
|
}
|
|
1075
1077
|
}
|
|
1076
1078
|
setParentOpen(nodes, node) {
|
|
@@ -1081,10 +1083,10 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1081
1083
|
if (!XIsEmpty(parent)) {
|
|
1082
1084
|
if (!this.expanded.includes(parent.id)) {
|
|
1083
1085
|
this.expanded = [...this.expanded, parent.id];
|
|
1084
|
-
parent.open = true;
|
|
1085
|
-
parent.change && parent.change();
|
|
1086
|
-
getParent(parent);
|
|
1087
1086
|
}
|
|
1087
|
+
parent.open = true;
|
|
1088
|
+
parent.change && parent.change();
|
|
1089
|
+
getParent(parent);
|
|
1088
1090
|
}
|
|
1089
1091
|
};
|
|
1090
1092
|
getParent(node);
|
|
@@ -1097,10 +1099,10 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1097
1099
|
if (!XIsEmpty(parent)) {
|
|
1098
1100
|
if (!this.expanded.includes(parent.id)) {
|
|
1099
1101
|
this.expanded = [...this.expanded, parent.id];
|
|
1100
|
-
parent.open = true;
|
|
1101
|
-
parent.change && parent.change();
|
|
1102
|
-
getParent(parent);
|
|
1103
1102
|
}
|
|
1103
|
+
parent.open = true;
|
|
1104
|
+
parent.change && parent.change();
|
|
1105
|
+
getParent(parent);
|
|
1104
1106
|
}
|
|
1105
1107
|
};
|
|
1106
1108
|
getParent(node);
|
|
@@ -1142,29 +1144,26 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1142
1144
|
let parent = this.treeData.find((x) => x.id === node.pid);
|
|
1143
1145
|
const _addNode = () => {
|
|
1144
1146
|
if (parent) {
|
|
1145
|
-
|
|
1146
|
-
parent.children = [];
|
|
1147
|
-
this.expanded = [...this.expanded, parent.id];
|
|
1148
|
-
this.setActivatedId(node);
|
|
1149
|
-
node.level = Number(parent.level) + 1;
|
|
1147
|
+
node.level = parent.level + 1;
|
|
1150
1148
|
node.pid = parent.id;
|
|
1151
1149
|
node.leaf = true;
|
|
1152
|
-
this.treeData.push(node);
|
|
1153
|
-
this.setActivatedNode(this.treeData);
|
|
1154
|
-
parent.open = true;
|
|
1155
1150
|
parent.leaf = false;
|
|
1156
|
-
parent.
|
|
1157
|
-
this.
|
|
1158
|
-
this.
|
|
1159
|
-
|
|
1151
|
+
parent.open = true;
|
|
1152
|
+
this.treeData = [...this.treeData, node];
|
|
1153
|
+
this.setParentOpen(this.treeData, node);
|
|
1154
|
+
this.setDataChange(this.treeData, true, false, false);
|
|
1155
|
+
this.setActivatedId(node);
|
|
1156
|
+
this.setActivatedNode(this.nodes, true, false);
|
|
1157
|
+
node.change && node.change();
|
|
1160
1158
|
}
|
|
1161
1159
|
else if (XIsEmpty(node.pid)) {
|
|
1162
|
-
this.setActivatedId(node);
|
|
1163
1160
|
node.level = 0;
|
|
1161
|
+
node.leaf = true;
|
|
1164
1162
|
this.treeData = [...this.treeData, node];
|
|
1165
1163
|
this.nodes = [...this.nodes, node];
|
|
1166
|
-
this.
|
|
1167
|
-
this.
|
|
1164
|
+
this.setActivatedId(node);
|
|
1165
|
+
this.setActivatedNode(this.nodes, true, false);
|
|
1166
|
+
node.change && node.change();
|
|
1168
1167
|
}
|
|
1169
1168
|
};
|
|
1170
1169
|
if (this.lazy && parent && !parent.childrenLoaded) {
|
|
@@ -1192,36 +1191,25 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1192
1191
|
}
|
|
1193
1192
|
removeNode(node) {
|
|
1194
1193
|
let parent = this.treeData.find((x) => x.id === node.pid);
|
|
1194
|
+
const removeChildren = (nd) => {
|
|
1195
|
+
XRemove(this.treeData, (x) => x.id === nd.id);
|
|
1196
|
+
if (nd.children) {
|
|
1197
|
+
for (let item of nd.children) {
|
|
1198
|
+
removeChildren(item);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
removeChildren(node);
|
|
1195
1203
|
if (parent) {
|
|
1196
1204
|
if (!parent.children)
|
|
1197
1205
|
parent.children = [];
|
|
1198
|
-
parent.children.
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
this.setActivatedId(parent);
|
|
1202
|
-
}
|
|
1203
|
-
let index = this.nodes.indexOf(node);
|
|
1204
|
-
let aindex = index - 1;
|
|
1205
|
-
if (index === 0 && this.nodes.length > 1) {
|
|
1206
|
-
aindex = 1;
|
|
1206
|
+
const childIndex = parent.children.findIndex((x) => x.id === node.id);
|
|
1207
|
+
if (childIndex > -1) {
|
|
1208
|
+
parent.children.splice(childIndex, 1);
|
|
1207
1209
|
}
|
|
1208
|
-
|
|
1209
|
-
this.setActivatedId(activatedNode);
|
|
1210
|
-
this.setActivatedNode(this.nodes);
|
|
1211
|
-
this.nodes.splice(index, 1);
|
|
1212
|
-
this.nodes = [...this.nodes];
|
|
1213
|
-
if (activatedNode) {
|
|
1214
|
-
activatedNode.change && activatedNode.change();
|
|
1215
|
-
}
|
|
1216
|
-
this.cdr.detectChanges();
|
|
1217
|
-
parent.change && parent.change();
|
|
1218
|
-
}
|
|
1219
|
-
else if (XIsEmpty(node.pid)) {
|
|
1220
|
-
this.treeData.splice(this.treeData.indexOf(node), 1);
|
|
1221
|
-
this.nodes.splice(this.nodes.indexOf(node), 1);
|
|
1222
|
-
this.nodes = [...this.nodes];
|
|
1223
|
-
this.cdr.detectChanges();
|
|
1210
|
+
parent.leaf = parent.children.length === 0;
|
|
1224
1211
|
}
|
|
1212
|
+
this.setDataChange(this.treeData, true, false, false);
|
|
1225
1213
|
}
|
|
1226
1214
|
updateNode(node, nowNode) {
|
|
1227
1215
|
Object.assign(node, nowNode);
|