From 831ca53b639062efd5a6e3e7c1b0b20f46ce6fc1 Mon Sep 17 00:00:00 2001 From: Xeltica <7106976+Xeltica@users.noreply.github.com> Date: Sun, 28 Jul 2019 05:33:12 +0900 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E5=89=8A=E9=99=A4=E3=81=97=E3=81=A6?= =?UTF-8?q?=E7=B7=A8=E9=9B=86=E3=80=8D=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=20(#5182)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 「削除して編集」機能を追加 * UXの調整 * 殆どの情報を保持したまま編集できるように * update lang --- locales/ja-JP.yml | 2 ++ src/client/app/common/scripts/post-form.ts | 26 ++++++++++++++++++ .../app/common/views/components/note-menu.vue | 27 ++++++++++++++++++- src/client/app/desktop/script.ts | 5 +++- .../views/components/post-form-window.vue | 22 ++++++++++++++- src/client/app/init.ts | 4 ++- src/client/app/mobile/script.ts | 5 +++- .../views/components/post-form-dialog.vue | 5 ++++ 8 files changed, 91 insertions(+), 5 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 526f9b0f3..c34f398c9 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -581,6 +581,8 @@ common/views/components/note-menu.vue: unpin: "ピン留め解除" delete: "削除" delete-confirm: "この投稿を削除しますか?" + delete-and-edit: "削除して編集" + delete-and-edit-confirm: "この投稿を削除してもう一度編集しますか?この投稿へのリアクション、リノート、返信も全て削除されます。" remote: "投稿元で見る" pin-limit-exceeded: "これ以上ピン留めできません。" diff --git a/src/client/app/common/scripts/post-form.ts b/src/client/app/common/scripts/post-form.ts index ff3fd0792..2b591ac65 100644 --- a/src/client/app/common/scripts/post-form.ts +++ b/src/client/app/common/scripts/post-form.ts @@ -35,6 +35,10 @@ export default (opts) => ({ type: String, required: false }, + initialNote: { + type: Object, + required: false + }, instant: { type: Boolean, required: false, @@ -195,6 +199,28 @@ export default (opts) => ({ this.$emit('change-attached-files', this.files); } } + if (this.initialNote) { + // 削除して編集 + const init = this.initialNote; + this.text = init.text ? init.text : ''; + this.files = init.files; + this.cw = init.cw; + this.useCw = init.cw != null; + if (init.poll) { + this.poll = true; + this.$nextTick(() => { + (this.$refs.poll as any).set({ + choices: init.poll.choices.map(c => c.text), + multiple: init.poll.multiple + }); + }); + } + // hack 位置情報投稿が動くようになったら適用する + this.geo = null; + this.visibility = init.visibility; + this.localOnly = init.localOnly; + this.quoteId = init.renote ? init.renote.id : null; + } this.$nextTick(() => this.watch()); }); diff --git a/src/client/app/common/views/components/note-menu.vue b/src/client/app/common/views/components/note-menu.vue index f3bb5c38c..6e2b778b3 100644 --- a/src/client/app/common/views/components/note-menu.vue +++ b/src/client/app/common/views/components/note-menu.vue @@ -74,7 +74,13 @@ export default Vue.extend({ action: () => this.togglePin(true) } : undefined, ...(this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin || this.$store.state.i.isModerator ? [ - null, { + null, + this.note.userId == this.$store.state.i.id ? { + icon: 'undo-alt', + text: this.$t('delete-and-edit'), + action: this.deleteAndEdit + } : undefined, + { icon: ['far', 'trash-alt'], text: this.$t('delete'), action: this.del @@ -154,6 +160,25 @@ export default Vue.extend({ }); }, + deleteAndEdit() { + this.$root.dialog({ + type: 'warning', + text: this.$t('delete-and-edit-confirm'), + showCancelButton: true + }).then(({ canceled }) => { + if (canceled) return; + this.$root.api('notes/delete', { + noteId: this.note.id + }).then(() => { + this.destroyDom(); + }); + this.$post({ + initialNote: this.note, + reply: this.note.reply, + }); + }); + }, + toggleFavorite(favorite: boolean) { this.$root.api(favorite ? 'notes/favorites/create' : 'notes/favorites/delete', { noteId: this.note.id diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts index 1a4be3302..32e4886de 100644 --- a/src/client/app/desktop/script.ts +++ b/src/client/app/desktop/script.ts @@ -63,7 +63,10 @@ init(async (launch, os) => { this.$root.newAsync(() => import('./views/components/post-form-window.vue').then(m => m.default), { reply: o.reply, mention: o.mention, - animation: o.animation == null ? true : o.animation + animation: o.animation == null ? true : o.animation, + initialText: o.initialText, + instant: o.instant, + initialNote: o.initialNote, }).then(vm => { if (o.cb) vm.$once('closed', o.cb); }); diff --git a/src/client/app/desktop/views/components/post-form-window.vue b/src/client/app/desktop/views/components/post-form-window.vue index 78e69049a..ff6f24b6e 100644 --- a/src/client/app/desktop/views/components/post-form-window.vue +++ b/src/client/app/desktop/views/components/post-form-window.vue @@ -15,6 +15,10 @@ { const vm = this.$root.new(PostFormDialog, { reply: o.reply, mention: o.mention, - renote: o.renote + renote: o.renote, + initialText: o.initialText, + instant: o.instant, + initialNote: o.initialNote, }); vm.$once('cancel', recover); vm.$once('posted', recover); diff --git a/src/client/app/mobile/views/components/post-form-dialog.vue b/src/client/app/mobile/views/components/post-form-dialog.vue index a6801be0e..716ad8fd0 100644 --- a/src/client/app/mobile/views/components/post-form-dialog.vue +++ b/src/client/app/mobile/views/components/post-form-dialog.vue @@ -7,6 +7,7 @@ :renote="renote" :mention="mention" :initial-text="initialText" + :initial-note="initialNote" :instant="instant" @posted="onPosted" @cancel="onCanceled"/> @@ -41,6 +42,10 @@ export default Vue.extend({ type: String, required: false }, + initialNote: { + type: Object, + required: false + }, instant: { type: Boolean, required: false,