Now with session searching working

This commit is contained in:
Scott Idem
2024-06-12 13:00:27 -04:00
parent bbd403b96d
commit 987e411956
4 changed files with 490 additions and 48 deletions

View File

@@ -209,6 +209,93 @@ async function handle_load_ae_obj_li__event_session(
}
async function handle_search__event_session(
{
api_cfg,
event_id,
fulltext_search_qry_str,
like_search_qry_str=null,
// session_type_code=null,
params={},
try_cache=true
}: {
api_cfg: any,
event_id: any,
fulltext_search_qry_str: any,
like_search_qry_str: any,
// session_type_code: any,
params: any,
try_cache: boolean
}
) {
console.log(`*** handle_search__event_session() *** event_id=${event_id}`);
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
let limit: number = (params.qry__limit ?? 25); // 99
let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
if (!fulltext_search_qry_str && !like_search_qry_str) {
console.log('No search string provided!!!');
return false; // Returning false instead of [] because no search was performed.
}
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
params_json['ft_qry'] = {
'default_qry_str': fulltext_search_qry_str,
};
}
if (like_search_qry_str && like_search_qry_str.length > 2) {
params_json['and_like'] = {
'default_qry_str': like_search_qry_str,
};
}
params_json['and_qry'] = {};
// if (session_type_code) {
// params_json['and_qry']['session_type_code'] = session_type_code;
// }
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'event_session',
for_obj_type: 'event',
for_obj_id: event_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params
})
.then(function (event_session_obj_li_get_result) {
if (event_session_obj_li_get_result) {
handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result});
return event_session_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
});
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
return ae_promises.load__event_session_obj_li;
}
// Updated 2024-06-10
async function handle_load_ae_obj_li__event_presentation(
{
@@ -458,16 +545,24 @@ async function handle_load_ae_obj_li__badge(
async function handle_search__event_badge(
{api_cfg, event_id, type_code=null, fulltext_search_qry_str, like_search_qry_str=null, external_event_id, params={}, try_cache=true
{
api_cfg,
event_id,
type_code=null,
fulltext_search_qry_str,
like_search_qry_str=null,
external_event_id,
params={},
try_cache=true
}: {
api_cfg: any,
event_id: any,
type_code: any,
fulltext_search_qry_str: any,
like_search_qry_str: any,
external_event_id: any,
params: any,
try_cache: boolean
api_cfg: any,
event_id: any,
type_code: any,
fulltext_search_qry_str: any,
like_search_qry_str: any,
external_event_id: any,
params: any,
try_cache: boolean
}
) {
console.log(`*** handle_search__event_badge() *** event_id=${event_id}`);
@@ -540,7 +635,6 @@ async function handle_search__event_badge(
params: params,
log_lvl: 1
})
.then(function (badge_obj_li_get_result) {
// console.log('Badge list:', badge_obj_li_get_result);
if (badge_obj_li_get_result) {
@@ -1393,6 +1487,7 @@ let export_obj = {
handle_load_ae_obj_id__event_session: handle_load_ae_obj_id__event_session,
handle_load_ae_obj_li__event_session: handle_load_ae_obj_li__event_session,
handle_search__event_session: handle_search__event_session,
handle_load_ae_obj_li__event_presentation: handle_load_ae_obj_li__event_presentation,

View File

@@ -245,6 +245,13 @@ let events_session_data_struct: key_val = {
},
// Presentation Management (Distributing)
'pres_mgmt': {
'fulltext_search_qry_str': null,
'status_qry__search': null,
show_form__search: true,
show_form__search_results: true,
},
// Speakers Management (Collection)

View File

@@ -48,51 +48,147 @@ let event_obj = liveQuery(
let event_obj_v2 = db_events.events.get($events_slct.event_id);
// Load the Event Obj with ID based on the slug param.
// $events_slct.event_id = param_slug_event_id;
// console.log('Selected Event ID:', $events_slct.event_id);
// $events_trigger = 'load__event_obj';
let license_submit_results: Promise<any>|key_val;
let load_obj_li_results: Promise<any>|key_val;
let search_submit_results: Promise<any>|key_val;
if (!$events_loc.leads.tab) {
$events_loc.leads.tab = {};
$events_loc.leads.tab[$events_slct.event_id] = 'start';
}
// These will likely be used for patch/update triggers. Maybe delete?
let ae_triggers: key_val = {};
if (!$events_loc.leads.auth_exhibit_kv) {
$events_loc.leads.auth_exhibit_kv = {};
}
let ae_event_session_get_promise: Promise<any>;
if ($events_loc.leads.auth_exhibit_kv && $events_loc.leads.auth_exhibit_kv[$events_slct.event_id]) {
console.log('Logged in using shared exhibit staff passcode.');
// if (!$events_loc.leads.tab) {
// $events_loc.leads.tab = {};
// $events_loc.leads.tab[$events_slct.event_id] = 'start';
// }
if ($events_loc.leads.auth_exhibit_kv[$events_slct.event_id].key) {
console.log(`Using the license key: ${$events_loc.leads.auth_exhibit_kv[$events_slct.event_id].key}`);
} else {
console.log('License key (email) not used.');
$events_loc.leads.tab[$events_slct.event_id] = 'start';
}
} else {
console.log('Not logged in using shared exhibit staff passcode.');
$events_loc.leads.tab[$events_slct.event_id] = 'start';
}
// if (!$events_loc.leads.auth_exhibit_kv) {
// $events_loc.leads.auth_exhibit_kv = {};
// }
// if ($events_loc.leads.auth_exhibit_kv && $events_loc.leads.auth_exhibit_kv[$events_slct.event_id]) {
// console.log('Logged in using shared exhibit staff passcode.');
// if ($events_loc.leads.auth_exhibit_kv[$events_slct.event_id].key) {
// console.log(`Using the license key: ${$events_loc.leads.auth_exhibit_kv[$events_slct.event_id].key}`);
// } else {
// console.log('License key (email) not used.');
// $events_loc.leads.tab[$events_slct.event_id] = 'start';
// }
// } else {
// console.log('Not logged in using shared exhibit staff passcode.');
// $events_loc.leads.tab[$events_slct.event_id] = 'start';
// }
onMount(() => {
console.log('Events Event [slug]: +page.svelte');
// console.log(`ae_events_leads exhibit [slug] +page.svelte data:`, data);
if (!$events_slct.event_id) {
console.log(`No ID! Nothing to show. Try setting the ID again.`);
$events_slct.event_id = $events_slct.event_id;
}
});
// console.log(`$ae_loc = `, $ae_loc);
// Updated 2024-06-12 late
$: 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}`);
$events_trigger = null;
if (!$events_sess.pres_mgmt.fulltext_search_qry_str || $events_sess?.pres_mgmt.fulltext_search_qry_str.length <= 1 ) {
$events_slct.session_obj_li = [];
// $events_sess.pres_mgmt.fulltext_search_qry_str = '';
} else {
// 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}"`;
} else if (search_method == 'lk') {
// Add a wildcard to the search string to make it a like match.
lk_search_str_new = search_str.trim().replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%');
lk_search_str_new = `%${lk_search_str_new}%`;
}
console.log(`"${search_str}"`);
let params = {
'qry__enabled': 'enabled',
'qry__hidden': 'not_hidden',
'qry__limit': 35,
}
if ($ae_loc.administrator_access) {
params['qry__enabled'] = 'all';
params['qry__hidden'] = 'all';
params['qry__limit'] = 150;
} else if ($ae_loc.trusted_access) {
params['qry__enabled'] = 'enabled';
params['qry__hidden'] = 'all';
params['qry__limit'] = 75;
} else {
params['qry__enabled'] = 'enabled';
params['qry__hidden'] = 'not_hidden';
params['qry__limit'] = 35;
}
if ($events_sess.status_qry__search == 'loading') {
console.log('*** $events_sess.status_qry__search == loading ***');
setTimeout(() => {
console.log("Delayed for X second.");
$events_sess.status_qry__search = 'loading';
search_submit_results = events_func.handle_search__event_session({
api_cfg: $ae_api,
event_id: $events_slct.event_id,
// type_code: type_code,
fulltext_search_qry_str: ft_search_str_new,
like_search_qry_str: lk_search_str_new,
// external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
params: params,
try_cache: false
})
.then(function (search_results) {
$events_slct.session_obj_li = search_results;
console.log(search_results);
$events_sess.status_qry__search = 'done';
});
}, 250);
} else {
console.log('*** $events_sess.status_qry__search != loading ***');
$events_sess.status_qry__search = 'loading';
search_submit_results = events_func.handle_search__event_session({
api_cfg: $ae_api,
event_id: $events_slct.event_id,
// type_code: type_code,
fulltext_search_qry_str: ft_search_str_new,
like_search_qry_str: lk_search_str_new,
// external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
params: params,
try_cache: false
})
.then(function (search_results) {
$events_slct.session_obj_li = search_results;
console.log(search_results);
$events_sess.status_qry__search = 'done';
});
}
} // end if search string is valid
}
@@ -105,10 +201,121 @@ onMount(() => {
{#if $events_slct.event_id && $event_obj}
<h2>{$event_obj.name}</h2>
{/if}
<div class="variant-ghost-success my-2 p-2 flex flex-row items-center">
<form
on:submit|preventDefault={() => {
$events_trigger = 'load__event_session_obj_li';
}}
autocomplete="off"
class="form flex-grow flex flex-row flex-wrap gap-1 justify-center items-center w-full"
>
<input
type="search"
placeholder="Search for a session"
id="session_fulltext_search_qry_str"
bind:value={$events_sess.pres_mgmt.fulltext_search_qry_str}
class="input text-1xl hover:text-2xl font-bold font-mono w-96 transition-all"
on:keyup={() => {
if ($events_sess.pres_mgmt.fulltext_search_qry_str.length >= 3) {
$events_trigger = 'load__event_session_obj_li';
}
}}
autofocus
suggest="off"
data-ignore="true"
/>
<button
type="submit"
class="btn btn-lg variant-ghost-success hover:variant-glass-success text-2xl font-bold w-48 transition-all"
on:click={() => {
}}
>
{#if $events_sess.pres_mgmt.status_qry__search == 'loading'}
<span class="fas fa-spinner fa-spin"></span>
{:else }
<!-- Nothing -->
{/if}
<span class="fas fa-search mx-1"></span>
Search
</button>
</form>
</div>
{#await load_obj_li_results}
<span class="modal-loading">
<span class="fas fa-spinner fa-spin"></span>
<span class="loading-text">
Loading...
</span>
</span>
{:then load_obj_li_results}
{#if load_obj_li_results}
<span class="fas fa-check text-green-500"></span>
<span class="saved-text">
Loaded
</span>
{/if}
{/await}
{#if $events_slct?.session_obj_li && $events_slct.session_obj_li.length > 0}
<section class="ae_h_scrollfix">
<h2 class="h3">Results:</h2>
<table class="table">
<thead>
<tr>
<th>Session</th>
<th>Date</th>
<th>Start</th>
<th>Location</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{#each $events_slct.session_obj_li as session_obj}
<tr>
<td>
<strong>{session_obj.name}</strong>
</td>
<td>
<span style="break-inside: avoid;">
{ae_util.iso_datetime_formatter(session_obj.start_datetime,'dddd')}
{ae_util.iso_datetime_formatter(session_obj.start_datetime,'date_long_month_day')}
</span>
<td>
<span style="break-inside: avoid;">
{ae_util.iso_datetime_formatter(session_obj.start_datetime,'time_short')}
</span>
</td>
<td>{session_obj.event_location_name ?? '-- not set --'}</td>
<td>
<a
href="/events_pres_mgmt/session/{session_obj.event_session_id_random}"
class="btn btn-md variant-ghost-secondary hover:variant-glass-secondary"
>
<span class="fas fa-eye"></span>
View
</a>
</td>
</tr>
{/each}
</tbody>
</table>
</section>
{/if}
</section>

View File

@@ -245,20 +245,22 @@ onMount(() => {
{#if $ae_loc.trusted_access || $events_loc.auth__kv.session[$events_slct.event_session_id]}
{#if $events_slct.presenter_obj.agree}
<button
class="btn btn-md variant-ghost-primary"
<a
class="btn btn-md variant-ghost-primary hover:variant-filled-primary"
href="https://static.oneskyit.com/c/LCI/files/LCI_Congress_Template_2024.pptx"
>
<span class="fas fa-download mx-1"></span>
Download
LCI Congress Template 2024 (PowerPoint)
</button>
<button
class="btn btn-md variant-ghost-primary"
</a>
<a
class="btn btn-md variant-ghost-primary hover:variant-filled-primary"
href="https://static.oneskyit.com/c/LCI/files/LCI_Speaker_and_Champion_Congress_Task_List_2024.xlsx"
>
<span class="fas fa-download mx-1"></span>
Download
LCI Speaker and Champion Congress Task List (Excel)
</button>
</a>
{:else}
<span class="text-xl text-red-500 font-bold text-center">
<p><strong>Read and Consent Agreement?</strong></p>
@@ -399,8 +401,18 @@ onMount(() => {
>
{#each event_presentation_obj_li as event_presentation_obj}
<li>
<h4 class="h4">
{event_presentation_obj.name}
<!-- Make sure to show the edit button only if the user has the correct permissions. Need to set the presentation ID in the store. -->
{#if $ae_loc.trusted_access || $events_loc.auth__kv.presentation[event_presentation_obj.event_presentation_id_random]}
<button title="Edit presentation title and description" class="btn btn-sm variant-soft-warning float-right">
<span class="fas fa-edit">
</span>
Edit Presentation
</button>
{/if}
<h4 class="h5">
"{event_presentation_obj.name}"
{#if event_presentation_obj.code || event_presentation_obj.abstract_code}
<span class="text-sm text-gray-500 bg-yellow-100 p-1 rounded-md border border-yellow-200"
title="Presentation code {event_presentation_obj.code} and abstract code {event_presentation_obj.abstract_code}"
@@ -456,6 +468,7 @@ onMount(() => {
<button
type="button"
class="btn btn-md variant-outline-success"
disabled={!$events_loc.auth__kv.person[event_presenter_obj.person_id_random]}
on:click={
() => {
console.log('View presenter details');
@@ -705,7 +718,7 @@ onMount(() => {
Marked as agreed
{/if}
{#if $ae_loc.trusted_access}
{#if $ae_loc.trusted_access || $events_loc.auth__kv.session[$events_slct.event_session_id]}
<button
type="button"
on:click={() => {
@@ -740,6 +753,126 @@ onMount(() => {
</section>
{/if}
{#if $events_loc.pres_mgmt.show_content__presenter_start}
<section class="ae_quick_modal_container">
<section class="ae_quick_popover">
<section class="ae_modal_scrollfix">
<button
on:click={
() => {
$events_loc.pres_mgmt.show_content__presenter_start = null;
}
}
class="btn btn-sm variant-soft-secondary float-right"
>
<span class="fas fa-times mx-1"></span>
Close
</button>
<h2 class="h3">
Presenter Details for:<br>
<strong>{$events_slct.presenter_obj.full_name} ({$events_slct.presenter_obj.email})</strong>
</h2>
<!-- <Element_data_store
ds_code="event_presenter_details"
ds_type="html"
display="block"
class_li="p-2"
/> -->
<section class="p-2">
<h3 class="h4">Title: "{$events_slct.presentation_obj.name}"</h3>
<h3 class="h4">Presenter:</h3>
<ul
class="space-y-2 px-4"
>
<li>
<span class="fas fa-user"></span>
{$events_slct.presenter_obj.full_name}
</li>
<li>
<span class="fas fa-envelope"></span>
<a
href="mailto:{$events_slct.presenter_obj.email}"
class="text-blue-500"
>{$events_slct.presenter_obj.email}</a>
</li>
<!-- <li>
<span class="fas fa-phone"></span>
{$events_slct.presenter_obj.phone}
</li> -->
<li>
<span class="fas fa-building"></span>
{$events_slct.presenter_obj.affiliations}
</li>
<li>
<span class="fas fa-user-tag"></span>
{$events_slct.presenter_obj.professional_title}
</li>
<li>
<span class="fas fa-user-secret"></span>
{$events_slct.presenter_obj.person_passcode} (your passcode)
<button title="Edit your passcode" class="btn btn-sm variant-soft-warning">
<span class="fas fa-edit">
</span>
Edit
</button>
</li>
</ul>
<h3 class="h4">Files:</h3>
<label>
Upload new file(s):
<input
type="file"
class="form-input"
multiple
>
</label>
<ul
class="space-y-2 px-4"
>
{#if $events_slct.presenter_obj.file_li}
{#each $events_slct.presenter_obj.file_li as file_obj}
<li>
<span class="fas fa-file"></span>
<a
href={file_obj.url}
class="text-blue-500"
>{file_obj.name}</a>
</li>
{/each}
{:else}
<li>
<span class="fas fa-file"></span>
No files uploaded
</li>
{/if}
</ul>
</section>
</section>
<button
on:click={
() => {
$events_loc.pres_mgmt.show_content__presenter_start = null;
}
}
class="btn btn-sm variant-soft-secondary float-right"
>
<span class="fas fa-times mx-1"></span>
Close
</button>
</section>
</section>
{/if}
<style lang="postcss">
/* Use the div.ae_quick_modal_container to block background clicks when using the section.ae_quick_popover. */