You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
<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>
|
|
<h1>Admin Tables</h1>
|
|
|
|
<block x-init="item = await Data.oneThing()" x-data="{item: {}}">
|
|
<form method="POST" action="/api/admin/table/{{ .Table }}/{{ .Id }}/">
|
|
<card>
|
|
<top><h1>{{ .Table }} : {{ .Id }}</h1></top>
|
|
<middle>
|
|
<template x-for="(value, key) in item">
|
|
<div>
|
|
<label x-text="key" x-bind:for="key"></label>
|
|
<input x-bind:name="key" x-text="value" x-model="item[key]" x-bind:id="key" />
|
|
</div>
|
|
</template>
|
|
</middle>
|
|
<bottom>
|
|
<button-group>
|
|
<button type="button"><a href="/admin/table/{{ .Table }}/">Back</a></button>
|
|
<button type="submit">Update</button>
|
|
<button type="button" @click.prevent="ConfirmDelete('{{ .Table }}', item.id)">Delete</button>
|
|
</button-group>
|
|
</bottom>
|
|
</card>
|
|
</form>
|
|
</block>
|
|
|
|
</blockstart>
|
|
|