Show recipe list above edit form in admin
This commit is contained in:
@@ -461,6 +461,34 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'delet
|
||||
<button type="submit" class="button" style="width: fit-content;">Save settings</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="list">
|
||||
<h2>Existing recipes (<?php echo count($allRecipes); ?>)</h2>
|
||||
<?php if (empty($allRecipes)): ?>
|
||||
<p>No recipes yet.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($allRecipes as $r): ?>
|
||||
<?php $display = localize_recipe($r, 'en'); ?>
|
||||
<div class="list-item">
|
||||
<div>
|
||||
<strong><?php echo e($display['title'] ?? $r['slug']); ?></strong>
|
||||
<span class="pill"><?php echo e($display['category'] ?? ''); ?></span>
|
||||
<?php if (!empty($r['featured'])): ?><span class="pill">Featured</span><?php endif; ?>
|
||||
<?php if (!empty($r['coming_soon'])): ?><span class="pill">Coming soon</span><?php endif; ?>
|
||||
</div>
|
||||
<div style="display:flex; gap:8px; align-items:center;">
|
||||
<small><?php echo e($r['slug']); ?></small>
|
||||
<a class="button" href="/admin.php?edit=<?php echo urlencode($r['slug']); ?>" style="padding:8px 12px;">Edit</a>
|
||||
<form method="post" style="margin:0;" onsubmit="return confirm('Delete this recipe?');">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="slug" value="<?php echo e($r['slug']); ?>">
|
||||
<button type="submit" class="button" style="padding:8px 12px;">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<form class="admin-form" method="post">
|
||||
<input type="hidden" name="action" value="save">
|
||||
<?php if ($editing): ?>
|
||||
@@ -558,34 +586,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'delet
|
||||
|
||||
<button type="submit" class="button" style="width: fit-content;"><?php echo $editing ? 'Save changes' : 'Save recipe'; ?></button>
|
||||
</form>
|
||||
|
||||
<div class="list">
|
||||
<h2>Existing recipes (<?php echo count($allRecipes); ?>)</h2>
|
||||
<?php if (empty($allRecipes)): ?>
|
||||
<p>No recipes yet.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($allRecipes as $r): ?>
|
||||
<?php $display = localize_recipe($r, 'en'); ?>
|
||||
<div class="list-item">
|
||||
<div>
|
||||
<strong><?php echo e($display['title'] ?? $r['slug']); ?></strong>
|
||||
<span class="pill"><?php echo e($display['category'] ?? ''); ?></span>
|
||||
<?php if (!empty($r['featured'])): ?><span class="pill">Featured</span><?php endif; ?>
|
||||
<?php if (!empty($r['coming_soon'])): ?><span class="pill">Coming soon</span><?php endif; ?>
|
||||
</div>
|
||||
<div style="display:flex; gap:8px; align-items:center;">
|
||||
<small><?php echo e($r['slug']); ?></small>
|
||||
<a class="button" href="/admin.php?edit=<?php echo urlencode($r['slug']); ?>" style="padding:8px 12px;">Edit</a>
|
||||
<form method="post" style="margin:0;" onsubmit="return confirm('Delete this recipe?');">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="slug" value="<?php echo e($r['slug']); ?>">
|
||||
<button type="submit" class="button" style="padding:8px 12px;">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user