✨ Site > File Tree > Add folder toggle
This commit is contained in:
@@ -49,25 +49,21 @@ export default
|
|||||||
|
|
||||||
this.projectSocket.on('update_project', (data) =>
|
this.projectSocket.on('update_project', (data) =>
|
||||||
{
|
{
|
||||||
// console.log('update_project', data)
|
|
||||||
this.$store.commit('updateFiles', data.files.items)
|
this.$store.commit('updateFiles', data.files.items)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.projectSocket.on('create_file', (data) =>
|
this.projectSocket.on('create_file', (data) =>
|
||||||
{
|
{
|
||||||
// console.log('create_file', data)
|
|
||||||
this.$store.commit('createFile', data)
|
this.$store.commit('createFile', data)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.projectSocket.on('delete_file', (data) =>
|
this.projectSocket.on('delete_file', (data) =>
|
||||||
{
|
{
|
||||||
// console.log('delete_file', data)
|
|
||||||
this.$store.commit('deleteFile', data)
|
this.$store.commit('deleteFile', data)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.projectSocket.on('createVersion', (data) =>
|
this.projectSocket.on('createVersion', (data) =>
|
||||||
{
|
{
|
||||||
// console.log('createVersion', data)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="name" :style="{paddingLeft:depth * 20 + 'px'}">
|
<div class="name" :style="{ paddingLeft:depth * 20 + 'px' }">
|
||||||
{{ content.name }}
|
{{ content.name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<template src="./template.html"></template>
|
<template src="./template.html"></template>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
<style src="./style.styl" lang="stylus"></style>
|
<style src="./style.styl" lang="stylus" scoped></style>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import FilesTreeFile from '@/components/files-tree-file'
|
import FilesTreeFile from '@/components/files-tree-file'
|
||||||
|
|
||||||
export default
|
export default
|
||||||
{
|
{
|
||||||
name: 'files-tree-folder',
|
name: 'files-tree-folder',
|
||||||
@@ -14,11 +15,22 @@ export default
|
|||||||
content: { type: Object }
|
content: { type: Object }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
open: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
created()
|
created()
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
methods:
|
methods:
|
||||||
{
|
{
|
||||||
|
onNameClick()
|
||||||
|
{
|
||||||
|
this.open = !this.open
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.name
|
||||||
|
cursor pointer
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="name" :style="{paddingLeft:depth * 20 + 'px'}">
|
<div class="name" :style="{ paddingLeft:depth * 20 + 'px' }" @click.prevent="onNameClick">
|
||||||
{{ content.name }}
|
{{ content.name }}
|
||||||
</div>
|
</div>
|
||||||
<files-tree-folder v-for="folder of content.folders" :key="+ new Date()" :content="folder" :depth="depth + 1"></files-tree-folder>
|
<div v-show="open">
|
||||||
<files-tree-file v-for="file of content.files" :key="+ new Date()" :content="file" :depth="depth + 1"></files-tree-file>
|
<files-tree-folder v-for="folder of content.folders" :key="folder.name" :content="folder" :depth="depth + 1"></files-tree-folder>
|
||||||
|
<files-tree-file v-for="file of content.files" :key="file.data.path.full" :content="file" :depth="depth + 1"></files-tree-file>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,22 +39,11 @@ export default
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
watch:
|
|
||||||
{
|
|
||||||
files: 'onFilesChange'
|
|
||||||
},
|
|
||||||
|
|
||||||
created()
|
created()
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
methods:
|
methods:
|
||||||
{
|
{
|
||||||
onFilesChange(newValue, oldValue)
|
|
||||||
{
|
|
||||||
console.log('onFilesChange')
|
|
||||||
console.log(newValue)
|
|
||||||
console.log(oldValue)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,15 +40,14 @@ class FileTree
|
|||||||
// Ending `/`
|
// Ending `/`
|
||||||
path = path.replace(/\/$/, '')
|
path = path.replace(/\/$/, '')
|
||||||
|
|
||||||
console.log(path)
|
|
||||||
|
|
||||||
// Starting `.`
|
|
||||||
path = path.replace(/^\./, '')
|
|
||||||
|
|
||||||
// Starting `/`
|
// Starting `/`
|
||||||
path = path.replace(/^\//, '')
|
path = path.replace(/^\//, '')
|
||||||
|
|
||||||
|
// Missing starting `./`
|
||||||
|
if(path !== '.' && path.search('./') !== 0)
|
||||||
|
{
|
||||||
path = './' + path
|
path = './' + path
|
||||||
|
}
|
||||||
|
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user