+
+
+
+
+
+
+ {#if is_admin}
+
+
+ Print Count
+ Admin · timestamps unchanged
+
+
+ {
+ const v = Math.max(0, Math.round(Number((e.currentTarget as HTMLInputElement).value)));
+ if (v !== print_count) save_field('print_count', { print_count: v });
+ }}
+ onkeydown={(e) => { if (e.key === 'Enter') (e.currentTarget as HTMLInputElement).blur(); }}
+ disabled={field_save_status['print_count'] === 'saving'}
+ class="input input-sm w-20 text-center font-mono" />
+ {#if field_save_status['print_count'] === 'saving'}
+
+ {:else if field_save_status['print_count'] === 'done'}
+
+ {/if}
+
+
+ {/if}
+
diff --git a/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_obj_li.svelte b/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_obj_li.svelte
index cb31ad11..eaa52937 100644
--- a/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_obj_li.svelte
+++ b/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_obj_li.svelte
@@ -19,11 +19,10 @@ let {
hide_badge_type = false
}: Props = $props();
-import { ae_loc, ae_api } from '$lib/stores/ae_stores';
+import { ae_loc } from '$lib/stores/ae_stores';
import { events_loc } from '$lib/stores/ae_events_stores';
import { badges_loc } from '$lib/stores/ae_events_stores__badges.svelte';
import { ae_util } from '$lib/ae_utils/ae_utils';
-import { events_func } from '$lib/ae_events/ae_events_functions';
import {
Check,
Eye,
@@ -42,55 +41,9 @@ let copy_status: Record
= $state({});
// Access level shortcuts
let is_trusted = $derived($ae_loc.trusted_access === true);
-let is_admin = $derived($ae_loc.administrator_access === true);
let is_public = $derived($ae_loc.public_access === true); // public passcode or higher — may print first prints
let is_edit_mode = $derived($ae_loc.edit_mode === true);
-// Per-badge async action states
-let hide_status: Record = $state({});
-let print_count_status: Record = $state({});
-
-async function toggle_badge_hide(badge_obj: any) {
- const id = badge_obj.event_badge_id;
- if (!id || hide_status[id] === 'loading') return;
- hide_status[id] = 'loading';
- try {
- await events_func.update_ae_obj__event_badge({
- api_cfg: $ae_api,
- event_id: badge_obj.event_id,
- event_badge_id: id,
- data_kv: { hide: !badge_obj.hide },
- log_lvl
- });
- } catch (e) {
- console.error('Failed to toggle hide:', e);
- }
- hide_status[id] = 'idle';
-}
-
-// Admin-only: edit the raw print count. Does NOT touch timestamps — those are
-// only set by the actual print action. This is a correction tool (e.g. "badge
-// was printed offline, count needs to match reality").
-async function save_print_count(badge_obj: any, new_count: number) {
- const id = badge_obj.event_badge_id;
- if (!id || print_count_status[id] === 'saving') return;
- const count = Math.max(0, Math.round(new_count));
- if (count === (badge_obj.print_count ?? 0)) return; // no-op
- print_count_status[id] = 'saving';
- try {
- await events_func.update_ae_obj__event_badge({
- api_cfg: $ae_api,
- event_id: badge_obj.event_id,
- event_badge_id: id,
- data_kv: { print_count: count },
- log_lvl
- });
- } catch (e) {
- console.error('Failed to update print count:', e);
- }
- print_count_status[id] = 'idle';
-}
-
/**
* Obscures an email address for display to non-trusted users.
* e.g. john.doe@example.com → joh***@example.com
@@ -320,25 +273,6 @@ let visible_badge_obj_li = $derived(
{/if}
-
- {#if is_trusted && is_edit_mode}
-
- {/if}
-
{#if is_trusted && is_edit_mode}
PC:
- {#if is_admin}
- save_print_count(event_badge_obj, Number((e.currentTarget as HTMLInputElement).value))}
- onkeydown={(e) => { if (e.key === 'Enter') (e.currentTarget as HTMLInputElement).blur(); }}
- disabled={print_count_status[event_badge_obj.event_badge_id] === 'saving'}
- class="w-14 rounded border border-surface-300 bg-surface-100 px-1 text-center font-mono text-[10px] dark:border-surface-700 dark:bg-surface-800"
- title="Edit print count (Admin+). Does not change timestamps." />
- {#if print_count_status[event_badge_obj.event_badge_id] === 'saving'}
-
- {/if}
- {:else}
- {print_count}
- {/if}
+ {print_count}
FP: