refactor(events, idaa): standardize on String-only IDs and remove '_random' suffix

Aligned the Events Badges, Templates, and IDAA Bulletin Board modules with
Aether UI/UX v3 standards by prioritizing semantic String IDs (e.g., event_id,
badge_id) over legacy '_random' variants in API helpers, Dexie processors,
and UI components.

- Refactored badge and template loaders to use clean ID field names.
- Updated search and LiveQuery logic in badge management views.
- Cleaned up unused imports and legacy code in +layout and +page components.
- Standardized ID mapping in generic object processors.
- Improved IDAA post creation UX with autofocus and empty title defaults.
This commit is contained in:
Scott Idem
2026-02-13 13:51:55 -05:00
parent de947c827a
commit 6bfd13f52c
16 changed files with 224 additions and 226 deletions

View File

@@ -51,11 +51,11 @@ 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}`);
// This keeps coming up as undefined: ae_promises.load__event_badge_obj.event_id
if (log_lvl) console.log(`Saving to local cache... Event ID: ${event_id} or ${ae_promises.load__event_badge_obj.event_id}`);
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,
event_id: event_id || ae_promises.load__event_badge_obj.event_id,
log_lvl
});
await db_save_ae_obj_li__ae_obj({
@@ -85,7 +85,7 @@ export async function load_ae_obj_id__event_badge({
if (inc_template && ae_promises.load__event_badge_obj) {
// Load the templates for the event badge
const current_template_id = ae_promises.load__event_badge_obj.event_badge_template_id || ae_promises.load__event_badge_obj.event_badge_template_id_random;
const current_template_id = ae_promises.load__event_badge_obj.event_badge_template_id;
if (current_template_id) {
ae_promises.load__event_badge_obj.event_badge_template = await load_ae_obj_id__event_badge_template({
api_cfg: api_cfg,
@@ -187,7 +187,7 @@ export async function load_ae_obj_li__event_badge({
if (inc_template && ae_promises.load__event_badge_obj_li) {
for (const badge_obj of ae_promises.load__event_badge_obj_li) {
const current_template_id = badge_obj.event_badge_template_id || badge_obj.event_badge_template_id_random;
const current_template_id = badge_obj.event_badge_template_id;
if (current_template_id) {
badge_obj.event_badge_template = await load_ae_obj_id__event_badge_template({
api_cfg: api_cfg,
@@ -388,7 +388,7 @@ export async function search__event_badge({
const search_query: any = {
q: '',
and: [{ field: 'event_id_random', op: 'eq', value: event_id }]
and: [{ field: 'event_id', op: 'eq', value: event_id }]
};
const params: key_val = {};
@@ -577,7 +577,7 @@ async function _process_generic_props<T extends Record<string, any>>({
(processed_obj as any)[newKey] = processed_obj[key];
}
}
const randomIdKey = `${obj_type}_id_random`;
const randomIdKey = `${obj_type}_id`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
@@ -621,7 +621,7 @@ export async function process_ae_obj__event_badge_props({
}
if (event_id) {
if (!obj.event_id) obj.event_id = event_id;
if (!obj.event_id_random) obj.event_id_random = event_id;
// if (!obj.event_id_random) obj.event_id_random = event_id;
}
return obj;
}

View File

@@ -74,7 +74,7 @@ async function _process_generic_props<T extends Record<string, any>>({
(processed_obj as any)[newKey] = processed_obj[key];
}
}
const randomIdKey = `${obj_type}_id_random`;
const randomIdKey = `${obj_type}_id`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
@@ -129,7 +129,7 @@ export async function load_ae_obj_id__event_badge_template({
if (log_lvl) {
console.log(`*** load_ae_obj_id__event_badge_template() *** [V3] id=${event_badge_template_id}`);
}
try {
ae_promises.load__event_badge_template_obj = await api.get_ae_obj_v3({
api_cfg,
@@ -161,7 +161,7 @@ export async function load_ae_obj_id__event_badge_template({
ae_promises.load__event_badge_template_obj = await db_events.badge_template.get(event_badge_template_id);
}
}
return ae_promises.load__event_badge_template_obj || null;
}
@@ -235,7 +235,7 @@ export async function load_ae_obj_li__event_badge_template({
.toArray();
}
}
return ae_promises.load__event_badge_template_obj_li || [];
}
@@ -257,7 +257,7 @@ export async function create_ae_obj__event_badge_template({
api_cfg,
obj_type: 'event_badge_template',
fields: {
event_id_random: event_id,
event_id: event_id,
...data_kv
},
log_lvl
@@ -376,7 +376,7 @@ export async function search__event_badge_template({
}) {
const search_query: any = {
q: qry_str,
and: [{ field: 'event_id_random', op: 'eq', value: event_id }]
and: [{ field: 'event_id', op: 'eq', value: event_id }]
};
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: true });

View File

@@ -11,9 +11,7 @@ const ae_promises: key_val = {};
export const properties_to_save_exhibit = [
'id',
'event_exhibit_id',
// 'event_exhibit_id_random',
'event_id',
// 'event_id_random',
'code',
'name',
'description',
@@ -74,7 +72,7 @@ async function _process_generic_props<T extends Record<string, any>>({
// 2. Primary Key Mapping (Dexie compatible)
const randomIdKey = `${obj_type}_id_random`;
const baseIdKey = `${obj_type}_id`;
// Prioritize the base ID field as the primary source of truth
if (processed_obj[baseIdKey]) {
(processed_obj as any).id = String(processed_obj[baseIdKey]);