Add menu enable toggle, user status, and mobile/UI polish

- Admin menu page: mobile item cards now put Actions in the top-right
  corner next to Status, matching the desktop row layout instead of
  stacking at the bottom; same treatment applied to announcements and
  users for consistency across all three admin lists
- Center button label text everywhere via .btn { justify-content: center }
  instead of one-off overrides
- Add a Disable/Enable Menu toggle to the admin menu toolbar; the public
  menu page shows its existing "menu being updated" message while disabled
- Add an Enabled/Disabled status to user accounts, with its own toggle
  badge, guardrails against disabling your own account or the last
  enabled account, and an immediate session kick for anyone disabled
  mid-session
- Fix the announcement banner / hero tagline "·" separators to hide only
  when their neighboring text actually wraps onto a different line,
  instead of a fixed breakpoint or always-on dot

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
David DyerandClaude Sonnet 5 committed 2026-09-01 14:10:08 -04:00
1 parent eab20899de
commit cd4c6c1969
13 files changed
+405 -50

No files matched your search

+42
View File
@@ -86,9 +86,51 @@ async function postForm(formData) {
return response.json();
}
// Applies a menu_enabled state to the toggle button and its alert banner —
// shared by the click handler below and, implicitly, the server-rendered
// initial state (see menu.php), so the two never drift apart.
function applyMenuEnabledState(enabled) {
const btn = document.getElementById('btn-toggle-menu');
btn.textContent = enabled ? 'Disable Menu' : 'Enable Menu';
btn.classList.toggle('btn-danger', enabled);
btn.classList.toggle('btn-outline', !enabled);
btn.dataset.enabled = enabled ? '1' : '0';
document.getElementById('menu-disabled-alert').hidden = enabled;
}
// Modal listeners
document.getElementById('btn-new-item').addEventListener('click', () => openItemModal());
document.getElementById('btn-new-cat').addEventListener('click', () => openCategoryModal());
document.getElementById('btn-toggle-menu').addEventListener('click', async (e) => {
const btn = e.currentTarget;
const isCurrentlyEnabled = btn.dataset.enabled === '1';
// Only the disabling direction needs a confirm — it immediately hides
// the menu from every visitor, where re-enabling it is harmless.
if (isCurrentlyEnabled && !confirm('Hide the menu from the public site? Visitors will see a "menu being updated" message until you re-enable it.')) {
return;
}
btn.disabled = true;
const fd = new FormData();
fd.append('action', 'toggle_menu_enabled');
fd.append('csrf_token', csrfToken);
try {
const data = await postForm(fd);
if (data.success) {
applyMenuEnabledState(data.menu_enabled);
} else {
alert(data.error || 'Failed to update menu visibility.');
}
} catch {
alert('Network error. Please try again.');
} finally {
btn.disabled = false;
}
});
document.getElementById('btn-create-first-cat')?.addEventListener('click', () => openCategoryModal());
document.getElementById('btn-close-item-modal').addEventListener('click', closeItemModal);
document.getElementById('btn-cancel-item').addEventListener('click', closeItemModal);