We have delete now. Last thing is insert.

main
Zed A. Shaw 2 days ago
parent 504433502a
commit ea3b59129f
  1. 8
      admin/handlers.go
  2. 15
      views/admin/table/view.html

@ -76,6 +76,14 @@ func PutApiInsert(c *fiber.Ctx) error {
}
func DeleteApi(c *fiber.Ctx) error {
table := c.Params("table")
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
if err != nil { return IfErrNil(err, c) }
err = Delete(table, id)
if err != nil { return IfErrNil(err, c) }
return c.JSON(fiber.Map{})
}

@ -1,5 +1,16 @@
<script>
let Data = new GetJson("/api/admin/table/{{ .Table }}/{{ .Id }}/");
const ConfirmDelete = async (table, obj_id) => {
if(confirm("Are you sure?")) {
await fetch("/api/admin/table/" + table + "/" + obj_id + "/",
{ method: "DELETE" });
window.location = "/admin/table/" + table + "/";
} else {
console.log("NOOOOO");
return false;
}
}
</script>
<blockstart>
@ -19,9 +30,9 @@
</middle>
<bottom>
<button-group>
<button type="button">Back</button>
<button type="button"><a href="/admin/table/{{ .Table }}/">Back</a></button>
<button type="submit">Update</button>
<button type="button" @click.prevent="console.log('DELETE', item.id)">Delete</button>
<button type="button" @click.prevent="ConfirmDelete('{{ .Table }}', item.id)">Delete</button>
</button-group>
</bottom>
</card>

Loading…
Cancel
Save