2017-07-28 20:04:12 +00:00
|
|
|
<template>
|
2017-07-31 09:04:01 +00:00
|
|
|
<div class="explorer flex flex--column">
|
2017-08-03 17:08:12 +00:00
|
|
|
<div class="side-title flex flex--row flex--space-between">
|
|
|
|
<div class="flex flex--row">
|
2017-10-07 11:22:24 +00:00
|
|
|
<button class="side-title__button button" @click="newItem()" v-title="'New file'">
|
2017-08-03 17:08:12 +00:00
|
|
|
<icon-file-plus></icon-file-plus>
|
|
|
|
</button>
|
2017-10-07 11:22:24 +00:00
|
|
|
<button class="side-title__button button" @click="newItem(true)" v-title="'New folder'">
|
2017-08-03 17:08:12 +00:00
|
|
|
<icon-folder-plus></icon-folder-plus>
|
|
|
|
</button>
|
2018-03-09 21:18:20 +00:00
|
|
|
<button class="side-title__button button" @click="deleteItem()" v-title="'Delete'">
|
2017-08-03 17:08:12 +00:00
|
|
|
<icon-delete></icon-delete>
|
|
|
|
</button>
|
2017-12-17 15:08:52 +00:00
|
|
|
<button class="side-title__button button" @click="editItem()" v-title="'Rename'">
|
|
|
|
<icon-pen></icon-pen>
|
|
|
|
</button>
|
2017-08-03 17:08:12 +00:00
|
|
|
</div>
|
2017-10-07 11:22:24 +00:00
|
|
|
<button class="side-title__button button" @click="toggleExplorer(false)" v-title="'Close explorer'">
|
2017-07-31 09:04:01 +00:00
|
|
|
<icon-close></icon-close>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="explorer__tree" :class="{'explorer__tree--new-item': !newChildNode.isNil}" tabindex="0">
|
|
|
|
<explorer-node :node="rootNode" :depth="0"></explorer-node>
|
2017-07-28 20:04:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-08-03 17:08:12 +00:00
|
|
|
import { mapState, mapGetters, mapActions } from 'vuex';
|
2017-07-31 09:04:01 +00:00
|
|
|
import ExplorerNode from './ExplorerNode';
|
|
|
|
|
2017-07-28 20:04:12 +00:00
|
|
|
export default {
|
2017-07-31 09:04:01 +00:00
|
|
|
components: {
|
|
|
|
ExplorerNode,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState('explorer', [
|
|
|
|
'newChildNode',
|
|
|
|
]),
|
|
|
|
...mapGetters('explorer', [
|
|
|
|
'rootNode',
|
2018-03-09 21:18:20 +00:00
|
|
|
'selectedNode',
|
2017-07-31 09:04:01 +00:00
|
|
|
]),
|
|
|
|
},
|
|
|
|
methods: {
|
2017-08-03 17:08:12 +00:00
|
|
|
...mapActions('data', [
|
2017-07-31 09:04:01 +00:00
|
|
|
'toggleExplorer',
|
|
|
|
]),
|
2018-03-09 21:18:20 +00:00
|
|
|
...mapActions('explorer', [
|
|
|
|
'newItem',
|
|
|
|
'deleteItem',
|
|
|
|
]),
|
2017-07-31 09:04:01 +00:00
|
|
|
editItem() {
|
2018-03-09 21:18:20 +00:00
|
|
|
const node = this.selectedNode;
|
|
|
|
if (!node.isTrash) {
|
|
|
|
this.$store.commit('explorer/setEditingId', node.item.id);
|
2017-08-03 17:08:12 +00:00
|
|
|
}
|
2017-07-31 09:04:01 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.$store.watch(
|
2017-08-17 23:10:35 +00:00
|
|
|
() => this.$store.getters['file/current'].id,
|
2017-07-31 09:04:01 +00:00
|
|
|
(currentFileId) => {
|
2017-08-03 17:08:12 +00:00
|
|
|
this.$store.commit('explorer/setSelectedId', currentFileId);
|
|
|
|
this.$store.dispatch('explorer/openNode', currentFileId);
|
2017-07-31 09:04:01 +00:00
|
|
|
}, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
|
|
|
},
|
2017-07-28 20:04:12 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2017-07-31 09:04:01 +00:00
|
|
|
.explorer,
|
|
|
|
.explorer__tree {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2017-08-03 17:08:12 +00:00
|
|
|
.explorer__tree {
|
|
|
|
overflow: auto;
|
|
|
|
|
|
|
|
/* fake element */
|
|
|
|
& > .explorer-node > .explorer-node__children > .explorer-node:last-child > .explorer-node__item {
|
|
|
|
height: 20px;
|
|
|
|
cursor: auto;
|
|
|
|
}
|
|
|
|
}
|
2017-07-28 20:04:12 +00:00
|
|
|
</style>
|