「削除して編集」機能を追加 (#5182)
* 「削除して編集」機能を追加 * UXの調整 * 殆どの情報を保持したまま編集できるように * update lang
This commit is contained in:
@@ -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());
|
||||
});
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user