Merge pull request 'Admin Pages list on phones: one card per page' (#18) from admin-mobile-pages-list into main
Reviewed-on: #18
This commit is contained in:
commit
cbc0f1b44e
1 changed files with 41 additions and 17 deletions
|
|
@ -24,7 +24,45 @@
|
|||
<div class="alert alert-error mb-4" role="alert">{form.message}</div>
|
||||
{/if}
|
||||
|
||||
<div class="overflow-x-auto rounded-box bg-base-100 shadow">
|
||||
{#snippet actions(page: (typeof data.pages)[number])}
|
||||
<a class="btn btn-sm" href={`/pages/${page.slug}`}>Edit</a>
|
||||
{#if siteUrl && page.published}
|
||||
<a class="btn btn-sm" href={publicUrl(page.slug)} target="_blank" rel="noopener" title="Open on the live site">View</a>
|
||||
{/if}
|
||||
<form method="POST" action="?/toggle">
|
||||
<input type="hidden" name="id" value={page.id} />
|
||||
<input type="hidden" name="published" value={page.published} />
|
||||
<button class="btn btn-sm btn-outline" type="submit">{page.published ? 'Unpublish' : 'Publish'}</button>
|
||||
</form>
|
||||
<form method="POST" action="?/delete" onsubmit={confirmSubmit(`Delete the page "${page.title}"? This cannot be undone.`)}>
|
||||
<input type="hidden" name="id" value={page.id} />
|
||||
<button class="btn btn-sm btn-error btn-outline" type="submit">Delete</button>
|
||||
</form>
|
||||
{/snippet}
|
||||
|
||||
{#snippet status(page: (typeof data.pages)[number])}
|
||||
<span class="badge" class:badge-success={page.published}>{page.published ? 'Published' : 'Draft'}</span>
|
||||
{/snippet}
|
||||
|
||||
<!-- Phones: one card per page, buttons under the title (a four-column table didn't fit). -->
|
||||
<ul class="divide-y divide-base-200 rounded-box bg-base-100 shadow md:hidden">
|
||||
{#each data.pages as page (page.id)}
|
||||
<li class="p-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<a class="min-w-0" href={`/pages/${page.slug}`}>
|
||||
<span class="block font-semibold break-words">{page.title}</span>
|
||||
<span class="block font-mono text-sm break-all text-base-content/60">/{page.slug}</span>
|
||||
</a>
|
||||
<span class="shrink-0">{@render status(page)}</span>
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap gap-2">{@render actions(page)}</div>
|
||||
</li>
|
||||
{:else}
|
||||
<li class="py-10 text-center text-base-content/60">No pages yet — create your first one.</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<div class="hidden overflow-x-auto rounded-box bg-base-100 shadow md:block">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr><th>Slug</th><th>Title</th><th>Status</th><th class="text-right">Actions</th></tr>
|
||||
|
|
@ -34,23 +72,9 @@
|
|||
<tr>
|
||||
<td class="font-mono">{page.slug}</td>
|
||||
<td>{page.title}</td>
|
||||
<td><span class="badge" class:badge-success={page.published}>{page.published ? 'Published' : 'Draft'}</span></td>
|
||||
<td>{@render status(page)}</td>
|
||||
<td>
|
||||
<div class="flex flex-wrap justify-end gap-2">
|
||||
<a class="btn btn-sm" href={`/pages/${page.slug}`}>Edit</a>
|
||||
{#if siteUrl && page.published}
|
||||
<a class="btn btn-sm" href={publicUrl(page.slug)} target="_blank" rel="noopener" title="Open on the live site">View</a>
|
||||
{/if}
|
||||
<form method="POST" action="?/toggle">
|
||||
<input type="hidden" name="id" value={page.id} />
|
||||
<input type="hidden" name="published" value={page.published} />
|
||||
<button class="btn btn-sm btn-outline" type="submit">{page.published ? 'Unpublish' : 'Publish'}</button>
|
||||
</form>
|
||||
<form method="POST" action="?/delete" onsubmit={confirmSubmit(`Delete the page "${page.title}"? This cannot be undone.`)}>
|
||||
<input type="hidden" name="id" value={page.id} />
|
||||
<button class="btn btn-sm btn-error btn-outline" type="submit">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="flex flex-wrap justify-end gap-2 xl:flex-nowrap">{@render actions(page)}</div>
|
||||
</td>
|
||||
</tr>
|
||||
{:else}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue