feat(events): reorganize badge admin tools and enhance dependency tracking
- Migrated 'Add New Badge' and 'Upload Badge List' to centralized Event Settings hub. - Secured Admin Tools visibility with Administrator access and Edit Mode requirements. - Restored and modernized Badge Template management route with Svelte 5 runes. - Patched 'Archive' and 'Session' database interfaces to resolve compiler errors. - Added project-wide dependency comments to key interfaces (Archive, Badge, Session) to prevent cascading change regressions. - Fixed duplicate import errors in the Settings page.
This commit is contained in:
@@ -58,7 +58,9 @@ export interface Archive {
|
||||
tmp_sort_2?: null | string;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
// archive_content_count?: number;
|
||||
topic_id?: null | string;
|
||||
topic_name?: null | string;
|
||||
archive_content_count?: number;
|
||||
// archive_content_kv?: null|key_val;
|
||||
// archive_content_li?: null|[];
|
||||
}
|
||||
|
||||
@@ -48,17 +48,17 @@ export async function load_ae_obj_id__event({
|
||||
const cached_event = await db_events.event.get(event_id);
|
||||
if (cached_event) {
|
||||
if (log_lvl) console.log('EVENT LOAD: Cache hit. Returning stale data immediately.');
|
||||
|
||||
|
||||
// Trigger background refresh
|
||||
_refresh_event_v3_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li,
|
||||
log_lvl: 0
|
||||
_refresh_event_v3_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li,
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
// Still handle nested loads for the cached version to ensure UI richness
|
||||
return await _handle_nested_loads(cached_event, {
|
||||
api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl
|
||||
return await _handle_nested_loads(cached_event, {
|
||||
api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -67,20 +67,20 @@ export async function load_ae_obj_id__event({
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: Wait for API if cache is empty or try_cache is false
|
||||
return await _refresh_event_v3_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li,
|
||||
log_lvl
|
||||
return await _refresh_event_v3_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal helper to perform the actual API fetch and cache update for events
|
||||
*/
|
||||
async function _refresh_event_v3_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li,
|
||||
log_lvl
|
||||
async function _refresh_event_v3_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li,
|
||||
log_lvl
|
||||
}: any) {
|
||||
// Check if offline
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) {
|
||||
@@ -113,9 +113,9 @@ async function _refresh_event_v3_background({
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return await _handle_nested_loads(processed_obj, {
|
||||
api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl
|
||||
|
||||
return await _handle_nested_loads(processed_obj, {
|
||||
api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl
|
||||
});
|
||||
}
|
||||
} catch (error: any) {
|
||||
@@ -128,6 +128,7 @@ async function _refresh_event_v3_background({
|
||||
* Shared logic for loading nested child collections
|
||||
*/
|
||||
async function _handle_nested_loads(event_obj: any, { api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl }: any) {
|
||||
if (log_lvl) console.log(`Loading nested collections for event: ${event_obj.event_id} (Devices: ${inc_device_li}, Files: ${inc_file_li}, Locations: ${inc_location_li}, Sessions: ${inc_session_li}, Templates: ${inc_template_li})`);
|
||||
// String-Only ID Vision: the '_id' field IS the string ID
|
||||
const current_event_id = event_obj.id || event_obj.event_id;
|
||||
|
||||
@@ -177,7 +178,7 @@ async function _handle_nested_loads(event_obj: any, { api_cfg, inc_device_li, in
|
||||
}
|
||||
|
||||
if (tasks.length > 0) await Promise.all(tasks);
|
||||
|
||||
|
||||
return event_obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,17 @@ import { load_ae_obj_id__event_badge_template } from '$lib/ae_events/ae_events__
|
||||
const ae_promises: key_val = {};
|
||||
|
||||
// Updated 2026-01-02
|
||||
/**
|
||||
* load_ae_obj_id__event_badge - Load a single event badge by ID
|
||||
* Related Files:
|
||||
* - src/lib/ae_events/db_events.ts (Dexie Interface)
|
||||
* - src/routes/events/[event_id]/(badges)/badges/[badge_id]/+page.svelte (View)
|
||||
* - src/routes/events/[event_id]/settings/+page.svelte (Admin Operations)
|
||||
*/
|
||||
export async function load_ae_obj_id__event_badge({
|
||||
api_cfg,
|
||||
event_badge_id,
|
||||
event_id, // This event_id should not be needed here... 2026-02-04
|
||||
view = 'base',
|
||||
inc_template = true,
|
||||
try_cache = true,
|
||||
@@ -20,6 +28,7 @@ export async function load_ae_obj_id__event_badge({
|
||||
}: {
|
||||
api_cfg: any;
|
||||
event_badge_id: string;
|
||||
event_id?: string;
|
||||
view?: string;
|
||||
inc_template?: boolean;
|
||||
try_cache?: boolean;
|
||||
@@ -41,8 +50,12 @@ export async function load_ae_obj_id__event_badge({
|
||||
|
||||
if (ae_promises.load__event_badge_obj) {
|
||||
if (try_cache) {
|
||||
// In theory we should be able to use the event_id found in the Badge load object. 2026-02-04
|
||||
// This keeps coming up as undefined: ae_promises.load__event_badge_obj.event_id_random
|
||||
if (log_lvl) console.log(`Saving to local cache... Event ID: ${event_id} or ${ae_promises.load__event_badge_obj.event_id_random}`);
|
||||
const processed_obj_li = await process_ae_obj__event_badge_props({
|
||||
obj_li: [ae_promises.load__event_badge_obj],
|
||||
event_id: event_id || ae_promises.load__event_badge_obj.event_id_random,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
@@ -603,6 +616,9 @@ export async function process_ae_obj__event_badge_props({
|
||||
obj_type: 'event_badge',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_badge_props() *** event_id=${event_id}`);
|
||||
}
|
||||
if (event_id) {
|
||||
if (!obj.event_id) obj.event_id = event_id;
|
||||
if (!obj.event_id_random) obj.event_id_random = event_id;
|
||||
|
||||
@@ -97,7 +97,13 @@ export interface Event {
|
||||
event_file_id_li_json?: null | string;
|
||||
}
|
||||
|
||||
// Updated 2025-10-06
|
||||
/**
|
||||
* Badge - An event badge
|
||||
* Related Files:
|
||||
* - src/lib/ae_events/ae_events__event_badge.ts (API)
|
||||
* - src/routes/events/[event_id]/(badges)/badges/[badge_id]/+page.svelte (View)
|
||||
* - src/routes/events/[event_id]/settings/+page.svelte (Admin)
|
||||
*/
|
||||
export interface Badge {
|
||||
id: string;
|
||||
// id_random: string;
|
||||
@@ -757,6 +763,7 @@ export interface Session {
|
||||
tmp_sort_2?: null | string;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
default_qry_str?: null | string;
|
||||
file_count?: null | number; // Only files directly under a session
|
||||
file_count_all?: null | number; // All files under a session
|
||||
internal_use_count?: null | number; // Files marked for internal use
|
||||
|
||||
@@ -779,6 +779,9 @@ export interface ae_Page extends ae_BaseObj {
|
||||
|
||||
/**
|
||||
* Archive - A collection of archival content
|
||||
* Related Files:
|
||||
* - src/lib/ae_archives/db_archives.ts (Dexie Interface)
|
||||
* - src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte (View)
|
||||
*/
|
||||
export interface ae_Archive extends ae_BaseObj {
|
||||
archive_id: string;
|
||||
|
||||
Reference in New Issue
Block a user