diff options
Diffstat (limited to 'internal/admin/templates/list.html')
| -rw-r--r-- | internal/admin/templates/list.html | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/internal/admin/templates/list.html b/internal/admin/templates/list.html index 561e317..b8a3a74 100644 --- a/internal/admin/templates/list.html +++ b/internal/admin/templates/list.html @@ -7,6 +7,7 @@ <th>Title</th> <th>Date</th> <th>Tags</th> + <th>Status</th> <th></th> </tr> </thead> @@ -18,16 +19,17 @@ <td> {{if .Tags}} <div class="tags"> - {{range (splitTags .Tags)}}<span class="tag">{{.}}</span>{{end}} + {{range .Tags}}<span class="tag">{{.}}</span>{{end}} </div> {{end}} </td> <td> + {{if .Draft}}<span class="badge badge-draft">Draft</span>{{else}}<span class="badge badge-published">Published</span>{{end}} + </td> + <td> <div class="actions"> - <a href="/admin/{{.Slug}}/edit" class="btn btn-secondary">Edit</a> - <form method="POST" action="/admin/{{.Slug}}/delete" onsubmit="return confirm('Delete {{.Title}}?')"> - <button type="submit" class="btn btn-danger">Delete</button> - </form> + <a href="/admin/{{.Slug}}" class="btn btn-secondary">Edit</a> + <button class="btn btn-danger" onclick="deletePost('{{.Slug}}', '{{.Title}}')">Delete</button> </div> </td> </tr> @@ -37,4 +39,13 @@ {{else}} <div class="empty">No posts yet. <a href="/admin/new">Create one.</a></div> {{end}} + + <script> + function deletePost(slug, title) { + if (!confirm('Delete "' + title + '"?')) return; + fetch('/admin/' + slug, { method: 'DELETE' }) + .then(() => window.location.href = '/admin/') + .catch(err => alert('Delete failed: ' + err)); + } + </script> {{end}} |
