mirror of
https://github.com/byulmaru/quesdon
synced 2024-12-03 01:08:01 +09:00
まだ回答する前の質問の削除に対応
This commit is contained in:
parent
731737c455
commit
e881924ea6
@ -23,6 +23,7 @@ my-question
|
|||||||
option(value="public") 公開
|
option(value="public") 公開
|
||||||
option(value="unlisted") 未収載
|
option(value="unlisted") 未収載
|
||||||
option(value="no") 投稿しない
|
option(value="no") 投稿しない
|
||||||
|
button.btn.btn-danger(type="button",style="float:right;",onclick="{delete}") 削除
|
||||||
script.
|
script.
|
||||||
this.submit = e => {
|
this.submit = e => {
|
||||||
var formData = new FormData(e.target)
|
var formData = new FormData(e.target)
|
||||||
@ -34,3 +35,12 @@ my-question
|
|||||||
location.reload()
|
location.reload()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
this.delete = e => {
|
||||||
|
if(!confirm("質問を削除します。\n削除した質問は二度と元に戻せません。\n本当に質問を削除しますか?")) return
|
||||||
|
apiFetch("/api/web/questions/"+this.opts.question._id+"/delete", {
|
||||||
|
method: "POST"
|
||||||
|
}).then(r => r.json()).then(r => {
|
||||||
|
alert("削除しました")
|
||||||
|
location.reload()
|
||||||
|
})
|
||||||
|
}
|
@ -54,6 +54,8 @@ router.post("/:id/delete", async ctx => {
|
|||||||
const question = await Question.findById(ctx.params.id)
|
const question = await Question.findById(ctx.params.id)
|
||||||
if (!question) return ctx.throw("not found", 404)
|
if (!question) return ctx.throw("not found", 404)
|
||||||
if (question.user.toString() != ctx.session!.user) return ctx.throw("not found", 404)
|
if (question.user.toString() != ctx.session!.user) return ctx.throw("not found", 404)
|
||||||
|
await question.remove()
|
||||||
|
ctx.body = {status: "ok"}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get("/:id", async ctx => {
|
router.get("/:id", async ctx => {
|
||||||
|
Loading…
Reference in New Issue
Block a user