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.
44 lines
1.1 KiB
44 lines
1.1 KiB
<script>
|
|
let thePage = new PaginateTable("/api/admin/table/{{ .table }}");
|
|
|
|
const craftTemplate = (example) => {
|
|
const tmpl = $id('table-row');
|
|
const tr = tmpl.content.children[0];
|
|
|
|
for(let header of Object.keys(example)) {
|
|
$append(tr,
|
|
$html("<td><a style='text-decoration: none' href='/admin/table/{{.table}}/${item.Id}/'>${item['" + header + "']}</a></td>"));
|
|
}
|
|
|
|
return tmpl;
|
|
}
|
|
|
|
$boot(async () => {
|
|
const items = await thePage.contents();
|
|
const tmpl = craftTemplate(items[0]);
|
|
const rows = $id('table-items');
|
|
|
|
for(let item of items) {
|
|
console.log("ITEM", item);
|
|
$append(rows, $render(tmpl, {item}));
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<h1><a href="/admin/table/">«</a> Admin {{ .table }}</h1>
|
|
|
|
<block x-data="thePage">
|
|
<bar>
|
|
<button type="button"><a href="/admin/table/new/{{ .table }}/">New</a></button>
|
|
<button type="button">Prev</button>
|
|
<button type="button">Next</button>
|
|
<input type="text" name="search" size="40" placeholder="Search" />
|
|
</bar>
|
|
|
|
<table id="table-items">
|
|
</table>
|
|
|
|
<template id="table-row">
|
|
<tr class="table-row"></tr>
|
|
</template>
|
|
</block>
|
|
|