mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 17:33:18 +00:00
resolve move to parent bug
This commit is contained in:
@@ -102,7 +102,7 @@ class TreeView extends React.Component {
|
|||||||
this.setState({isTreeViewDropTipShow: false});
|
this.setState({isTreeViewDropTipShow: false});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.onMoveItems(dragStartNodeData, dropNodeData, this.props.currentRepoInfo, node.path);
|
this.onMoveItems(dragStartNodeData, dropNodeData, this.props.currentRepoInfo, dropNodeData.path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ class TreeView extends React.Component {
|
|||||||
|
|
||||||
onMoveItems = (dragStartNodeData, dropNodeData, destRepo, destDirentPath) => {
|
onMoveItems = (dragStartNodeData, dropNodeData, destRepo, destDirentPath) => {
|
||||||
let direntPaths = [];
|
let direntPaths = [];
|
||||||
let destDirentPathArr = destDirentPath.split('/');
|
let destDirentPathDetail = destDirentPath.split('/');
|
||||||
dragStartNodeData.forEach(dirent => {
|
dragStartNodeData.forEach(dirent => {
|
||||||
let path = dirent.nodeRootPath;
|
let path = dirent.nodeRootPath;
|
||||||
direntPaths.push(path);
|
direntPaths.push(path);
|
||||||
@@ -163,11 +163,16 @@ class TreeView extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move dirents to current path
|
||||||
|
if (dragStartNodeData[0].nodeParentPath && dragStartNodeData[0].nodeParentPath === dropNodeData.path ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// move dirents to one of their child. eg: A/B, A/D -> A/B/C
|
// move dirents to one of their child. eg: A/B, A/D -> A/B/C
|
||||||
let isChildPath = direntPaths.some(direntPath => {
|
let isChildPath = direntPaths.some(direntPath => {
|
||||||
let direntPathArr = direntPath.split('/');
|
let direntPathdetail = direntPath.split('/');
|
||||||
|
let flag = this.compareArray(direntPathdetail, destDirentPathDetail);
|
||||||
let flag = this.compareArray(direntPathArr, destDirentPathArr);
|
|
||||||
return flag;
|
return flag;
|
||||||
});
|
});
|
||||||
if (isChildPath) {
|
if (isChildPath) {
|
||||||
@@ -177,12 +182,12 @@ class TreeView extends React.Component {
|
|||||||
this.props.onItemsMove(destRepo, destDirentPath);
|
this.props.onItemsMove(destRepo, destDirentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
compareArray = (direntPathArr, destDirentPathArr) => {
|
compareArray = (direntPathdetail, destDirentPathDetail) => {
|
||||||
if (destDirentPathArr.length < direntPathArr.length) {
|
if (destDirentPathDetail.length < direntPathdetail.length) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < direntPathArr.length; i++) {
|
for (let i = 0; i < direntPathdetail.length; i++) {
|
||||||
if (direntPathArr[i] !== destDirentPathArr[i]) {
|
if (direntPathdetail[i] !== destDirentPathDetail[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user