Show recipe list above edit form in admin

This commit is contained in:
2026-03-23 16:30:19 +01:00
parent f4c40fe8eb
commit b03fe9315e
+28 -28
View File
@@ -461,6 +461,34 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'delet
<button type="submit" class="button" style="width: fit-content;">Save settings</button> <button type="submit" class="button" style="width: fit-content;">Save settings</button>
</form> </form>
<?php else: ?> <?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"> <form class="admin-form" method="post">
<input type="hidden" name="action" value="save"> <input type="hidden" name="action" value="save">
<?php if ($editing): ?> <?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> <button type="submit" class="button" style="width: fit-content;"><?php echo $editing ? 'Save changes' : 'Save recipe'; ?></button>
</form> </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; ?> <?php endif; ?>
</body> </body>
</html> </html>