I can now list the contents of a table and display a form for one row to update/delete, but haven't implemented update and delete.
This commit is contained in:
parent
2b40d6fdc3
commit
d12817f4cc
4 changed files with 49 additions and 17 deletions
|
@ -24,14 +24,14 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let Tables = new GetJson("/api/admin/table/")
|
let Rows = new GetJson("/api/admin/table/")
|
||||||
console.log("Tables", Tables)
|
console.log("Rows", Rows)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<blockstart>
|
<blockstart>
|
||||||
<h1>Admin Tables</h1>
|
<h1>Admin Rows</h1>
|
||||||
|
|
||||||
<block x-data="Tables">
|
<block x-data="Rows">
|
||||||
<ul>
|
<ul>
|
||||||
<template x-for="item in theData">
|
<template x-for="item in theData">
|
||||||
<li><a x-bind:href="'/admin/table/' + item + '/'">
|
<li><a x-bind:href="'/admin/table/' + item + '/'">
|
||||||
|
|
|
@ -3,6 +3,7 @@ class GetJson {
|
||||||
constructor(url) {
|
constructor(url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.items = [];
|
this.items = [];
|
||||||
|
this.item = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async theData() {
|
async theData() {
|
||||||
|
@ -11,5 +12,10 @@ class GetJson {
|
||||||
this.items = await resp.json();
|
this.items = await resp.json();
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
async oneThing() {
|
||||||
|
this.item = await this.theData();
|
||||||
|
console.log("ITEMS", this.items);
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,14 +7,24 @@
|
||||||
<h1>Admin Tables</h1>
|
<h1>Admin Tables</h1>
|
||||||
|
|
||||||
<block x-data="Tables">
|
<block x-data="Tables">
|
||||||
<ul>
|
|
||||||
<template x-for="item in theData">
|
|
||||||
<table>
|
<table>
|
||||||
<td><a x-bind:href="'/admin/table/{{ .Table }}/' + item.id + '/'" x-text="item.id"></td>
|
<template x-for="item in theData">
|
||||||
<td x-text="item.Email"></td>
|
<tr>
|
||||||
</table>
|
<td>
|
||||||
|
<a x-bind:href="'/admin/table/{{ .Table }}/' + item.id + '/'">
|
||||||
|
^
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<template x-for="(value, key) in item">
|
||||||
|
<td x-text="value"></td>
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</tr>
|
||||||
|
</template>
|
||||||
|
</table>
|
||||||
|
<block class="horizontal">
|
||||||
|
<a href="/admin/table/{{.Table}}/?page=2">Prev</a>
|
||||||
|
<a href="/admin/table/{{.Table}}/?page=2">Next</a>
|
||||||
|
</block>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
</blockstart>
|
</blockstart>
|
||||||
|
|
|
@ -1,15 +1,31 @@
|
||||||
<script>
|
<script>
|
||||||
let Data = new GetJson("/api/admin/table/{{ .Table }}/{{ .Id }}/")
|
let Data = new GetJson("/api/admin/table/{{ .Table }}/{{ .Id }}/");
|
||||||
console.log("Data", Data)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<blockstart>
|
<blockstart>
|
||||||
<h1>Admin Tables</h1>
|
<h1>Admin Tables</h1>
|
||||||
|
|
||||||
<block x-data="Data">
|
<block x-init="item = await Data.oneThing()" x-data="{item: {}}">
|
||||||
<ul>
|
<form method="POST" action="/api/admin/table/{{ .Table }}/{{ .Id }}/">
|
||||||
<h1 x-text="item.id"></h1>
|
<card>
|
||||||
</ul>
|
<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-text="value" x-bind:value="value" x-bind:id="key" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</middle>
|
||||||
|
<bottom>
|
||||||
|
<button-group>
|
||||||
|
<button type="button">Back</button>
|
||||||
|
<button type="submit">Update</button>
|
||||||
|
<button type="button">Delete</button>
|
||||||
|
</button-group>
|
||||||
|
</bottom>
|
||||||
|
</card>
|
||||||
|
</form>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
</blockstart>
|
</blockstart>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue