We have delete now. Last thing is insert.
This commit is contained in:
parent
504433502a
commit
ea3b59129f
2 changed files with 21 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue