You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
1.9 KiB

import fileStore from './../stores/file.js'
/**
* Mixin to Extend a Sidebar
*
* @author Björn Hase
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/tiny-components/sidebar-form
*
*/
export default {
state: {
files: [],
path: [],
marked: []
},
onMounted() {
fileStore.on('update', (data) => {
this.state.files = data
this.update()
})
fileStore.get(this.props.hubId)
},
/**
*
*
*
*/
handleParentClick(event) {
this.state.path.pop()
fileStore.get(this.props.hubId, this.state.path)
},
/**
*
*
*
*
*/
handleMarked(event, file) {
let exists = this.isFileInArray(file)
if (exists === false) {
this.state.marked.push(file)
} else {
this.state.marked.splice(this.state.marked.indexOf(file), 1)
}
this.update()
},
/**
*
* @return {Boolean} [description]
*/
isFileInArray(file)
{
let exists = false
this.state.marked.forEach((f, index) => {
if (file.name === f.name) {
exists = true
}
})
return exists
},
handleDirectoryClick(event, file) {
this.state.path.push(file.name)
fileStore.get(this.props.hubId, this.state.path)
},
/**
*
* @param {[type]} event [description]
* @param {[type]} file [description]
* @return {[type]} [description]
*/
handleDownload(event, file) {
},
/**
*
* @param {[type]} event [description]
* @param {[type]} file [description]
* @return {[type]} [description]
*/
handleDelete(event, file) {
}
}