Skip to content

Commit

Permalink
#63 & #64 fix the drag and drop bug in the workspace directory (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcheng15 authored Jan 6, 2022
1 parent 84b0387 commit 3f859d3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/page/Workspace/Wrapper/WorkspaceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</el-dropdown>
</div>
<div class="notebook-list-tree" @scroll="scrollTree">
<el-tree
<el-tree
ref="notebookTree"
:data="renderList"
show-overflow-tooltip
Expand Down Expand Up @@ -194,7 +194,7 @@ export default class WorkspaceList extends Vue {
if (item.data.id) {
this.$emit('changeActiveTab', this.getNotebookItem(item))
}
}
}
handleWorkspace (command, node) {
this[command](node)
Expand Down Expand Up @@ -262,7 +262,7 @@ export default class WorkspaceList extends Vue {
}
}
getMoveTip (target_folder_name, move_name, type) {
const titleType = type === 'notebook' ? this.$t('notebook') : this.$t('folder')
const titleType = type === 'notebook' ? this.$t('workspace.notebook') : this.$t('workspace.folder')
const titleText = titleType.toLowerCase()
const notebookText = target_folder_name === '' ? this.$t('notebook.moveTipText2', { type: titleText }) : this.$t('notebook.moveTipText1', { type: titleText, folderName: target_folder_name })
const folderText = target_folder_name === '' ? this.$t('notebook.moveFolderTipText2', { type: titleText }) : this.$t('notebook.moveFolderTipText1', { type: titleText, folderName: target_folder_name })
Expand Down Expand Up @@ -308,12 +308,13 @@ export default class WorkspaceList extends Vue {
let targetFolder = ''
let targetFolderChildren = []
if (dropType === 'inner') {
targetFolder = dropNode.data || dropNode.parent.data
targetFolder = dropNode.data.type === 'folder' ? dropNode.data : dropNode.parent.data
targetFolderChildren = dropNode.data.children
} else {
targetFolder = Array.isArray(dropNode.parent.data) ? '' : dropNode.parent.data
targetFolder = dropNode.parent.data
targetFolderChildren = Array.isArray(dropNode.parent.data) ? dropNode.parent.data : dropNode.parent.data.children
}
targetFolder = Array.isArray(targetFolder) ? '' : targetFolder
const { name, type } = draggingNode.data
let hasExsited = targetFolderChildren.filter(v => v.id && (v.name === name && v.type === type)).length > 1
const notebookId = draggingNode.data.id
Expand All @@ -337,12 +338,13 @@ export default class WorkspaceList extends Vue {
let targetFolder = ''
let targetFolderChildren = []
if (dropType === 'inner') {
targetFolder = dropNode.data || dropNode.parent.data
targetFolder = dropNode.data.type === 'folder' ? dropNode.data : dropNode.parent.data
targetFolderChildren = dropNode.data.children
} else {
targetFolder = Array.isArray(dropNode.parent.data) ? '' : dropNode.parent.data
targetFolder = dropNode.parent.data
targetFolderChildren = Array.isArray(dropNode.parent.data) ? dropNode.parent.data : dropNode.parent.data.children
}
targetFolder = Array.isArray(targetFolder) ? '' : targetFolder
let hasExsited = targetFolderChildren.filter(v => v.folder_id && (v.name === draggingNode.data.name)).length > 1
const currentFolderId = draggingNode.data.folder_id
const currentParentFolder = this.findParentFolder(currentFolderId, this.originalList, 'folder')
Expand Down Expand Up @@ -386,7 +388,7 @@ export default class WorkspaceList extends Vue {
allowDrag () {
return true
}
}
}
</script>
<style lang="scss">
@import '../../../assets/css/variable.scss';
Expand Down Expand Up @@ -454,4 +456,4 @@ export default class WorkspaceList extends Vue {
}
}
}
</style>
</style>

0 comments on commit 3f859d3

Please sign in to comment.