From 18458f418f96fa4fe5f45c9ec967ee5fa1089735 Mon Sep 17 00:00:00 2001 From: fuyu <54523771+mfmfuyu@users.noreply.github.com> Date: Sat, 8 Feb 2020 13:09:38 +0900 Subject: [PATCH] =?UTF-8?q?[wip]=20=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E3=83=BC=E5=90=8D=E3=81=AE=E5=A4=89=E6=9B=B4=E3=81=A8=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E6=A9=9F=E8=83=BD=E3=82=92=E5=AE=9F=E8=A3=85=20(#5874?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * フォルダーの削除機能を実装 * フォルダ名の変更を実装 * ダイアログの削除(v11準拠)とエラーメッセージを表示するように * ダイアログのテキストのkeypathを変更 --- src/client/components/drive.vue | 43 +++++++++++++++++++++++++++++++++ src/client/pages/drive.vue | 4 +-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/client/components/drive.vue b/src/client/components/drive.vue index 2279e2eb6e..8a4349ae35 100644 --- a/src/client/components/drive.vue +++ b/src/client/components/drive.vue @@ -319,6 +319,49 @@ export default Vue.extend({ }); }, + renameFolder(folder) { + this.$root.dialog({ + title: this.$t('contextmenu.rename-folder'), + input: { + placeholder: this.$t('contextmenu.input-new-folder-name'), + default: folder.name + } + }).then(({ canceled, result: name }) => { + if (canceled) return; + this.$root.api('drive/folders/update', { + folderId: folder.id, + name: name + }).then(folder => { + // FIXME: 画面を更新するために自分自身に移動 + this.move(folder); + }); + }); + }, + + deleteFolder(folder) { + this.$root.api('drive/folders/delete', { + folderId: folder.id + }).then(() => { + // 削除時に親フォルダに移動 + this.move(folder.parentId); + }).catch(err => { + switch(err.id) { + case 'b0fc8a17-963c-405d-bfbc-859a487295e1': + this.$root.dialog({ + type: 'error', + title: this.$t('unable-to-delete'), + text: this.$t('has-child-files-or-folders') + }); + break; + default: + this.$root.dialog({ + type: 'error', + text: this.$t('unable-to-delete') + }); + } + }); + }, + onChangeFileInput() { for (const file of Array.from((this.$refs.fileInput as any).files)) { this.upload(file, this.folder); diff --git a/src/client/pages/drive.vue b/src/client/pages/drive.vue index 24a0d91ff6..7b648939f2 100644 --- a/src/client/pages/drive.vue +++ b/src/client/pages/drive.vue @@ -57,11 +57,11 @@ export default Vue.extend({ }, this.folder ? { text: this.$t('renameFolder'), icon: faICursor, - action: () => { this.$refs.drive.renameFolder(); } + action: () => { this.$refs.drive.renameFolder(this.folder); } } : undefined, this.folder ? { text: this.$t('deleteFolder'), icon: faTrashAlt, - action: () => { this.$refs.drive.deleteFolder(); } + action: () => { this.$refs.drive.deleteFolder(this.folder); } } : undefined, { text: this.$t('createFolder'), icon: faFolderPlus,