fix(badges): trusted staff visibility driven by filter, not edit mode

Edit mode should not override the filter state — staff set their
filters and turn off edit mode all the time. The real split is
trusted staff vs kiosk/public, not edit mode on/off.

Trusted and above: qry_printed_status is the sole control over
printed badge visibility, regardless of edit mode state.

Public (kiosk) / authenticated / anonymous: always unprinted only.
Badge kiosks run at public_access and should never expose a list
of already-printed badges to attendees.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-04-13 19:44:30 -04:00
parent ae00ddffb0
commit 6aeaef6f1d

View File

@@ -96,21 +96,20 @@ let visible_badge_obj_li = $derived(
if (list === undefined || list === null) return null;
if (!Array.isArray(list)) return [];
// The Printed Status filter dropdown is accessible to: trusted+edit OR manager+.
// Match that gate here so the filter actually controls what's displayed.
const can_use_filter = (is_trusted && is_edit_mode) || $ae_loc.manager_access;
const filtered = list.filter((item: any) => {
if (!item) return false;
if (can_use_filter) {
// Filter dropdown controls visibility for users who can access it.
if (is_trusted) {
// Trusted staff and above: qry_printed_status is the authoritative control.
// Filter state persists across edit mode toggles — intentional. Staff set
// their filter and it stays regardless of whether edit mode is on or off.
const ps = badges_loc.current.qry_printed_status;
if (ps === 'printed') return (item.print_count ?? 0) >= 1 && !item.hide;
if (ps === 'not_printed') return (item.print_count ?? 0) < 1 && !item.hide;
return !item.hide; // 'all' — show everything non-hidden
}
// Kiosk / attendee / below-trusted: only unprinted badges.
// The filter dropdown is not visible at these access levels, so
// qry_printed_status is not a reliable signal here.
// Public (kiosk) / authenticated / anonymous: only unprinted.
// Badge kiosks run at public_access — attendees should only see their own
// unprinted badge, never a list of already-printed ones.
return (item.print_count ?? 0) < 1 && !item.hide;
});