diff --git a/src/routes/events/[event_id]/(badges)/badges/+layout.svelte b/src/routes/events/[event_id]/(badges)/badges/+layout.svelte
index 2f8d28a2..72794b07 100644
--- a/src/routes/events/[event_id]/(badges)/badges/+layout.svelte
+++ b/src/routes/events/[event_id]/(badges)/badges/+layout.svelte
@@ -36,9 +36,13 @@
let lq__event_obj = $derived(
liveQuery(async () => {
if (log_lvl) {
- console.log(`*** LiveQuery: lq__event_obj *** event_id=${$events_slct.event_id}`);
+ console.log(
+ `*** LiveQuery: lq__event_obj *** event_id=${$events_slct.event_id}`
+ );
}
- let results = await db_events.event.get($events_slct?.event_id ?? '');
+ let results = await db_events.event.get(
+ $events_slct?.event_id ?? ''
+ );
return results;
})
diff --git a/src/routes/events/[event_id]/(badges)/badges/+page.svelte b/src/routes/events/[event_id]/(badges)/badges/+page.svelte
index a41e5f9c..7df7e68b 100644
--- a/src/routes/events/[event_id]/(badges)/badges/+page.svelte
+++ b/src/routes/events/[event_id]/(badges)/badges/+page.svelte
@@ -15,10 +15,7 @@
// *** Import Aether specific variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
- import {
- ae_loc,
- ae_api
- } from '$lib/stores/ae_stores';
+ import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import { db_events } from '$lib/ae_events/db_events';
import {
@@ -39,13 +36,20 @@
// *** Initialization & Store Guard ***
// Ensure all search fields are initialized to prevent circular undefined triggers
if ($events_loc.badges) {
- if (typeof $events_loc.badges.search_version === 'undefined') $events_loc.badges.search_version = 0;
- if (typeof $events_loc.badges.qry__remote_first === 'undefined') $events_loc.badges.qry__remote_first = false;
- if (typeof $events_loc.badges.fulltext_search_qry_str === 'undefined') $events_loc.badges.fulltext_search_qry_str = '';
- if (typeof $events_loc.badges.search_badge_type_code === 'undefined') $events_loc.badges.search_badge_type_code = '';
- if (typeof $events_loc.badges.qry_printed_status === 'undefined') $events_loc.badges.qry_printed_status = 'all';
- if (typeof $events_loc.badges.qry_affiliations === 'undefined') $events_loc.badges.qry_affiliations = '';
- if (typeof $events_loc.badges.qry_sort_order === 'undefined') $events_loc.badges.qry_sort_order = '';
+ if (typeof $events_loc.badges.search_version === 'undefined')
+ $events_loc.badges.search_version = 0;
+ if (typeof $events_loc.badges.qry__remote_first === 'undefined')
+ $events_loc.badges.qry__remote_first = false;
+ if (typeof $events_loc.badges.fulltext_search_qry_str === 'undefined')
+ $events_loc.badges.fulltext_search_qry_str = '';
+ if (typeof $events_loc.badges.search_badge_type_code === 'undefined')
+ $events_loc.badges.search_badge_type_code = '';
+ if (typeof $events_loc.badges.qry_printed_status === 'undefined')
+ $events_loc.badges.qry_printed_status = 'all';
+ if (typeof $events_loc.badges.qry_affiliations === 'undefined')
+ $events_loc.badges.qry_affiliations = '';
+ if (typeof $events_loc.badges.qry_sort_order === 'undefined')
+ $events_loc.badges.qry_sort_order = '';
}
// Variables
@@ -61,18 +65,28 @@
let lq__event_badge_obj_li = $derived.by(() => {
const ids = event_badge_id_li;
const event_id = $events_slct?.event_id;
-
+
return liveQuery(async () => {
// SCENARIO 1: Specific IDs provided (Search Results)
if (Array.isArray(ids) && ids.length > 0) {
- if (log_lvl) console.log(`Badge Page LQ: bulkGet ${ids.length} IDs`);
+ if (log_lvl)
+ console.log(`Badge Page LQ: bulkGet ${ids.length} IDs`);
const results = await db_events.badge.bulkGet(ids);
- return results.filter(item => item !== undefined);
+ return results.filter((item) => item !== undefined);
}
-
+
// SCENARIO 2: Fallback broad search (Only if no active filters)
- if (event_id && !$events_loc.badges.fulltext_search_qry_str && $events_loc.badges.qry_printed_status === 'all' && !$events_loc.badges.qry_affiliations && !$events_loc.badges.search_badge_type_code) {
- if (log_lvl) console.log(`Badge Page LQ: Fallback search for event: ${event_id}`);
+ if (
+ event_id &&
+ !$events_loc.badges.fulltext_search_qry_str &&
+ $events_loc.badges.qry_printed_status === 'all' &&
+ !$events_loc.badges.qry_affiliations &&
+ !$events_loc.badges.search_badge_type_code
+ ) {
+ if (log_lvl)
+ console.log(
+ `Badge Page LQ: Fallback search for event: ${event_id}`
+ );
return await db_events.badge
.where('event_id_random')
.equals(event_id)
@@ -88,7 +102,9 @@
// 1. Isolate dependencies into a stable derived object
let search_params = $derived({
v: $events_loc.badges.search_version,
- str: ($events_loc.badges.fulltext_search_qry_str ?? '').toLowerCase().trim(),
+ str: ($events_loc.badges.fulltext_search_qry_str ?? '')
+ .toLowerCase()
+ .trim(),
type: $events_loc.badges.search_badge_type_code,
printed: $events_loc.badges.qry_printed_status,
aff: ($events_loc.badges.qry_affiliations ?? '').toLowerCase().trim(),
@@ -122,9 +138,12 @@
const current_search_id = ++last_search_id;
const event_id = params.event_id;
const remote_first = params.remote_first;
-
- if (log_lvl) console.log(`[Badge Search #${current_search_id}] Refreshing (remote=${remote_first}, event=${event_id}, str=${params.str})...`);
-
+
+ if (log_lvl)
+ console.log(
+ `[Badge Search #${current_search_id}] Refreshing (remote=${remote_first}, event=${event_id}, str=${params.str})...`
+ );
+
untrack(() => {
$events_sess.badges.search_status = 'loading';
$events_sess.badges.search_complete = false;
@@ -142,36 +161,56 @@
let local_results = await db_events.badge
.where('event_id_random')
.equals(event_id)
- .filter(badge => {
- if (type_code && badge.badge_type_code !== type_code) return false;
-
+ .filter((badge) => {
+ if (
+ type_code &&
+ badge.badge_type_code !== type_code
+ )
+ return false;
+
if (printed_status !== 'all') {
const is_printed = (badge.print_count ?? 0) > 0;
- if (printed_status === 'printed' && !is_printed) return false;
- if (printed_status === 'not_printed' && is_printed) return false;
+ if (printed_status === 'printed' && !is_printed)
+ return false;
+ if (
+ printed_status === 'not_printed' &&
+ is_printed
+ )
+ return false;
}
-
+
if (qry_str) {
- const given_name = (badge.given_name ?? '').toLowerCase();
- const family_name = (badge.family_name ?? '').toLowerCase();
- const full_name = `${given_name} ${family_name}`.toLowerCase();
+ const given_name = (
+ badge.given_name ?? ''
+ ).toLowerCase();
+ const family_name = (
+ badge.family_name ?? ''
+ ).toLowerCase();
+ const full_name =
+ `${given_name} ${family_name}`.toLowerCase();
const email = (badge.email ?? '').toLowerCase();
- const qry_string = (badge.default_qry_str ?? '').toLowerCase();
-
- const match = full_name.includes(qry_str) ||
- given_name.includes(qry_str) ||
- family_name.includes(qry_str) ||
- email.includes(qry_str) ||
- qry_string.includes(qry_str);
-
+ const qry_string = (
+ badge.default_qry_str ?? ''
+ ).toLowerCase();
+
+ const match =
+ full_name.includes(qry_str) ||
+ given_name.includes(qry_str) ||
+ family_name.includes(qry_str) ||
+ email.includes(qry_str) ||
+ qry_string.includes(qry_str);
+
if (!match) return false;
}
-
+
if (aff_str) {
- const affiliations = (badge.affiliations ?? '').toLowerCase();
- if (!affiliations.includes(aff_str)) return false;
+ const affiliations = (
+ badge.affiliations ?? ''
+ ).toLowerCase();
+ if (!affiliations.includes(aff_str))
+ return false;
}
-
+
return true;
})
.toArray();
@@ -180,27 +219,57 @@
local_results.sort((a, b) => {
switch (params.sort) {
case 'name_asc':
- return (a.given_name ?? '').localeCompare(b.given_name ?? '') || (a.family_name ?? '').localeCompare(b.family_name ?? '');
+ return (
+ (a.given_name ?? '').localeCompare(
+ b.given_name ?? ''
+ ) ||
+ (a.family_name ?? '').localeCompare(
+ b.family_name ?? ''
+ )
+ );
case 'name_desc':
- return (b.given_name ?? '').localeCompare(a.given_name ?? '') || (b.family_name ?? '').localeCompare(a.family_name ?? '');
+ return (
+ (b.given_name ?? '').localeCompare(
+ a.given_name ?? ''
+ ) ||
+ (b.family_name ?? '').localeCompare(
+ a.family_name ?? ''
+ )
+ );
case 'updated_desc':
- return new Date(b.updated_on || 0).getTime() - new Date(a.updated_on || 0).getTime();
+ return (
+ new Date(b.updated_on || 0).getTime() -
+ new Date(a.updated_on || 0).getTime()
+ );
case 'updated_asc':
- return new Date(a.updated_on || 0).getTime() - new Date(b.updated_on || 0).getTime();
+ return (
+ new Date(a.updated_on || 0).getTime() -
+ new Date(b.updated_on || 0).getTime()
+ );
case 'print_count_desc':
- return (b.print_count ?? 0) - (a.print_count ?? 0);
+ return (
+ (b.print_count ?? 0) - (a.print_count ?? 0)
+ );
default:
- return (a.given_name ?? '').localeCompare(b.given_name ?? '');
+ return (a.given_name ?? '').localeCompare(
+ b.given_name ?? ''
+ );
}
});
- const local_ids = local_results.map(b => b.id || b.event_badge_id_random).filter(Boolean);
+ const local_ids = local_results
+ .map((b) => b.id || b.event_badge_id_random)
+ .filter(Boolean);
if (current_search_id === last_search_id) {
- if (log_lvl) console.log(`[Badge Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`);
+ if (log_lvl)
+ console.log(
+ `[Badge Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`
+ );
untrack(() => {
event_badge_id_li = local_ids;
- if (local_ids.length > 0) $events_sess.badges.search_status = 'done';
+ if (local_ids.length > 0)
+ $events_sess.badges.search_status = 'done';
});
}
}
@@ -218,12 +287,23 @@
// Map sort param to API order_by_li
let order_by_li: any = {};
switch (params.sort) {
- case 'name_asc': order_by_li = { given_name: 'ASC', family_name: 'ASC' }; break;
- case 'name_desc': order_by_li = { given_name: 'DESC', family_name: 'DESC' }; break;
- case 'updated_desc': order_by_li = { updated_on: 'DESC' }; break;
- case 'updated_asc': order_by_li = { updated_on: 'ASC' }; break;
- case 'print_count_desc': order_by_li = { print_count: 'DESC' }; break;
- default: order_by_li = { given_name: 'ASC' };
+ case 'name_asc':
+ order_by_li = { given_name: 'ASC', family_name: 'ASC' };
+ break;
+ case 'name_desc':
+ order_by_li = { given_name: 'DESC', family_name: 'DESC' };
+ break;
+ case 'updated_desc':
+ order_by_li = { updated_on: 'DESC' };
+ break;
+ case 'updated_asc':
+ order_by_li = { updated_on: 'ASC' };
+ break;
+ case 'print_count_desc':
+ order_by_li = { print_count: 'DESC' };
+ break;
+ default:
+ order_by_li = { given_name: 'ASC' };
}
const results = await events_func.search__event_badge({
@@ -240,15 +320,20 @@
if (current_search_id === last_search_id) {
const api_results = results || [];
- const api_ids = api_results.map((b: any) => b.id || b.event_badge_id_random).filter(Boolean);
-
+ const api_ids = api_results
+ .map((b: any) => b.id || b.event_badge_id_random)
+ .filter(Boolean);
+
untrack(() => {
$events_sess.badge_li = api_results;
event_badge_id_li = api_ids;
$events_sess.badges.search_status = 'done';
$events_sess.badges.search_complete = true;
});
- if (log_lvl) console.log(`[Badge Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`);
+ if (log_lvl)
+ console.log(
+ `[Badge Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`
+ );
}
} catch (error) {
if (current_search_id === last_search_id) {
@@ -265,24 +350,24 @@
Loading badges...
No IDB record found for ID: {event_badge_id}
diff --git a/src/routes/events/[event_id]/(badges)/badges/[badge_id]/ae_comp__badge_obj_view.svelte b/src/routes/events/[event_id]/(badges)/badges/[badge_id]/ae_comp__badge_obj_view.svelte index 9247af30..caf28e49 100644 --- a/src/routes/events/[event_id]/(badges)/badges/[badge_id]/ae_comp__badge_obj_view.svelte +++ b/src/routes/events/[event_id]/(badges)/badges/[badge_id]/ae_comp__badge_obj_view.svelte @@ -100,20 +100,27 @@ $effect(() => { if ($lq__event_badge_obj) { if (log_lvl) { - console.log('Initializing editable fields from lq__event_badge_obj'); + console.log( + 'Initializing editable fields from lq__event_badge_obj' + ); } editable_full_name_override = - $lq__event_badge_obj.full_name_override ?? $lq__event_badge_obj.full_name; + $lq__event_badge_obj.full_name_override ?? + $lq__event_badge_obj.full_name; editable_professional_title_override = $lq__event_badge_obj.professional_title_override ?? $lq__event_badge_obj.professional_title; editable_affiliations_override = - $lq__event_badge_obj.affiliations_override ?? $lq__event_badge_obj.affiliations; + $lq__event_badge_obj.affiliations_override ?? + $lq__event_badge_obj.affiliations; editable_location_override = - $lq__event_badge_obj.location_override ?? $lq__event_badge_obj.location; - editable_allow_tracking = $lq__event_badge_obj.allow_tracking ?? null; + $lq__event_badge_obj.location_override ?? + $lq__event_badge_obj.location; + editable_allow_tracking = + $lq__event_badge_obj.allow_tracking ?? null; editable_email = $lq__event_badge_obj.email ?? null; - editable_badge_type_code = $lq__event_badge_obj.badge_type_code ?? null; + editable_badge_type_code = + $lq__event_badge_obj.badge_type_code ?? null; if (is_review_mode) { edit_mode_active = true; @@ -137,7 +144,6 @@ let option_other_1_override = $state(''); let option_other_2_override = $state(''); - let slct_badge_type = ''; /* *** BEGIN *** This should be moved out */ @@ -154,8 +160,10 @@ code_to_html.option_1['1'] = ''; code_to_html.option_1['true'] = ''; code_to_html.option_1['True'] = ''; - code_to_html.option_1['Dairy Free'] = ''; - code_to_html.option_1['Gluten Free'] = ''; + code_to_html.option_1['Dairy Free'] = + ''; + code_to_html.option_1['Gluten Free'] = + ''; code_to_html.option_1['Halal'] = ''; code_to_html.option_1['Kosher'] = ''; code_to_html.option_1['Meat'] = ''; @@ -167,7 +175,8 @@ code_to_html.option_2['true'] = ''; code_to_html.option_2['True'] = ''; - code_to_html.option_2['First Time '] = ''; + code_to_html.option_2['First Time '] = + ''; /* *** END *** This should be moved out */ let full_name_class_size: string = $state('text-[.60in]'); @@ -177,7 +186,6 @@ // WARNING: This does not currently take into account the total lengths of the strings, only the longest part when split by spaces. This help with wrapping in the tighter spaces of the badge. - $effect(() => { // Re-calculate font sizes based on potentially edited values // Only run if we have the badge object @@ -190,11 +198,14 @@ $lq__event_badge_obj.professional_title ?? ''; const current_affiliations = - editable_affiliations_override ?? $lq__event_badge_obj.affiliations ?? ''; + editable_affiliations_override ?? + $lq__event_badge_obj.affiliations ?? + ''; const current_location = editable_location_override ?? $lq__event_badge_obj.location ?? ''; - let longest_full_name_override_part = longest_str_part(current_full_name); + let longest_full_name_override_part = + longest_str_part(current_full_name); if (longest_full_name_override_part >= 9) { full_name_class_size = 'text-[.45in]'; } else if (longest_full_name_override_part >= 7) { @@ -203,7 +214,9 @@ full_name_class_size = 'text-[.75in]'; } - let longest_professional_title_override_part = longest_str_part(current_professional_title); + let longest_professional_title_override_part = longest_str_part( + current_professional_title + ); if (longest_professional_title_override_part >= 13) { professional_title_class_size = 'text-[.35in]'; } else if (longest_professional_title_override_part >= 10) { @@ -214,7 +227,8 @@ professional_title_class_size = 'text-[.35in]'; } - let longest_affiliations_override_part = longest_str_part(current_affiliations); + let longest_affiliations_override_part = + longest_str_part(current_affiliations); if (longest_affiliations_override_part >= 55) { affiliations_class_size = 'text-[.30in]'; } else if (longest_affiliations_override_part >= 45) { @@ -260,7 +274,7 @@ // *** Functions and Logic function prevent_default- This was allowed at the time your badge - was printed. You may opt-out at anytime. + This was allowed at the time your badge was printed. + You may opt-out at anytime.
- By allowing this QR code to be scanned by an - exhibitor or staff, you understand and agree that - they may use your personal information. + By allowing this QR code to be + scanned by an exhibitor or + staff, you understand and agree + that they may use your personal + information.
{:else}- Tracking was not allowed at the time - your badge was printed. You may opt-in at anytime. + Tracking was not allowed at the time your badge was + printed. You may opt-in at anytime.
- If this QR code is scanned by an exhibitor or staff, - they will not have access to your information. + If this QR code is scanned by an + exhibitor or staff, they will not have access to your information.
{/if}Debug Information +{JSON.stringify($lq__event_badge_obj, null, 2)}-{JSON.stringify($lq__event_badge_template_obj, null, 2)}-