Site > File Tree > Add folder toggle

This commit is contained in:
brunosimon
2017-08-09 23:54:53 +02:00
parent c7cf01747a
commit 5cac120de2
8 changed files with 26 additions and 26 deletions
@@ -1,3 +1,3 @@
<template src="./template.html"></template>
<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'
export default
{
name: 'files-tree-folder',
@@ -14,11 +15,22 @@ export default
content: { type: Object }
},
data()
{
return {
open: true
}
},
created()
{
},
methods:
{
onNameClick()
{
this.open = !this.open
}
}
}
@@ -0,0 +1,2 @@
.name
cursor pointer
@@ -1,7 +1,9 @@
<div>
<div class="name" :style="{paddingLeft:depth * 20 + 'px'}">
<div class="name" :style="{ paddingLeft:depth * 20 + 'px' }" @click.prevent="onNameClick">
{{ content.name }}
</div>
<files-tree-folder v-for="folder of content.folders" :key="+ new Date()" :content="folder" :depth="depth + 1"></files-tree-folder>
<files-tree-file v-for="file of content.files" :key="+ new Date()" :content="file" :depth="depth + 1"></files-tree-file>
<div v-show="open">
<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>