refs #2258 Add delete filter form

This commit is contained in:
AkiraFukushima 2021-05-10 01:05:03 +09:00
parent 783ddddafe
commit 9b16716a80
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
3 changed files with 26 additions and 2 deletions

View File

@ -139,7 +139,10 @@
}
},
"delete": {
"title": "Delete"
"title": "Delete",
"confirm": "Are you sure to delete this filter?",
"confirm_ok": "Delete",
"confirm_cancel": "Cancel"
}
}
},

View File

@ -60,7 +60,13 @@ export default {
return this.$route.params.id
},
deleteFilter(id) {
console.log(id)
this.$confirm(this.$t('settings.filters.delete.confirm'), 'Warning', {
confirmButtonText: this.$t('settings.filters.delete.confirm_ok'),
cancelButtonText: this.$t('settings.filters.delete.confirm_cancel'),
type: 'warning'
}).then(() => {
return this.$store.dispatch('Settings/Filters/deleteFilter', id)
})
}
}
}

View File

@ -42,6 +42,21 @@ export const actions: ActionTree<FiltersState, RootState> = {
} finally {
commit(MUTATION_TYPES.CHANGE_LOADING, false)
}
},
deleteFilter: async ({ commit, dispatch, rootState }, id: string) => {
const client = generator(
rootState.TimelineSpace.sns,
rootState.TimelineSpace.account.baseURL,
rootState.TimelineSpace.account.accessToken,
rootState.App.userAgent
)
try {
commit(MUTATION_TYPES.CHANGE_LOADING, true)
await client.deleteFilter(id)
await dispatch('fetchFilters')
} finally {
commit(MUTATION_TYPES.CHANGE_LOADING, false)
}
}
}