refs #2068 Add delete button for delete list

This commit is contained in:
AkiraFukushima 2021-01-24 16:34:32 +09:00
parent bd6ca2a4dd
commit cc3b598ed6
3 changed files with 34 additions and 1 deletions

View File

@ -387,7 +387,15 @@
"lists": {
"index": {
"new_list": "New List",
"edit": "Edit"
"edit": "Edit",
"delete": {
"confirm": {
"title": "Confirm",
"message": "This operation can not be undone, this list will be permanently deleted",
"ok": "Delete",
"cancel": "Cancel"
}
}
}
},
"login": {

View File

@ -16,6 +16,9 @@
<el-button type="text" @click="edit(list)">
<icon name="regular/edit"></icon>
</el-button>
<el-button type="text" @click="del(list)">
<icon name="regular/trash-alt"></icon>
</el-button>
</div>
</div>
</div>
@ -73,6 +76,17 @@ export default {
},
edit(list) {
return this.$router.push(`/${this.id()}/lists/${list.id}/edit`)
},
del(list) {
this.$confirm(this.$t('lists.index.delete.confirm.message'), this.$t('lists.index.delete.confirm.title'), {
confirmButtonText: this.$t('lists.index.delete.confirm.ok'),
cancelButtonText: this.$t('lists.index.delete.confirm.cancel'),
type: 'warning'
})
.then(() => {
this.$store.dispatch('TimelineSpace/Contents/Lists/Index/deleteList', list)
})
.catch(() => {})
}
}
}

View File

@ -41,6 +41,17 @@ const actions: ActionTree<IndexState, RootState> = {
)
const res = await client.createList(title)
return res.data
},
deleteList: async ({ dispatch, rootState }, list: Entity.List) => {
const client = generator(
rootState.TimelineSpace.sns,
rootState.TimelineSpace.account.baseURL,
rootState.TimelineSpace.account.accessToken,
rootState.App.userAgent
)
const res = await client.deleteList(list.id)
dispatch('fetchLists')
return res.data
}
}