From 1f998168e2f6ff94d0119fe5f95ad03b47d19d60 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Apr 2020 00:34:56 +0900 Subject: [PATCH] feat(client): Implement default upload folder setting Resolve #5985 --- locales/ja-JP.yml | 2 + src/client/components/drive-window.vue | 15 +- src/client/components/drive.file.vue | 19 ++- src/client/components/drive.folder.vue | 32 +++- src/client/components/drive.vue | 40 +++-- src/client/components/page/page.post.vue | 3 + src/client/components/window.vue | 21 ++- src/client/pages/my-settings/drive.vue | 198 +++------------------- src/client/scripts/select-drive-file.ts | 1 + src/client/scripts/select-drive-folder.ts | 13 ++ webpack.config.ts | 4 +- 11 files changed, 140 insertions(+), 208 deletions(-) create mode 100644 src/client/scripts/select-drive-folder.ts diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 29ceb8ebfd..3db383e378 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -239,6 +239,8 @@ drive: "ドライブ" fileName: "ファイル名" selectFile: "ファイルを選択" selectFiles: "ファイルを選択" +selectFolder: "フォルダーを選択" +selectFolders: "フォルダーを選択" renameFile: "ファイル名を変更" folderName: "フォルダー名" createFolder: "フォルダーを作成" diff --git a/src/client/components/drive-window.vue b/src/client/components/drive-window.vue index 64c4cee0c1..d63881c0ed 100644 --- a/src/client/components/drive-window.vue +++ b/src/client/components/drive-window.vue @@ -1,8 +1,11 @@ @@ -25,7 +28,7 @@ export default Vue.extend({ type: { type: String, required: false, - default: undefined + default: 'file' }, multiple: { type: Boolean, @@ -45,8 +48,8 @@ export default Vue.extend({ this.$refs.window.close(); }, - onChangeSelection(files) { - this.selected = files; + onChangeSelection(xs) { + this.selected = xs; } } }); diff --git a/src/client/components/drive.file.vue b/src/client/components/drive.file.vue index 014e1a6ca5..a547abf9a0 100644 --- a/src/client/components/drive.file.vue +++ b/src/client/components/drive.file.vue @@ -42,11 +42,20 @@ import { faDownload, faLink, faICursor, faTrashAlt } from '@fortawesome/free-sol export default Vue.extend({ i18n, + components: { + XFileThumbnail + }, + props: { file: { type: Object, required: true, }, + isSelected: { + type: Boolean, + required: false, + default: false, + }, selectMode: { type: Boolean, required: false, @@ -54,10 +63,6 @@ export default Vue.extend({ } }, - components: { - XFileThumbnail - }, - data() { return { isDragging: false @@ -65,12 +70,10 @@ export default Vue.extend({ }, computed: { + // TODO: parentへの参照を無くす browser(): any { return this.$parent; }, - isSelected(): boolean { - return this.browser.selectedFiles.some(f => f.id == this.file.id); - }, title(): string { return `${this.file.name}\n${this.file.type} ${Vue.filter('bytes')(this.file.size)}`; } @@ -79,7 +82,7 @@ export default Vue.extend({ methods: { onClick(ev) { if (this.selectMode) { - this.browser.chooseFile(this.file); + this.$emit('chosen', this.file); } else { this.$root.menu({ items: [{ diff --git a/src/client/components/drive.folder.vue b/src/client/components/drive.folder.vue index 2e861e2480..b778acc77f 100644 --- a/src/client/components/drive.folder.vue +++ b/src/client/components/drive.folder.vue @@ -21,6 +21,7 @@

{{ $t('uploadFolder') }}

+ @@ -36,6 +37,16 @@ export default Vue.extend({ folder: { type: Object, required: true, + }, + isSelected: { + type: Boolean, + required: false, + default: false, + }, + selectMode: { + type: Boolean, + required: false, + default: false, } }, @@ -56,7 +67,12 @@ export default Vue.extend({ return this.folder.name; } }, + methods: { + checkboxClicked(e) { + this.$emit('chosen', this.folder); + }, + onClick() { this.browser.move(this.folder); }, @@ -241,10 +257,24 @@ export default Vue.extend({ cursor: pointer; } - * { + *:not(.checkbox) { pointer-events: none; } + > .checkbox { + position: absolute; + bottom: 8px; + right: 8px; + width: 16px; + height: 16px; + background: #fff; + border: solid 1px #000; + + &.checked { + background: var(--accent); + } + } + &[data-draghover] { &:after { content: ""; diff --git a/src/client/components/drive.vue b/src/client/components/drive.vue index fddac5b9aa..08c7097a8f 100644 --- a/src/client/components/drive.vue +++ b/src/client/components/drive.vue @@ -3,9 +3,9 @@