2626 :item-key =" 'id'"
2727 :active =" [value]"
2828 :open =" [tree.id]"
29- :items =" [filterOutBookmarks(tree) ]"
29+ :items =" [privateTree ]"
3030 dense
3131 @update:active =" onUpdateSelection" >
3232 <template #prepend =" { open } " >
3737 <template #label =" {item } " >
3838 {{ item.title || t('LabelUntitledfolder') }}
3939 </template >
40+ <template #append =" {item } " >
41+ <v-btn
42+ small
43+ rounded
44+ @click =" onCreate(item.id)" >
45+ <v-icon >
46+ mdi-plus
47+ </v-icon >
48+ </v-btn >
49+ </template >
4050 </v-treeview >
4151 </v-card >
4252 </v-dialog >
4353</template >
4454
4555<script >
46- import { mutations } from ' ../../store/definitions'
56+ import { actions , mutations } from ' ../../store/definitions'
57+ import { Folder } from ' ../../../lib/Tree'
4758
4859export default {
4960 name: ' DialogChooseFolder' ,
61+ components: {},
5062 props: {
5163 value: {
5264 type: Number ,
@@ -64,6 +76,7 @@ export default {
6476 data () {
6577 return {
6678 selectedFolder: this .value ,
79+ privateTree: [],
6780 }
6881 },
6982 computed: {
@@ -74,6 +87,17 @@ export default {
7487 return this .accountId && this .$store .state .accounts [this .accountId ].data .sortBy
7588 }
7689 },
90+ watch: {
91+ async tree (newTree , oldTree ) {
92+ if (await newTree .hash () === await oldTree .hash ()) {
93+ return
94+ }
95+ this .privateTree = this .filterOutBookmarks (newTree)
96+ }
97+ },
98+ mounted () {
99+ this .privateTree = this .filterOutBookmarks (this .tree )
100+ },
77101 methods: {
78102 filterOutBookmarks (item ) {
79103 let children = item .children
@@ -91,6 +115,13 @@ export default {
91115 onUpdateSelection (active ) {
92116 this .selectedFolder = active[0 ]
93117 },
118+ onCreate (parentId ) {
119+ const title = prompt (' New folder title' )
120+ this .$store .dispatch (actions .CREATE_FOLDER , {
121+ accountId: this .accountId ,
122+ folder: new Folder ({title, id: null , parentId})
123+ })
124+ },
94125 onSave () {
95126 this .$store .commit (mutations .SET_LAST_FOLDER , {folderId: this .selectedFolder , accountId: this .$route .params .accountId })
96127 this .$emit (' update:display' , false )
0 commit comments