chore(badges): remove legacy badge_id_only_search; sync remote badges config into badges_loc; docs update

This commit is contained in:
Scott Idem
2026-04-02 18:03:23 -04:00
parent 0ab8b936ce
commit c198ca2454
12 changed files with 254 additions and 86 deletions

View File

@@ -0,0 +1,18 @@
/**
* ae_events_stores__badges.svelte.ts
*
* Svelte 5 PersistedState store for Badge module local config.
* Replaces the `events_loc.badges` sub-object from the Svelte 4 persisted store.
*
* localStorage key: 'ae_badges_loc'
* Version gate: AE_BADGES_LOC_VERSION in store_versions.ts
*
* Usage:
* import { badges_loc } from '$lib/stores/ae_events_stores__badges.svelte';
* badges_loc.current.fulltext_search_qry_str // read
* badges_loc.current.search_version++ // write
*/
import { PersistedState } from 'runed';
import { badges_loc_defaults } from './ae_events_stores__badges_defaults';
export const badges_loc = new PersistedState('ae_badges_loc', badges_loc_defaults);

View File

@@ -1,11 +1,89 @@
/**
* ae_events_stores__badges_defaults.ts
*
* Default state for the badges (badge printing) section of ae_events_stores.ts.
* badges_loc_defaults → events_loc.badges (persisted to localStorage)
* badges_sess_defaults → events_sess.badges (in-memory, resets on page load)
* Type definitions and defaults for the Badges stores.
*
* BadgesRemoteCfg → shape of event.mod_badges_json (server-side admin config)
* BadgesLocState → badges_loc (PersistedState, localStorage key 'ae_badges_loc')
* BadgesSessState → events_sess.badges (in-memory, resets on page load)
*/
// ---------------------------------------------------------------------------
// Remote config — shape of event.mod_badges_json
// This is the admin-controlled, server-side config for an event.
// ---------------------------------------------------------------------------
export interface BadgesRemoteCfg {
// Search & UI behaviour
enable_mass_print: boolean; // show the mass-print controls
enable_add_badge_btn: boolean; // show the "Add Badge" button
enable_upload_badge_li_btn: boolean; // show the "Upload Badge List" button
enable_search_qr: boolean; // enable QR scan search
// QR code configuration
qr_type: string | null; // QR payload format (e.g. 'badge_id', 'url')
// Access control — passcodes for attendee / staff tiered access.
// Only expose to administrator_access. Never render for lower access levels.
trusted_passcode: string | null;
administrator_passcode: string | null;
// Field-level edit permissions per access tier.
// can_edit is a string[] of field keys, or '*' for all fields.
edit_permissions: {
authenticated?: { can_edit: string[] | '*' };
trusted?: { can_edit: string[] | '*' };
administrator?: { can_edit: string[] | '*' };
};
}
// Default field lists — used when edit_permissions is absent from mod_badges_json.
export const default_authenticated_can_edit: string[] = [
'pronouns_override',
'full_name_override',
'professional_title_override',
'affiliations_override',
'phone_override',
'location_override',
'allow_tracking',
'agree_to_tc'
];
export const default_trusted_can_edit: string[] = [
'pronouns_override',
'full_name_override',
'professional_title_override',
'affiliations_override',
'email_override',
'phone_override',
'location_override',
'badge_type_code_override',
'registration_type_code_override',
'other_1_code',
'other_2_code',
'other_3_code',
'other_4_code',
'other_5_code',
'other_6_code',
'other_7_code',
'other_8_code',
'ticket_1_code',
'ticket_2_code',
'ticket_3_code',
'ticket_4_code',
'ticket_5_code',
'ticket_6_code',
'ticket_7_code',
'ticket_8_code',
'allow_tracking',
'agree_to_tc',
'hide',
'priority',
'notes'
];
// ---------------------------------------------------------------------------
// Local state — persisted to localStorage via PersistedState ('ae_badges_loc')
// ---------------------------------------------------------------------------
export interface BadgesLocState {
auto_view: boolean;
show_hidden: boolean;
@@ -26,6 +104,21 @@ export interface BadgesLocState {
search_status: string | null;
search_complete: boolean;
classes__form: string;
// Server-mirrored flags (copied from event.mod_badges_json)
enable_mass_print: boolean;
enable_add_badge_btn: boolean;
enable_upload_badge_li_btn: boolean;
enable_search_qr: boolean;
qr_type: string | null;
trusted_passcode: string | null;
administrator_passcode: string | null;
edit_permissions: {
authenticated?: { can_edit: string[] | '*' };
trusted?: { can_edit: string[] | '*' };
administrator?: { can_edit: string[] | '*' };
} | null;
// Timestamp when the remote config was last mirrored locally
remote_cfg_last_synced_on: string | null;
}
export interface BadgesSessState {
@@ -43,6 +136,7 @@ export interface BadgesSessState {
}
// Persisted badge UI state — survives browser sessions.
// Stored in localStorage as 'ae_badges_loc' via PersistedState (runed).
export const badges_loc_defaults: BadgesLocState = {
auto_view: true,
@@ -73,6 +167,17 @@ export const badges_loc_defaults: BadgesLocState = {
search_complete: false,
classes__form: 'border border-surface-200 p-4 space-y-4 rounded-container'
,
// Default values for server-mirrored flags
enable_mass_print: true,
enable_add_badge_btn: true,
enable_upload_badge_li_btn: true,
enable_search_qr: true,
qr_type: null,
trusted_passcode: null,
administrator_passcode: null,
edit_permissions: null,
remote_cfg_last_synced_on: null
};
// In-memory badge state — resets on page load.

View File

@@ -34,6 +34,7 @@ export const AE_LOC_VERSION = 2; // Bumped 2026-03-30: force-clear stale site_cf
export const AE_EVENTS_LOC_VERSION = 1;
export const AE_IDAA_LOC_VERSION = 1; // Added 2026-03-30: was missing, no wipe mechanism existed
export const AE_PRES_MGMT_LOC_VERSION = 1; // Added 2026-04-02: new standalone PersistedState store
export const AE_BADGES_LOC_VERSION = 1; // Added 2026-04-02: promoted from events_loc.badges
// Version check side-effect: runs on import, before any persisted() call.
// Guard presence of `localStorage` and its functions for safety (SSR, Node flags).