Trying to make this LiveQuery work.
This commit is contained in:
@@ -16,16 +16,35 @@ import Element_manage_event_file_li from '$lib/element_manage_event_file_li_all.
|
|||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
// export let container_class_li: string|Array<string> = [];
|
// export let container_class_li: string|Array<string> = [];
|
||||||
// export let event_presentation_id_random_li: Array<string>;
|
|
||||||
export let lq__event_obj: any;
|
export let lq__event_obj: any;
|
||||||
export let lq__event_presentation_obj_li: any;
|
export let lq__event_presentation_obj_li: any;
|
||||||
|
// It is important that these not be set to a value! It messes with the Dexie LiveQuery.
|
||||||
|
// export let event_presentation_id_random_li: Array<string>;
|
||||||
|
let event_presentation_id_random_li: Array<string>;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
// let ae_promises: key_val = {};
|
// let ae_promises: key_val = {};
|
||||||
// let ae_tmp: key_val = {};
|
// let ae_tmp: key_val = {};
|
||||||
// let ae_triggers: key_val = {};
|
// let ae_triggers: key_val = {};
|
||||||
|
|
||||||
|
|
||||||
|
let tmp_li: Array<string> = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||||
|
if (!event_presentation_id_random_li?.length) {
|
||||||
|
console.log(`No ID list was passed to the component. Loading all presentations for the session.`);
|
||||||
|
if ($lq__event_presentation_obj_li?.length) {
|
||||||
|
console.log(`Count: ${$lq__event_presentation_obj_li?.length}`, $lq__event_presentation_obj_li);
|
||||||
|
for (let i = 0; i < $lq__event_presentation_obj_li?.length; i++) {
|
||||||
|
tmp_li.push($lq__event_presentation_obj_li[i].event_presentation_id_random);
|
||||||
|
}
|
||||||
|
event_presentation_id_random_li = tmp_li;
|
||||||
|
} else {
|
||||||
|
console.log(`No presentations found for the session!`);
|
||||||
|
}
|
||||||
|
console.log(`event_presentation_id_random_li:`, event_presentation_id_random_li);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Functions and Logic
|
// Functions and Logic
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
@@ -33,13 +52,35 @@ if (browser) {
|
|||||||
console.log('Browser environment detected.');
|
console.log('Browser environment detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// let lq_kv__event_presentation_obj_li = liveQuery(
|
let lq_kv__event_presentation_obj_li = liveQuery(
|
||||||
// () => db_events.presentations
|
() => db_events.presentations
|
||||||
// .bulkGet(event_presentation_id_random_li)
|
.bulkGet(event_presentation_id_random_li)
|
||||||
// );
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Pull the IDs out of the object list. This may need to be an async function.
|
||||||
|
let lq_fancy__event_presentation_obj_li = liveQuery(
|
||||||
|
() => db_events.presentations
|
||||||
|
.bulkGet(async () => {
|
||||||
|
console.log('DO STUFF?');
|
||||||
|
await $lq__event_presentation_obj_li;
|
||||||
|
console.log(`Count: ${$lq__event_presentation_obj_li?.length}`, $lq__event_presentation_obj_li);
|
||||||
|
let tmp_li: Array<string> = [];
|
||||||
|
if ($lq__event_presentation_obj_li?.length) {
|
||||||
|
for (let i = 0; i < $lq__event_presentation_obj_li?.length; i++) {
|
||||||
|
tmp_li.push($lq__event_presentation_obj_li[i].event_presentation_id_random);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp_li;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<div class="float-right space-2 flex flex-row items-center">
|
<div class="float-right space-2 flex flex-row items-center">
|
||||||
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
||||||
<button
|
<button
|
||||||
@@ -84,6 +125,39 @@ if (browser) {
|
|||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Testing!? -->
|
||||||
|
<hr>
|
||||||
|
{#await $lq_kv__event_presentation_obj_li}
|
||||||
|
waiting
|
||||||
|
{:then event_presentation_obj_li}
|
||||||
|
done
|
||||||
|
{#if $lq_kv__event_presentation_obj_li && $lq_kv__event_presentation_obj_li?.length > 0}
|
||||||
|
length: {$lq_kv__event_presentation_obj_li?.length}
|
||||||
|
{/if}
|
||||||
|
{event_presentation_obj_li?.length}
|
||||||
|
{:catch}
|
||||||
|
error
|
||||||
|
{/await}
|
||||||
|
<hr>
|
||||||
|
{#await $lq_fancy__event_presentation_obj_li}
|
||||||
|
waiting
|
||||||
|
{:then event_presentation_obj_li}
|
||||||
|
done
|
||||||
|
{#if $lq_fancy__event_presentation_obj_li && $lq_fancy__event_presentation_obj_li?.length > 0}
|
||||||
|
length: {$lq_fancy__event_presentation_obj_li?.length}
|
||||||
|
{/if}
|
||||||
|
{event_presentation_obj_li?.length}
|
||||||
|
{:catch}
|
||||||
|
error
|
||||||
|
{/await}
|
||||||
|
<hr>
|
||||||
|
<!-- Testing!? -->
|
||||||
|
|
||||||
|
<!-- {#await lq__event_presentation_obj_li}
|
||||||
|
Loading...
|
||||||
|
{:then} -->
|
||||||
|
|
||||||
{#if $lq__event_presentation_obj_li && $lq__event_presentation_obj_li?.length > 0}
|
{#if $lq__event_presentation_obj_li && $lq__event_presentation_obj_li?.length > 0}
|
||||||
<ul
|
<ul
|
||||||
class="space-y-4 p-4 m-2 bg-gray-100 rounded-md"
|
class="space-y-4 p-4 m-2 bg-gray-100 rounded-md"
|
||||||
@@ -106,7 +180,7 @@ if (browser) {
|
|||||||
let presenter_data = {
|
let presenter_data = {
|
||||||
event_id_random: $events_slct.event_id,
|
event_id_random: $events_slct.event_id,
|
||||||
event_session_id_random: $events_slct.event_session_id,
|
event_session_id_random: $events_slct.event_session_id,
|
||||||
event_presentation_id_random: event_presentation_obj.event_presentation_id_random,
|
event_presentation_id_random: event_presentation_obj?.event_presentation_id_random,
|
||||||
given_name: 'New',
|
given_name: 'New',
|
||||||
family_name: 'Presenter',
|
family_name: 'Presenter',
|
||||||
email: 'test+newpres@oneskyit.com',
|
email: 'test+newpres@oneskyit.com',
|
||||||
@@ -137,10 +211,10 @@ if (browser) {
|
|||||||
<Element_ae_crud
|
<Element_ae_crud
|
||||||
api_cfg={$ae_api}
|
api_cfg={$ae_api}
|
||||||
object_type={'event_presentation'}
|
object_type={'event_presentation'}
|
||||||
object_id={event_presentation_obj.event_presentation_id_random}
|
object_id={event_presentation_obj?.event_presentation_id_random}
|
||||||
field_name={'name'}
|
field_name={'name'}
|
||||||
field_type={'text'}
|
field_type={'text'}
|
||||||
field_value={event_presentation_obj.name}
|
field_value={event_presentation_obj?.name}
|
||||||
allow_null={false}
|
allow_null={false}
|
||||||
hide_edit_btn={!$ae_loc.trusted_access || !$ae_loc.edit_mode}
|
hide_edit_btn={!$ae_loc.trusted_access || !$ae_loc.edit_mode}
|
||||||
outline_element={false}
|
outline_element={false}
|
||||||
@@ -163,15 +237,15 @@ if (browser) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<!-- <strong class="text-sm">Name/Title:</strong> -->
|
<!-- <strong class="text-sm">Name/Title:</strong> -->
|
||||||
"{event_presentation_obj.name}"
|
"{event_presentation_obj?.name}"
|
||||||
</Element_ae_crud>
|
</Element_ae_crud>
|
||||||
<!-- "{event_presentation_obj.name}" -->
|
<!-- "{event_presentation_obj.name}" -->
|
||||||
{#if event_presentation_obj.code || event_presentation_obj.abstract_code}
|
{#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"
|
<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}"
|
title="Presentation code {event_presentation_obj?.code} and abstract code {event_presentation_obj?.abstract_code}"
|
||||||
>
|
>
|
||||||
<span class="fas fa-barcode"></span>
|
<span class="fas fa-barcode"></span>
|
||||||
{event_presentation_obj.code ?? ''} {event_presentation_obj.abstract_code ?? ''}
|
{event_presentation_obj?.code ?? ''} {event_presentation_obj?.abstract_code ?? ''}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</h4>
|
</h4>
|
||||||
@@ -180,10 +254,10 @@ if (browser) {
|
|||||||
<Element_ae_crud
|
<Element_ae_crud
|
||||||
api_cfg={$ae_api}
|
api_cfg={$ae_api}
|
||||||
object_type={'event_presentation'}
|
object_type={'event_presentation'}
|
||||||
object_id={event_presentation_obj.event_presentation_id_random}
|
object_id={event_presentation_obj?.event_presentation_id_random}
|
||||||
field_name={'description'}
|
field_name={'description'}
|
||||||
field_type={'textarea'}
|
field_type={'textarea'}
|
||||||
field_value={event_presentation_obj.description}
|
field_value={event_presentation_obj?.description}
|
||||||
allow_null={false}
|
allow_null={false}
|
||||||
hide_edit_btn={!$ae_loc.trusted_access || !$ae_loc.edit_mode}
|
hide_edit_btn={!$ae_loc.trusted_access || !$ae_loc.edit_mode}
|
||||||
outline_element={false}
|
outline_element={false}
|
||||||
@@ -202,7 +276,7 @@ if (browser) {
|
|||||||
Description:
|
Description:
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
{#if event_presentation_obj.description}
|
{#if event_presentation_obj?.description}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
@@ -250,11 +324,11 @@ if (browser) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Show presenters for this presentation -->
|
<!-- Show presenters for this presentation -->
|
||||||
{#if event_presentation_obj.event_presentation_id_random}
|
{#if event_presentation_obj?.event_presentation_id_random}
|
||||||
<Comp_event_presenter_obj_li
|
<Comp_event_presenter_obj_li
|
||||||
lq__event_obj={lq__event_obj}
|
lq__event_obj={lq__event_obj}
|
||||||
link_to_type={'event_presentation'}
|
link_to_type={'event_presentation'}
|
||||||
link_to_id={event_presentation_obj.event_presentation_id_random}
|
link_to_id={event_presentation_obj?.event_presentation_id_random}
|
||||||
>
|
>
|
||||||
</Comp_event_presenter_obj_li>
|
</Comp_event_presenter_obj_li>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -263,7 +337,7 @@ if (browser) {
|
|||||||
<!-- Show files for this presentation -->
|
<!-- Show files for this presentation -->
|
||||||
<Element_manage_event_file_li
|
<Element_manage_event_file_li
|
||||||
link_to_type={'event_presentation'}
|
link_to_type={'event_presentation'}
|
||||||
link_to_id={event_presentation_obj.event_presentation_id_random}
|
link_to_id={event_presentation_obj?.event_presentation_id_random}
|
||||||
allow_basic={$events_loc.auth__kv.session[$events_slct.event_session_id] || $events_loc.auth__kv.presenter[$events_slct.event_presenter_id]}
|
allow_basic={$events_loc.auth__kv.session[$events_slct.event_session_id] || $events_loc.auth__kv.presenter[$events_slct.event_presenter_id]}
|
||||||
allow_moderator={$events_loc.auth__kv.session[$events_slct.event_session_id]}
|
allow_moderator={$events_loc.auth__kv.session[$events_slct.event_session_id]}
|
||||||
container_class_li={''}
|
container_class_li={''}
|
||||||
@@ -275,3 +349,5 @@ if (browser) {
|
|||||||
{:else}
|
{:else}
|
||||||
Nothing to show yet...!
|
Nothing to show yet...!
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<!-- {/await} -->
|
||||||
|
|||||||
@@ -60,36 +60,36 @@ let lq__event_presentation_obj = liveQuery(
|
|||||||
() => db_events.presentations.get($events_slct.event_presentation_id)
|
() => db_events.presentations.get($events_slct.event_presentation_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
let lq_kv__event_presenter_obj_li_2 = liveQuery(
|
// let lq_kv__event_presenter_obj_li_2 = liveQuery(
|
||||||
() => db_events.presenters
|
// () => db_events.presenters
|
||||||
.bulkGet(event_presenter_id_random_li)
|
// .bulkGet(event_presenter_id_random_li)
|
||||||
.then(results => {
|
// .then(results => {
|
||||||
// console.log(`LQ Results:`, results);
|
// // console.log(`LQ Results:`, results);
|
||||||
// If the results are an array
|
// // If the results are an array
|
||||||
if (results.length == 1) {
|
// if (results.length == 1) {
|
||||||
// If the first item is undefined we need to do something.
|
// // If the first item is undefined we need to do something.
|
||||||
if (results[0] == undefined) {
|
// if (results[0] == undefined) {
|
||||||
console.log('Something went wrong! No presenters found?');
|
// console.log('Something went wrong! No presenters found?');
|
||||||
// return [];
|
// // return [];
|
||||||
// return [{ id: '' }];
|
// // return [{ id: '' }];
|
||||||
// return 'NOTHING???';
|
// // return 'NOTHING???';
|
||||||
}
|
// }
|
||||||
return results;
|
// return results;
|
||||||
}else if (results.length > 1) {
|
// }else if (results.length > 1) {
|
||||||
return results;
|
// return results;
|
||||||
} else {
|
// } else {
|
||||||
return ['No presenters found.'];
|
// return ['No presenters found.'];
|
||||||
}
|
// }
|
||||||
// return results;
|
// // return results;
|
||||||
})
|
// })
|
||||||
.catch(error => {
|
// .catch(error => {
|
||||||
console.error(`LQ Error: ${error}`);
|
// console.error(`LQ Error: ${error}`);
|
||||||
return ['No presenters found.'];
|
// return ['No presenters found.'];
|
||||||
})
|
// })
|
||||||
.finally(() => {
|
// .finally(() => {
|
||||||
console.log(`LQ Finally:`, $lq_kv__event_presenter_obj_li_2);
|
// console.log(`LQ Finally:`, $lq_kv__event_presenter_obj_li_2);
|
||||||
})
|
// })
|
||||||
);
|
// );
|
||||||
|
|
||||||
// let lq__event_presentation_obj_li = liveQuery(
|
// let lq__event_presentation_obj_li = liveQuery(
|
||||||
// () => db_events.presentations
|
// () => db_events.presentations
|
||||||
|
|||||||
@@ -793,12 +793,20 @@ $: if ($lq__event_session_obj) {
|
|||||||
|
|
||||||
<!-- Presentations in the session -->
|
<!-- Presentations in the session -->
|
||||||
<section>
|
<section>
|
||||||
|
{#await $lq__event_presentation_obj_li}
|
||||||
|
Loading....
|
||||||
|
{:then event_presentation_obj_li}
|
||||||
|
{#if $lq__event_presentation_obj_li && $lq__event_presentation_obj_li?.length > 0}
|
||||||
|
<!-- {$lq__event_presentation_obj_li?.length} Presentations -->
|
||||||
|
<Comp_event_presentation_obj_li
|
||||||
|
lq__event_obj={lq__event_obj}
|
||||||
|
lq__event_presentation_obj_li={lq__event_presentation_obj_li}
|
||||||
|
>
|
||||||
|
<!-- event_presentation_id_random_li={[]} -->
|
||||||
|
</Comp_event_presentation_obj_li>
|
||||||
|
{/if}
|
||||||
|
{/await}
|
||||||
|
|
||||||
<Comp_event_presentation_obj_li
|
|
||||||
lq__event_obj={lq__event_obj}
|
|
||||||
lq__event_presentation_obj_li={lq__event_presentation_obj_li}
|
|
||||||
>
|
|
||||||
</Comp_event_presentation_obj_li>
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user