refactor(sessions): standardize reactive search and fix list layout
- Migrated Session search to the debounced pattern with Search Guards and shared observables. - Implemented 'Remote First' toggle support (Edit Mode only) for background-only revalidation. - Resolved 'each_key_duplicate' crash and fixed icon scaling issues in the session list. - Restored missing session alert visibility for managers. - Standardized store initialization to prevent reactivity loops.
This commit is contained in:
@@ -247,6 +247,10 @@ const events_local_data_struct: key_val = {
|
||||
qry__files_offset_seconds: null,
|
||||
qry__files_sort: 'created_on',
|
||||
|
||||
// New additions for search stabilization (Standardized Pattern 2026-01-27)
|
||||
search_version: 0,
|
||||
qry__remote_first: false,
|
||||
|
||||
qry_and__file_count: true, // Essentially it should be greater than 0
|
||||
|
||||
save_search_text: true,
|
||||
|
||||
@@ -5,20 +5,17 @@
|
||||
log_lvl?: number;
|
||||
}
|
||||
|
||||
let { data, log_lvl = 0 }: Props = $props();
|
||||
let { data, log_lvl = $bindable(0) }: Props = $props();
|
||||
|
||||
// *** Import Svelte specific
|
||||
import { untrack } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
// import { goto, invalidate, pushState, replaceState } from '$app/navigation';
|
||||
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
// import Element_data_store from '$lib/element_data_store_v2.svelte';
|
||||
// import Comp_event_session_obj_li from '../ae_comp__event_session_obj_li.svelte';
|
||||
import Comp_event_session_obj_li_wrapper from '../ae_comp__event_session_obj_li_wrapper.svelte';
|
||||
|
||||
import { liveQuery } from 'dexie';
|
||||
// import { core_func } from '$lib/ae_core_functions';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
import {
|
||||
ae_snip,
|
||||
@@ -42,42 +39,28 @@
|
||||
import Event_page_menu from './event_page_menu.svelte';
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
// $slct.account_id = data.account_id;
|
||||
// console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`event_id layout A: ${data.params.event_id}`);
|
||||
console.log(`event_id layout B: ${ae_acct.slct.event_id}`);
|
||||
console.log(`event_id layout C: ${$events_slct.event_id}`);
|
||||
}
|
||||
let event_id = data.params.event_id;
|
||||
$events_slct.event_id = ae_acct.slct.event_id;
|
||||
// $events_slct.event_device_id = null;
|
||||
// $events_slct.event_location_id = null;
|
||||
// $events_slct.event_session_id = null;
|
||||
|
||||
// *** Initialization & Store Guard ***
|
||||
if ($events_loc.pres_mgmt) {
|
||||
if (typeof $events_loc.pres_mgmt.search_version === 'undefined') $events_loc.pres_mgmt.search_version = 0;
|
||||
if (typeof $events_loc.pres_mgmt.qry__remote_first === 'undefined') $events_loc.pres_mgmt.qry__remote_first = false;
|
||||
if (typeof $events_loc.pres_mgmt.fulltext_search_qry_str === 'undefined') $events_loc.pres_mgmt.fulltext_search_qry_str = '';
|
||||
if (typeof $events_loc.pres_mgmt.location_name_qry_str === 'undefined') $events_loc.pres_mgmt.location_name_qry_str = '';
|
||||
}
|
||||
|
||||
let lq__event_obj = $derived(
|
||||
liveQuery(async () => {
|
||||
if (log_lvl) {
|
||||
console.log(`*** LiveQuery: lq__event_obj *** event_id=${$events_slct.event_id}`);
|
||||
}
|
||||
let results = await db_events.event.get($events_slct?.event_id ?? '');
|
||||
|
||||
return results;
|
||||
if (log_lvl) console.log(`*** LiveQuery: lq__event_obj *** event_id=${$events_slct.event_id}`);
|
||||
return await db_events.event.get($events_slct?.event_id ?? '');
|
||||
})
|
||||
);
|
||||
|
||||
// JSON formatted configuration options for an event, and specifically for the presentation management module.
|
||||
$effect(() => {
|
||||
if ($lq__event_obj?.mod_pres_mgmt_json) {
|
||||
// if (log_lvl) {
|
||||
// console.log(`*** Event Pres Mgmt JSON *** pres_mgmt_cfg_local`, $events_loc.pres_mgmt);
|
||||
// }
|
||||
// $events_loc.pres_mgmt =
|
||||
events_func.sync_config__event_pres_mgmt({
|
||||
pres_mgmt_cfg_remote: $lq__event_obj.mod_pres_mgmt_json,
|
||||
pres_mgmt_cfg_local: $events_loc.pres_mgmt,
|
||||
@@ -86,33 +69,37 @@
|
||||
}
|
||||
});
|
||||
|
||||
let event_session_id_random_li: Array<string> = $state([]);
|
||||
let event_session_id_li: Array<string> = $state([]);
|
||||
let search_debounce_timer: any = null;
|
||||
let last_search_id = 0;
|
||||
let last_executed_key = ''; // Search Guard Key
|
||||
|
||||
// OMG THIS WORKS!!! 2024-09-17
|
||||
// Using the $: seems to have fixed it along with the async await?
|
||||
// let lq__event_session_obj_li = $derived(liveQuery(async () => {
|
||||
// // console.log(`*** LiveQuery: lq__event_session_obj_li *** event_session_id_random_li`, $state.snapshot(event_session_id_random_li));
|
||||
// // if (!event_session_id_random_li) {
|
||||
// // // return [];
|
||||
// // return;
|
||||
// // }
|
||||
// if (event_session_id_random_li.length) {
|
||||
// console.log(`*** LiveQuery: lq__event_session_obj_li *** time to bulkGet`, $state.snapshot(event_session_id_random_li));
|
||||
// let results = await db_events.session
|
||||
// .bulkGet(event_session_id_random_li);
|
||||
// Stable LiveQuery Pattern (Aether UI V3)
|
||||
let lq__event_session_obj_li = $derived.by(() => {
|
||||
const ids = event_session_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(`Session Page LQ: bulkGet ${ids.length} IDs`);
|
||||
const results = await db_events.session.bulkGet(ids);
|
||||
return results.filter(item => item !== undefined);
|
||||
}
|
||||
|
||||
// SCENARIO 2: Fallback broad search (Only if no active filters)
|
||||
if (event_id && !$events_loc.pres_mgmt.fulltext_search_qry_str && !$events_loc.pres_mgmt.location_name_qry_str) {
|
||||
if (log_lvl) console.log(`Session Page LQ: Fallback search for event: ${event_id}`);
|
||||
return await db_events.session
|
||||
.where('event_id_random')
|
||||
.equals(event_id)
|
||||
.limit(50)
|
||||
.sortBy('name');
|
||||
}
|
||||
|
||||
// return results;
|
||||
// } else {
|
||||
// let results = await db_events.session
|
||||
// .where('event_id')
|
||||
// .equals($events_slct?.event_id ?? '') // null or undefined does not reset things like '' does
|
||||
// .reverse()
|
||||
// .sortBy('name');
|
||||
|
||||
// return results;
|
||||
// }
|
||||
|
||||
// }));
|
||||
return [];
|
||||
});
|
||||
});
|
||||
|
||||
let lq__event_location_obj_li = $derived(
|
||||
liveQuery(async () => {
|
||||
@@ -124,28 +111,144 @@
|
||||
})
|
||||
);
|
||||
|
||||
// let load_obj_li_results: Promise<any>|key_val;
|
||||
let search_submit_results: Promise<any> | key_val;
|
||||
// Standardized Reactive Search Pattern (Aether UI V3)
|
||||
let search_params = $derived({
|
||||
v: $events_loc.pres_mgmt.search_version,
|
||||
str: ($events_loc.pres_mgmt.fulltext_search_qry_str ?? '').toLowerCase().trim(),
|
||||
location: $events_loc.pres_mgmt.location_name_qry_str,
|
||||
event_id: $events_slct?.event_id,
|
||||
remote_first: $events_loc.pres_mgmt.qry__remote_first
|
||||
});
|
||||
|
||||
let ae_tmp: key_val = {};
|
||||
let ae_triggers: key_val = {};
|
||||
$effect(() => {
|
||||
const params = search_params;
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
search_debounce_timer = setTimeout(() => {
|
||||
untrack(() => {
|
||||
handle_search_refresh(params);
|
||||
});
|
||||
}, 300);
|
||||
return () => {
|
||||
if (search_debounce_timer) clearTimeout(search_debounce_timer);
|
||||
};
|
||||
});
|
||||
|
||||
async function handle_search_refresh(params: any) {
|
||||
// 1. Guard
|
||||
const qry_key = JSON.stringify(params);
|
||||
if (qry_key === last_executed_key) return;
|
||||
last_executed_key = qry_key;
|
||||
|
||||
const current_search_id = ++last_search_id;
|
||||
const event_id = params.event_id;
|
||||
const remote_first = params.remote_first;
|
||||
|
||||
if (log_lvl) console.log(`[Session Search #${current_search_id}] Refreshing (remote=${remote_first}, event=${event_id}, str=${params.str})...`);
|
||||
|
||||
untrack(() => {
|
||||
$events_sess.pres_mgmt.status_qry__search = 'loading';
|
||||
});
|
||||
|
||||
const qry_str = params.str;
|
||||
const location_name = params.location;
|
||||
|
||||
// 2. FAST PATH: Local IDB Search
|
||||
if (!remote_first) {
|
||||
try {
|
||||
if (event_id) {
|
||||
let local_results = await db_events.session
|
||||
.where('event_id_random')
|
||||
.equals(event_id)
|
||||
.filter(session => {
|
||||
if (location_name && session.event_location_name !== location_name) return false;
|
||||
|
||||
if (qry_str) {
|
||||
const name = (session.name ?? '').toLowerCase();
|
||||
const code = (session.code ?? '').toLowerCase();
|
||||
const description = (session.description ?? '').toLowerCase();
|
||||
const qry_string = (session.default_qry_str ?? '').toLowerCase();
|
||||
|
||||
const match = name.includes(qry_str) ||
|
||||
code.includes(qry_str) ||
|
||||
description.includes(qry_str) ||
|
||||
qry_string.includes(qry_str);
|
||||
|
||||
if (!match) return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.toArray();
|
||||
|
||||
local_results.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''));
|
||||
const local_ids = local_results.map(s => s.id || s.event_session_id_random).filter(Boolean);
|
||||
|
||||
if (current_search_id === last_search_id) {
|
||||
if (log_lvl) console.log(`[Session Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`);
|
||||
untrack(() => {
|
||||
event_session_id_li = local_ids;
|
||||
if (local_ids.length > 0) $events_sess.pres_mgmt.status_qry__search = 'done';
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (log_lvl) console.warn('Session Fast Path failed.', e);
|
||||
}
|
||||
} else {
|
||||
untrack(() => {
|
||||
event_session_id_li = [];
|
||||
});
|
||||
}
|
||||
|
||||
// 3. REVALIDATE: API Request
|
||||
try {
|
||||
const results = await events_func.search__event_session({
|
||||
api_cfg: $ae_api,
|
||||
event_id: event_id,
|
||||
fulltext_search_qry_str: qry_str || null,
|
||||
like_search_qry_str: qry_str || null,
|
||||
location_name: location_name || null,
|
||||
enabled: $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
|
||||
hidden: $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
|
||||
limit: $events_loc.pres_mgmt.qry_limit__sessions ?? 100,
|
||||
try_cache: true,
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
if (current_search_id === last_search_id) {
|
||||
const api_results = results || [];
|
||||
const api_ids = api_results.map((s: any) => s.id || s.event_session_id_random).filter(Boolean);
|
||||
|
||||
untrack(() => {
|
||||
$events_slct.event_session_obj_li = api_results;
|
||||
event_session_id_li = api_ids;
|
||||
$events_sess.pres_mgmt.status_qry__search = 'done';
|
||||
});
|
||||
if (log_lvl) console.log(`[Session Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`);
|
||||
}
|
||||
} catch (error) {
|
||||
if (current_search_id === last_search_id) {
|
||||
console.error('Session revalidation failed:', error);
|
||||
untrack(() => {
|
||||
$events_sess.pres_mgmt.status_qry__search = 'error';
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($events_loc.pres_mgmt?.save_search_text && $events_loc.pres_mgmt?.saved_search__session) {
|
||||
$events_sess.pres_mgmt.fulltext_search_qry_str =
|
||||
$events_loc.pres_mgmt.fulltext_search_qry_str =
|
||||
$events_loc.pres_mgmt.saved_search__session;
|
||||
}
|
||||
if (
|
||||
$events_loc.pres_mgmt?.save_search_text &&
|
||||
$events_loc.pres_mgmt?.saved_search__session_location_name
|
||||
) {
|
||||
$events_sess.pres_mgmt.location_name_qry_str =
|
||||
$events_loc.pres_mgmt.location_name_qry_str =
|
||||
$events_loc.pres_mgmt.saved_search__session_location_name;
|
||||
}
|
||||
|
||||
// *** Functions and Logic
|
||||
if (browser) {
|
||||
// console.log('Events Event [event_id]: +page.svelte');
|
||||
$events_trigger = 'load__event_session_obj_li';
|
||||
function handle_search_trigger() {
|
||||
$events_loc.pres_mgmt.search_version++;
|
||||
}
|
||||
|
||||
function preventDefault<T extends Event>(fn: (event: T) => void) {
|
||||
@@ -154,241 +257,6 @@
|
||||
fn(event);
|
||||
};
|
||||
}
|
||||
|
||||
// Updated 2024-06-12 late
|
||||
$effect(() => {
|
||||
if ($events_trigger == 'load__event_session_obj_li' && $events_slct.event_id) {
|
||||
console.log(
|
||||
`load__event_session_obj_li() $events_slct.event_id=${$events_slct.event_id}`
|
||||
);
|
||||
log_lvl = 1;
|
||||
$events_trigger = null;
|
||||
|
||||
if ($events_loc.pres_mgmt.save_search_text) {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** Save search text *** ${$events_loc.pres_mgmt.save_search_text}`
|
||||
);
|
||||
}
|
||||
$events_loc.pres_mgmt.saved_search__session =
|
||||
$events_sess.pres_mgmt.fulltext_search_qry_str;
|
||||
$events_loc.pres_mgmt.saved_search__session_location_name =
|
||||
$events_sess.pres_mgmt.location_name_qry_str;
|
||||
}
|
||||
|
||||
if ($events_sess.pres_mgmt.fulltext_search_qry_str?.length > 2) {
|
||||
console.log('*** Search string is valid ***');
|
||||
process_search_string($events_sess.pres_mgmt.fulltext_search_qry_str);
|
||||
} else if ($ae_loc.authenticated_access) {
|
||||
console.log('*** Administrator Access or Trusted Access ***');
|
||||
process_search_string($events_sess.pres_mgmt.fulltext_search_qry_str);
|
||||
} else {
|
||||
console.log(
|
||||
'*** Check permissions and or search string. Not allowed or too short. ***'
|
||||
);
|
||||
$events_slct.event_session_obj_li = [];
|
||||
event_session_id_random_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
// if ($events_sess.pres_mgmt.status_qry__search == 'done' && $events_slct?.event_session_obj_li) {
|
||||
log_lvl = 1;
|
||||
if ($events_trigger == 'search_done') {
|
||||
$events_trigger = null;
|
||||
$events_sess.pres_mgmt.status_qry__search = null;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('TEST search done: Pulling out the event_session_id_randoms...');
|
||||
}
|
||||
|
||||
// We need to loop through the array of objects and get the event_session_id_random from each object a new list of event_session_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 ($events_slct.event_session_obj_li && $events_slct.event_session_obj_li.length) {
|
||||
event_session_id_random_li = [];
|
||||
// console.log(`TEST SEARCH - Get ids:`, $events_slct.event_session_obj_li);
|
||||
for (let i = 0; i < $events_slct.event_session_obj_li.length; i++) {
|
||||
tmp_li.push($events_slct.event_session_obj_li[i].event_session_id_random);
|
||||
}
|
||||
}
|
||||
event_session_id_random_li = tmp_li;
|
||||
console.log(
|
||||
`TEST search results: event_session_id_random_li`,
|
||||
$state.snapshot(event_session_id_random_li)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function process_search_string(search_str: string) {
|
||||
if (log_lvl) {
|
||||
console.log(`process_search_string() search_str=${search_str}`);
|
||||
}
|
||||
|
||||
if (search_str?.length) {
|
||||
// console.log(`*** Search string length: ${search_str.length} ***`);
|
||||
} else {
|
||||
// console.log(`*** Search string is empty ***`);
|
||||
}
|
||||
|
||||
// let type_code = $events_sess.pres_mgmt.search_badge_type_code;
|
||||
|
||||
// let search_str = $events_sess.pres_mgmt.fulltext_search_qry_str.trim();
|
||||
|
||||
let search_method = 'lk'; // 'ft', 'lk', 'eq'
|
||||
let ft_search_str_new = '';
|
||||
let lk_search_str_new = '';
|
||||
|
||||
if (search_method == 'ft') {
|
||||
// Add quotes around the search string to make it an exact match.
|
||||
ft_search_str_new = `${search_str}`;
|
||||
// ft_search_str_new = `"${search_str}"`;
|
||||
} else if (search_method == 'lk') {
|
||||
if (search_str == null) {
|
||||
search_str = '';
|
||||
}
|
||||
// Add a wildcard to the search string to make it a like match.
|
||||
lk_search_str_new = search_str
|
||||
.trim()
|
||||
.replace(',', ' ')
|
||||
.replace(';', ' ')
|
||||
.replaceAll(' ', '%')
|
||||
.replaceAll(' ', '%');
|
||||
lk_search_str_new = `%${lk_search_str_new}%`;
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
// console.log(`*** Search method: ${search_method} ***`);
|
||||
console.log(`*** Search string: ${search_str} ***`);
|
||||
// console.log(`*** Fulltext search string: ${ft_search_str_new} ***`);
|
||||
// console.log(`*** Like search string: ${lk_search_str_new} ***`);
|
||||
}
|
||||
|
||||
let location_name = '';
|
||||
if ($events_sess.pres_mgmt.location_name_qry_str?.length) {
|
||||
location_name = $events_sess.pres_mgmt.location_name_qry_str;
|
||||
console.log(`Location name: ${location_name}`);
|
||||
}
|
||||
|
||||
handle_search__event_session({
|
||||
ft_search_str: ft_search_str_new,
|
||||
lk_search_str: lk_search_str_new,
|
||||
and_lk_location_name: location_name,
|
||||
// fulltext_search_qry_str: ft_search_str_new,
|
||||
// ft_presenter_search_qry_str: null,
|
||||
// like_search_qry_str: lk_search_str_new,
|
||||
// like_presentation_search_qry_str: lk_search_str_new,
|
||||
// like_presenter_search_qry_str: lk_search_str_new,
|
||||
// params: params,
|
||||
try_cache: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
async function handle_search__event_session({
|
||||
ft_search_str = '',
|
||||
lk_search_str = '',
|
||||
and_lk_location_name = '',
|
||||
search_delay = 0,
|
||||
max_tries = 5,
|
||||
enabled = $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
|
||||
hidden = $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
|
||||
limit = $events_loc.pres_mgmt.qry_limit__sessions ?? 35,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
ft_search_str?: string;
|
||||
lk_search_str?: string;
|
||||
and_lk_location_name?: string;
|
||||
search_delay?: number; // In milliseconds
|
||||
max_tries?: number;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||
limit?: number;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log('handle_search__event_session()');
|
||||
}
|
||||
|
||||
if (
|
||||
$events_sess.pres_mgmt?.status_qry__search != null &&
|
||||
$events_sess.pres_mgmt?.status_qry__search != '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.
|
||||
$events_sess.pres_mgmt.status_qry__last_request_str = lk_search_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 (
|
||||
$events_sess.pres_mgmt?.status_qry__search != null &&
|
||||
$events_sess.pres_mgmt?.status_qry__search != 'done'
|
||||
) {
|
||||
let random_delay = Math.floor(Math.random() * 25);
|
||||
search_delay += 25 + random_delay;
|
||||
console.log(
|
||||
`*** TEST SEARCH - $events_sess.pres_mgmt.status_qry__search == loading wait *** search_delay=${search_delay}`
|
||||
);
|
||||
// $events_sess.status_qry__last_request_str = lk_search_str;
|
||||
} else {
|
||||
// console.log('*** TEST SEARCH - $events_sess.pres_mgmt.status_qry__search != loading ***');
|
||||
|
||||
$events_trigger = 'loading_search_results';
|
||||
$events_sess.pres_mgmt.status_qry__search = 'loading';
|
||||
|
||||
event_session_id_random_li = []; // Resetting this seems to help trigger the new results to show correctly???
|
||||
|
||||
search_submit_results = events_func
|
||||
.search__event_session({
|
||||
api_cfg: $ae_api,
|
||||
event_id: $events_slct.event_id,
|
||||
// type_code: type_code,
|
||||
fulltext_search_qry_str: ft_search_str,
|
||||
ft_presenter_search_qry_str: null,
|
||||
like_search_qry_str: lk_search_str,
|
||||
like_presentation_search_qry_str: lk_search_str,
|
||||
like_presenter_search_qry_str: lk_search_str,
|
||||
like_poc_name_qry_str: lk_search_str,
|
||||
// external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
|
||||
location_name: and_lk_location_name,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
limit: limit,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (search_results) {
|
||||
// Processing the results from the search.
|
||||
$events_trigger = 'process_search_results';
|
||||
$events_sess.pres_mgmt.status_qry__search = 'processing';
|
||||
$events_slct.event_session_obj_li = search_results;
|
||||
})
|
||||
.finally(() => {
|
||||
// Finally done with the search.
|
||||
$events_trigger = 'search_done';
|
||||
$events_sess.pres_mgmt.status_qry__search = 'done';
|
||||
});
|
||||
clearInterval(request_loop);
|
||||
}
|
||||
}, search_delay);
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -399,41 +267,17 @@
|
||||
</title>
|
||||
</svelte:head>
|
||||
|
||||
<!-- container h-full mx-auto
|
||||
flex flex-col gap-1
|
||||
py-1 px-2 pb-16
|
||||
items-center
|
||||
min-w-full
|
||||
max-w-max -->
|
||||
<!-- <section
|
||||
class="
|
||||
ae_events_pres_mgmt_event
|
||||
md:container
|
||||
flex flex-col gap-1
|
||||
items-center
|
||||
justify-start
|
||||
mx-auto
|
||||
py-1 px-2 pb-16
|
||||
h-full
|
||||
min-w-full
|
||||
max-w-max
|
||||
"
|
||||
> -->
|
||||
<!-- lg:bg-green-100
|
||||
xl:bg-green-200 -->
|
||||
|
||||
<Event_page_menu {lq__event_obj} />
|
||||
|
||||
{#if !$lq__event_obj}
|
||||
<div>
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
<div class="flex items-center justify-center p-10 opacity-50">
|
||||
<span class="fas fa-spinner fa-spin mx-1 text-2xl"></span>
|
||||
<span>Loading event information...</span>
|
||||
</div>
|
||||
{:else if $lq__event_obj?.enable || $ae_loc.trusted_access}
|
||||
<header class="ae_module_header">
|
||||
<span class="flex flex-row flex-wrap gap-1 items-center justify-center">
|
||||
<span class="fas fa-calendar-day m-1 text-neutral-800/80"></span>
|
||||
<!-- Button to toggle between the regular event view and managing event files -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
@@ -444,15 +288,12 @@ max-w-max -->
|
||||
}
|
||||
}}
|
||||
class="btn ae_btn_secondary"
|
||||
class:preset-filled-secondary-500={$events_loc.pres_mgmt.show_content__event_view ==
|
||||
'manage_files'}
|
||||
class:preset-filled-tertiary-500={$events_loc.pres_mgmt.show_content__event_view !=
|
||||
'manage_files'}
|
||||
class:preset-filled-secondary-500={$events_loc.pres_mgmt.show_content__event_view == 'manage_files'}
|
||||
class:preset-filled-tertiary-500={$events_loc.pres_mgmt.show_content__event_view != 'manage_files'}
|
||||
class:hidden={!$ae_loc.administrator_access}
|
||||
title="View event search or manage files for the event"
|
||||
>
|
||||
{#if $events_loc.pres_mgmt.show_content__event_view == 'manage_files'}
|
||||
<!-- <span class="fas fa-info m-1"></span> -->
|
||||
<span class="fas fa-search m-1"></span>
|
||||
Event Search?
|
||||
{:else}
|
||||
@@ -462,7 +303,6 @@ max-w-max -->
|
||||
class="badge preset-tonal-success"
|
||||
class:hidden={!$lq__event_obj?.file_count}
|
||||
>
|
||||
<!-- absolute -top-1.5 -right-1.5 z-10 -->
|
||||
<span class="fas fa-file-alt m-1"></span>
|
||||
{$lq__event_obj?.file_count}×
|
||||
</span>
|
||||
@@ -484,49 +324,39 @@ max-w-max -->
|
||||
</header>
|
||||
|
||||
{#if !$events_loc.pres_mgmt.show_content__event_view || $events_loc.pres_mgmt.show_content__event_view == 'default'}
|
||||
<!-- This session search section should be moved to a separate Svelte component -->
|
||||
<div class="ae_container_actions">
|
||||
<form
|
||||
onsubmit={preventDefault(() => {
|
||||
$events_trigger = 'load__event_session_obj_li';
|
||||
})}
|
||||
onsubmit={preventDefault(() => handle_search_trigger())}
|
||||
autocomplete="off"
|
||||
class="form grow flex flex-row flex-wrap gap-1 justify-center items-center w-full"
|
||||
>
|
||||
<!-- Show/Hide session location name search button -->
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm mx-1 ae_btn_warning"
|
||||
class:hidden={!$ae_loc.authenticated_access}
|
||||
onclick={() => {
|
||||
$events_sess.pres_mgmt.location_name_qry_str = '';
|
||||
$events_loc.pres_mgmt.show_content__session_search_room_name =
|
||||
!$events_loc.pres_mgmt.show_content__session_search_room_name;
|
||||
$events_loc.pres_mgmt.location_name_qry_str = '';
|
||||
$events_loc.pres_mgmt.show_content__session_search_room_name = !$events_loc.pres_mgmt.show_content__session_search_room_name;
|
||||
handle_search_trigger();
|
||||
}}
|
||||
title="Search by location name"
|
||||
>
|
||||
<span class="fas fa-search-location"></span>
|
||||
<span class="hidden">Search on location</span>
|
||||
</button>
|
||||
|
||||
<select
|
||||
name="location_name_list"
|
||||
id="session_location_name_list"
|
||||
bind:value={$events_sess.pres_mgmt.location_name_qry_str}
|
||||
bind:value={$events_loc.pres_mgmt.location_name_qry_str}
|
||||
class="input text-xs font-bold font-mono min-w-fit w-min max-w-40 transition-all mx-1"
|
||||
class:hidden={!$ae_loc.authenticated_access ||
|
||||
!$events_loc.pres_mgmt.show_content__session_search_room_name}
|
||||
onchange={() => {
|
||||
$events_trigger = 'load__event_session_obj_li';
|
||||
}}
|
||||
class:hidden={!$ae_loc.authenticated_access || !$events_loc.pres_mgmt.show_content__session_search_room_name}
|
||||
onchange={() => handle_search_trigger()}
|
||||
title="Select to filter based on the location/room name"
|
||||
>
|
||||
{#if $lq__event_location_obj_li}
|
||||
<option value="">Location / Room</option>
|
||||
{#each $lq__event_location_obj_li as event_location_obj}
|
||||
<option value={event_location_obj?.name}
|
||||
>{event_location_obj.name}</option
|
||||
>
|
||||
<option value={event_location_obj?.name}>{event_location_obj.name}</option>
|
||||
{/each}
|
||||
{/if}
|
||||
</select>
|
||||
@@ -534,34 +364,24 @@ max-w-max -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
$events_sess.pres_mgmt.fulltext_search_qry_str = '';
|
||||
$events_trigger = 'load__event_session_obj_li';
|
||||
$events_loc.pres_mgmt.fulltext_search_qry_str = '';
|
||||
handle_search_trigger();
|
||||
}}
|
||||
class:hidden={!$events_sess.pres_mgmt.fulltext_search_qry_str ||
|
||||
$events_sess.pres_mgmt.fulltext_search_qry_str.length == 0}
|
||||
class:hidden={!$events_loc.pres_mgmt.fulltext_search_qry_str}
|
||||
class="btn btn-sm mx-1 ae_btn_warning"
|
||||
title="Clear search text"
|
||||
>
|
||||
<!-- <span class="fas fa-backspace"></span> -->
|
||||
<!-- <span class="fas fa-broom"></span> -->
|
||||
<span class="fas fa-remove-format"></span>
|
||||
<!-- Clear text -->
|
||||
</button>
|
||||
|
||||
<!-- svelte-ignore a11y_autofocus -->
|
||||
<input
|
||||
type="search"
|
||||
placeholder="Search for a session"
|
||||
id="session_fulltext_search_qry_str"
|
||||
bind:value={$events_sess.pres_mgmt.fulltext_search_qry_str}
|
||||
bind:value={$events_loc.pres_mgmt.fulltext_search_qry_str}
|
||||
class="input text-1xl hover:text-2xl font-bold font-mono w-80 transition-all mx-1 ae_btn_info"
|
||||
onkeyup={() => {
|
||||
if (
|
||||
$events_sess.pres_mgmt?.fulltext_search_qry_str &&
|
||||
$events_sess.pres_mgmt.fulltext_search_qry_str.length >= 3
|
||||
) {
|
||||
$events_trigger = 'load__event_session_obj_li';
|
||||
}
|
||||
onkeyup={(e) => {
|
||||
if (e.key === 'Enter') handle_search_trigger();
|
||||
}}
|
||||
autofocus
|
||||
data-ignore="true"
|
||||
@@ -570,7 +390,6 @@ max-w-max -->
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-lg text-2xl font-bold w-48 mx-1 ae_btn_primary"
|
||||
onclick={() => {}}
|
||||
title="Search for a session"
|
||||
>
|
||||
{#if $events_sess.pres_mgmt.status_qry__search == 'loading'}
|
||||
@@ -580,13 +399,24 @@ max-w-max -->
|
||||
{/if}
|
||||
Search
|
||||
</button>
|
||||
|
||||
{#if $ae_loc.edit_mode}
|
||||
<label class="flex items-center gap-1 cursor-pointer bg-surface-200-800 px-2 py-1 rounded-token text-xs font-semibold opacity-70 hover:opacity-100 transition-all">
|
||||
<span> Remote First </span>
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={$events_loc.pres_mgmt.qry__remote_first}
|
||||
onchange={() => handle_search_trigger()}
|
||||
class="checkbox checkbox-sm"
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- This needs to be called only when there is a list of IDs ready. This should be done on the list wrapper the list itself. -->
|
||||
{#if event_session_id_random_li.length}
|
||||
{#if event_session_id_li.length}
|
||||
<Comp_event_session_obj_li_wrapper
|
||||
{event_session_id_random_li}
|
||||
lq__event_session_obj_li={lq__event_session_obj_li}
|
||||
hide__session_location={$events_loc.pres_mgmt?.hide__session_li_location_field}
|
||||
hide__session_poc={$events_loc.pres_mgmt?.hide__session_li_poc_field}
|
||||
hide__launcher_link_legacy={$events_loc.pres_mgmt?.hide__launcher_link_legacy}
|
||||
@@ -594,10 +424,13 @@ max-w-max -->
|
||||
hide__location_link={$events_loc.pres_mgmt?.hide__location_link}
|
||||
log_lvl={1}
|
||||
/>
|
||||
{:else if $events_sess.pres_mgmt.status_qry__search === 'loading'}
|
||||
<div class="flex flex-col items-center justify-center p-20 opacity-50 text-center">
|
||||
<span class="fas fa-spinner fa-spin text-4xl mb-4"></span>
|
||||
<p class="text-xl">Searching sessions...</p>
|
||||
</div>
|
||||
{:else}
|
||||
<section
|
||||
class="text-center text-2xl bg-yellow-100 p-4 rounded-md lg:max-w-lg space-y-2"
|
||||
>
|
||||
<section class="text-center text-2xl bg-yellow-100 p-4 rounded-md lg:max-w-lg space-y-2 mx-auto">
|
||||
<div>
|
||||
<span class="fas fa-exclamation-triangle text-2xl text-yellow-500"></span>
|
||||
<strong>No results to show</strong>
|
||||
@@ -658,8 +491,7 @@ max-w-max -->
|
||||
<Element_manage_event_file_li_wrap
|
||||
link_to_type={'event'}
|
||||
link_to_id={$lq__event_obj?.event_id_random}
|
||||
allow_basic={$events_loc.auth__kv.session[$lq__event_obj?.event_id_random] ||
|
||||
$events_loc.auth__kv.session[$lq__event_obj?.event_id_random]}
|
||||
allow_basic={$events_loc.auth__kv.session[$lq__event_obj?.event_id_random]}
|
||||
allow_moderator={$events_loc.auth__kv.session[$lq__event_obj?.event_id_random]}
|
||||
container_class_li={''}
|
||||
/>
|
||||
@@ -672,40 +504,9 @@ max-w-max -->
|
||||
<span class="fas fa-exclamation-triangle text-red-500 m-1"></span>
|
||||
Event Disabled
|
||||
</h2>
|
||||
<p>
|
||||
This event is currently disabled. Please contact the event organizer for more
|
||||
information.
|
||||
</p>
|
||||
<p>This event is currently disabled. Please contact the event organizer for more information.</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- </section> -->
|
||||
|
||||
<style lang="postcss">
|
||||
/* Use the div.ae_quick_modal_container to block background clicks when using the section.ae_quick_popover. */
|
||||
/* div.ae_quick_modal_container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 0%, .5);
|
||||
} */
|
||||
|
||||
/* The section.ae_quick_popover should be above the rest of the content and centered on the page. */
|
||||
/* section.ae_quick_popover {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 100%, .95);
|
||||
padding: 1rem;
|
||||
border-radius: .5rem;
|
||||
box-shadow: 0 0 1rem hsla(0, 0%, 0%, .5);
|
||||
|
||||
min-height: 30%;
|
||||
min-width: 80%;
|
||||
} */
|
||||
</style>
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,7 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
// Exports
|
||||
container_class_li?: string | Array<string>;
|
||||
// export let display_mode: string = 'default'; // 'default', 'compact', 'minimal', 'launcher'
|
||||
lq__event_session_obj_li?: any; // New Shared Observable Pattern
|
||||
event_session_id_random_li?: Array<string>;
|
||||
link_to_type?: string;
|
||||
link_to_id?: string;
|
||||
@@ -17,6 +16,7 @@
|
||||
|
||||
let {
|
||||
container_class_li = [],
|
||||
lq__event_session_obj_li: lq__shared,
|
||||
event_session_id_random_li = [],
|
||||
link_to_type,
|
||||
link_to_id,
|
||||
@@ -31,50 +31,29 @@
|
||||
|
||||
// Imports
|
||||
import Comp_event_session_obj_li from './ae_comp__event_session_obj_li.svelte';
|
||||
|
||||
import { liveQuery } from 'dexie';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log(`event_session list: link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`);
|
||||
console.log(
|
||||
`event_session list: event_session_id_random_li: ${event_session_id_random_li}`
|
||||
);
|
||||
}
|
||||
// Logic: Use shared observable if provided, otherwise create internal one
|
||||
let lq__event_session_obj_li = $derived.by(() => {
|
||||
if (lq__shared) return lq__shared;
|
||||
|
||||
// Variables
|
||||
// let ae_promises: key_val = {};
|
||||
// let ae_tmp: key_val = {};
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
let dq__where_type_id_val: string = `${link_to_type}_id_random`;
|
||||
let dq__where_eq_id_val: string = link_to_id ?? '';
|
||||
|
||||
let lq__event_session_obj_li = $derived(
|
||||
liveQuery(async () => {
|
||||
return liveQuery(async () => {
|
||||
if (link_to_type && link_to_id) {
|
||||
let results = await db_events.session
|
||||
.where(dq__where_type_id_val)
|
||||
.equals(dq__where_eq_id_val)
|
||||
// .sortBy('name')
|
||||
const results = await db_events.session
|
||||
.where(`${link_to_type}_id_random`)
|
||||
.equals(link_to_id)
|
||||
.sortBy('start_datetime');
|
||||
// This should be sorted by a custom sort field
|
||||
|
||||
return results;
|
||||
} else if (event_session_id_random_li.length > 0) {
|
||||
let results = await db_events.session.bulkGet(event_session_id_random_li);
|
||||
|
||||
return results;
|
||||
} else {
|
||||
return null;
|
||||
const results = await db_events.session.bulkGet(event_session_id_random_li);
|
||||
return results.filter(item => item !== undefined);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// *** Functions and Logic
|
||||
return null;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- {#if $lq__event_session_obj_li?.length > 0} -->
|
||||
<Comp_event_session_obj_li
|
||||
{container_class_li}
|
||||
{lq__event_session_obj_li}
|
||||
@@ -85,5 +64,4 @@
|
||||
{hide__launcher_link}
|
||||
{hide__location_link}
|
||||
{log_lvl}
|
||||
></Comp_event_session_obj_li>
|
||||
<!-- {/if} -->
|
||||
></Comp_event_session_obj_li>
|
||||
Reference in New Issue
Block a user