mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-13 15:05:30 +00:00
optimization code
This commit is contained in:
parent
ee9b319fb8
commit
f2ba1f3d77
@ -112,7 +112,6 @@ class CopyDirent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy the dirent to it's child. eg: A/B -> A/B/C
|
// copy the dirent to it's child. eg: A/B -> A/B/C
|
||||||
//find problem eg ABC can't move AB/ABC and A can't move B/AB
|
|
||||||
if ( selectedPath && selectedPath.length > direntPath.length && selectedPath.indexOf(direntPath) > -1) {
|
if ( selectedPath && selectedPath.length > direntPath.length && selectedPath.indexOf(direntPath) > -1) {
|
||||||
message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s');
|
message = gettext('Can not copy directory %(src)s to its subdirectory %(des)s');
|
||||||
message = message.replace('%(src)s', direntPath);
|
message = message.replace('%(src)s', direntPath);
|
||||||
|
@ -136,21 +136,10 @@ class TreeView extends React.Component {
|
|||||||
if (dropNodeData.parentNode.path !== nodeParentPath) {
|
if (dropNodeData.parentNode.path !== nodeParentPath) {
|
||||||
let dropNodeDataArr = dropNodeData.path.split('/');
|
let dropNodeDataArr = dropNodeData.path.split('/');
|
||||||
let nodeRootPathArr = nodeRootPath.split('/');
|
let nodeRootPathArr = nodeRootPath.split('/');
|
||||||
let isFather = '';
|
let flag = this.compareArray(nodeRootPathArr, dropNodeDataArr);
|
||||||
|
if (flag) {
|
||||||
let smallArr = dropNodeDataArr.length > nodeRootPathArr.length ? nodeRootPathArr : dropNodeDataArr;
|
|
||||||
for (let i = 0; i< smallArr.length; i++) {
|
|
||||||
if (dropNodeDataArr[i] !== nodeRootPathArr[i]) {
|
|
||||||
isFather = smallArr[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isFather.length === 0) {
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
// if (dropNodeData.path.indexOf(nodeRootPath) !== -1) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,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 destDirentPathArr = destDirentPath.split('/');
|
||||||
dragStartNodeData.forEach(dirent => {
|
dragStartNodeData.forEach(dirent => {
|
||||||
let path = dirent.nodeRootPath;
|
let path = dirent.nodeRootPath;
|
||||||
direntPaths.push(path);
|
direntPaths.push(path);
|
||||||
@ -189,10 +178,10 @@ class TreeView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compareArray = (direntPathArr, destDirentPathArr) => {
|
compareArray = (direntPathArr, destDirentPathArr) => {
|
||||||
if (destDirentPathArr.length < direntPathArr.length) { // 往上移
|
if (destDirentPathArr.length < direntPathArr.length) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < direntPathArr.length; i++) { //往下移
|
for (let i = 0; i < direntPathArr.length; i++) {
|
||||||
if (direntPathArr[i] !== destDirentPathArr[i]) {
|
if (direntPathArr[i] !== destDirentPathArr[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user