@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.
|
@@ -771,7 +771,7 @@ class XTreeComponent extends XTreeProperty {
|
|
|
771
771
|
insertNode(dragNode, hoverNode, dragPosition) {
|
|
772
772
|
let parent = this.nodes.find((x) => x.id === dragNode.pid);
|
|
773
773
|
this.treeService.moveNode(this.treeData, dragNode, hoverNode, dragPosition);
|
|
774
|
-
this.setDataChange(this.treeData, true, false, parent);
|
|
774
|
+
this.setDataChange(this.treeData, true, false, true, parent);
|
|
775
775
|
}
|
|
776
776
|
cdkDragMoved(event) {
|
|
777
777
|
if (!this.dragging || !this.hoverTreeNode)
|
|
@@ -813,13 +813,13 @@ class XTreeComponent extends XTreeProperty {
|
|
|
813
813
|
this.setDataChange(x);
|
|
814
814
|
});
|
|
815
815
|
}
|
|
816
|
-
setDataChange(value, regetChildren = false, init = true, lazyParant) {
|
|
816
|
+
setDataChange(value, regetChildren = false, init = true, parentOpen = true, lazyParant) {
|
|
817
817
|
if (XIsEmpty(this.checked))
|
|
818
818
|
this.checked = [];
|
|
819
819
|
const getChildren = (node, level) => {
|
|
820
820
|
if (init) {
|
|
821
821
|
node.level = level;
|
|
822
|
-
node.open = Boolean(this.expandedAll) || level <= this.expandedLevel || this.expanded.indexOf(node.id) >= 0 || node.open;
|
|
822
|
+
node.open = Boolean(this.expandedAll) || level <= Number(this.expandedLevel) || this.expanded.indexOf(node.id) >= 0 || node.open;
|
|
823
823
|
node.checked = this.checked.indexOf(node.id) >= 0;
|
|
824
824
|
node.childrenLoaded = node.open;
|
|
825
825
|
}
|
|
@@ -841,9 +841,11 @@ class XTreeComponent extends XTreeProperty {
|
|
|
841
841
|
};
|
|
842
842
|
this.treeData = value;
|
|
843
843
|
this.nodes = value.filter((x) => XIsEmpty(x.pid)).map((x) => getChildren(x, 0));
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
844
|
+
if (parentOpen) {
|
|
845
|
+
for (let item of value) {
|
|
846
|
+
if (!item.leaf && item.open) {
|
|
847
|
+
this.setParentOpen(value, item);
|
|
848
|
+
}
|
|
847
849
|
}
|
|
848
850
|
}
|
|
849
851
|
this.setExpanded();
|
|
@@ -1027,7 +1029,7 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1027
1029
|
}
|
|
1028
1030
|
}
|
|
1029
1031
|
}
|
|
1030
|
-
setActivatedNode(nodes) {
|
|
1032
|
+
setActivatedNode(nodes, parentOpen = true, dataChange = true) {
|
|
1031
1033
|
if (XIsEmpty(this.activatedId) && this.multiple) {
|
|
1032
1034
|
this.activatedId = [];
|
|
1033
1035
|
}
|
|
@@ -1038,7 +1040,7 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1038
1040
|
for (let i = 0; i < ids.length; i++) {
|
|
1039
1041
|
let node = nodes.find((x) => x.id === ids[i]);
|
|
1040
1042
|
if (node) {
|
|
1041
|
-
this.setParentOpen(nodes, node);
|
|
1043
|
+
parentOpen && this.setParentOpen(nodes, node);
|
|
1042
1044
|
if (i === ids.length - 1) {
|
|
1043
1045
|
this.activatedNode = node;
|
|
1044
1046
|
this.activatedChange.emit(this.activatedNode);
|
|
@@ -1051,15 +1053,15 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1051
1053
|
let activatedId = this.activatedId;
|
|
1052
1054
|
this.activatedNode = nodes.find((x) => x.id == activatedId);
|
|
1053
1055
|
if (this.activatedNode) {
|
|
1054
|
-
this.setParentOpen(nodes, this.activatedNode);
|
|
1056
|
+
parentOpen && this.setParentOpen(nodes, this.activatedNode);
|
|
1055
1057
|
this.activatedChange.emit(this.activatedNode);
|
|
1056
1058
|
}
|
|
1057
1059
|
}
|
|
1058
1060
|
if (before) {
|
|
1059
1061
|
before.change && before.change();
|
|
1060
1062
|
}
|
|
1061
|
-
if (!XIsEmpty(nodes)) {
|
|
1062
|
-
this.setDataChange(nodes);
|
|
1063
|
+
if (!XIsEmpty(nodes) && dataChange) {
|
|
1064
|
+
this.setDataChange(nodes, false, true, parentOpen);
|
|
1063
1065
|
}
|
|
1064
1066
|
}
|
|
1065
1067
|
setParentOpen(nodes, node) {
|
|
@@ -1070,10 +1072,10 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1070
1072
|
if (!XIsEmpty(parent)) {
|
|
1071
1073
|
if (!this.expanded.includes(parent.id)) {
|
|
1072
1074
|
this.expanded = [...this.expanded, parent.id];
|
|
1073
|
-
parent.open = true;
|
|
1074
|
-
parent.change && parent.change();
|
|
1075
|
-
getParent(parent);
|
|
1076
1075
|
}
|
|
1076
|
+
parent.open = true;
|
|
1077
|
+
parent.change && parent.change();
|
|
1078
|
+
getParent(parent);
|
|
1077
1079
|
}
|
|
1078
1080
|
};
|
|
1079
1081
|
getParent(node);
|
|
@@ -1086,10 +1088,10 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1086
1088
|
if (!XIsEmpty(parent)) {
|
|
1087
1089
|
if (!this.expanded.includes(parent.id)) {
|
|
1088
1090
|
this.expanded = [...this.expanded, parent.id];
|
|
1089
|
-
parent.open = true;
|
|
1090
|
-
parent.change && parent.change();
|
|
1091
|
-
getParent(parent);
|
|
1092
1091
|
}
|
|
1092
|
+
parent.open = true;
|
|
1093
|
+
parent.change && parent.change();
|
|
1094
|
+
getParent(parent);
|
|
1093
1095
|
}
|
|
1094
1096
|
};
|
|
1095
1097
|
getParent(node);
|
|
@@ -1131,29 +1133,26 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1131
1133
|
let parent = this.treeData.find((x) => x.id === node.pid);
|
|
1132
1134
|
const _addNode = () => {
|
|
1133
1135
|
if (parent) {
|
|
1134
|
-
|
|
1135
|
-
parent.children = [];
|
|
1136
|
-
this.expanded = [...this.expanded, parent.id];
|
|
1137
|
-
this.setActivatedId(node);
|
|
1138
|
-
node.level = Number(parent.level) + 1;
|
|
1136
|
+
node.level = parent.level + 1;
|
|
1139
1137
|
node.pid = parent.id;
|
|
1140
1138
|
node.leaf = true;
|
|
1141
|
-
this.treeData.push(node);
|
|
1142
|
-
this.setActivatedNode(this.treeData);
|
|
1143
|
-
parent.open = true;
|
|
1144
1139
|
parent.leaf = false;
|
|
1145
|
-
parent.
|
|
1146
|
-
this.
|
|
1147
|
-
this.
|
|
1148
|
-
|
|
1140
|
+
parent.open = true;
|
|
1141
|
+
this.treeData = [...this.treeData, node];
|
|
1142
|
+
this.setParentOpen(this.treeData, node);
|
|
1143
|
+
this.setDataChange(this.treeData, true, false, false);
|
|
1144
|
+
this.setActivatedId(node);
|
|
1145
|
+
this.setActivatedNode(this.nodes, true, false);
|
|
1146
|
+
node.change && node.change();
|
|
1149
1147
|
}
|
|
1150
1148
|
else if (XIsEmpty(node.pid)) {
|
|
1151
|
-
this.setActivatedId(node);
|
|
1152
1149
|
node.level = 0;
|
|
1150
|
+
node.leaf = true;
|
|
1153
1151
|
this.treeData = [...this.treeData, node];
|
|
1154
1152
|
this.nodes = [...this.nodes, node];
|
|
1155
|
-
this.
|
|
1156
|
-
this.
|
|
1153
|
+
this.setActivatedId(node);
|
|
1154
|
+
this.setActivatedNode(this.nodes, true, false);
|
|
1155
|
+
node.change && node.change();
|
|
1157
1156
|
}
|
|
1158
1157
|
};
|
|
1159
1158
|
if (this.lazy && parent && !parent.childrenLoaded) {
|
|
@@ -1181,36 +1180,25 @@ class XTreeComponent extends XTreeProperty {
|
|
|
1181
1180
|
}
|
|
1182
1181
|
removeNode(node) {
|
|
1183
1182
|
let parent = this.treeData.find((x) => x.id === node.pid);
|
|
1183
|
+
const removeChildren = (nd) => {
|
|
1184
|
+
XRemove(this.treeData, (x) => x.id === nd.id);
|
|
1185
|
+
if (nd.children) {
|
|
1186
|
+
for (let item of nd.children) {
|
|
1187
|
+
removeChildren(item);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
removeChildren(node);
|
|
1184
1192
|
if (parent) {
|
|
1185
1193
|
if (!parent.children)
|
|
1186
1194
|
parent.children = [];
|
|
1187
|
-
parent.children.
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
this.setActivatedId(parent);
|
|
1191
|
-
}
|
|
1192
|
-
let index = this.nodes.indexOf(node);
|
|
1193
|
-
let aindex = index - 1;
|
|
1194
|
-
if (index === 0 && this.nodes.length > 1) {
|
|
1195
|
-
aindex = 1;
|
|
1195
|
+
const childIndex = parent.children.findIndex((x) => x.id === node.id);
|
|
1196
|
+
if (childIndex > -1) {
|
|
1197
|
+
parent.children.splice(childIndex, 1);
|
|
1196
1198
|
}
|
|
1197
|
-
|
|
1198
|
-
this.setActivatedId(activatedNode);
|
|
1199
|
-
this.setActivatedNode(this.nodes);
|
|
1200
|
-
this.nodes.splice(index, 1);
|
|
1201
|
-
this.nodes = [...this.nodes];
|
|
1202
|
-
if (activatedNode) {
|
|
1203
|
-
activatedNode.change && activatedNode.change();
|
|
1204
|
-
}
|
|
1205
|
-
this.cdr.detectChanges();
|
|
1206
|
-
parent.change && parent.change();
|
|
1207
|
-
}
|
|
1208
|
-
else if (XIsEmpty(node.pid)) {
|
|
1209
|
-
this.treeData.splice(this.treeData.indexOf(node), 1);
|
|
1210
|
-
this.nodes.splice(this.nodes.indexOf(node), 1);
|
|
1211
|
-
this.nodes = [...this.nodes];
|
|
1212
|
-
this.cdr.detectChanges();
|
|
1199
|
+
parent.leaf = parent.children.length === 0;
|
|
1213
1200
|
}
|
|
1201
|
+
this.setDataChange(this.treeData, true, false, false);
|
|
1214
1202
|
}
|
|
1215
1203
|
updateNode(node, nowNode) {
|
|
1216
1204
|
Object.assign(node, nowNode);
|