refactor(search): standardize debounced reactive search across modules
- Standardized the search pattern using Svelte 5 debounced $effects in Recovery Meetings, Badge Search, and Journals to eliminate manual triggers and stuttering. - Fixed a bug in 'ae_idaa_comp__event_obj_li.svelte' where the Results count was inconsistent with the displayed list by implementing a derived 'visible_event_obj_li' state. - Hardened 'ae_idaa_comp__event_obj_li_wrapper.svelte' to filter out 'undefined' entries from database 'bulkGet' calls. - Cleaned up legacy search handling code in 'ae_idaa_comp__event_obj_qry.svelte'. - Updated 'TODO.md' and 'GEMINI.md' to reflect search logic hardening accomplishments.
This commit is contained in:
@@ -165,65 +165,81 @@
|
||||
};
|
||||
}
|
||||
|
||||
// Trigger doing a search query for event badges
|
||||
// Debounced Search Logic (Refactored 2026-01-27)
|
||||
let search_debounce_timer: any = null;
|
||||
let last_search_id = 0;
|
||||
|
||||
$effect(() => {
|
||||
if (ae_triggers.event_badge_qry) {
|
||||
ae_triggers.event_badge_qry = false;
|
||||
search_status = 'loading';
|
||||
search_complete = false;
|
||||
event_badge_id_li = [];
|
||||
// Reactive dependencies
|
||||
const s_qry_str = qry_str;
|
||||
const s_qry_type_code = qry_type_code;
|
||||
const s_qry_printed_status = qry_printed_status;
|
||||
const s_qry_affiliations = qry_affiliations;
|
||||
const s_qry_sort_order = qry_sort_order;
|
||||
const s_event_id = event_id;
|
||||
const s_trigger = ae_triggers.event_badge_qry;
|
||||
|
||||
// qry_str = $events_loc.badges.fulltext_search_qry_str ?? '';
|
||||
// qry_type_code = $events_sess.badges.search_badge_type_code ?? '';
|
||||
// Debounce search
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
|
||||
// Manual trigger or threshold check for automatic search
|
||||
const should_search = s_trigger ||
|
||||
s_qry_str.length === 0 ||
|
||||
s_qry_str.length >= 3 ||
|
||||
s_qry_affiliations.length >= 3;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`Triggered: event_badge_qry: ft search qry str:=${$events_loc.badges.fulltext_search_qry_str} sort order:=`,
|
||||
computed_order_by_li
|
||||
);
|
||||
}
|
||||
|
||||
// ae_promises.load__event_badge_obj_li = events_func.qry__event_badge({
|
||||
ae_promises.load__event_badge_obj_li = events_func
|
||||
.search__event_badge({
|
||||
api_cfg: $ae_api,
|
||||
event_id: event_id,
|
||||
fulltext_search_qry_str: qry_str,
|
||||
type_code: qry_type_code,
|
||||
printed_status: qry_printed_status,
|
||||
affiliations_qry_str: qry_affiliations,
|
||||
order_by_li: computed_order_by_li,
|
||||
limit: search_limit,
|
||||
log_lvl: 2
|
||||
})
|
||||
.then(function (search_results) {
|
||||
search_status = 'processing';
|
||||
let tmp_event_badge_id_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
for (let i = 0; i < search_results.length; i++) {
|
||||
let event_badge_obj = search_results[i];
|
||||
let event_badge_id_random = event_badge_obj.event_badge_id_random;
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`Found badge: ${event_badge_obj.full_name}, id_random: ${event_badge_id_random}`
|
||||
);
|
||||
}
|
||||
tmp_event_badge_id_li.push(event_badge_id_random);
|
||||
}
|
||||
event_badge_id_li = tmp_event_badge_id_li;
|
||||
console.log('event_badge_id_li', event_badge_id_li);
|
||||
|
||||
$events_sess.badge_li = search_results;
|
||||
|
||||
return search_results;
|
||||
})
|
||||
.finally(() => {
|
||||
search_status = 'done';
|
||||
search_complete = true;
|
||||
});
|
||||
if (should_search) {
|
||||
search_debounce_timer = setTimeout(() => {
|
||||
ae_triggers.event_badge_qry = false;
|
||||
handle_search_refresh();
|
||||
}, 400);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
};
|
||||
});
|
||||
|
||||
async function handle_search_refresh() {
|
||||
const current_search_id = ++last_search_id;
|
||||
|
||||
if (log_lvl) console.log(`[Badge Search #${current_search_id}] ft=${qry_str}`);
|
||||
|
||||
search_status = 'loading';
|
||||
search_complete = false;
|
||||
|
||||
try {
|
||||
const results = await events_func.search__event_badge({
|
||||
api_cfg: $ae_api,
|
||||
event_id: event_id,
|
||||
fulltext_search_qry_str: qry_str,
|
||||
type_code: qry_type_code,
|
||||
printed_status: qry_printed_status,
|
||||
affiliations_qry_str: qry_affiliations,
|
||||
order_by_li: computed_order_by_li,
|
||||
limit: search_limit,
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
if (current_search_id === last_search_id) {
|
||||
let tmp_event_badge_id_li = results.map((b: any) => b.event_badge_id_random);
|
||||
|
||||
event_badge_id_li = tmp_event_badge_id_li;
|
||||
$events_sess.badge_li = results;
|
||||
|
||||
search_status = 'done';
|
||||
search_complete = true;
|
||||
if (log_lvl) console.log(`[Badge Search #${current_search_id}] Done. Found ${results.length} results.`);
|
||||
}
|
||||
} catch (error) {
|
||||
if (current_search_id === last_search_id) {
|
||||
console.error('Badge search failed:', error);
|
||||
search_status = 'error';
|
||||
search_complete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handle_qr_scan_result(event: CustomEvent) {
|
||||
console.log('*** handle_qr_scan_result() ***');
|
||||
|
||||
|
||||
@@ -68,300 +68,77 @@
|
||||
let event_id_random_li: Array<string> = $state([]);
|
||||
|
||||
// *** Functions and Logic
|
||||
// let lq_new__event_obj_li = $derived(liveQuery(async () => {
|
||||
// let link_to_type: string = 'account';
|
||||
// let link_to_id: string = $ae_lock.account_id;
|
||||
// if (log_lvl > 1) {
|
||||
// console.log(`link_to_type: ${link_to_type}; link_to_id: ${link_to_id}; event_id_random_li:`, event_id_random_li);
|
||||
// }
|
||||
|
||||
// // Check if event_id_random_li is an array and not undefined
|
||||
// if (event_id_random_li) {
|
||||
// if (log_lvl) {
|
||||
// console.log(`Trying bulkGet:`, event_id_random_li);
|
||||
// }
|
||||
// let results = await db_events.event
|
||||
// .bulkGet(event_id_random_li);
|
||||
// Debounced Search Logic (Refactored 2026-01-27)
|
||||
let search_debounce_timer: any = null;
|
||||
let last_search_id = 0;
|
||||
|
||||
// return results;
|
||||
// } else if (link_to_type && link_to_id) {
|
||||
// if (log_lvl) {
|
||||
// console.log(`Trying where: ${link_to_type}; equals: ${link_to_id}`);
|
||||
// }
|
||||
// let results: any = null;
|
||||
// if ($idaa_loc.recovery_meetings.qry__order_by == 'name') {
|
||||
// results = await db_events.event
|
||||
// .where(`${link_to_type}_id`)
|
||||
// .equals(link_to_id)
|
||||
// .and((event) => {
|
||||
// return event.hide == false;
|
||||
// })
|
||||
// .and((event) => {
|
||||
// return event.enable == true;
|
||||
// })
|
||||
// .sortBy('name')
|
||||
// } else {
|
||||
// results = await db_events.event
|
||||
// .where(`${link_to_type}_id`)
|
||||
// .equals(link_to_id)
|
||||
// .and((event) => {
|
||||
// return event.hide == false;
|
||||
// })
|
||||
// .and((event) => {
|
||||
// return event.enable == true;
|
||||
// })
|
||||
// .sortBy('updated_on')
|
||||
// }
|
||||
|
||||
// return results;
|
||||
// } else {
|
||||
// if (log_lvl) {
|
||||
// console.log('Trying... Nothing to load');
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }));
|
||||
|
||||
// let lq__event_obj = $derived(liveQuery(async () => {
|
||||
// let results = await db_events.event
|
||||
// .get($idaa_slct.event_id ?? '');
|
||||
|
||||
// return results;
|
||||
// }));
|
||||
|
||||
// This (event_li trigger for IDAA) is not currently being used.
|
||||
// Updated 2024-11-19
|
||||
// $effect(() => {
|
||||
// if ($idaa_trig.event_li) {
|
||||
// $idaa_trig.event_li = false;
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log(`Triggered: $idaa_trig.event_li`);
|
||||
// }
|
||||
|
||||
// if ($idaa_loc.recovery_meetings.qry__enabled !== 'all' || $idaa_loc.recovery_meetings.qry__hidden !== 'all') {
|
||||
// console.log(`Deleting disabled or hidden event.`);
|
||||
// let results = db_events.event
|
||||
// .clear();
|
||||
// console.log(`Deleted ${results} disabled event.`);
|
||||
|
||||
// }
|
||||
|
||||
// $idaa_prom.load__event_obj_li = events_func.load_ae_obj_li__event({
|
||||
// api_cfg: $ae_api,
|
||||
// for_obj_type: 'account',
|
||||
// for_obj_id: $ae_loc.account_id,
|
||||
// qry_conference: false,
|
||||
// enabled: $idaa_loc.recovery_meetings.qry__enabled,
|
||||
// hidden: $idaa_loc.recovery_meetings.qry__hidden,
|
||||
// limit: $idaa_loc.recovery_meetings.qry__limit,
|
||||
// order_by_li: $idaa_loc.recovery_meetings.qry__order_by_li,
|
||||
// try_cache: true,
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
// Updated 2024-11-19
|
||||
$effect(() => {
|
||||
if ($idaa_trig.event_li_qry) {
|
||||
$idaa_trig.event_li_qry = false;
|
||||
// Reactive dependencies
|
||||
const qry_str = $idaa_loc.recovery_meetings.qry__fulltext_str;
|
||||
const qry_physical = $idaa_loc.recovery_meetings.qry__physical;
|
||||
const qry_virtual = $idaa_loc.recovery_meetings.qry__virtual;
|
||||
const qry_type = $idaa_loc.recovery_meetings.qry__type;
|
||||
const qry_enabled = $idaa_loc.recovery_meetings.qry__enabled;
|
||||
const qry_hidden = $idaa_loc.recovery_meetings.qry__hidden;
|
||||
const qry_limit = $idaa_loc.recovery_meetings.qry__limit;
|
||||
const qry_order_by_li = $idaa_loc.recovery_meetings.qry__order_by_li;
|
||||
const account_id = $ae_loc.account_id;
|
||||
const s_trigger = $idaa_trig.event_li_qry;
|
||||
|
||||
log_lvl = 2;
|
||||
// Trigger search on parameter change (debounced)
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
search_debounce_timer = setTimeout(() => {
|
||||
handle_search_refresh();
|
||||
}, 350);
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Triggered: $idaa_trig.event_li_qry`);
|
||||
}
|
||||
|
||||
// $idaa_sess.recovery_meetings.qry__status = 'loading';
|
||||
|
||||
let and_physical = $idaa_loc.recovery_meetings.qry__physical;
|
||||
let and_virtual = $idaa_loc.recovery_meetings.qry__virtual;
|
||||
let and_type = $idaa_loc.recovery_meetings.qry__type;
|
||||
let fulltext_str = $idaa_loc.recovery_meetings.qry__fulltext_str?.trim() ?? null;
|
||||
let enabled = $idaa_loc.recovery_meetings.qry__enabled;
|
||||
let hidden = $idaa_loc.recovery_meetings.qry__hidden;
|
||||
let limit = $idaa_loc.recovery_meetings.qry__limit;
|
||||
let order_by_li = $idaa_loc.recovery_meetings.qry__order_by_li;
|
||||
let search_delay = 15;
|
||||
let max_tries = 5;
|
||||
|
||||
if (enabled !== 'all' || hidden !== 'all') {
|
||||
console.log(`Deleting disabled or hidden event.`);
|
||||
let results = db_events.event.clear();
|
||||
console.log(`Deleted ${results} disabled event.`);
|
||||
}
|
||||
|
||||
if (
|
||||
$idaa_sess.recovery_meetings?.qry__status != null &&
|
||||
$idaa_sess.recovery_meetings?.qry__status != 'done'
|
||||
) {
|
||||
console.log(
|
||||
'*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != done ***'
|
||||
);
|
||||
// WARNING: This is a temporary fix for the search string. It needs to be fixed in the future. Using lk_search_str for now.
|
||||
$idaa_sess.recovery_meetings.status_qry__last_request_str = fulltext_str;
|
||||
|
||||
// We want to delay the initial search request to give the previous search request to finish.
|
||||
let random_delay = Math.floor(Math.random() * 50);
|
||||
search_delay += 50 + random_delay;
|
||||
}
|
||||
|
||||
event_id_random_li = []; // Resetting this seems to help trigger the new results to show correctly??? 2025-07-10
|
||||
|
||||
let count = 0;
|
||||
let request_loop = setInterval(() => {
|
||||
count++;
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** TEST SEARCH - Search delay: ${search_delay} *** loop count=${count}`
|
||||
);
|
||||
}
|
||||
if (count >= max_tries) {
|
||||
console.log('*** TEST SEARCH - Max tries reached ***');
|
||||
clearInterval(request_loop);
|
||||
}
|
||||
|
||||
if (
|
||||
$idaa_sess.recovery_meetings?.qry__status != null &&
|
||||
$idaa_sess.recovery_meetings?.qry__status != 'done'
|
||||
) {
|
||||
let random_delay = Math.floor(Math.random() * 25);
|
||||
search_delay += 25 + random_delay;
|
||||
console.log(
|
||||
`*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status == loading wait *** search_delay=${search_delay}`
|
||||
);
|
||||
// $idaa_sess.status_qry__last_request_str = fulltext_str;
|
||||
} else {
|
||||
console.log(
|
||||
'*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != loading ***'
|
||||
);
|
||||
|
||||
$idaa_sess.recovery_meetings.qry__status = 'loading';
|
||||
// event_id_random_li = [];
|
||||
|
||||
and_physical ?? null;
|
||||
and_virtual ?? null;
|
||||
and_type ?? null;
|
||||
// if (and_type) and_type = and_type;
|
||||
// if (!and_type) {
|
||||
// and_type = null;
|
||||
// }
|
||||
|
||||
console.log(
|
||||
`TEST - and_physical: ${and_physical}; and_virtual: ${and_virtual}; and_type: ${and_type}; qry__fulltext_str: ${fulltext_str}`
|
||||
);
|
||||
|
||||
$idaa_prom.load__event_obj_qry = events_func
|
||||
.search__event({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
|
||||
qry_conference: false,
|
||||
qry_physical: and_physical,
|
||||
qry_virtual: and_virtual,
|
||||
qry_type: and_type,
|
||||
qry_str: fulltext_str,
|
||||
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
limit: limit,
|
||||
order_by_li: order_by_li,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (search_results) {
|
||||
// Processing the results from the search.
|
||||
$idaa_sess.recovery_meetings.qry__status = 'processing';
|
||||
$idaa_slct.event_obj_li = search_results;
|
||||
if (log_lvl) {
|
||||
console.log(`Found ${search_results.length} matching events.`);
|
||||
console.log(
|
||||
'TEST SEARCH - Search done. Need to pull out the id_random list for bulk load.'
|
||||
);
|
||||
}
|
||||
event_id_random_li = generate_id_random_li({
|
||||
event_obj_li: search_results
|
||||
});
|
||||
|
||||
// $idaa_sess.recovery_meetings.qry__status = 'done';
|
||||
|
||||
// if (log_lvl) {
|
||||
//
|
||||
// }
|
||||
// console.log(`TEST search: ${$lq_kv__event_obj_li}`);
|
||||
|
||||
// event_id_random_li = [];
|
||||
|
||||
// // We need to loop through the array of objects and get the event_id_random from each object a new list of event_id_randoms. Then we can use this list to get the full objects from the database.
|
||||
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
// if (search_results && search_results.length) {
|
||||
// for (let i = 0; i < search_results.length; i++) {
|
||||
// tmp_li.push($idaa_slct.event_obj_li[i].event_id_random);
|
||||
// }
|
||||
// }
|
||||
// event_id_random_li = tmp_li;
|
||||
})
|
||||
.finally(() => {
|
||||
// event_id_random_li = $idaa_slct.event_obj_li.map(session_obj => session_obj.event_id_random);
|
||||
|
||||
// Finally done with the search.
|
||||
$idaa_sess.recovery_meetings.qry__status = 'done';
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log(
|
||||
`TEST SEARCH - qry__status: ${$idaa_sess.recovery_meetings.qry__status} event_id_random_li:`,
|
||||
event_id_random_li
|
||||
);
|
||||
// console.log(`TEST SEARCH - search live query: ${$lq_kv__event_obj_li}`);
|
||||
}
|
||||
});
|
||||
clearInterval(request_loop);
|
||||
}
|
||||
}, search_delay);
|
||||
}
|
||||
return () => {
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
};
|
||||
});
|
||||
|
||||
// $effect(() => {
|
||||
// if ($idaa_sess.recovery_meetings.qry__status == 'done') {
|
||||
// if (log_lvl) {
|
||||
// console.log(`*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status == done ***`);
|
||||
// }
|
||||
// // We are done with the search.
|
||||
// $idaa_sess.recovery_meetings.qry__status = null;
|
||||
async function handle_search_refresh() {
|
||||
const current_search_id = ++last_search_id;
|
||||
|
||||
if (log_lvl) console.log(`[Search #${current_search_id}] Refreshing recovery meetings...`);
|
||||
|
||||
$idaa_sess.recovery_meetings.qry__status = 'loading';
|
||||
|
||||
// Clearing logic for hidden/disabled filter changes
|
||||
if ($idaa_loc.recovery_meetings.qry__enabled !== 'all' || $idaa_loc.recovery_meetings.qry__hidden !== 'all') {
|
||||
await db_events.event.clear();
|
||||
}
|
||||
|
||||
// // We need to loop through the array of objects and get the event_id_random from each object a new list of event_id_randoms. Then we can use this list to get the full objects from the database.
|
||||
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
// if ($idaa_slct.event_obj_li && $idaa_slct.event_obj_li.length) {
|
||||
// event_id_random_li = [];
|
||||
// // console.log(`TEST SEARCH - Get ids:`, $idaa_slct.event_obj_li);
|
||||
// for (let i = 0; i < $idaa_slct.event_obj_li.length; i++) {
|
||||
// tmp_li.push($idaa_slct.event_obj_li[i].event_id_random);
|
||||
// }
|
||||
// }
|
||||
// event_id_random_li = tmp_li;
|
||||
// // console.log(`TEST search: event_id_random_li`, $state.snapshot(event_id_random_li));
|
||||
// }
|
||||
// });
|
||||
try {
|
||||
const results = await events_func.search__event({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
qry_conference: false,
|
||||
qry_physical: $idaa_loc.recovery_meetings.qry__physical,
|
||||
qry_virtual: $idaa_loc.recovery_meetings.qry__virtual,
|
||||
qry_type: $idaa_loc.recovery_meetings.qry__type,
|
||||
qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str?.trim() ?? null,
|
||||
enabled: $idaa_loc.recovery_meetings.qry__enabled,
|
||||
hidden: $idaa_loc.recovery_meetings.qry__hidden,
|
||||
limit: $idaa_loc.recovery_meetings.qry__limit,
|
||||
order_by_li: $idaa_loc.recovery_meetings.qry__order_by_li,
|
||||
log_lvl: 0 // Keep noise low during typing
|
||||
});
|
||||
|
||||
function generate_id_random_li({
|
||||
event_obj_li = $idaa_slct.event_obj_li
|
||||
}: {
|
||||
event_obj_li?: Array<any>;
|
||||
} = {}) {
|
||||
let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
// We need to loop through the array of objects and get the id_random from each object a new list of id_randoms. Then we can use this list to get the full objects from the database.
|
||||
if (event_obj_li && event_obj_li.length) {
|
||||
for (let i = 0; i < event_obj_li.length; i++) {
|
||||
tmp_li.push(event_obj_li[i].event_id_random);
|
||||
// Race condition check: only update if this is still the latest request
|
||||
if (current_search_id === last_search_id) {
|
||||
$idaa_slct.event_obj_li = results;
|
||||
event_id_random_li = results.map((e: any) => e.event_id_random);
|
||||
$idaa_sess.recovery_meetings.qry__status = 'done';
|
||||
if (log_lvl) console.log(`[Search #${current_search_id}] Done. Found ${results.length} results.`);
|
||||
}
|
||||
} catch (error) {
|
||||
if (current_search_id === last_search_id) {
|
||||
console.error('Search failed:', error);
|
||||
$idaa_sess.recovery_meetings.qry__status = 'error';
|
||||
}
|
||||
}
|
||||
if (log_lvl) {
|
||||
console.log(`generate_id_random_li:`, tmp_li);
|
||||
}
|
||||
|
||||
return tmp_li;
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
@@ -369,15 +146,9 @@
|
||||
|
||||
let message = { event_id: $idaa_slct?.event_id ?? null };
|
||||
window.parent.postMessage(message, '*');
|
||||
|
||||
// add_activity_log(
|
||||
// {
|
||||
// action: 'idaa_meetings_page',
|
||||
// action_with: 'browser',
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
|
||||
function add_activity_log({
|
||||
action = 'idaa_meetings_page',
|
||||
action_with = 'none'
|
||||
|
||||
@@ -38,17 +38,26 @@
|
||||
import { idaa_loc, idaa_sess, idaa_slct, idaa_trig } from '$lib/stores/ae_idaa_stores';
|
||||
import MyClipboard from '$lib/app_components/e_app_clipboard.svelte';
|
||||
|
||||
// Derived list of visible items (Refactored 2026-01-27)
|
||||
// Ensures count matches exactly what is rendered to the user
|
||||
let visible_event_obj_li = $derived((() => {
|
||||
if (!$lq__event_obj_li) return [];
|
||||
return $lq__event_obj_li
|
||||
.filter((item: any) => {
|
||||
if (!item) return false;
|
||||
// If not trusted, exclude hidden or disabled items
|
||||
if (!$ae_loc.trusted_access) {
|
||||
return !item.hide && item.enable;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.slice(0, $idaa_loc.recovery_meetings.qry__limit);
|
||||
})());
|
||||
|
||||
if (browser) {
|
||||
if (log_lvl) {
|
||||
console.log(`link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`);
|
||||
}
|
||||
|
||||
// add_activity_log(
|
||||
// {
|
||||
// action: 'idaa_meetings_page',
|
||||
// action_with: 'search',
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
function add_activity_log({
|
||||
@@ -72,10 +81,7 @@
|
||||
name: `IDAA: ${$idaa_loc.novi_full_name ?? 'none'} ${$idaa_loc.novi_email ?? ''}`,
|
||||
description: activity_description ?? null,
|
||||
object_type: 'event', // archive, post, event
|
||||
// object_id_random: data?.params?.event_id ?? null,
|
||||
// object_id_random: ae_acct.slct.archive_id, // data?.params?.archive_id ?? null,
|
||||
url_root: data?.url.origin,
|
||||
// url_full_path: data?.url.href,
|
||||
url_full_path: data?.url.pathname,
|
||||
url_params: data?.url.searchParams.toString(),
|
||||
action: action,
|
||||
@@ -87,11 +93,6 @@
|
||||
last_cache_refresh_locale: last_cache_refresh_iso.toLocaleString(),
|
||||
access_level: $ae_loc?.access_level,
|
||||
iframe: $ae_loc?.iframe
|
||||
// site_access_key: $ae_loc?.site_access_key,
|
||||
// site_domain_access_key: $ae_loc?.site_domain_access_key,
|
||||
// site_domain: $ae_loc?.site_domain,
|
||||
// extra_data: extra_data ?? '',
|
||||
// log_lvl: log_lvl,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -111,26 +112,22 @@
|
||||
{container_class_li}
|
||||
"
|
||||
>
|
||||
<!-- {#if Array.isArray(event_id_random_li) && event_id_random_li.length} -->
|
||||
{#if $lq__event_obj_li && $lq__event_obj_li.length}
|
||||
{#if visible_event_obj_li && visible_event_obj_li.length}
|
||||
<div class="space-y-2">
|
||||
<h2 class="h3">
|
||||
<span class="text-base text-gray-500"> Results: </span>
|
||||
|
||||
{#if $lq__event_obj_li?.length}
|
||||
<span
|
||||
class="text-3xl font-bold bg-success-100 px-4 border rounded-lg border-success-200"
|
||||
title="Count {($lq__event_obj_li.length > $idaa_loc.recovery_meetings.qry__limit ? $idaa_loc.recovery_meetings.qry__limit : $lq__event_obj_li.length) ?? 'None'}"
|
||||
>
|
||||
<span class="fas fa-list-ol mx-4"></span>
|
||||
{($lq__event_obj_li.length > $idaa_loc.recovery_meetings.qry__limit ? $idaa_loc.recovery_meetings.qry__limit : $lq__event_obj_li.length) ?? 'None'}
|
||||
</span>
|
||||
{/if}
|
||||
<span
|
||||
class="text-3xl font-bold bg-success-100 px-4 border rounded-lg border-success-200"
|
||||
title="Visible Count {visible_event_obj_li.length}"
|
||||
>
|
||||
<span class="fas fa-list-ol mx-4"></span>
|
||||
{visible_event_obj_li.length}
|
||||
</span>
|
||||
</h2>
|
||||
|
||||
{#each $lq__event_obj_li as idaa_event_obj, index}
|
||||
{#if idaa_event_obj && index < $idaa_loc.recovery_meetings.qry__limit}
|
||||
<!-- This check for the idaa_event_obj is here in case the IDB entry is deleted. -->
|
||||
{#each visible_event_obj_li as idaa_event_obj, index}
|
||||
{#if idaa_event_obj}
|
||||
<div
|
||||
class="container recovery_meeting event_obj border rounded-lg p-2 mb-2 space-y-2 w-full max-w-(--breakpoint-lg) flex flex-col items-center justify-center bg-white"
|
||||
class:hidden={(idaa_event_obj?.hide || !idaa_event_obj?.enable) &&
|
||||
@@ -168,7 +165,6 @@
|
||||
>
|
||||
<span class="fas fa-exclamation-triangle m-1"></span>
|
||||
Not Confirmed by IDAA
|
||||
<!-- Unknown Status -->
|
||||
<span class="fas fa-exclamation-triangle m-1"></span>
|
||||
</span>
|
||||
{/if}
|
||||
@@ -222,23 +218,12 @@
|
||||
"
|
||||
title={`View: ${idaa_event_obj?.name}`}
|
||||
>
|
||||
<!-- <span class="fas fa-envelope-open m-1"></span> -->
|
||||
<span class="fas fa-calendar-check m-1 text-neutral-800/80"></span>
|
||||
<!-- <span class="fas fa-info-circle"></span> -->
|
||||
Meeting Details
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<section class="ae_section event__content w-full">
|
||||
<!-- <div
|
||||
class="meeting_description description"
|
||||
>
|
||||
<div class="ae_label event__description">Description:</div>
|
||||
<pre class="ae_value event__description">
|
||||
{@html idaa_event_obj?.description}
|
||||
</pre>
|
||||
</div> -->
|
||||
|
||||
<div class="event__type" class:ae_d_none={!idaa_event_obj?.type}>
|
||||
<span class="ae_label">Type of Recovery Meeting:</span>
|
||||
<span class="ae_value">{idaa_event_obj?.type}</span>
|
||||
@@ -253,7 +238,6 @@
|
||||
Zoom Meeting:
|
||||
</span>
|
||||
<span class="ae_value">
|
||||
<!-- text-blue-800 hover:underline -->
|
||||
<a
|
||||
href={idaa_event_obj?.attend_json?.zoom?.full_url}
|
||||
target="_blank"
|
||||
@@ -267,9 +251,7 @@
|
||||
"
|
||||
>
|
||||
<span class="fas fa-link m-1"></span>
|
||||
<!-- {idaa_event_obj?.attend_json?.zoom?.full_url} -->
|
||||
Join: Zoom ID {idaa_event_obj?.attend_json?.zoom
|
||||
?.meeting_id}
|
||||
Join: Zoom ID {idaa_event_obj?.attend_json?.zoom?.meeting_id}
|
||||
{#if idaa_event_obj?.attend_json?.zoom?.passcode}
|
||||
Passcode: {idaa_event_obj?.attend_json?.zoom?.passcode}
|
||||
{/if}
|
||||
@@ -300,7 +282,6 @@
|
||||
Jitsi Meeting:
|
||||
</span>
|
||||
<span class="ae_value">
|
||||
<!-- text-blue-800 hover:underline -->
|
||||
<a
|
||||
href={idaa_event_obj?.attend_json?.jitsi?.full_url}
|
||||
target="_blank"
|
||||
@@ -314,9 +295,7 @@
|
||||
"
|
||||
>
|
||||
<span class="fas fa-link m-1"></span>
|
||||
<!-- {idaa_event_obj?.attend_json?.jitsi?.full_url} -->
|
||||
Join: {idaa_event_obj?.attend_json?.jitsi?.name ??
|
||||
'Jitsi Meeting'}
|
||||
Join: {idaa_event_obj?.attend_json?.jitsi?.name ?? 'Jitsi Meeting'}
|
||||
{#if idaa_event_obj?.attend_json?.jitsi?.passcode}
|
||||
Passcode: {idaa_event_obj?.attend_json?.jitsi?.passcode}
|
||||
{/if}
|
||||
@@ -343,36 +322,19 @@
|
||||
<span class="fas fa-clock m-1"></span>
|
||||
When:
|
||||
</span>
|
||||
<!-- class:ae_d_none={!idaa_event_obj?.timezone} -->
|
||||
{#if idaa_event_obj?.weekday_sunday || idaa_event_obj?.weekday_monday || idaa_event_obj?.weekday_tuesday || idaa_event_obj?.weekday_wednesday || idaa_event_obj?.weekday_thursday || idaa_event_obj?.weekday_friday || idaa_event_obj?.weekday_saturday}
|
||||
<span class="event__weekdays event__recurring_days_of_week">
|
||||
<!-- <span class="ae_label">Days of week:</span> -->
|
||||
{#if idaa_event_obj?.weekday_sunday}<span class="ae_value"
|
||||
>Sunday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_monday}<span class="ae_value"
|
||||
>Monday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_tuesday}<span class="ae_value"
|
||||
>Tuesday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_wednesday}<span
|
||||
class="ae_value">Wednesday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_thursday}<span class="ae_value"
|
||||
>Thursday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_friday}<span class="ae_value"
|
||||
>Friday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_saturday}<span class="ae_value"
|
||||
>Saturday</span
|
||||
>{/if}
|
||||
{#if idaa_event_obj?.weekday_sunday}<span class="ae_value">Sunday</span>{/if}
|
||||
{#if idaa_event_obj?.weekday_monday}<span class="ae_value">Monday</span>{/if}
|
||||
{#if idaa_event_obj?.weekday_tuesday}<span class="ae_value">Tuesday</span>{/if}
|
||||
{#if idaa_event_obj?.weekday_wednesday}<span class="ae_value">Wednesday</span>{/if}
|
||||
{#if idaa_event_obj?.weekday_thursday}<span class="ae_value">Thursday</span>{/if}
|
||||
{#if idaa_event_obj?.weekday_friday}<span class="ae_value">Friday</span>{/if}
|
||||
{#if idaa_event_obj?.weekday_saturday}<span class="ae_value">Saturday</span>{/if}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{#if idaa_event_obj?.recurring_start_time}
|
||||
<!-- <span class="ae_label">Time:</span> -->
|
||||
<span class="ae_value"
|
||||
>{ae_util.iso_datetime_formatter(
|
||||
`2023-01-01 ${idaa_event_obj?.recurring_start_time}`,
|
||||
@@ -381,7 +343,6 @@
|
||||
>
|
||||
{/if}
|
||||
{#if idaa_event_obj?.timezone}
|
||||
<!-- <span class="ae_label">Timezone:</span> -->
|
||||
(<span class="ae_value">{idaa_event_obj?.timezone}</span>)
|
||||
{:else}
|
||||
<div class="event__tiemzone ae_warning bg-warning-100">
|
||||
@@ -394,8 +355,7 @@
|
||||
{#if idaa_event_obj?.contact_li_json && idaa_event_obj?.contact_li_json.length && idaa_event_obj?.contact_li_json[0].full_name}
|
||||
<div
|
||||
class="event__contact"
|
||||
class:ae_d_none={!idaa_event_obj?.contact_li_json[0]
|
||||
.full_name}
|
||||
class:ae_d_none={!idaa_event_obj?.contact_li_json[0].full_name}
|
||||
>
|
||||
<span class="ae_label">
|
||||
<span class="fas fa-user m-1"></span> Contact:
|
||||
@@ -403,8 +363,7 @@
|
||||
{idaa_event_obj?.contact_li_json[0].full_name}
|
||||
{#if idaa_event_obj?.contact_li_json[0].email}
|
||||
| <a
|
||||
href="mailto:{idaa_event_obj?.contact_li_json[0]
|
||||
.email}?Subject=IDAA: {idaa_event_obj?.name}"
|
||||
href="mailto:{idaa_event_obj?.contact_li_json[0].email}?Subject=IDAA: {idaa_event_obj?.name}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[0].email}
|
||||
</a>
|
||||
@@ -412,18 +371,15 @@
|
||||
{#if idaa_event_obj?.contact_li_json[0].phone_mobile}
|
||||
<span class="ae_label">| Mobile:</span>
|
||||
<a
|
||||
href="tel:{idaa_event_obj?.contact_li_json[0]
|
||||
.phone_mobile}"
|
||||
href="tel:{idaa_event_obj?.contact_li_json[0].phone_mobile}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[0]
|
||||
.phone_mobile}</a
|
||||
>{idaa_event_obj?.contact_li_json[0].phone_mobile}</a
|
||||
>
|
||||
{/if}
|
||||
{#if idaa_event_obj?.contact_li_json[0].phone_home}
|
||||
<span class="ae_label">| Home:</span>
|
||||
<a
|
||||
href="tel:{idaa_event_obj?.contact_li_json[0]
|
||||
.phone_home}"
|
||||
href="tel:{idaa_event_obj?.contact_li_json[0].phone_home}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[0].phone_home}</a
|
||||
>
|
||||
@@ -431,30 +387,23 @@
|
||||
{#if idaa_event_obj?.contact_li_json[0].phone_office}
|
||||
<span class="ae_label">| Office:</span>
|
||||
<a
|
||||
href="tel:{idaa_event_obj?.contact_li_json[0]
|
||||
.phone_office}"
|
||||
href="tel:{idaa_event_obj?.contact_li_json[0].phone_office}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[0]
|
||||
.phone_office}</a
|
||||
>{idaa_event_obj?.contact_li_json[0].phone_office}</a
|
||||
>
|
||||
{/if}
|
||||
{#if idaa_event_obj?.contact_li_json[0].other_text}| {idaa_event_obj
|
||||
?.contact_li_json[0].other_text}{/if}
|
||||
{#if idaa_event_obj?.contact_li_json[0].other_text}| {idaa_event_obj?.contact_li_json[0].other_text}{/if}
|
||||
</div>
|
||||
{:else if $ae_loc.trusted_access}
|
||||
<div class="event__contact ae_warning bg-warning-100">
|
||||
ALERT: The primary contact information may be missing? This
|
||||
meeting should be checked and updated. Please Edit and Save
|
||||
to use the new format.
|
||||
<!-- This must be done by March 1, 2024. -->
|
||||
ALERT: The primary contact information may be missing?
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if idaa_event_obj?.contact_li_json && idaa_event_obj?.contact_li_json.length && idaa_event_obj?.contact_li_json[1].full_name}
|
||||
<div
|
||||
class="event__contact"
|
||||
class:ae_d_none={!idaa_event_obj?.contact_li_json[1]
|
||||
.full_name}
|
||||
class:ae_d_none={!idaa_event_obj?.contact_li_json[1].full_name}
|
||||
>
|
||||
<span class="ae_label">
|
||||
<span class="fas fa-user m-1"></span> Contact:
|
||||
@@ -462,8 +411,7 @@
|
||||
{idaa_event_obj?.contact_li_json[1].full_name}
|
||||
{#if idaa_event_obj?.contact_li_json[1].email}
|
||||
| <a
|
||||
href="mailto:{idaa_event_obj?.contact_li_json[1]
|
||||
.email}?Subject=IDAA: {idaa_event_obj?.name}"
|
||||
href="mailto:{idaa_event_obj?.contact_li_json[1].email}?Subject=IDAA: {idaa_event_obj?.name}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[1].email}
|
||||
</a>
|
||||
@@ -471,18 +419,15 @@
|
||||
{#if idaa_event_obj?.contact_li_json[1].phone_mobile}
|
||||
<span class="ae_label">| Mobile:</span>
|
||||
<a
|
||||
href="tel:{idaa_event_obj?.contact_li_json[1]
|
||||
.phone_mobile}"
|
||||
href="tel:{idaa_event_obj?.contact_li_json[1].phone_mobile}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[1]
|
||||
.phone_mobile}</a
|
||||
>{idaa_event_obj?.contact_li_json[1].phone_mobile}</a
|
||||
>
|
||||
{/if}
|
||||
{#if idaa_event_obj?.contact_li_json[1].phone_home}
|
||||
<span class="ae_label">| Home:</span>
|
||||
<a
|
||||
href="tel:{idaa_event_obj?.contact_li_json[1]
|
||||
.phone_home}"
|
||||
href="tel:{idaa_event_obj?.contact_li_json[1].phone_home}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[1].phone_home}</a
|
||||
>
|
||||
@@ -490,15 +435,12 @@
|
||||
{#if idaa_event_obj?.contact_li_json[1].phone_office}
|
||||
<span class="ae_label">| Office:</span>
|
||||
<a
|
||||
href="tel:{idaa_event_obj?.contact_li_json[1]
|
||||
.phone_office}"
|
||||
href="tel:{idaa_event_obj?.contact_li_json[1].phone_office}"
|
||||
class="text-blue-800 hover:underline"
|
||||
>{idaa_event_obj?.contact_li_json[1]
|
||||
.phone_office}</a
|
||||
>{idaa_event_obj?.contact_li_json[1].phone_office}</a
|
||||
>
|
||||
{/if}
|
||||
{#if idaa_event_obj?.contact_li_json[1].other_text}| {idaa_event_obj
|
||||
?.contact_li_json[1].other_text}{/if}
|
||||
{#if idaa_event_obj?.contact_li_json[1].other_text}| {idaa_event_obj?.contact_li_json[1].other_text}{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if $ae_loc.trusted_access}
|
||||
@@ -520,21 +462,6 @@
|
||||
<section
|
||||
class="ae_section ae_footer ae_meta event__meta text-sm text-neutral-500"
|
||||
>
|
||||
<!-- {#if idaa_event_obj.location_address_json}
|
||||
<span
|
||||
class="event__location_address_json"
|
||||
>
|
||||
Found location JSON: {idaa_event_obj.location_address_json}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{#if idaa_event_obj.contact_li_json && idaa_event_obj.contact_li_json.length}
|
||||
<span
|
||||
class="event__contact_li_json"
|
||||
>
|
||||
Found contact JSON: {idaa_event_obj.contact_li_json}
|
||||
</span>
|
||||
{/if} -->
|
||||
<div class="ae_group">
|
||||
<span class="event__created_on">
|
||||
Created on: {ae_util.iso_datetime_formatter(
|
||||
@@ -559,11 +486,9 @@
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<!-- Does this actually ever show? -->
|
||||
<div class="space-y-2">
|
||||
{#if $idaa_sess.recovery_meetings.qry__status === 'loading'}
|
||||
<div class="ae_highlight ae_padding_md ae_row ae_flex_justify_center">
|
||||
<!-- <Spinner class="m-3" /> -->
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
Loading...
|
||||
</div>
|
||||
@@ -584,23 +509,11 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ae_header h3 {
|
||||
/* font-size: 1.2em; */
|
||||
/* margin: 0; */
|
||||
/* padding: 0; */
|
||||
}
|
||||
|
||||
.event_obj .ae_meta {
|
||||
flex-direction: column;
|
||||
/* justify-content: space-between; */
|
||||
}
|
||||
|
||||
.event_obj .ae_meta .ae_group {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
/* .event_obj .ae_meta .ae_options {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
} */
|
||||
</style>
|
||||
</style>
|
||||
@@ -64,9 +64,10 @@
|
||||
// if (!event_id_random_li.length) {
|
||||
// return [];
|
||||
// }
|
||||
let results = await db_events.event.bulkGet(event_id_random_li);
|
||||
|
||||
return results;
|
||||
const results = await db_events.event.bulkGet(event_id_random_li);
|
||||
|
||||
// Filter out undefined items (holes in bulkGet)
|
||||
return results.filter(item => item !== undefined);
|
||||
} else if (link_to_type && link_to_id) {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
|
||||
@@ -36,16 +36,7 @@
|
||||
|
||||
import Help_tech from '$lib/app_components/e_app_help_tech.svelte';
|
||||
|
||||
// export let event_id_random_li: Array<string>;
|
||||
|
||||
// export let container_class_li = [];
|
||||
|
||||
let ae_promises: key_val = $state({});
|
||||
// let ae_tmp: key_val = {};
|
||||
// let ae_trigger: any = null;
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
// let search_submit_results: any = null;
|
||||
|
||||
if (
|
||||
$idaa_loc.recovery_meetings?.save_search_text &&
|
||||
@@ -69,163 +60,6 @@
|
||||
fn(event);
|
||||
};
|
||||
}
|
||||
|
||||
// if ($idaa_loc.recovery_meetings.qry__fulltext_str && $idaa_loc.recovery_meetings.qry__fulltext_str.length) {
|
||||
// $idaa_trig.event_li_qry = true;
|
||||
// }
|
||||
|
||||
// Updated 2024-10-01
|
||||
// $: if (ae_trigger == 'load__event_obj_li') {
|
||||
// if (log_lvl) {
|
||||
// console.log('*** TEST SEARCH - load__event_obj_li == load__event_obj_li ***');
|
||||
// }
|
||||
// ae_trigger = null;
|
||||
// $idaa_trig.event_li_qry = true;
|
||||
// if ($idaa_sess.recovery_meetings.qry_status == 'loading') {
|
||||
// console.log('*** $idaa_sess.recovery_meetings.qry_status == loading ***');
|
||||
|
||||
// setTimeout(() => {
|
||||
// console.log("Delayed for X second.");
|
||||
// // ae_trigger = null;
|
||||
// // handle_qry__event({ft_qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str});
|
||||
// $idaa_trig.event_li_qry = true;
|
||||
// }, 250);
|
||||
// } else {
|
||||
// console.log('*** $idaa_sess.recovery_meetings.qry_status != loading ***');
|
||||
// // ae_trigger = null;
|
||||
// // handle_qry__event({ft_qry_str: $idaa_loc.recovery_meetings.qry__fulltext_str});
|
||||
// $idaa_trig.event_li_qry = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// async function handle_qry__event(
|
||||
// {
|
||||
// ft_qry_str = '',
|
||||
// and_physical = $idaa_loc.recovery_meetings.qry__physical,
|
||||
// and_virtual = $idaa_loc.recovery_meetings.qry__virtual,
|
||||
// and_type = $idaa_loc.recovery_meetings.qry__type,
|
||||
// order_by_li = $idaa_loc.recovery_meetings.qry__order_by_li,
|
||||
// search_delay = 0,
|
||||
// max_tries = 5,
|
||||
// params = {
|
||||
// 'qry__enabled': $idaa_loc.recovery_meetings.qry__enabled ?? 'enabled',
|
||||
// 'qry__hidden': $idaa_loc.recovery_meetings.qry__hidden ?? 'not_hidden',
|
||||
// 'qry__limit': $idaa_loc.recovery_meetings.qry__limit ?? 35,
|
||||
// },
|
||||
// try_cache = true,
|
||||
// log_lvl = 1,
|
||||
// }: {
|
||||
// ft_qry_str?: string,
|
||||
// and_physical?: null|boolean,
|
||||
// and_virtual?: null|boolean,
|
||||
// and_type?: null|string,
|
||||
// order_by_li?: key_val,
|
||||
// search_delay?: number, // In milliseconds
|
||||
// max_tries?: number,
|
||||
// params?: key_val,
|
||||
// try_cache?: boolean,
|
||||
// log_lvl?: number,
|
||||
// }
|
||||
// ) {
|
||||
// console.log('handle_qry__event()');
|
||||
|
||||
// if ($idaa_sess.recovery_meetings?.qry__status != null && $idaa_sess.recovery_meetings?.qry__status != 'done') {
|
||||
// console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != done ***');
|
||||
// // WARNING: This is a temporary fix for the search string. It needs to be fixed in the future. Using lk_search_str for now.
|
||||
// $idaa_sess.recovery_meetings.status_qry__last_request_str = ft_qry_str;
|
||||
|
||||
// // We want to delay the initial search request to give the previous search request to finish.
|
||||
// let random_delay = Math.floor(Math.random() * 50);
|
||||
// search_delay += 50+random_delay;
|
||||
// }
|
||||
|
||||
// log_lvl = 1;
|
||||
|
||||
// let count = 0;
|
||||
// let request_loop = setInterval(() => {
|
||||
// count++;
|
||||
// if (log_lvl) {
|
||||
// console.log(`*** TEST SEARCH - Search delay: ${search_delay} *** loop count=${count}`);
|
||||
// }
|
||||
// if (count >= max_tries) {
|
||||
// console.log('*** TEST SEARCH - Max tries reached ***');
|
||||
// clearInterval(request_loop);
|
||||
// }
|
||||
|
||||
// if ($idaa_sess.recovery_meetings?.qry__status != null && $idaa_sess.recovery_meetings?.qry__status != 'done') {
|
||||
// let random_delay = Math.floor(Math.random() * 25);
|
||||
// search_delay += 25+random_delay;
|
||||
// console.log(`*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status == loading wait *** search_delay=${search_delay}`);
|
||||
// // $idaa_sess.status_qry__last_request_str = ft_qry_str;
|
||||
// } else {
|
||||
// console.log('*** TEST SEARCH - $idaa_sess.recovery_meetings.qry__status != loading ***');
|
||||
|
||||
// $idaa_sess.recovery_meetings.qry__status = 'loading';
|
||||
|
||||
// (and_physical) ?? null;
|
||||
// (and_virtual) ?? null;
|
||||
// (and_type) ?? null;
|
||||
// // if (and_type) and_type = and_type;
|
||||
// // if (!and_type) {
|
||||
// // and_type = null;
|
||||
// // }
|
||||
|
||||
// console.log(`TEST - and_physical: ${and_physical}; and_virtual: ${and_virtual}; and_type: ${and_type}; ft_qry_str: ${ft_qry_str}; params:`, params);
|
||||
|
||||
// // search_submit_results = events_func.qry_ae_obj_li__event({
|
||||
// // api_cfg: $ae_api,
|
||||
// // for_obj_type: 'account',
|
||||
// // for_obj_id: $ae_loc.account_id,
|
||||
// // order_by_li: order_by_li,
|
||||
// // qry_conference: false,
|
||||
// // qry_physical: and_physical,
|
||||
// // qry_virtual: and_virtual,
|
||||
// // qry_type: and_type,
|
||||
// // qry_str: ft_qry_str,
|
||||
// // params: params,
|
||||
// // try_cache: try_cache,
|
||||
// // log_lvl: log_lvl,
|
||||
// // })
|
||||
// // .then(function (search_results) {
|
||||
// // // Processing the results from the search.
|
||||
// // $idaa_sess.recovery_meetings.qry__status = 'processing';
|
||||
// // $idaa_slct.event_obj_li = search_results;
|
||||
// // console.log(search_results);
|
||||
// // // $idaa_sess.recovery_meetings.qry__status = 'done';
|
||||
|
||||
// // if (log_lvl) {
|
||||
// // console.log('TEST SEARCH - Search done. Pulling out the event_id_randoms.');
|
||||
// // }
|
||||
// // // console.log(`TEST search: ${$lq_kv__event_obj_li}`);
|
||||
|
||||
// // // event_id_random_li = [];
|
||||
|
||||
// // // We need to loop through the array of objects and get the event_id_random from each object a new list of event_id_randoms. Then we can use this list to get the full objects from the database.
|
||||
// // let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
// // if (search_results && search_results.length) {
|
||||
// // for (let i = 0; i < search_results.length; i++) {
|
||||
// // tmp_li.push($idaa_slct.event_obj_li[i].event_id_random);
|
||||
// // }
|
||||
// // }
|
||||
// // event_id_random_li = tmp_li;
|
||||
// // })
|
||||
// // .finally(() => {
|
||||
|
||||
// // // event_id_random_li = $idaa_slct.event_obj_li.map(session_obj => session_obj.event_id_random);
|
||||
|
||||
// // // Finally done with the search.
|
||||
// // $idaa_sess.recovery_meetings.qry__status = 'done';
|
||||
|
||||
// // if (log_lvl > 1) {
|
||||
// // console.log(`TEST SEARCH - event_id_random_li:`, event_id_random_li);
|
||||
// // // console.log(`TEST SEARCH - search live query: ${$lq_kv__event_obj_li}`);
|
||||
// // }
|
||||
|
||||
// // });
|
||||
// clearInterval(request_loop);
|
||||
// }
|
||||
// }, search_delay);
|
||||
// }
|
||||
</script>
|
||||
|
||||
<!-- preset-filled-surface-200-800 -->
|
||||
@@ -300,7 +134,7 @@
|
||||
name="qry__fulltext_str"
|
||||
bind:value={$idaa_loc.recovery_meetings.qry__fulltext_str}
|
||||
onkeyup={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
// Reactive effect in +page handles this debounced
|
||||
}}
|
||||
autofocus
|
||||
style="width: 50%;"
|
||||
@@ -351,9 +185,6 @@
|
||||
name="qry_virtual"
|
||||
type="checkbox"
|
||||
bind:checked={$idaa_loc.recovery_meetings.qry__virtual}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="checkbox inline form-check-input d-inline-block"
|
||||
/>
|
||||
</label>
|
||||
@@ -365,9 +196,6 @@
|
||||
name="qry_physical"
|
||||
type="checkbox"
|
||||
bind:checked={$idaa_loc.recovery_meetings.qry__physical}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="checkbox inline form-check-input d-inline-block"
|
||||
/>
|
||||
</label>
|
||||
@@ -389,9 +217,6 @@
|
||||
type="radio"
|
||||
value=""
|
||||
bind:group={$idaa_loc.recovery_meetings.qry__type}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="radio inline form-check-input d-inline-block"
|
||||
title="Show all meeting types"
|
||||
/>
|
||||
@@ -405,9 +230,6 @@
|
||||
type="radio"
|
||||
value="IDAA"
|
||||
bind:group={$idaa_loc.recovery_meetings.qry__type}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="radio inline form-check-input d-inline-block"
|
||||
title="Open to IDAA members only"
|
||||
/>
|
||||
@@ -421,9 +243,6 @@
|
||||
type="radio"
|
||||
value="Caduceus"
|
||||
bind:group={$idaa_loc.recovery_meetings.qry__type}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="radio inline form-check-input d-inline-block"
|
||||
title="Open to all healthcare workers including those who do not qualify for IDAA"
|
||||
/>
|
||||
@@ -437,43 +256,13 @@
|
||||
type="radio"
|
||||
value="Family Recovery"
|
||||
bind:group={$idaa_loc.recovery_meetings.qry__type}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="radio inline form-check-input d-inline-block"
|
||||
title="Open to spouses, parents, and children of medical professionals who have substance use disorder."
|
||||
/>
|
||||
</label>
|
||||
<!-- {#if $ae_loc.administrator_access}
|
||||
<label>Al-Anon (old)
|
||||
<input
|
||||
name="qry_type"
|
||||
type="radio"
|
||||
value="Al-Anon"
|
||||
bind:group={$idaa_loc.recovery_meetings.qry__type}
|
||||
on:change={() => {$idaa_trig.event_li_qry = true;}}
|
||||
>
|
||||
</label>
|
||||
<label>Other (old)
|
||||
<input
|
||||
name="qry_type"
|
||||
type="radio"
|
||||
value="Other"
|
||||
bind:group={$idaa_loc.recovery_meetings.qry__type}
|
||||
on:change={() => {$idaa_trig.event_li_qry = true;}}
|
||||
>
|
||||
</label>
|
||||
{/if} -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- {#await idaa_event_obj_li_get_promise}
|
||||
<div>Loading events...</div>
|
||||
{:catch error}
|
||||
<div>Error: {error.message}</div>
|
||||
{/await} -->
|
||||
|
||||
<div
|
||||
class="ae_group ae_row flex flex-row flex-wrap gap-2 w-full max-w-full items-center justify-center p-1"
|
||||
>
|
||||
@@ -485,9 +274,6 @@
|
||||
<select
|
||||
id="qry_limit__events"
|
||||
bind:value={$idaa_loc.recovery_meetings.qry__limit}
|
||||
onchange={() => {
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="
|
||||
select w-20 text-sm inline-block
|
||||
px-1
|
||||
@@ -520,7 +306,6 @@
|
||||
bind:value={$idaa_loc.recovery_meetings.qry__order_by}
|
||||
onchange={() => {
|
||||
if ($idaa_loc.recovery_meetings.qry__order_by == 'updated_on') {
|
||||
$idaa_loc.recovery_meetings.qry__order_by = 'updated_on'; // For the IDB index query
|
||||
$idaa_loc.recovery_meetings.qry__order_by_li = {
|
||||
priority: 'DESC',
|
||||
sort: 'DESC',
|
||||
@@ -529,7 +314,6 @@
|
||||
name: 'ASC'
|
||||
}; // For the SQL query
|
||||
} else {
|
||||
$idaa_loc.recovery_meetings.qry__order_by = 'name'; // For the IDB index query
|
||||
$idaa_loc.recovery_meetings.qry__order_by_li = {
|
||||
priority: 'DESC',
|
||||
sort: 'DESC',
|
||||
@@ -538,7 +322,6 @@
|
||||
created_on: 'DESC'
|
||||
}; // For the SQL query
|
||||
}
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="
|
||||
select w-40 text-sm inline-block
|
||||
@@ -561,7 +344,6 @@
|
||||
onclick={() => {
|
||||
$idaa_loc.recovery_meetings.qry__hidden = 'all';
|
||||
$idaa_loc.recovery_meetings.qry__limit = 200;
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="
|
||||
novi_btn btn_show_recovery_mtg_event ae_btn btn-info
|
||||
@@ -577,8 +359,6 @@
|
||||
type="button"
|
||||
onclick={() => {
|
||||
$idaa_loc.recovery_meetings.qry__hidden = 'not_hidden';
|
||||
// $idaa_loc.recovery_meetings.qry__limit = 100;
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="
|
||||
novi_btn btn_hide_recovery_mtg_event ae_btn btn-info
|
||||
@@ -598,7 +378,6 @@
|
||||
$idaa_loc.recovery_meetings.qry__hidden = 'all';
|
||||
$idaa_loc.recovery_meetings.qry__enabled = 'all';
|
||||
$idaa_loc.recovery_meetings.qry__limit = 500;
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="
|
||||
novi_btn btn_show_recovery_mtg_event ae_btn btn-warning
|
||||
@@ -614,7 +393,6 @@
|
||||
type="button"
|
||||
onclick={() => {
|
||||
$idaa_loc.recovery_meetings.qry__enabled = 'enabled';
|
||||
$idaa_trig.event_li_qry = true;
|
||||
}}
|
||||
class="
|
||||
novi_btn btn_hide_recovery_mtg_event ae_btn btn-warning
|
||||
@@ -639,13 +417,8 @@
|
||||
$idaa_slct.event_id = null;
|
||||
$idaa_slct.event_obj = {};
|
||||
|
||||
// Get the users current timezone
|
||||
// let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
// let timezone = $ae_loc.timezone || 'UTC'; // Fallback to UTC if timezone is not set
|
||||
|
||||
let data_kv = {
|
||||
name: 'Change NEW Recovery Meeting Name'
|
||||
// timezone: timezone,
|
||||
};
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
@@ -662,33 +435,16 @@
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((results) => {
|
||||
if (log_lvl) {
|
||||
console.log('New event (recovery meeting) created:', results);
|
||||
if (results) {
|
||||
$idaa_slct.event_id = results.event_id_random;
|
||||
$idaa_slct.event_obj = { ...results };
|
||||
$idaa_sess.recovery_meetings.edit__event_obj = results.event_id_random;
|
||||
goto(`/idaa/recovery_meetings/${results.event_id_random}`);
|
||||
}
|
||||
$idaa_slct.event_id = results?.event_id_random;
|
||||
$idaa_slct.event_obj = {
|
||||
...results
|
||||
};
|
||||
$idaa_sess.recovery_meetings.edit__event_obj = $idaa_slct.event_id;
|
||||
$idaa_loc.recovery_meetings.edit__event_obj = $idaa_slct.event_id;
|
||||
|
||||
// if (!$idaa_loc.recovery_meetings.edit_kv) {
|
||||
// $idaa_loc.recovery_meetings.edit_kv = {};
|
||||
// }
|
||||
// $idaa_loc.recovery_meetings.edit_kv[$idaa_slct.event_id] = 'current';
|
||||
|
||||
// alert(`Event created successfully! ${$idaa_slct.event_id}`);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error updating event (recovery meeting):', error);
|
||||
alert('Failed to update event (recovery meeting).');
|
||||
})
|
||||
.finally(() => {
|
||||
if ($idaa_slct.event_id) {
|
||||
goto(`/idaa/recovery_meetings/${$idaa_slct.event_id}`);
|
||||
} else {
|
||||
alert('Failed to create new event (recovery meeting).');
|
||||
}
|
||||
console.error('Error creating event:', error);
|
||||
alert('Failed to create new event.');
|
||||
});
|
||||
}}
|
||||
class="
|
||||
@@ -711,13 +467,12 @@
|
||||
if (!confirm('Download exported data Excel file?')) {
|
||||
return false;
|
||||
}
|
||||
// Use snake_case method name 'download_export__obj_type'
|
||||
ae_promises.download__events_export =
|
||||
core_func.download_export__obj_type({
|
||||
api_cfg: $ae_api,
|
||||
get_obj_type: 'event',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $slct.account_id,
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
exp_alt: 'idaa',
|
||||
file_type: 'Excel',
|
||||
return_file: true,
|
||||
@@ -737,11 +492,7 @@
|
||||
>
|
||||
{#await ae_promises.download__events_export}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<!-- <span class="loading-text">
|
||||
Downloading...
|
||||
</span> -->
|
||||
{:then}
|
||||
<!-- Done? -->
|
||||
<span class="fas fa-download m-1"></span>
|
||||
{/await}
|
||||
Export All Data
|
||||
@@ -749,5 +500,4 @@
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
<!-- END: div filters_and_search -->
|
||||
</section>
|
||||
@@ -68,56 +68,76 @@
|
||||
} from '$lib/ae_journals/ae_journals_stores';
|
||||
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
|
||||
|
||||
// Trigger doing a search query for journal entries
|
||||
$effect(async () => {
|
||||
if ($journals_trig.journal_entry_qry) {
|
||||
$journals_trig.journal_entry_qry = false;
|
||||
// Debounced Search Logic (Refactored 2026-01-27)
|
||||
let search_debounce_timer: any = null;
|
||||
let last_search_id = 0;
|
||||
|
||||
log_lvl = 1;
|
||||
$effect(() => {
|
||||
// Reactive dependencies
|
||||
const s_search_text = $journals_loc.entry.qry__search_text;
|
||||
const s_category_code = $journals_loc.entry.qry__category_code;
|
||||
const s_enabled = $journals_loc.entry.qry__enabled;
|
||||
const s_hidden = $journals_loc.entry.qry__hidden;
|
||||
const s_journal_id = $lq__journal_obj?.journal_id;
|
||||
const s_trigger = $journals_trig.journal_entry_qry;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`Triggered: $journals_trig.journal_entry_qry: text="${$journals_loc.entry.qry__search_text}" cat="${$journals_loc.entry.qry__category_code}"`
|
||||
);
|
||||
}
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
|
||||
// $journals_prom.load__journal_entry_obj_qry = journals_func.qry__journal_entry({
|
||||
$journals_prom.load__journal_entry_obj_li = await journals_func.qry__journal_entry({
|
||||
// Auto-search if text is cleared or long enough, or if category changes
|
||||
const should_search = s_trigger ||
|
||||
s_search_text.length === 0 ||
|
||||
s_search_text.length >= 3 ||
|
||||
s_category_code !== '';
|
||||
|
||||
if (should_search && s_journal_id) {
|
||||
search_debounce_timer = setTimeout(() => {
|
||||
$journals_trig.journal_entry_qry = false;
|
||||
handle_search_refresh();
|
||||
}, 400);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
};
|
||||
});
|
||||
|
||||
async function handle_search_refresh() {
|
||||
const current_search_id = ++last_search_id;
|
||||
const qry_str = $journals_loc.entry.qry__search_text;
|
||||
const category_code = $journals_loc.entry.qry__category_code;
|
||||
|
||||
if (log_lvl) console.log(`[Journal Search #${current_search_id}] text="${qry_str}" cat="${category_code}"`);
|
||||
|
||||
try {
|
||||
const results = await journals_func.qry__journal_entry({
|
||||
api_cfg: $ae_api,
|
||||
journal_id: $lq__journal_obj?.journal_id ?? '',
|
||||
qry_str: $journals_loc.entry.qry__search_text,
|
||||
qry_category_code: $journals_loc.entry.qry__category_code,
|
||||
|
||||
// qry_created_on: null,
|
||||
// qry_alert: null,
|
||||
// qry_priority: null,
|
||||
// qry_type: and_type,
|
||||
|
||||
qry_str: qry_str,
|
||||
qry_category_code: category_code,
|
||||
enabled: $journals_loc.entry.qry__enabled ?? 'enabled',
|
||||
hidden: $journals_loc.entry.qry__hidden ?? 'not_hidden',
|
||||
// order_by_li: $journals_loc.entry.qry__order_by_li,
|
||||
// limit: $journals_loc.entry.qry__limit,
|
||||
// try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
if (!$journals_loc.entry.qry__search_text && !$journals_loc.entry.qry__category_code) {
|
||||
// If search text and category were cleared or empty, reset to default view (null)
|
||||
$journals_sess.entry_li = null;
|
||||
} else if ($journals_prom.load__journal_entry_obj_li && $journals_prom.load__journal_entry_obj_li.length > 0) {
|
||||
$journals_sess.entry_li = $journals_prom.load__journal_entry_obj_li;
|
||||
$journals_sess = { ...$journals_sess }; // ensure session is updated
|
||||
} else {
|
||||
console.log('Clear the search results: no entries found for that query.');
|
||||
// Explicitly set to empty array to indicate "0 results found" (vs null which is "default view")
|
||||
$journals_sess.entry_li = [];
|
||||
}
|
||||
if (current_search_id === last_search_id) {
|
||||
$journals_prom.load__journal_entry_obj_li = results;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`$journals_sess.entry_li = `, $journals_sess.entry_li);
|
||||
if (!qry_str && !category_code) {
|
||||
// Reset to default view if everything cleared
|
||||
$journals_sess.entry_li = null;
|
||||
} else {
|
||||
$journals_sess.entry_li = results || [];
|
||||
$journals_sess = { ...$journals_sess };
|
||||
}
|
||||
|
||||
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Done. Found ${results?.length ?? 0} results.`);
|
||||
}
|
||||
} catch (error) {
|
||||
if (current_search_id === last_search_id) {
|
||||
console.error('Journal search failed:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Search input form -->
|
||||
@@ -130,7 +150,6 @@
|
||||
bind:value={$journals_loc.entry.qry__search_text}
|
||||
onkeyup={(event) => {
|
||||
if (event.key === 'Enter') {
|
||||
// $journals_loc.entry.qry__search_text = (event.target as HTMLInputElement).value;
|
||||
$journals_trig.journal_entry_qry = true;
|
||||
}
|
||||
}}
|
||||
@@ -208,9 +227,7 @@
|
||||
"
|
||||
bind:value={$journals_loc.entry.qry__category_code}
|
||||
onchange={(event) => {
|
||||
// WARNING: This will cause pages to reset if the journal entry list is being filtered by category. This is a bug that should be fixed.
|
||||
$journals_loc.entry.qry__category_code = (event.target as HTMLInputElement).value;
|
||||
// Trigger the query search instead of the full list load
|
||||
$journals_trig.journal_entry_qry = true;
|
||||
console.log('Selected category:', $journals_loc.entry.qry__category_code);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user