2018-02-14 03:21:15 -07:00
|
|
|
<template>
|
2018-02-22 15:56:35 -07:00
|
|
|
<div class="root nav-folder"
|
2018-02-14 03:21:15 -07:00
|
|
|
:data-draghover="draghover"
|
|
|
|
@click="onClick"
|
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragenter="onDragenter"
|
|
|
|
@dragleave="onDragleave"
|
|
|
|
@drop.stop="onDrop"
|
|
|
|
>
|
2018-11-05 09:40:11 -07:00
|
|
|
<i v-if="folder == null" class="cloud"><fa icon="cloud"/></i>
|
2018-11-08 11:44:35 -07:00
|
|
|
<span>{{ folder == null ? $t('@.drive') : folder.name }}</span>
|
2018-02-14 03:21:15 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 11:44:35 -07:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-14 03:21:15 -07:00
|
|
|
export default Vue.extend({
|
2018-11-08 11:44:35 -07:00
|
|
|
i18n: i18n(),
|
2018-02-18 06:14:51 -07:00
|
|
|
props: ['folder'],
|
2018-02-14 03:21:15 -07:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
hover: false,
|
|
|
|
draghover: false
|
2017-02-21 01:52:10 -07:00
|
|
|
};
|
2018-02-14 03:21:15 -07:00
|
|
|
},
|
2018-02-18 06:14:51 -07:00
|
|
|
computed: {
|
|
|
|
browser(): any {
|
|
|
|
return this.$parent;
|
|
|
|
}
|
|
|
|
},
|
2018-02-14 03:21:15 -07:00
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
this.browser.move(this.folder);
|
|
|
|
},
|
|
|
|
onMouseover() {
|
|
|
|
this.hover = true;
|
|
|
|
},
|
|
|
|
onMouseout() {
|
|
|
|
this.hover = false;
|
|
|
|
},
|
|
|
|
onDragover(e) {
|
2017-02-19 17:53:57 -07:00
|
|
|
// このフォルダがルートかつカレントディレクトリならドロップ禁止
|
2017-02-21 01:52:10 -07:00
|
|
|
if (this.folder == null && this.browser.folder == null) {
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
2018-02-26 14:25:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const isFile = e.dataTransfer.items[0].kind == 'file';
|
|
|
|
const isDriveFile = e.dataTransfer.types[0] == 'mk_drive_file';
|
|
|
|
const isDriveFolder = e.dataTransfer.types[0] == 'mk_drive_folder';
|
|
|
|
|
|
|
|
if (isFile || isDriveFile || isDriveFolder) {
|
|
|
|
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move';
|
2017-02-21 01:52:10 -07:00
|
|
|
} else {
|
2018-02-26 14:25:17 -07:00
|
|
|
e.dataTransfer.dropEffect = 'none';
|
2017-02-21 01:52:10 -07:00
|
|
|
}
|
2018-02-26 14:35:16 -07:00
|
|
|
|
|
|
|
return false;
|
2018-02-14 03:21:15 -07:00
|
|
|
},
|
|
|
|
onDragenter() {
|
2017-02-21 01:52:10 -07:00
|
|
|
if (this.folder || this.browser.folder) this.draghover = true;
|
2018-02-14 03:21:15 -07:00
|
|
|
},
|
|
|
|
onDragleave() {
|
2017-02-21 01:52:10 -07:00
|
|
|
if (this.folder || this.browser.folder) this.draghover = false;
|
2018-02-14 03:21:15 -07:00
|
|
|
},
|
|
|
|
onDrop(e) {
|
2017-02-21 01:52:10 -07:00
|
|
|
this.draghover = false;
|
2016-12-28 15:49:51 -07:00
|
|
|
|
2017-02-19 17:53:57 -07:00
|
|
|
// ファイルだったら
|
2017-02-21 01:52:10 -07:00
|
|
|
if (e.dataTransfer.files.length > 0) {
|
2017-11-13 02:05:35 -07:00
|
|
|
Array.from(e.dataTransfer.files).forEach(file => {
|
2017-02-21 01:52:10 -07:00
|
|
|
this.browser.upload(file, this.folder);
|
|
|
|
});
|
2018-02-26 14:25:17 -07:00
|
|
|
return;
|
|
|
|
}
|
2017-01-11 13:55:38 -07:00
|
|
|
|
2018-02-26 14:25:17 -07:00
|
|
|
//#region ドライブのファイル
|
|
|
|
const driveFile = e.dataTransfer.getData('mk_drive_file');
|
|
|
|
if (driveFile != null && driveFile != '') {
|
|
|
|
const file = JSON.parse(driveFile);
|
|
|
|
this.browser.removeFile(file.id);
|
2018-02-17 20:35:18 -07:00
|
|
|
(this as any).api('drive/files/update', {
|
2018-03-28 23:48:47 -06:00
|
|
|
fileId: file.id,
|
|
|
|
folderId: this.folder ? this.folder.id : null
|
2017-02-21 01:52:10 -07:00
|
|
|
});
|
2018-02-26 14:25:17 -07:00
|
|
|
}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region ドライブのフォルダ
|
|
|
|
const driveFolder = e.dataTransfer.getData('mk_drive_folder');
|
|
|
|
if (driveFolder != null && driveFolder != '') {
|
|
|
|
const folder = JSON.parse(driveFolder);
|
2017-02-19 17:53:57 -07:00
|
|
|
// 移動先が自分自身ならreject
|
2018-02-26 14:25:17 -07:00
|
|
|
if (this.folder && folder.id == this.folder.id) return;
|
|
|
|
this.browser.removeFolder(folder.id);
|
2018-02-17 20:35:18 -07:00
|
|
|
(this as any).api('drive/folders/update', {
|
2018-03-28 23:48:47 -06:00
|
|
|
folderId: folder.id,
|
|
|
|
parentId: this.folder ? this.folder.id : null
|
2017-02-21 01:52:10 -07:00
|
|
|
});
|
|
|
|
}
|
2018-02-26 14:25:17 -07:00
|
|
|
//#endregion
|
2018-02-14 03:21:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-02-22 15:56:35 -07:00
|
|
|
.root.nav-folder
|
2018-02-26 14:35:16 -07:00
|
|
|
> *
|
|
|
|
pointer-events none
|
|
|
|
|
2018-02-14 03:21:15 -07:00
|
|
|
&[data-draghover]
|
|
|
|
background #eee
|
|
|
|
|
2018-11-05 09:40:11 -07:00
|
|
|
i.cloud
|
2018-04-14 16:41:10 -06:00
|
|
|
margin-right 4px
|
|
|
|
|
2018-02-14 03:21:15 -07:00
|
|
|
</style>
|