Handle manage-categories form.
This commit is contained in:
parent
0e28f8a16b
commit
f9e9e54aed
@ -25,3 +25,25 @@ function delete_post(e) {
|
|||||||
|
|
||||||
for (const delete_post_button of document.getElementsByName("delete-post"))
|
for (const delete_post_button of document.getElementsByName("delete-post"))
|
||||||
delete_post_button.addEventListener("click", delete_post);
|
delete_post_button.addEventListener("click", delete_post);
|
||||||
|
|
||||||
|
document.getElementById("manage-categories").elements["add"].addEventListener("click", ev => {
|
||||||
|
let data = new URLSearchParams();
|
||||||
|
data.append("name", get_field(ev.target, "name"));
|
||||||
|
fetch(`/api/mindflow-category`, {method: "POST", body: data})
|
||||||
|
.catch(e => console.log(e))
|
||||||
|
.then(() => window.location = "/mindflow/admin");
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("manage-categories").elements["edit"].addEventListener("click", ev => {
|
||||||
|
let data = new URLSearchParams();
|
||||||
|
data.append("name", get_field(ev.target, "name"));
|
||||||
|
fetch(`/api/mindflow-category/${get_field(e.target, "post-id")}`, {method: "PATCH", body: data})
|
||||||
|
.catch(e => console.log(e))
|
||||||
|
.then(() => window.location = "/mindflow/admin");
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById("manage-categories").elements["delete"].addEventListener("click", ev => {
|
||||||
|
fetch(`/api/mindflow-category/${get_field(e.target, "post-id")}`, {method: "DELETE"})
|
||||||
|
.catch(e => console.log(e))
|
||||||
|
.then(() => window.location = "/mindflow/admin");
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user